1. 20 Mar, 2012 7 commits
    • Alvaro Herrera's avatar
      pg_dump: get rid of die_horribly · 9d23a70d
      Alvaro Herrera authored
      The old code was using exit_horribly or die_horribly other depending on
      whether it had an ArchiveHandle on which to close the connection or not;
      but there were places that were passing a NULL ArchiveHandle to
      die_horribly, and other places that used exit_horribly while having an
      AH available.  So there wasn't all that much consistency.
      
      Improve the situation by keeping only one of the routines, and instead
      of having to pass the AH down from the caller, arrange for it to be
      present for an on_exit_nicely callback to operate on.
      
      Author: Joachim Wieland
      Some tweaks by me
      
      Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump"
      saga.
      9d23a70d
    • Alvaro Herrera's avatar
      Fix trigger example code to match header changes · b251cf31
      Alvaro Herrera authored
      I should have done this in b93f5a56 but
      didn't notice the problem at the time.
      
      Per report from Marco Nenciarini
      b251cf31
    • Alvaro Herrera's avatar
      Update struct Trigger in docs · 438269eb
      Alvaro Herrera authored
      438269eb
    • Robert Haas's avatar
      0b43edbc
    • Peter Eisentraut's avatar
      1b12c3e8
    • Peter Eisentraut's avatar
      pg_dump: Remove undocumented "files" output format · 19f45565
      Peter Eisentraut authored
      This was for demonstration only, and now it was creating compiler
      warnings from zlib without an obvious fix (see also
      d923125b), let's just remove it.  The
      "directory" format is presumably similar enough anyway.
      19f45565
    • Tom Lane's avatar
      Restructure SELECT INTO's parsetree representation into CreateTableAsStmt. · 9dbf2b7d
      Tom Lane authored
      Making this operation look like a utility statement seems generally a good
      idea, and particularly so in light of the desire to provide command
      triggers for utility statements.  The original choice of representing it as
      SELECT with an IntoClause appendage had metastasized into rather a lot of
      places, unfortunately, so that this patch is a great deal more complicated
      than one might at first expect.
      
      In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
      subcommands required restructuring some EXPLAIN-related APIs.  Add-on code
      that calls ExplainOnePlan or ExplainOneUtility, or uses
      ExplainOneQuery_hook, will need adjustment.
      
      Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
      which formerly were accepted though undocumented, are no longer accepted.
      The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
      The CREATE RULE case doesn't seem to have much real-world use (since the
      rule would work only once before failing with "table already exists"),
      so we'll not bother with that one.
      
      Both SELECT INTO and CREATE TABLE AS still return a command tag of
      "SELECT nnnn".  There was some discussion of returning "CREATE TABLE nnnn",
      but for the moment backwards compatibility wins the day.
      
      Andres Freund and Tom Lane
      9dbf2b7d
  2. 19 Mar, 2012 3 commits
  3. 17 Mar, 2012 3 commits
  4. 16 Mar, 2012 9 commits
    • Bruce Momjian's avatar
      In pg_upgrade, create a script to incrementally generate more accurate · faec2815
      Bruce Momjian authored
      optimizer statistics so the cluster can be made available sooner.
      faec2815
    • Peter Eisentraut's avatar
      libpq: Fix minor memory leaks · d4318483
      Peter Eisentraut authored
      When using connection info arrays with a conninfo string in the dbname
      slot, some memory would be leaked if an error occurred while
      processing the following array slots.
      
      found by Coverity
      d4318483
    • Peter Eisentraut's avatar
      psql: Remove inappropriate const qualifiers · 598bb8cd
      Peter Eisentraut authored
      Since mbvalidate() can alter the string it validates, having the
      callers claim that the strings they accept are const is inappropriate.
      598bb8cd
    • Peter Eisentraut's avatar
      pg_dump: Fix crash with invalid pg_cast row · 359dea28
      Peter Eisentraut authored
      An invalid combination of pg_cast.castfunc and pg_cast.castmethod
      would result in a segmentation fault.  Now it prints a warning.
      
      found by Coverity
      359dea28
    • Peter Eisentraut's avatar
      d8e5b342
    • Peter Eisentraut's avatar
      backend: Fix minor memory leak in configuration file processing · 693ff85d
      Peter Eisentraut authored
      Just for consistency with the other code paths.
      
      found by Coverity
      693ff85d
    • Tom Lane's avatar
      Improve commentary in match_pathkeys_to_index(). · b67ad046
      Tom Lane authored
      For a little while there I thought match_pathkeys_to_index() was broken
      because it wasn't trying to match index columns to pathkeys in order.
      Actually that's correct, because GiST can support ordering operators
      on any random collection of index columns, but it sure needs a comment.
      b67ad046
    • Tom Lane's avatar
      Revisit handling of UNION ALL subqueries with non-Var output columns. · dd4134ea
      Tom Lane authored
      In commit 57664ed2 I tried to fix a bug
      reported by Teodor Sigaev by making non-simple-Var output columns distinct
      (by wrapping their expressions with dummy PlaceHolderVar nodes).  This did
      not work too well.  Commit b28ffd0f fixed
      some ensuing problems with matching to child indexes, but per a recent
      report from Claus Stadler, constraint exclusion of UNION ALL subqueries was
      still broken, because constant-simplification didn't handle the injected
      PlaceHolderVars well either.  On reflection, the original patch was quite
      misguided: there is no reason to expect that EquivalenceClass child members
      will be distinct.  So instead of trying to make them so, we should ensure
      that we can cope with the situation when they're not.
      
      Accordingly, this patch reverts the code changes in the above-mentioned
      commits (though the regression test cases they added stay).  Instead, I've
      added assorted defenses to make sure that duplicate EC child members don't
      cause any problems.  Teodor's original problem ("MergeAppend child's
      targetlist doesn't match MergeAppend") is addressed more directly by
      revising prepare_sort_from_pathkeys to let the parent MergeAppend's sort
      list guide creation of each child's sort list.
      
      In passing, get rid of add_sort_column; as far as I can tell, testing for
      duplicate sort keys at this stage is dead code.  Certainly it doesn't
      trigger often enough to be worth expending cycles on in ordinary queries.
      And keeping the test would've greatly complicated the new logic in
      prepare_sort_from_pathkeys, because comparing pathkey list entries against
      a previous output array requires that we not skip any entries in the list.
      
      Back-patch to 9.1, like the previous patches.  The only known issue in
      this area that wasn't caused by the ill-advised previous patches was the
      MergeAppend planning failure, which of course is not relevant before 9.1.
      It's possible that we need some of the new defenses against duplicate child
      EC entries in older branches, but until there's some clear evidence of that
      I'm going to refrain from back-patching further.
      dd4134ea
    • Heikki Linnakangas's avatar
  5. 15 Mar, 2012 5 commits
  6. 14 Mar, 2012 5 commits
  7. 13 Mar, 2012 6 commits
    • Peter Eisentraut's avatar
      pg_dump: Fix some minor memory leaks · acfaa596
      Peter Eisentraut authored
      Although we often don't care about freeing all memory in pg_dump,
      these functions already freed the same memory in other code paths, so
      we might as well do it consistently.
      
      found by Coverity
      acfaa596
    • Tom Lane's avatar
      Patch some corner-case bugs in pl/python. · 5cd72c7a
      Tom Lane authored
      Dave Malcolm of Red Hat is working on a static code analysis tool for
      Python-related C code.  It reported a number of problems in plpython,
      most of which were failures to check for NULL results from object-creation
      functions, so would only be an issue in very-low-memory situations.
      
      Patch in HEAD and 9.1.  We could go further back but it's not clear that
      these issues are important enough to justify the work.
      
      Jan Urbański
      5cd72c7a
    • Tom Lane's avatar
      Fix minor memory leak in PLy_typeinfo_dealloc(). · a14fa846
      Tom Lane authored
      We forgot to free the per-attribute array element descriptors.
      
      Jan Urbański
      a14fa846
    • Tom Lane's avatar
      Create a stack of pl/python "execution contexts". · ed75380b
      Tom Lane authored
      This replaces the former global variable PLy_curr_procedure, and provides
      a place to stash per-call-level information.  In particular we create a
      per-call-level scratch memory context.
      
      For the moment, the scratch context is just used to avoid leaking memory
      from datatype output function calls in PLyDict_FromTuple.  There probably
      will be more use-cases in future.
      
      Although this is a fix for a pre-existing memory leakage bug, it seems
      sufficiently invasive to not want to back-patch; it feels better as part
      of the major rearrangement of plpython code that we've already done as
      part of 9.2.
      
      Jan Urbański
      ed75380b
    • Robert Haas's avatar
      pgstattuple: Use a BufferAccessStrategy object to avoid cache-trashing. · 2e46bf67
      Robert Haas authored
      Jaime Casanova, reviewed by Noah Misch, slightly modified by me.
      2e46bf67
    • Robert Haas's avatar
      pgstattuple: Add new error case for spgist indexes. · 97c85098
      Robert Haas authored
      Extracted from a larger patch by Jaime Casanova, reviewed by Noah Misch.
      I think this error message could use some more extensive revision, but
      this at least makes the handling of spgist consistent with what we do for
      other types of indexes that this code doesn't know how to handle.
      97c85098
  8. 12 Mar, 2012 2 commits
    • Bruce Momjian's avatar
      In pg_upgrade, add various logging improvements: · 717f6d60
      Bruce Momjian authored
      	add ability to control permissions of created files
      	have psql echo its queries for easier debugging
      	output four separate log files, and delete them on success
      	add -r/--retain option to keep log files after success
      	make logs file append-only
      	remove -g/-G/-l logging options
      	sugggest tailing appropriate log file on failure
      	enhance -v/--verbose behavior
      717f6d60
    • Tom Lane's avatar
      Fix SPGiST vacuum algorithm to handle concurrent tuple motion properly. · b4af1c25
      Tom Lane authored
      A leaf tuple that we need to delete could get moved as a consequence of an
      insertion happening concurrently with the VACUUM scan.  If it moves from a
      page past the current scan point to a page before, we'll miss it, which is
      not acceptable.  Hence, when we see a leaf-page REDIRECT that could have
      been made since our scan started, chase down the redirection pointer much
      as if we were doing a normal index search, and be sure to vacuum every page
      it leads to.  This fixes the issue because, if the tuple was on page N at
      the instant we start our scan, we will surely find it as a consequence of
      chasing the redirect from page N, no matter how much it moves around in
      between.  Problem noted by Takashi Yamamoto.
      b4af1c25