1. 28 Nov, 2013 4 commits
  2. 27 Nov, 2013 13 commits
    • Tom Lane's avatar
      Fix stale-pointer problem in fast-path locking logic. · 7db285af
      Tom Lane authored
      When acquiring a lock in fast-path mode, we must reset the locallock
      object's lock and proclock fields to NULL.  They are not necessarily that
      way to start with, because the locallock could be left over from a failed
      lock acquisition attempt earlier in the transaction.  Failure to do this
      led to all sorts of interesting misbehaviors when LockRelease tried to
      clean up no-longer-related lock and proclock objects in shared memory.
      Per report from Dan Wood.
      
      In passing, modify LockRelease to elog not just Assert if it doesn't find
      lock and proclock objects for a formerly fast-path lock, matching the code
      in FastPathGetRelationLockEntry and LockRefindAndRelease.  This isn't a
      bug but it will help in diagnosing any future bugs in this area.
      
      Also, modify FastPathTransferRelationLocks and FastPathGetRelationLockEntry
      to break out of their loops over the fastpath array once they've found the
      sole matching entry.  This was inconsistently done in some search loops
      and not others.
      
      Improve assorted related comments, too.
      
      Back-patch to 9.2 where the fast-path mechanism was introduced.
      7db285af
    • Kevin Grittner's avatar
      Minor correction of READ COMMITTED isolation level docs. · 89ba8150
      Kevin Grittner authored
      Per report from AK
      89ba8150
    • Tom Lane's avatar
      Minor corrections in lmgr/README. · 8c84803e
      Tom Lane authored
      Correct an obsolete statement that no backend touches another backend's
      PROCLOCK lists.  This was probably wrong even when written (the deadlock
      checker looks at everybody's lists), and it's certainly quite wrong now
      that fast-path locking can require creation of lock and proclock objects
      on behalf of another backend.  Also improve some statements in the hot
      standby explanation, and do one or two other trivial bits of wordsmithing/
      reformatting.
      8c84803e
    • Heikki Linnakangas's avatar
      Get rid of the post-recovery cleanup step of GIN page splits. · 631118fe
      Heikki Linnakangas authored
      Replace it with an approach similar to what GiST uses: when a page is split,
      the left sibling is marked with a flag indicating that the parent hasn't been
      updated yet. When the parent is updated, the flag is cleared. If an insertion
      steps on a page with the flag set, it will finish split before proceeding
      with the insertion.
      
      The post-recovery cleanup mechanism was never totally reliable, as insertion
      to the parent could fail e.g because of running out of memory or disk space,
      leaving the tree in an inconsistent state.
      
      This also divides the responsibility of WAL-logging more clearly between
      the generic ginbtree.c code, and the parts specific to entry and posting
      trees. There is now a common WAL record format for insertions and deletions,
      which is written by ginbtree.c, followed by tree-specific payload, which is
      returned by the placetopage- and split- callbacks.
      631118fe
    • Heikki Linnakangas's avatar
      More GIN refactoring. · ce5326ee
      Heikki Linnakangas authored
      Separate the insertion payload from the more static portions of GinBtree.
      GinBtree now only contains information related to searching the tree, and
      the information of what to insert is passed separately.
      
      Add root block number to GinBtree, instead of passing it around all the
      functions as argument.
      
      Split off ginFinishSplit() from ginInsertValue(). ginFinishSplit is
      responsible for finding the parent and inserting the downlink to it.
      ce5326ee
    • Heikki Linnakangas's avatar
      Fix plpython3 expected output. · 4118f7e8
      Heikki Linnakangas authored
      I neglected this in the previous commit that updated the plpython2 output,
      which I forgot to "git add" earlier.
      
      As pointed out by Rodolfo Campero and Marko Kreen.
      4118f7e8
    • Heikki Linnakangas's avatar
      Don't update relfrozenxid if any pages were skipped. · 82b43f7d
      Heikki Linnakangas authored
      Vacuum recognizes that it can update relfrozenxid by checking whether it has
      processed all pages of a relation. Unfortunately it performed that check
      after truncating the dead pages at the end of the relation, and used the new
      number of pages to decide whether all pages have been scanned. If the new
      number of pages happened to be smaller or equal to the number of pages
      scanned, it incorrectly decided that all pages were scanned.
      
      This can lead to relfrozenxid being updated, even though some pages were
      skipped that still contain old XIDs. That can lead to data loss due to xid
      wraparounds with some rows suddenly missing. This likely has escaped notice
      so far because it takes a large number (~2^31) of xids being used to see the
      effect, while a full-table vacuum before that would fix the issue.
      
      The incorrect logic was introduced by commit
      b4b6923e. Backpatch this fix down to 8.4,
      like that commit.
      
      Andres Freund, with some modifications by me.
      82b43f7d
    • Michael Meskes's avatar
      Documentation fix for ecpg. · 2390f2b2
      Michael Meskes authored
      The latest fixes removed a limitation that was still in the docs, so Zoltan updated the docs, too.
      2390f2b2
    • Michael Meskes's avatar
      ECPG: Fix searching for quoted cursor names case-sensitively. · 51867a0f
      Michael Meskes authored
      Patch by Böszörményi Zoltán <zb@cybertec.at>
      51867a0f
    • Fujii Masao's avatar
      Add --xlogdir option to pg_basebackup, for specifying the pg_xlog directory. · d1b88f6b
      Fujii Masao authored
      Haribabu kommi, slightly modified by me.
      d1b88f6b
    • Fujii Masao's avatar
      Fix typo in release note. · 551c7828
      Fujii Masao authored
      Backpatch to 9.1.
      
      Josh Kupershmidt
      551c7828
    • Peter Eisentraut's avatar
    • Peter Eisentraut's avatar
      doc: Add id to index in XSLT build · 3803ff98
      Peter Eisentraut authored
      That way, the HTML file name of the index will be the same as currently
      for the DSSSL build.
      3803ff98
  3. 26 Nov, 2013 9 commits
  4. 25 Nov, 2013 2 commits
  5. 24 Nov, 2013 7 commits
    • Jeff Davis's avatar
      Lessen library-loading log level. · 559d5358
      Jeff Davis authored
      Previously, messages were emitted at the LOG level every time a
      backend preloaded a library. That was acceptable (though unnecessary)
      for shared_preload_libraries; but it was excessive for
      local_preload_libraries and session_preload_libraries. Reduce to
      DEBUG1.
      
      Also, there was logic in the EXEC_BACKEND case to avoid repeated
      messages for shared_preload_libraries by demoting them to
      DEBUG2. DEBUG1 seems more appropriate there, as well, so eliminate
      that special case.
      
      Peter Geoghegan.
      559d5358
    • Tom Lane's avatar
      Fix new and latent bugs with errno handling in secure_read/secure_write. · 36a3be65
      Tom Lane authored
      These functions must be careful that they return the intended value of
      errno to their callers.  There were several scenarios where this might
      not happen:
      
      1. The recent SSL renegotiation patch added a hunk of code that would
      execute after setting errno.  In the first place, it's doubtful that we
      should consider renegotiation to be successfully completed after a failure,
      and in the second, there's no real guarantee that the called OpenSSL
      routines wouldn't clobber errno.  Fix by not executing that hunk except
      during success exit.
      
      2. errno was left in an unknown state in case of an unrecognized return
      code from SSL_get_error().  While this is a "can't happen" case, it seems
      like a good idea to be sure we know what would happen, so reset errno to
      ECONNRESET in such cases.  (The corresponding code in libpq's fe-secure.c
      already did this.)
      
      3. There was an (undocumented) assumption that client_read_ended() wouldn't
      change errno.  While true in the current state of the code, this seems less
      than future-proof.  Add explicit saving/restoring of errno to make sure
      that changes in the called functions won't break things.
      
      I see no need to back-patch, since #1 is new code and the other two issues
      are mostly hypothetical.
      
      Per discussion with Amit Kapila.
      36a3be65
    • Michael Meskes's avatar
      Allow C array definitions to use sizeof(). · 08d1b22b
      Michael Meskes authored
      When parsing C variable definitions ecpg should allow sizeof() operators as array dimensions.
      08d1b22b
    • Michael Meskes's avatar
      Distinguish between C and SQL mode for C-style comments. · 8ac5e88f
      Michael Meskes authored
      SQL standard asks for allowing nested comments, while C does not. Therefore the
      two comments, while mostly similar, have to be parsed seperately.
      8ac5e88f
    • Tom Lane's avatar
      Defend against bad trigger definitions in contrib/lo's lo_manage() trigger. · 64d15e42
      Tom Lane authored
      This function formerly crashed if called as a statement-level trigger,
      or if a column-name argument wasn't given.
      
      In passing, add the trigger name to all error messages from the function.
      (None of them are expected cases, so this shouldn't pose any compatibility
      risk.)
      
      Marc Cousin, reviewed by Sawada Masahiko
      64d15e42
    • Peter Eisentraut's avatar
      PL/Tcl: Add event trigger support · a5036ca9
      Peter Eisentraut authored
      From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
      a5036ca9
    • Tom Lane's avatar
      Fix array slicing of int2vector and oidvector values. · 45e02e32
      Tom Lane authored
      The previous coding labeled expressions such as pg_index.indkey[1:3] as
      being of int2vector type; which is not right because the subscript bounds
      of such a result don't, in general, satisfy the restrictions of int2vector.
      To fix, implicitly promote the result of slicing int2vector to int2[],
      or oidvector to oid[].  This is similar to what we've done with domains
      over arrays, which is a good analogy because these types are very much
      like restricted domains of the corresponding regular-array types.
      
      A side-effect is that we now also forbid array-element updates on such
      columns, eg while "update pg_index set indkey[4] = 42" would have worked
      before if you were superuser (and corrupted your catalogs irretrievably,
      no doubt) it's now disallowed.  This seems like a good thing since, again,
      some choices of subscripting would've led to results not satisfying the
      restrictions of int2vector.  The case of an array-slice update was
      rejected before, though with a different error message than you get now.
      We could make these cases work in future if we added a cast from int2[]
      to int2vector (with a cast function checking the subscript restrictions)
      but it seems unlikely that there's any value in that.
      
      Per report from Ronan Dunklau.  Back-patch to all supported branches
      because of the crash risks involved.
      45e02e32
  6. 23 Nov, 2013 3 commits
    • Tom Lane's avatar
      Ensure _dosmaperr() actually sets errno correctly. · f145454d
      Tom Lane authored
      If logging is enabled, either ereport() or fprintf() might stomp on errno
      internally, causing this function to return the wrong result.  That might
      only end in a misleading error report, but in any code that's examining
      errno to decide what to do next, the consequences could be far graver.
      
      This has been broken since the very first version of this file in 2006
      ... it's a bit astonishing that we didn't identify this long ago.
      
      Reported by Amit Kapila, though this isn't his proposed fix.
      f145454d
    • Peter Eisentraut's avatar
      Fix thinko in SPI_execute_plan() calls · b7212c97
      Peter Eisentraut authored
      Two call sites were apparently thinking that the last argument of
      SPI_execute_plan() is the number of query parameters, but it is actually
      the row limit.  Change the calls to 0, since we don't care about the
      limit there.  The previous code didn't break anything, but it was still
      wrong.
      b7212c97
    • Peter Eisentraut's avatar
      Avoid potential buffer overflow crash · 4053189d
      Peter Eisentraut authored
      A pointer to a C string was treated as a pointer to a "name" datum and
      passed to SPI_execute_plan().  This pointer would then end up being
      passed through datumCopy(), which would try to copy the entire 64 bytes
      of name data, thus running past the end of the C string.  Fix by
      converting the string to a proper name structure.
      
      Found by LLVM AddressSanitizer.
      4053189d
  7. 22 Nov, 2013 2 commits
    • Tom Lane's avatar
      Flatten join alias Vars before pulling up targetlist items from a subquery. · f19e92ed
      Tom Lane authored
      pullup_replace_vars()'s decisions about whether a pulled-up replacement
      expression needs to be wrapped in a PlaceHolderVar depend on the assumption
      that what looks like a Var behaves like a Var.  However, if the Var is a
      join alias reference, later flattening of join aliases might replace the
      Var with something that's not a Var at all, and should have been wrapped.
      
      To fix, do a forcible pass of flatten_join_alias_vars() on the subquery
      targetlist before we start to copy items out of it.  We'll re-run that
      processing on the pulled-up expressions later, but that's harmless.
      
      Per report from Ken Tanzer; the added regression test case is based on his
      example.  This bug has been there since the PlaceHolderVar mechanism was
      invented, but has escaped detection because the circumstances that trigger
      it are fairly narrow.  You need a flattenable query underneath an outer
      join, which contains another flattenable query inside a join of its own,
      with a dangerous expression (a constant or something else non-strict)
      in that one's targetlist.
      
      Having seen this, I'm wondering if it wouldn't be prudent to do all
      alias-variable flattening earlier, perhaps even in the rewriter.
      But that would probably not be a back-patchable change.
      f19e92ed
    • Tom Lane's avatar
      Fix quoting in help messages in uuid-ossp extension scripts. · f29baf92
      Tom Lane authored
      The command we're telling people to type needs to include double-quoting
      around the unfortunately-chosen extension name.  Twiddle the textual
      quoting so that it looks somewhat sane.  Per gripe from roadrunner6.
      f29baf92