1. 29 Jan, 2012 4 commits
    • Tom Lane's avatar
      Fix pushing of index-expression qualifications through UNION ALL. · b28ffd0f
      Tom Lane authored
      In commit 57664ed2, I made the planner
      wrap non-simple-variable outputs of appendrel children (IOW, child SELECTs
      of UNION ALL subqueries) inside PlaceHolderVars, in order to solve some
      issues with EquivalenceClass processing.  However, this means that any
      upper-level WHERE clauses mentioning such outputs will now contain
      PlaceHolderVars after they're pushed down into the appendrel child,
      and that prevents indxpath.c from recognizing that they could be matched
      to index expressions.  To fix, add explicit stripping of PlaceHolderVars
      from index operands, same as we have long done for RelabelType nodes.
      Add a regression test covering both this and the plain-UNION case (which
      is a totally different code path, but should also be able to do it).
      
      Per bug #6416 from Matteo Beccati.  Back-patch to 9.1, same as the
      previous change.
      b28ffd0f
    • Tom Lane's avatar
      Add caution about multiple unique indexes breaking plpgsql upsert example. · ed6e0545
      Tom Lane authored
      Per Phil Sorber, though I didn't use his wording exactly.
      ed6e0545
    • Tom Lane's avatar
      Update statement about sorting of character-string data. · 17d3233e
      Tom Lane authored
      The sort order is no longer fixed at database creation time, but can be
      controlled via COLLATE.  Noted by Thomas Kellerer.
      17d3233e
    • Tom Lane's avatar
      Fix handling of init_plans list in inheritance_planner(). · 4ec6581c
      Tom Lane authored
      Formerly we passed an empty list to each per-child-table invocation of
      grouping_planner, and then merged the results into the global list.
      However, that fails if there's a CTE attached to the statement, because
      create_ctescan_plan uses the list to find the plan referenced by a CTE
      reference; so it was unable to find any CTEs attached to the outer UPDATE
      or DELETE.  But there's no real reason not to use the same list throughout
      the process, and doing so is simpler and faster anyway.
      
      Per report from Josh Berkus of "could not find plan for CTE" failures.
      Back-patch to 9.1 where we added support for WITH attached to UPDATE or
      DELETE.  Add some regression test cases, too.
      4ec6581c
  2. 28 Jan, 2012 6 commits
    • Tom Lane's avatar
      Add simple tests of EvalPlanQual using the isolationtester infrastructure. · 759d9d67
      Tom Lane authored
      Much more could be done here, but at least now we have *some* automated
      test coverage of that mechanism.  In particular this tests the writable-CTE
      case reported by Phil Sorber.
      
      In passing, remove isolationtester's arbitrary restriction on the number of
      steps in a permutation list.  I used this so that a single spec file could
      be used to run several related test scenarios, but there are other possible
      reasons to want a step series that's not exactly a permutation.  Improve
      documentation and fix a couple other nits as well.
      759d9d67
    • Tom Lane's avatar
      Fix handling of data-modifying CTE subplans in EvalPlanQual. · 7c1719bc
      Tom Lane authored
      We can't just skip initializing such subplans, because the referencing CTE
      node will expect to find the subplan available when it initializes.  That
      in turn means that ExecInitModifyTable must allow the case (which actually
      it needed to do anyway, since there's no guarantee that ModifyTable is
      exactly at the top of the CTE plan tree).  So move the complaint about not
      being allowed in EvalPlanQual mode to execution instead of initialization.
      Testing turned up yet another problem, which is that we'd try to
      re-initialize the result relation's index list, leading to leaks and
      dangling pointers.
      
      Per report from Phil Sorber.  Back-patch to 9.1 where data-modifying CTEs
      were introduced.
      7c1719bc
    • Magnus Hagander's avatar
      Prevent logging "failed to stat file: success" for temp files · 672614cf
      Magnus Hagander authored
      This was broken in commit bc334748, the
      addition of statistics counters for temp files.
      
      Reported by Thom Brown
      672614cf
    • Tom Lane's avatar
      Fix error detection in contrib/pgcrypto's encrypt_iv() and decrypt_iv(). · a8b4b843
      Tom Lane authored
      Due to oversights, the encrypt_iv() and decrypt_iv() functions failed to
      report certain types of invalid-input errors, and would instead return
      random garbage values.
      
      Marko Kreen, per report from Stefan Kaltenbrunner
      a8b4b843
    • Tom Lane's avatar
      Undo 8.4-era lobotomization of subquery pullup rules. · 0816fad6
      Tom Lane authored
      After the planner was fixed to convert some IN/EXISTS subqueries into
      semijoins or antijoins, we had to prevent it from doing that in some
      cases where the plans risked getting much worse.  The reason the plans
      got worse was that in the unoptimized implementation, subqueries could
      reference parameters from the outer query at any join level, and so
      full table scans could be avoided even if they were one or more levels
      of join below where the semi/anti join would be.  Now that we have
      sufficient mechanism in the planner to handle such cases properly,
      it should no longer be necessary to play dumb here.
      
      This reverts commits 07b9936a and
      cd1f0d04.  The latter was a stopgap
      fix that wasn't really sufficiently analyzed at the time.  Rather
      than just restricting ourselves to cases where the new join can be
      stacked on the right-hand input, we should also consider whether it
      can be stacked on the left-hand input.
      0816fad6
    • Tom Lane's avatar
      Use parameterized paths to generate inner indexscans more flexibly. · e2fa76d8
      Tom Lane authored
      This patch fixes the planner so that it can generate nestloop-with-
      inner-indexscan plans even with one or more levels of joining between
      the indexscan and the nestloop join that is supplying the parameter.
      The executor was fixed to handle such cases some time ago, but the
      planner was not ready.  This should improve our plans in many situations
      where join ordering restrictions formerly forced complete table scans.
      
      There is probably a fair amount of tuning work yet to be done, because
      of various heuristics that have been added to limit the number of
      parameterized paths considered.  However, we are not going to find out
      what needs to be adjusted until the code gets some real-world use, so
      it's time to get it in there where it can be tested easily.
      
      Note API change for index AM amcostestimate functions.  I'm not aware of
      any non-core index AMs, but if there are any, they will need minor
      adjustments.
      e2fa76d8
  3. 27 Jan, 2012 13 commits
  4. 26 Jan, 2012 11 commits
  5. 25 Jan, 2012 6 commits
    • Alvaro Herrera's avatar
      Have \copy go through SendQuery · 08146775
      Alvaro Herrera authored
      This enables a bunch of features, notably ON_ERROR_ROLLBACK.  It also
      makes COPY failure (either in the server or psql) as a whole behave more
      sanely in psql.
      
      Additionally, having more commands in the same command line as COPY
      works better (though since psql splits lines at semicolons, this doesn't
      matter much unless you're using -c).
      
      Also tighten a couple of switches on PQresultStatus() to add
      PGRES_COPY_BOTH support and stop assuming that unknown statuses received
      are errors; have those print diagnostics where warranted.
      
      Author: Noah Misch
      08146775
    • Robert Haas's avatar
      Make CheckIndexCompatible simpler and more bullet-proof. · 6eb71ac5
      Robert Haas authored
      This gives up the "don't rewrite the index" behavior in a couple of
      relatively unimportant cases, such as changing between an array type
      and an unconstrained domain over that array type, in return for
      making this code more future-proof.
      
      Noah Misch
      6eb71ac5
    • Simon Riggs's avatar
      Allow pg_basebackup from standby node with safety checking. · 8366c780
      Simon Riggs authored
      Base backup follows recommended procedure, plus goes to great
      lengths to ensure that partial page writes are avoided.
      
      Jun Ishizuka and Fujii Masao, with minor modifications
      8366c780
    • Alvaro Herrera's avatar
      Add pg_trigger_depth() function · 74ab96a4
      Alvaro Herrera authored
      This reports the depth level of triggers currently in execution, or zero
      if not called from inside a trigger.
      
      No catversion bump in this patch, but you have to initdb if you want
      access to the new function.
      
      Author: Kevin Grittner
      74ab96a4
    • Bruce Momjian's avatar
      Now that the shared library name can be adjusted in the library test, · 6d5aae7a
      Bruce Momjian authored
      have pg_upgrade allocate a maximum fixed size buffer for testing the
      library file name, rather than base the allocation on the library name.
      
      Backpatch to 9.1.
      6d5aae7a
    • Bruce Momjian's avatar
      a7f2c79a