1. 16 Aug, 2017 10 commits
  2. 15 Aug, 2017 18 commits
    • Peter Eisentraut's avatar
      Include foreign tables in information_schema.table_privileges · 0659465c
      Peter Eisentraut authored
      This appears to have been an omission in the original commit
      0d692a0d.  All related information_schema views already include
      foreign tables.
      Reported-by: default avatarNicolas Thauvin <nicolas.thauvin@dalibo.com>
      0659465c
    • Peter Eisentraut's avatar
      psql: Add tab completion for \pset pager · 0f0ee68e
      Peter Eisentraut authored
      Author: Pavel Stehule <pavel.stehule@gmail.com>
      0f0ee68e
    • Alvaro Herrera's avatar
      Simplify autovacuum work-item implementation · 31ae1638
      Alvaro Herrera authored
      The initial implementation of autovacuum work-items used a dynamic
      shared memory area (DSA).  However, it's argued that dynamic shared
      memory is not portable enough, so we cannot rely on it being supported
      everywhere; at the same time, autovacuum work-items are now a critical
      part of the server, so it's not acceptable that they don't work in the
      cases where dynamic shared memory is disabled.  Therefore, let's fall
      back to a simpler implementation of work-items that just uses
      autovacuum's main shared memory segment for storage.
      
      Discussion: https://postgr.es/m/CA+TgmobQVbz4K_+RSmiM9HeRKpy3vS5xnbkL95gSEnWijzprKQ@mail.gmail.com
      31ae1638
    • Tom Lane's avatar
      Make simpler-simple-expressions code cope with a Gather plan. · b73f1b5c
      Tom Lane authored
      Commit 00418c61 expected that the plan generated for a simple-expression
      query would always be a plain Result node.  However, if force_parallel_mode
      is on, the planner might stick a Gather atop that.  Cope by looking through
      the Gather.  For safety, assert that the Gather's tlist is trivial.
      
      Per buildfarm.
      
      Discussion: https://postgr.es/m/23425.1502822098@sss.pgh.pa.us
      b73f1b5c
    • Peter Eisentraut's avatar
      Fix logical replication protocol comparison logic · 70b573b2
      Peter Eisentraut authored
      Since we currently only have one protocol, this doesn't make much of a
      difference other than the error message.
      
      Author: Yugo Nagata <nagata@sraoss.co.jp>
      70b573b2
    • Peter Eisentraut's avatar
      doc: Add missing logical replication protocol message · 34a23a34
      Peter Eisentraut authored
      Author: Masahiko Sawada <sawada.mshk@gmail.com>
      34a23a34
    • Peter Eisentraut's avatar
      Simplify some code in logical replication launcher · e42351ae
      Peter Eisentraut authored
      Avoid unnecessary locking calls when a subscription is disabled.
      
      Author: Yugo Nagata <nagata@sraoss.co.jp>
      e42351ae
    • Peter Eisentraut's avatar
      doc: Improve PDF bookmarks · 270fec9f
      Peter Eisentraut authored
      Also create PDF bookmarks/ToC entries for subsections of reference
      pages.  This was a regression from the previous jadetex-based build.
      Reported-by: default avatarErik Rijkers <er@xs4all.nl>
      270fec9f
    • Tom Lane's avatar
      Avoid out-of-memory in a hash join with many duplicate inner keys. · 4867d7f6
      Tom Lane authored
      The executor is capable of splitting buckets during a hash join if
      too much memory is being used by a small number of buckets.  However,
      this only helps if a bucket's population is actually divisible; if
      all the hash keys are alike, the tuples still end up in the same
      new bucket.  This can result in an OOM failure if there are enough
      inner keys with identical hash values.  The planner's cost estimates
      will bias it against choosing a hash join in such situations, but not
      by so much that it will never do so.  To mitigate the OOM hazard,
      explicitly estimate the hash bucket space needed by just the inner
      side's most common value, and if that would exceed work_mem then
      add disable_cost to the hash cost estimate.
      
      This approach doesn't account for the possibility that two or more
      common values would share the same hash value.  On the other hand,
      work_mem is normally a fairly conservative bound, so that eating
      two or more times that much space is probably not going to kill us.
      
      If we have no stats about the inner side, ignore this consideration.
      There was some discussion of making a conservative assumption, but that
      would effectively result in disabling hash join whenever we lack stats,
      which seems like an overreaction given how seldom the problem manifests
      in the field.
      
      Per a complaint from David Hinkle.  Although this could be viewed
      as a bug fix, the lack of similar complaints weighs against back-
      patching; indeed we waited for v11 because it seemed already rather
      late in the v10 cycle to be making plan choice changes like this one.
      
      Discussion: https://postgr.es/m/32013.1487271761@sss.pgh.pa.us
      4867d7f6
    • Alvaro Herrera's avatar
      Fix error handling path in autovacuum launcher · d9a622ce
      Alvaro Herrera authored
      The original code (since 00e6a16d) was assuming aborting the
      transaction in autovacuum launcher was sufficient to release all
      resources, but in reality the launcher runs quite a lot of code out of
      any transactions.  Re-introduce individual cleanup calls to make abort
      more robust.
      
      Reported-by: Robert Haas
      Discussion: https://postgr.es/m/CA+TgmobQVbz4K_+RSmiM9HeRKpy3vS5xnbkL95gSEnWijzprKQ@mail.gmail.com
      d9a622ce
    • Robert Haas's avatar
      Assorted preparatory refactoring for partition-wise join. · e139f195
      Robert Haas authored
      Instead of duplicating the logic to search for a matching
      ParamPathInfo in multiple places, factor it out into a separate
      function.
      
      Pass only the relevant bits of the PartitionKey to
      partition_bounds_equal instead of the whole thing, because
      partition-wise join will want to call this without having a
      PartitionKey available.
      
      Adjust allow_star_schema_join and calc_nestloop_required_outer
      to take relevant Relids rather than the entire Path, because
      partition-wise join will want to call it with the top-parent
      relids to determine whether a child join is allowable.
      
      Ashutosh Bapat.  Review and testing of the larger patch set of which
      this is a part by Amit Langote, Rajkumar Raghuwanshi, Rafia Sabih,
      Thomas Munro, Dilip Kumar, and me.
      
      Discussion: http://postgr.es/m/CA+TgmobQK80vtXjAsPZWWXd7c8u13G86gmuLupN+uUJjA+i4nA@mail.gmail.com
      e139f195
    • Tom Lane's avatar
      Simplify plpgsql's check for simple expressions. · 00418c61
      Tom Lane authored
      plpgsql wants to recognize expressions that it can execute directly
      via ExecEvalExpr() instead of going through the full SPI machinery.
      Originally the test for this consisted of recursively groveling through
      the post-planning expression tree to see if it contained only nodes that
      plpgsql recognized as safe.  That was a major maintenance headache, since
      it required updating plpgsql every time we added any kind of expression
      node.  It was also kind of expensive, so over time we added various
      pre-planning checks to try to short-circuit having to do that.
      Robert Haas pointed out that as of the SRF-processing changes in v10,
      particularly the addition of Query.hasTargetSRFs, there really isn't
      any reason to make the recursive scan at all: the initial checks cover
      everything we really care about.  We do have to make sure that those
      checks agree with what inline_function() considers, so that inlining
      of a function that formerly wasn't inlined can't cause an expression
      considered simple to become non-simple.
      
      Hence, delete the recursive function exec_simple_check_node(), and tweak
      those other tests to more exactly agree with inline_function().  Adjust
      some comments and function naming to match.
      
      Discussion: https://postgr.es/m/CA+TgmoZGZpwdEV2FQWaVxA_qZXsQE1DAS5Fu8fwxXDNvfndiUQ@mail.gmail.com
      00418c61
    • Michael Meskes's avatar
      a4619b26
    • Tom Lane's avatar
      Distinguish wait-for-connection from wait-for-write-ready on Windows. · f3a4d7e7
      Tom Lane authored
      The API for WaitLatch and friends followed the Unix convention in which
      waiting for a socket connection to complete is identical to waiting for
      the socket to accept a write.  While Windows provides a select(2)
      emulation that agrees with that, the native WaitForMultipleObjects API
      treats them as quite different --- and for some bizarre reason, it will
      report a not-yet-connected socket as write-ready.  libpq itself has so
      far escaped dealing with this because it waits with select(), but in
      libpqwalreceiver.c we want to wait using WaitLatchOrSocket.  The semantics
      mismatch resulted in replication connection failures on Windows, but only
      for remote connections (apparently, localhost connections complete
      immediately, or at least too fast for anyone to have noticed the problem
      in single-machine testing).
      
      To fix, introduce an additional WL_SOCKET_CONNECTED wait flag for
      WaitLatchOrSocket, which is identical to WL_SOCKET_WRITEABLE on
      non-Windows, but results in waiting for FD_CONNECT events on Windows.
      
      Ideally, we would also distinguish the two conditions in the API for
      PQconnectPoll(), but changing that API at this point seems infeasible.
      Instead, cheat by checking for PQstatus() == CONNECTION_STARTED to
      determine that we're still waiting for the connection to complete.
      (This is a cheat mainly because CONNECTION_STARTED is documented as an
      internal state rather than something callers should rely on.  Perhaps
      we ought to change the documentation ... but this patch doesn't.)
      
      Per reports from Jobin Augustine and Igor Neyman.  Back-patch to v10
      where commit 1e8a8500 exposed this longstanding shortcoming.
      
      Andres Freund, minor fix and some code review/beautification by me
      
      Discussion: https://postgr.es/m/CAHBggj8g2T+ZDcACZ2FmzX9CTxkWjKBsHd6NkYB4i9Ojf6K1Fw@mail.gmail.com
      f3a4d7e7
    • Robert Haas's avatar
      Teach adjust_appendrel_attrs(_multilevel) to do multiple translations. · 480f1f43
      Robert Haas authored
      Currently, child relations are always base relations, so when we
      translate parent relids to child relids, we only need to translate
      a singler relid.  However, the proposed partition-wise join feature
      will create child joins, which will mean we need to translate a set
      of parent relids to the corresponding child relids.  This is
      preliminary refactoring to make that possible.
      
      Ashutosh Bapat.  Review and testing of the larger patch set of which
      this is a part by Amit Langote, Rajkumar Raghuwanshi, Rafia Sabih,
      Thomas Munro, Dilip Kumar, and me.  Some adjustments, mostly
      cosmetic, by me.
      
      Discussion: http://postgr.es/m/CA+TgmobQK80vtXjAsPZWWXd7c8u13G86gmuLupN+uUJjA+i4nA@mail.gmail.com
      480f1f43
    • Robert Haas's avatar
      Avoid unnecessary single-child Append nodes. · d57929af
      Robert Haas authored
      Before commit d3cc37f1, an inheritance parent
      whose only children were temp tables of other sessions would end up
      as a simple scan of the parent; but with that commit, we end up with
      an Append node, per a report from Ashutosh Bapat.  Tweak the logic
      so that we go back to the old way, and update the function header
      comment for partitioning while we're at it.
      
      Ashutosh Bapat, reviewed by Amit Langote and adjusted by me.
      
      Discussion: http://postgr.es/m/CAFjFpReWJr1yTkHU=OqiMBmcYCMoSW3VPR39RBuQ_ovwDFBT5Q@mail.gmail.com
      d57929af
    • Robert Haas's avatar
    • Robert Haas's avatar
      pg_dump: Add a --load-via-partition-root option. · 23d7680d
      Robert Haas authored
      Rushabh Lathia, reviewed and somewhat revised by me.  Testing by
      Rajkumar Raghuwanshi.
      
      Discussion: http://postgr.es/m/CAGPqQf0C1he087bz9xRBOGZBuESYz9X=Fp8Ca_g+TfHgAff75g@mail.gmail.com
      23d7680d
  3. 14 Aug, 2017 8 commits
    • Andres Freund's avatar
      Expand coverage of parallel gather merge a bit. · d2bc5015
      Andres Freund authored
      Previously paths reaching heap_compare_slots weren't covered.
      
      Author: Rushabh Lathia
      Reviewed-By: Andres Freund
      Discussion:
      	https://postgr.es/m/CAGPqQf3C+3PBujb+7m=ceWeii4-vBY=XS99LjzrpkpefvzJbFg@mail.gmail.com
      	https://postgr.es/m/27200.1502482851@sss.pgh.pa.us
      Backpatch: 10, where gather merge was introduced
      d2bc5015
    • Tom Lane's avatar
      Stamp HEAD as 11devel. · 9f14dc39
      Tom Lane authored
      Note that we no longer require any manual adjustments to shared-library
      minor version numbers, cf commit a3bce17e.  So this should be everything.
      9f14dc39
    • Tom Lane's avatar
      Final pgindent + perltidy run for v10. · 21d304df
      Tom Lane authored
      21d304df
    • Tom Lane's avatar
      Handle elog(FATAL) during ROLLBACK more robustly. · 5b6289c1
      Tom Lane authored
      Stress testing by Andreas Seltenreich disclosed longstanding problems that
      occur if a FATAL exit (e.g. due to receipt of SIGTERM) occurs while we are
      trying to execute a ROLLBACK of an already-failed transaction.  In such a
      case, xact.c is in TBLOCK_ABORT state, so that AbortOutOfAnyTransaction
      would skip AbortTransaction and go straight to CleanupTransaction.  This
      led to an assert failure in an assert-enabled build (due to the ROLLBACK's
      portal still having a cleanup hook) or without assertions, to a FATAL exit
      complaining about "cannot drop active portal".  The latter's not
      disastrous, perhaps, but it's messy enough to want to improve it.
      
      We don't really want to run all of AbortTransaction in this code path.
      The minimum required to clean up the open portal safely is to do
      AtAbort_Memory and AtAbort_Portals.  It seems like a good idea to
      do AtAbort_Memory unconditionally, to be entirely sure that we are
      starting with a safe CurrentMemoryContext.  That means that if the
      main loop in AbortOutOfAnyTransaction does nothing, we need an extra
      step at the bottom to restore CurrentMemoryContext = TopMemoryContext,
      which I chose to do by invoking AtCleanup_Memory.  This'll result in
      calling AtCleanup_Memory twice in many of the paths through this function,
      but that seems harmless and reasonably inexpensive.
      
      The original motivation for the assertion in AtCleanup_Portals was that
      we wanted to be sure that any user-defined code executed as a consequence
      of the cleanup hook runs during AbortTransaction not CleanupTransaction.
      That still seems like a valid concern, and now that we've seen one case
      of the assertion firing --- which means that exactly that would have
      happened in a production build --- let's replace the Assert with a runtime
      check.  If we see the cleanup hook still set, we'll emit a WARNING and
      just drop the hook unexecuted.
      
      This has been like this a long time, so back-patch to all supported
      branches.
      
      Discussion: https://postgr.es/m/877ey7bmun.fsf@ansel.ydns.eu
      5b6289c1
    • Peter Eisentraut's avatar
      Fix typo · 7f1bb1d7
      Peter Eisentraut authored
      Author: Masahiko Sawada <sawada.mshk@gmail.com>
      7f1bb1d7
    • Peter Eisentraut's avatar
      doc: Fix logical replication protocol doc detail · 79e5de69
      Peter Eisentraut authored
      Author: Masahiko Sawada <sawada.mshk@gmail.com>
      Reported-by: default avatarKyle Conroy <kyle@kyleconroy.com>
      Bug: #14775
      79e5de69
    • Tom Lane's avatar
      Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant. · 5a5c2fec
      Tom Lane authored
      Commit 3c163a7f's original choice to ignore all #define symbols whose
      names begin with underscore turns out to be too simplistic.  On Windows,
      some Perl installations are built with -D_USE_32BIT_TIME_T, and we must
      absorb that or we get the wrong result for sizeof(PerlInterpreter).
      
      This effectively re-reverts commit ef58b87d, which injected that symbol
      in a hacky way, making it apply to all of Postgres not just PL/Perl.
      More significantly, it did so on *all* 32-bit Windows builds, even when
      the Perl build to be used did not select this option; so that it fails
      to work properly with some newer Perl builds.
      
      By making this change, we would be introducing an ABI break in 32-bit
      Windows builds; but fortunately we have not used type time_t in any
      exported Postgres APIs in a long time.  So it should be OK, both for
      PL/Perl itself and for third-party extensions, if an extension library
      is built with a different _USE_32BIT_TIME_T setting than the core code.
      
      Patch by me, based on research by Ashutosh Sharma and Robert Haas.
      Back-patch to all supported branches, as commit 3c163a7f was.
      
      Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
      5a5c2fec
    • Michael Meskes's avatar
  4. 13 Aug, 2017 3 commits
    • Tom Lane's avatar
      Remove AtEOXact_CatCache(). · 004a9702
      Tom Lane authored
      The sole useful effect of this function, to check that no catcache
      entries have positive refcounts at transaction end, has really been
      obsolete since we introduced ResourceOwners in PG 8.1.  We reduced the
      checks to assertions years ago, so that the function was a complete
      no-op in production builds.  There have been previous discussions about
      removing it entirely, but consensus up to now was that it had some small
      value as a cross-check for bugs in the ResourceOwner logic.
      
      However, it now emerges that it's possible to trigger these assertions
      if you hit an assert-enabled backend with SIGTERM during a call to
      SearchCatCacheList, because that function temporarily increases the
      refcounts of entries it's intending to add to a catcache list construct.
      In a normal ERROR scenario, the extra refcounts are cleaned up by
      SearchCatCacheList's PG_CATCH block; but in a FATAL exit we do a
      transaction abort and exit without ever executing PG_CATCH handlers.
      
      There's a case to be made that this is a generic hazard and we should
      consider restructuring elog(FATAL) handling so that pending PG_CATCH
      handlers do get run.  That's pretty scary though: it could easily create
      more problems than it solves.  Preliminary stress testing by Andreas
      Seltenreich suggests that there are not many live problems of this ilk,
      so we rejected that idea.
      
      There are more-localized ways to fix the problem; the most principled
      one would be to use PG_ENSURE_ERROR_CLEANUP instead of plain PG_TRY.
      But adding cycles to SearchCatCacheList isn't very appealing.  We could
      also weaken the assertions in AtEOXact_CatCache in some more or less
      ad-hoc way, but that just makes its raison d'etre even less compelling.
      In the end, the most reasonable solution seems to be to just remove
      AtEOXact_CatCache altogether, on the grounds that it's not worth trying
      to fix it.  It hasn't found any bugs for us in many years.
      
      Per report from Jeevan Chalke.  Back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/CAM2+6=VEE30YtRQCZX7_sCFsEpoUkFBV1gZazL70fqLn8rcvBA@mail.gmail.com
      004a9702
    • Alvaro Herrera's avatar
      2336f842
    • Noah Misch's avatar
  5. 12 Aug, 2017 1 commit