Skip to content
Snippets Groups Projects
  1. Jul 17, 2013
  2. Jul 15, 2013
    • Stephen Frost's avatar
      Correct off-by-one when reading from pipe · a3957ac1
      Stephen Frost authored
      In pg_basebackup.c:reached_end_position(), we're reading from an
      internal pipe with our own background process but we're possibly
      reading more bytes than will actually fit into our buffer due to
      an off-by-one error.  As we're reading from an internal pipe
      there's no real risk here, but it's good form to not depend on
      such convenient arrangements.
      
      Bug spotted by the Coverity scanner.
      
      Back-patch to 9.2 where this showed up.
      a3957ac1
  3. Jul 14, 2013
    • Stephen Frost's avatar
      Ensure 64bit arithmetic when calculating tapeSpace · 89c09fe0
      Stephen Frost authored
      In tuplesort.c:inittapes(), we calculate tapeSpace by first figuring
      out how many 'tapes' we can use (maxTapes) and then multiplying the
      result by the tape buffer overhead for each.  Unfortunately, when
      we are on a system with an 8-byte long, we allow work_mem to be
      larger than 2GB and that allows maxTapes to be large enough that the
      32bit arithmetic can overflow when multiplied against the buffer
      overhead.
      
      When this overflow happens, we end up adding the overflow to the
      amount of space available, causing the amount of memory allocated to
      be larger than work_mem.
      
      Note that to reach this point, you have to set work mem to at least
      24GB and be sorting a set which is at least that size.  Given that a
      user who can set work_mem to 24GB could also set it even higher, if
      they were looking to run the system out of memory, this isn't
      considered a security issue.
      
      This overflow risk was found by the Coverity scanner.
      
      Back-patch to all supported branches, as this issue has existed
      since before 8.4.
      89c09fe0
  4. Jul 12, 2013
  5. Jul 11, 2013
    • Bruce Momjian's avatar
      pg_upgrade: document possible pg_hba.conf options · 921a0b20
      Bruce Momjian authored
      Previously, pg_upgrade docs recommended using .pgpass if using MD5
      authentication to avoid being prompted for a password.  Turns out pg_ctl
      never prompts for a password, so MD5 requires .pgpass --- document that.
      Also recommend 'peer' for authentication too.
      Backpatch back to 9.1.
      921a0b20
  6. Jul 08, 2013
    • Tom Lane's avatar
      Fix planning of parameterized appendrel paths with expensive join quals. · 1bd25c03
      Tom Lane authored
      The code in set_append_rel_pathlist() for building parameterized paths
      for append relations (inheritance and UNION ALL combinations) supposed
      that the cheapest regular path for a child relation would still be cheapest
      when reparameterized.  Which might not be the case, particularly if the
      added join conditions are expensive to compute, as in a recent example from
      Jeff Janes.  Fix it to compare child path costs *after* reparameterizing.
      We can short-circuit that if the cheapest pre-existing path is already
      parameterized correctly, which seems likely to be true often enough to be
      worth checking for.
      
      Back-patch to 9.2 where parameterized paths were introduced.
      1bd25c03
  7. Jul 07, 2013
  8. Jul 06, 2013
  9. Jul 05, 2013
  10. Jul 03, 2013
  11. Jul 02, 2013
    • Alvaro Herrera's avatar
      Mention extra_float_digits in floating point docs · ca871e71
      Alvaro Herrera authored
      Make it easier for readers of the FP docs to find out about possibly
      truncated values.
      
      Per complaint from Tom Duffey in message
      F0E0F874-C86F-48D1-AA2A-0C5365BF5118@trillitech.com
      
      Author: Albe Laurenz
      Reviewed by: Abhijit Menon-Sen
      ca871e71
    • Heikki Linnakangas's avatar
      Silence compiler warning in assertion-enabled builds. · c4f386f5
      Heikki Linnakangas authored
      With -Wtype-limits, gcc correctly points out that size_t can never be < 0.
      Backpatch to 9.3 and 9.2. It's been like this forever, but in <= 9.1 you got
      a lot other warnings with -Wtype-limits anyway (at least with my version of
      gcc).
      
      Andres Freund
      c4f386f5
  12. Jun 27, 2013
    • Tom Lane's avatar
      Mark index-constraint comments with correct dependency in pg_dump. · 538ecfad
      Tom Lane authored
      When there's a comment on an index that was created with UNIQUE or PRIMARY
      KEY constraint syntax, we need to label the comment as depending on the
      constraint not the index, since only the constraint object actually appears
      in the dump.  This incorrect dependency can lead to parallel pg_restore
      trying to restore the comment before the index has been created, per bug
      #8257 from Lloyd Albin.
      
      This patch fixes pg_dump to produce the right dependency in dumps made
      in the future.  Usually we also try to hack pg_restore to work around
      bogus dependencies, so that existing (wrong) dumps can still be restored in
      parallel mode; but that doesn't seem practical here since there's no easy
      way to relate the constraint dump entry to the comment after the fact.
      
      Andres Freund
      538ecfad
    • Tom Lane's avatar
      Expect EWOULDBLOCK from a non-blocking connect() call only on Windows. · 2beeabcd
      Tom Lane authored
      On Unix-ish platforms, EWOULDBLOCK may be the same as EAGAIN, which is
      *not* a success return, at least not on Linux.  We need to treat it as a
      failure to avoid giving a misleading error message.  Per the Single Unix
      Spec, only EINPROGRESS and EINTR returns indicate that the connection
      attempt is in progress.
      
      On Windows, on the other hand, EWOULDBLOCK (WSAEWOULDBLOCK) is the expected
      case.  We must accept EINPROGRESS as well because Cygwin will return that,
      and it doesn't seem worth distinguishing Cygwin from native Windows here.
      It's not very clear whether EINTR can occur on Windows, but let's leave
      that part of the logic alone in the absence of concrete trouble reports.
      
      Also, remove the test for errno == 0, effectively reverting commit
      da9501bd, which AFAICS was just a thinko;
      or at best it might have been a workaround for a platform-specific bug,
      which we can hope is gone now thirteen years later.  In any case, since
      libpq makes no effort to reset errno to zero before calling connect(),
      it seems unlikely that that test has ever reliably done anything useful.
      
      Andres Freund and Tom Lane
      2beeabcd
    • Tom Lane's avatar
      Tweak wording in sequence-function docs to avoid PDF build failures. · 60d7edb8
      Tom Lane authored
      Adjust the wording in the first para of "Sequence Manipulation Functions"
      so that neither of the link phrases in it break across line boundaries,
      in either A4- or US-page-size PDF output.  This fixes a reported build
      failure for the 9.3beta2 A4 PDF docs, and future-proofs this particular
      para against causing similar problems in future.  (Perhaps somebody will
      fix this issue in the SGML/TeX documentation tool chain someday, but I'm
      not holding my breath.)
      
      Back-patch to all supported branches, since the same problem could rise up
      to bite us in future updates if anyone changes anything earlier than this
      in func.sgml.
      60d7edb8
    • Noah Misch's avatar
      Document effect of constant folding on CASE. · 1f3fbced
      Noah Misch authored
      Back-patch to all supported versions.
      
      Laurenz Albe
      1f3fbced
  13. Jun 25, 2013
    • Andrew Dunstan's avatar
      Properly dump dropped foreign table cols in binary-upgrade mode. · 5734eb2c
      Andrew Dunstan authored
      In binary upgrade mode, we need to recreate and then drop dropped
      columns so that all the columns get the right attribute number. This is
      true for foreign tables as well as for native tables. For foreign
      tables we have been getting the first part right but not the second,
      leading to bogus columns in the upgraded database. Fix this all the way
      back to 9.1, where foreign tables were introduced.
      5734eb2c
    • Fujii Masao's avatar
      Support clean switchover. · bee4a4d3
      Fujii Masao authored
      In replication, when we shutdown the master, walsender tries to send
      all the outstanding WAL records to the standby, and then to exit. This
      basically means that all the WAL records are fully synced between
      two servers after the clean shutdown of the master. So, after
      promoting the standby to new master, we can restart the stopped
      master as new standby without the need for a fresh backup from
      new master.
      
      But there was one problem so far: though walsender tries to send all
      the outstanding WAL records, it doesn't wait for them to be replicated
      to the standby. Then, before receiving all the WAL records,
      walreceiver can detect the closure of connection and exit. We cannot
      guarantee that there is no missing WAL in the standby after clean
      shutdown of the master. In this case, backup from new master is
      required when restarting the stopped master as new standby.
      
      This patch fixes this problem. It just changes walsender so that it
      waits for all the outstanding WAL records to be replicated to the
      standby before closing the replication connection.
      
      Per discussion, this is a fix that needs to get backpatched rather than
      new feature. So, back-patch to 9.1 where enough infrastructure for
      this exists.
      
      Patch by me, reviewed by Andres Freund.
      bee4a4d3
  14. Jun 23, 2013
    • Simon Riggs's avatar
      Ensure no xid gaps during Hot Standby startup · 99ee15b3
      Simon Riggs authored
      In some cases with higher numbers of subtransactions
      it was possible for us to incorrectly initialize
      subtrans leading to complaints of missing pages.
      
      Bug report by Sergey Konoplev
      Analysis and fix by Andres Freund
      99ee15b3
  15. Jun 20, 2013
  16. Jun 19, 2013
    • Kevin Grittner's avatar
      Fix the create_index regression test for Danish collation. · de31442b
      Kevin Grittner authored
      In Danish collations, there are letter combinations which sort
      higher than 'Z'.  A test for values > 'WA' was picking up rows
      where the value started with 'AA', causing the test to fail.
      
      Backpatch to 9.2, where the failing test was added.
      
      Per report from Svenne Krap and analysis by Jeff Janes
      de31442b
  17. Jun 18, 2013
    • Simon Riggs's avatar
      Fix docs on lock level for ALTER TABLE VALIDATE · 20a562f9
      Simon Riggs authored
      ALTER TABLE .. VALIDATE CONSTRAINT previously
      gave incorrect details about lock levels and
      therefore incomplete reasons to use the option.
      
      Initial bug report and fix from Marko Tiikkaja
      Reworded by me to include comments by Kevin Grittner
      20a562f9
  18. Jun 15, 2013
  19. Jun 14, 2013
    • Tom Lane's avatar
      Avoid deadlocks during insertion into SP-GiST indexes. · cbabf50d
      Tom Lane authored
      SP-GiST's original scheme for avoiding deadlocks during concurrent index
      insertions doesn't work, as per report from Hailong Li, and there isn't any
      evident way to make it work completely.  We could possibly lock individual
      inner tuples instead of their whole pages, but preliminary experimentation
      suggests that the performance penalty would be huge.  Instead, if we fail
      to get a buffer lock while descending the tree, just restart the tree
      descent altogether.  We keep the old tuple positioning rules, though, in
      hopes of reducing the number of cases where this can happen.
      
      Teodor Sigaev, somewhat edited by Tom Lane
      cbabf50d
  20. Jun 13, 2013
    • Tom Lane's avatar
      Only install a portal's ResourceOwner if it actually has one. · 7e0b9ed6
      Tom Lane authored
      In most scenarios a portal without a ResourceOwner is dead and not subject
      to any further execution, but a portal for a cursor WITH HOLD remains in
      existence with no ResourceOwner after the creating transaction is over.
      In this situation, if we attempt to "execute" the portal directly to fetch
      data from it, we were setting CurrentResourceOwner to NULL, leading to a
      segfault if the datatype output code did anything that required a resource
      owner (such as trying to fetch system catalog entries that weren't already
      cached).  The case appears to be impossible to provoke with stock libpq,
      but psqlODBC at least is able to cause it when working with held cursors.
      
      Simplest fix is to just skip the assignment to CurrentResourceOwner, so
      that any resources used by the data output operations will be managed by
      the transaction-level resource owner instead.  For consistency I changed
      all the places that install a portal's resowner as current, even though
      some of them are probably not reachable with a held cursor's portal.
      
      Per report from Joshua Berry (with thanks to Hiroshi Inoue for developing
      a self-contained test case).  Back-patch to all supported versions.
      7e0b9ed6
  21. Jun 12, 2013
  22. Jun 11, 2013
    • Tom Lane's avatar
      Fix cache flush hazard in cache_record_field_properties(). · fd59974f
      Tom Lane authored
      We need to increment the refcount on the composite type's cached tuple
      descriptor while we do lookups of its column types.  Otherwise a cache
      flush could occur and release the tuple descriptor before we're done with
      it.  This fails reliably with -DCLOBBER_CACHE_ALWAYS, but the odds of a
      failure in a production build seem rather low (since the pfree'd descriptor
      typically wouldn't get scribbled on immediately).  That may explain the
      lack of any previous reports.  Buildfarm issue noted by Christian Ullrich.
      
      Back-patch to 9.1 where the bogus code was added.
      fd59974f
    • Tatsuo Ishii's avatar
      Add description that loread()/lowrite() are corresponding to · c571b516
      Tatsuo Ishii authored
      lo_read()/lo_write() in libpq to avoid confusion.
      c571b516
  23. Jun 10, 2013
    • Joe Conway's avatar
      Fix ordering of obj id for Rules and EventTriggers in pg_dump. · 1723df6e
      Joe Conway authored
      getSchemaData() must identify extension member objects and mark them
      as not to be dumped. This must happen after reading all objects that can be
      direct members of extensions, but before we begin to process table subsidiary
      objects. Both rules and event triggers were wrong in this regard.
      
      Backport rules portion of patch to 9.1 -- event triggers do not exist prior to 9.3.
      Suggested fix by Tom Lane, initial complaint and patch by me.
      1723df6e
    • Tom Lane's avatar
      Remove unnecessary restrictions about RowExprs in transformAExprIn(). · 5cd77baa
      Tom Lane authored
      When the existing code here was written, it made sense to special-case
      RowExprs because that was the only way that we could handle row comparisons
      at all.  Now that we have record_eq() and arrays of composites, the generic
      logic for "scalar" types will in fact work on RowExprs too, so there's no
      reason to throw error for combinations of RowExprs and other ways of
      forming composite values, nor to ignore the possibility of using a
      ScalarArrayOpExpr.  But keep using the old logic when comparing two
      RowExprs, for consistency with the main transformAExprOp() logic.  (This
      allows some cases with not-quite-identical rowtypes to succeed, so we might
      get push-back if we removed it.)  Per bug #8198 from Rafal Rzepecki.
      
      Back-patch to all supported branches, since this works fine as far back as
      8.4.
      
      Rafal Rzepecki and Tom Lane
      5cd77baa
  24. Jun 09, 2013
    • Tom Lane's avatar
      Remove ALTER DEFAULT PRIVILEGES' requirement of schema CREATE permissions. · 5f4a3116
      Tom Lane authored
      Per discussion, this restriction isn't needed for any real security reason,
      and it seems to confuse people more often than it helps them.  It could
      also result in some database states being unrestorable.  So just drop it.
      
      Back-patch to 9.0, where ALTER DEFAULT PRIVILEGES was introduced.
      5f4a3116
    • Tom Lane's avatar
      Remove fixed limit on the number of concurrent AllocateFile() requests. · a9ec978e
      Tom Lane authored
      AllocateFile(), AllocateDir(), and some sister routines share a small array
      for remembering requests, so that the files can be closed on transaction
      failure.  Previously that array had a fixed size, MAX_ALLOCATED_DESCS (32).
      While historically that had seemed sufficient, Steve Toutant pointed out
      that this meant you couldn't scan more than 32 file_fdw foreign tables in
      one query, because file_fdw depends on the COPY code which uses
      AllocateFile().  There are probably other cases, or will be in the future,
      where this nonconfigurable limit impedes users.
      
      We can't completely remove any such limit, at least not without a lot of
      work, since each such request requires a kernel file descriptor and most
      platforms limit the number we can have.  (In principle we could
      "virtualize" these descriptors, as fd.c already does for the main VFD pool,
      but not without an additional layer of overhead and a lot of notational
      impact on the calling code.)  But we can at least let the array size be
      configurable.  Hence, change the code to allow up to max_safe_fds/2
      allocated file requests.  On modern platforms this should allow several
      hundred concurrent file_fdw scans, or more if one increases the value of
      max_files_per_process.  To go much further than that, we'd need to do some
      more work on the data structure, since the current code for closing
      requests has potentially O(N^2) runtime; but it should still be all right
      for request counts in this range.
      
      Back-patch to 9.1 where contrib/file_fdw was introduced.
      a9ec978e
  25. Jun 08, 2013
    • Andrew Dunstan's avatar
      Don't downcase non-ascii identifier chars in multi-byte encodings. · a56c92f9
      Andrew Dunstan authored
      Long-standing code has called tolower() on identifier character bytes
      with the high bit set. This is clearly an error and produces junk output
      when the encoding is multi-byte. This patch therefore restricts this
      activity to cases where there is a character with the high bit set AND
      the encoding is single-byte.
      
      There have been numerous gripes about this, most recently from Martin
      Schäfer.
      
      Backpatch to all live releases.
      a56c92f9
  26. Jun 07, 2013
  27. Jun 06, 2013
Loading