Skip to content
Snippets Groups Projects
  1. Jun 27, 2013
  2. 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
  3. 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
  4. Jun 20, 2013
  5. 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
  6. 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
  7. Jun 15, 2013
  8. 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
  9. 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
  10. Jun 12, 2013
  11. 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
  12. 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
  13. 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
  14. 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
  15. Jun 07, 2013
  16. Jun 06, 2013
    • Heikki Linnakangas's avatar
      Fix typo in comment. · 7e775be6
      Heikki Linnakangas authored
      7e775be6
    • Robert Haas's avatar
      17fa4c32
    • Robert Haas's avatar
      Backport log_newpage_buffer. · 4c641d99
      Robert Haas authored
      Andres' fix for XLOG_HEAP2_VISIBLE on unitialized pages requires
      this.
      4c641d99
    • Bruce Momjian's avatar
      pg_upgrade: document that --link should be used with --check · 6ab834fd
      Bruce Momjian authored
      Backpatch to 9.2.
      6ab834fd
    • Tom Lane's avatar
      Prevent pushing down WHERE clauses into unsafe UNION/INTERSECT nests. · 341757bd
      Tom Lane authored
      The planner is aware that it mustn't push down upper-level quals into
      subqueries if the quals reference subquery output columns that contain
      set-returning functions or volatile functions, or are non-DISTINCT outputs
      of a DISTINCT ON subquery.  However, it missed making this check when
      there were one or more levels of UNION or INTERSECT above the dangerous
      expression.  This could lead to "set-valued function called in context that
      cannot accept a set" errors, as seen in bug #8213 from Eric Soroos, or to
      silently wrong answers in the other cases.
      
      To fix, refactor the checks so that we make the column-is-unsafe checks
      during subquery_is_pushdown_safe(), which already has to recursively
      inspect all arms of a set-operation tree.  This makes
      qual_is_pushdown_safe() considerably simpler, at the cost that we will
      spend some cycles checking output columns that possibly aren't referenced
      in any upper qual.  But the cases where this code gets executed at all
      are already nontrivial queries, so it's unlikely anybody will notice any
      slowdown of planning.
      
      This has been broken since commit 05f916e6,
      which makes the bug over ten years old.  A bit surprising nobody noticed it
      before now.
      341757bd
  17. Jun 05, 2013
    • Tom Lane's avatar
      Put analyze_keyword back in explain_option_name production. · 48b51209
      Tom Lane authored
      In commit 2c92edad, I broke "EXPLAIN
      (ANALYZE)" syntax, because I mistakenly thought that ANALYZE/ANALYSE were
      only partially reserved and thus would be included in NonReservedWord;
      but actually they're fully reserved so they still need to be called out
      here.
      
      A nicer solution would be to demote these words to type_func_name_keyword
      status (they can't be less than that because of "VACUUM [ANALYZE] ColId").
      While that works fine so far as the core grammar is concerned, it breaks
      ECPG's grammar for reasons I don't have time to isolate at the moment.
      So do this for the time being.
      
      Per report from Kevin Grittner.  Back-patch to 9.0, like the previous
      commit.
      48b51209
    • Peter Eisentraut's avatar
      doc: Add IDs to link targets used by phpPgAdmin · 75b161d0
      Peter Eisentraut authored
      Karl O. Pinc
      75b161d0
  18. Jun 04, 2013
    • Tom Lane's avatar
      Provide better message when CREATE EXTENSION can't find a target schema. · 2ff74efa
      Tom Lane authored
      The new message (and SQLSTATE) matches the corresponding error cases in
      namespace.c.
      
      This was thought to be a "can't happen" case when extension.c was written,
      so we didn't think hard about how to report it.  But it definitely can
      happen in 9.2 and later, since we no longer require search_path to contain
      any valid schema names.  It's probably also possible in 9.1 if search_path
      came from a noninteractive source.  So, back-patch to all releases
      containing this code.
      
      Per report from Sean Chittenden, though this isn't exactly his patch.
      2ff74efa
    • Tom Lane's avatar
      Add ARM64 (aarch64) support to s_lock.h. · 612ecf31
      Tom Lane authored
      Use the same gcc atomic functions as we do on newer ARM chips.
      (Basically this is a copy and paste of the __arm__ code block,
      but omitting the SWPB option since that definitely won't work.)
      
      Back-patch to 9.2.  The patch would work further back, but we'd also
      need to update config.guess/config.sub in older branches to make them
      build out-of-the-box, and there hasn't been demand for it.
      
      Mark Salter
      612ecf31
    • Tom Lane's avatar
      Fix memory leak in LogStandbySnapshot(). · 81fe138b
      Tom Lane authored
      The array allocated by GetRunningTransactionLocks() needs to be pfree'd
      when we're done with it.  Otherwise we leak some memory during each
      checkpoint, if wal_level = hot_standby.  This manifests as memory bloat
      in the checkpointer process, or in bgwriter in versions before we made
      the checkpointer separate.
      
      Reported and fixed by Naoya Anzai.  Back-patch to 9.0 where the issue
      was introduced.
      
      In passing, improve comments for GetRunningTransactionLocks(), and add
      an Assert that we didn't overrun the palloc'd array.
      81fe138b
  19. Jun 03, 2013
    • Tom Lane's avatar
      Add semicolons to eval'd strings to hide a minor Perl behavioral change. · cc510d97
      Tom Lane authored
      "eval q{foo}" used to complain that the error was on line 2 of the eval'd
      string, because eval internally tacked on "\n;" so that the end of the
      erroneous command was indeed on line 2.  But as of Perl 5.18 it more
      sanely says that the error is on line 1.  To avoid Perl-version-dependent
      regression test results, use "eval q{foo;}" instead in the two places
      where this matters.  Per buildfarm.
      
      Since people might try to use newer Perl versions with older PG releases,
      back-patch as far as 9.0 where these test cases were added.
      cc510d97
    • Tom Lane's avatar
      Allow type_func_name_keywords in some places where they weren't before. · 17a22a74
      Tom Lane authored
      This change makes type_func_name_keywords less reserved than they were
      before, by allowing them for role names, language names, EXPLAIN and COPY
      options, and SET values for GUCs; which are all places where few if any
      actual keywords could appear instead, so no new ambiguities are introduced.
      
      The main driver for this change is to allow "COPY ... (FORMAT BINARY)"
      to work without quoting the word "binary".  That is an inconsistency that
      has been complained of repeatedly over the years (at least by Pavel Golub,
      Kurt Lidl, and Simon Riggs); but we hadn't thought of any non-ugly solution
      until now.
      
      Back-patch to 9.0 where the COPY (FORMAT BINARY) syntax was introduced.
      17a22a74
  20. May 29, 2013
  21. May 27, 2013
    • Stephen Frost's avatar
      Documentation fix for ALTER TYPE .. RENAME · 02230d3c
      Stephen Frost authored
      The documentation for ALTER TYPE .. RENAME claimed to support a
      RESTRICT/CASCADE option at the 'type' level, which wasn't implemented
      and doesn't make a whole lot of sense to begin with.  What is supported,
      and previously undocumented, is
      
      ALTER TYPE .. RENAME ATTRIBUTE .. RESTRICT/CASCADE.
      
      I've updated the documentation and back-patched this to 9.1 where it was
      first introduced.
      02230d3c
  22. May 23, 2013
    • Robert Haas's avatar
      Fix typo in comment. · 6e83fc6d
      Robert Haas authored
      Pavan Deolasee
      6e83fc6d
    • Heikki Linnakangas's avatar
      Print line number correctly in COPY. · fcf91c06
      Heikki Linnakangas authored
      When COPY uses the multi-insert method to insert a batch of tuples into the
      heap at a time, incorrect line number was printed if something went wrong in
      inserting the index tuples (primary key failure, for exampl), or processing
      after row triggers.
      
      Fixes bug #8173 reported by Lloyd Albin. Backpatch to 9.2, where the multi-
      insert code was added.
      fcf91c06
  23. May 16, 2013
    • Tom Lane's avatar
      Fix fd.c to preserve errno where needed. · e7e005ed
      Tom Lane authored
      PathNameOpenFile failed to ensure that the correct value of errno was
      returned to its caller after a failure (because it incorrectly supposed
      that free() can never change errno).  In some cases this would result
      in a user-visible failure because an expected ENOENT errno was replaced
      with something else.  Bogus EINVAL failures have been observed on OS X,
      for example.
      
      There were also a couple of places that could mangle an important value
      of errno if FDDEBUG was defined.  While the usefulness of that debug
      support is highly debatable, we might as well make it safe to use,
      so add errno save/restore logic to the DO_DB macro.
      
      Per bug #8167 from Nelson Minar, diagnosed by RhodiumToad.
      Back-patch to all supported branches.
      e7e005ed
  24. May 13, 2013
    • Tom Lane's avatar
      Fix handling of OID wraparound while in standalone mode. · 630a8af5
      Tom Lane authored
      If OID wraparound should occur while in standalone mode (unlikely but
      possible), we want to advance the counter to FirstNormalObjectId not
      FirstBootstrapObjectId.  Otherwise, user objects might be created with OIDs
      in the system-reserved range.  That isn't immediately harmful but it poses
      a risk of conflicts during future pg_upgrade operations.
      
      Noted by Andres Freund.  Back-patch to all supported branches, since all of
      them are supported sources for pg_upgrade operations.
      630a8af5
  25. May 11, 2013
  26. May 10, 2013
    • Tom Lane's avatar
      Guard against input_rows == 0 in estimate_num_groups(). · 4ebbbf3c
      Tom Lane authored
      This case doesn't normally happen, because the planner usually clamps
      all row estimates to at least one row; but I found that it can arise
      when dealing with relations excluded by constraints.  Without a defense,
      estimate_num_groups() can return zero, which leads to divisions by zero
      inside the planner as well as assertion failures in the executor.
      
      An alternative fix would be to change set_dummy_rel_pathlist() to make
      the size estimate for a dummy relation 1 row instead of 0, but that seemed
      pretty ugly; and probably someday we'll want to drop the convention that
      the minimum rowcount estimate is 1 row.
      
      Back-patch to 8.4, as the problem can be demonstrated that far back.
      4ebbbf3c
Loading