1. 24 Jan, 2018 1 commit
  2. 23 Jan, 2018 14 commits
    • Bruce Momjian's avatar
      doc: mention psql -l uses the 'postgres' database by default · e0a0deca
      Bruce Momjian authored
      Reported-by: Mark Wood
      
      Bug: 14912
      
      Discussion: https://postgr.es/m/20171116171735.1474.30450@wrigleys.postgresql.org
      
      Author: David G. Johnston
      
      Backpatch-through: 10
      e0a0deca
    • Tom Lane's avatar
      Teach reparameterize_path() to handle AppendPaths. · bb94ce4d
      Tom Lane authored
      If we're inside a lateral subquery, there may be no unparameterized paths
      for a particular child relation of an appendrel, in which case we *must*
      be able to create similarly-parameterized paths for each other child
      relation, else the planner will fail with "could not devise a query plan
      for the given query".  This means that there are situations where we'd
      better be able to reparameterize at least one path for each child.
      
      This calls into question the assumption in reparameterize_path() that
      it can just punt if it feels like it.  However, the only case that is
      known broken right now is where the child is itself an appendrel so that
      all its paths are AppendPaths.  (I think possibly I disregarded that in
      the original coding on the theory that nested appendrels would get folded
      together --- but that only happens *after* reparameterize_path(), so it's
      not excused from handling a child AppendPath.)  Given that this code's been
      like this since 9.3 when LATERAL was introduced, it seems likely we'd have
      heard of other cases by now if there were a larger problem.
      
      Per report from Elvis Pranskevichus.  Back-patch to 9.3.
      
      Discussion: https://postgr.es/m/5981018.zdth1YWmNy@hammer.magicstack.net
      bb94ce4d
    • Alvaro Herrera's avatar
      Remove unnecessary include · 95be5ce1
      Alvaro Herrera authored
      autovacuum.c no longer needs dsa.h, since commit 31ae1638.
      Author: Masahiko Sawada
      Discussion: https://postgr.es/m/CAD21AoCWvYyXrvdANSHWWWEWJH5TeAWAkJ_2gqrHhukG+OBo1g@mail.gmail.com
      95be5ce1
    • Tom Lane's avatar
      c9707d94
    • Peter Eisentraut's avatar
      pgbench: Remove accidental garbage in test file · f9bbd46a
      Peter Eisentraut authored
      Author: Fabien COELHO <coelho@cri.ensmp.fr>
      f9bbd46a
    • Robert Haas's avatar
      Update obsolete sentence in README.parallel. · 28e04155
      Robert Haas authored
      Since 9.6, heavyweight locking is not an abstract and unhandled
      concern of the parallel machinery, but rather something to which
      we have a specific approach.
      28e04155
    • Robert Haas's avatar
      Report an ERROR if a parallel worker fails to start properly. · 2badb5af
      Robert Haas authored
      Commit 28724fd9 fixed things so that
      if a background worker fails to start due to fork() failure or because
      it is terminated before startup succeeds, BGWH_STOPPED will be
      reported.  However, that only helps if the code that uses the
      background worker machinery notices the change in status, and the code
      in parallel.c did not.
      
      To fix that, do two things.  First, make sure that when a worker
      exits, it triggers the leader to read from error queues.  That way, if
      a worker which has attached to an error queue exits uncleanly, the
      leader is sure to throw some error, either the contents of the
      ErrorResponse sent by the worker, or "lost connection to parallel
      worker" if it exited without sending one.  To cover the case where
      the worker never starts up in the first place or exits before
      attaching to the error queue, the ParallelContext now keeps track
      of which workers have sent at least one message via the error
      queue.  A worker which sends no messages by the time the parallel
      operation finishes will be checked to see whether it exited before
      attaching to the error queue; if so, a new error message, "parallel
      worker failed to initialize", will be reported.  If not, we'll
      continue to wait until it either starts up and exits cleanly, starts
      up and exits uncleanly, or fails to start, and then take the
      appropriate action.
      
      Patch by me, reviewed by Amit Kapila.
      
      Discussion: http://postgr.es/m/CA+TgmoYnBgXgdTu6wk5YPdWhmgabYc9nY_pFLq=tB=FSLYkD8Q@mail.gmail.com
      2badb5af
    • Tom Lane's avatar
      In pg_dump, force reconnection after issuing ALTER DATABASE SET command(s). · 160a4f62
      Tom Lane authored
      The folly of not doing this was exposed by the buildfarm: in some cases,
      the GUC settings applied through ALTER DATABASE SET may be essential to
      interpreting the reloaded data correctly.  Another argument why we can't
      really get away with the scheme proposed in commit b3f84012 is that it
      cannot work for parallel restore: even if the parent process manages to
      hang onto the previous GUC state, worker processes would see the state
      post-ALTER-DATABASE.  (Perhaps we could have dodged that bullet by
      delaying DATABASE PROPERTIES restoration to the end of the run, but
      that does nothing for the data semantics problem.)
      
      This leaves us with no solution for the default_transaction_read_only issue
      that commit 4bd371f6 intended to work around, other than "you gotta remove
      such settings before dumping/upgrading".  However, in view of the fact that
      parallel restore broke that hack years ago and no one has noticed, it's
      fair to question how many people care.  I'm unexcited about adding a large
      dollop of new complexity to handle that corner case.
      
      This would be a one-liner fix, except it turns out that ReconnectToServer
      tries to optimize away "redundant" reconnections.  While that may have been
      valuable when coded, a quick survey of current callers shows that there are
      no cases where that's actually useful, so just remove that check.  While at
      it, remove the function's useless return value.
      
      Discussion: https://postgr.es/m/12453.1516655001@sss.pgh.pa.us
      160a4f62
    • Bruce Momjian's avatar
      doc: simplify intermediate certificate mention in libpq docs · a541dbb6
      Bruce Momjian authored
      Backpatch-through: 9.3
      a541dbb6
    • Peter Eisentraut's avatar
      Extract common bits from OpenSSL implementation · 1c218340
      Peter Eisentraut authored
      Some things in be-secure-openssl.c and fe-secure-openssl.c were not
      actually specific to OpenSSL but could also be used by other
      implementations.  In order to avoid copy-and-pasting, move some of that
      code to common files.
      1c218340
    • Peter Eisentraut's avatar
      Move SSL API comments to header files · f966101d
      Peter Eisentraut authored
      Move the documentation of the SSL API calls are supposed to do into the
      headers files, instead of keeping them in the files for the OpenSSL
      implementation.  That way, they don't have to be duplicated or be
      inconsistent when other implementations are added.
      f966101d
    • Peter Eisentraut's avatar
      Move EDH support to common files · 573bd08b
      Peter Eisentraut authored
      The EDH support is not really specific to the OpenSSL implementation, so
      move the support and documentation comments to common files.
      573bd08b
    • Peter Eisentraut's avatar
      Split out documentation of SSL parameters into their own section · 7404e77c
      Peter Eisentraut authored
      Split the "Authentication and Security" section into two separate
      sections "Authentication" and "SSL".  The latter part has gotten much
      longer over time, and doesn't primarily have to do with authentication.
      
      Also, the row_security parameter was inconsistently categorized, so
      clean that up while we're here.
      7404e77c
    • Peter Eisentraut's avatar
      Add installcheck support to more test suites · f5da5683
      Peter Eisentraut authored
      Several of the test suites under src/test/ were missing an installcheck
      target.
      f5da5683
  3. 22 Jan, 2018 6 commits
    • Tom Lane's avatar
      Move handling of database properties from pg_dumpall into pg_dump. · b3f84012
      Tom Lane authored
      This patch rearranges the division of labor between pg_dump and pg_dumpall
      so that pg_dump itself handles all properties attached to a single
      database.  Notably, a database's ACL (GRANT/REVOKE status) and local GUC
      settings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SET
      can be dumped and restored by pg_dump.  This is a long-requested
      improvement.
      
      "pg_dumpall -g" will now produce only role- and tablespace-related output,
      nothing about individual databases.  The total output of a regular
      pg_dumpall run remains the same.
      
      pg_dump (or pg_restore) will restore database-level properties only when
      creating the target database with --create.  This applies not only to
      ACLs and GUCs but to the other database properties it already handled,
      that is database comments and security labels.  This is more consistent
      and useful, but does represent an incompatibility in the behavior seen
      without --create.
      
      (This change makes the proposed patch to have pg_dump use "COMMENT ON
      DATABASE CURRENT_DATABASE" unnecessary, since there is no case where
      the command is issued that we won't know the true name of the database.
      We might still want that patch as a feature in its own right, but pg_dump
      no longer needs it.)
      
      pg_dumpall with --clean will now drop and recreate the "postgres" and
      "template1" databases in the target cluster, allowing their locale and
      encoding settings to be changed if necessary, and providing a cleaner
      way to set nondefault tablespaces for them than we had before.  This
      means that such a script must now always be started in the "postgres"
      database; the order of drops and reconnects will not work otherwise.
      Without --clean, the script will not adjust any database-level properties
      of those two databases (including their comments, ACLs, and security
      labels, which it formerly would try to set).
      
      Another minor incompatibility is that the CREATE DATABASE commands in a
      pg_dumpall script will now always specify locale and encoding settings.
      Formerly those would be omitted if they matched the cluster's default.
      While that behavior had some usefulness in some migration scenarios,
      it also posed a significant hazard of unwanted locale/encoding changes.
      To migrate to another locale/encoding, it's now necessary to use pg_dump
      without --create to restore into a database with the desired settings.
      
      Commit 4bd371f6's hack to emit "SET default_transaction_read_only = off"
      is gone: we now dodge that problem by the expedient of not issuing ALTER
      DATABASE SET commands until after reconnecting to the target database.
      Therefore, such settings won't apply during the restore session.
      
      In passing, improve some shaky grammar in the docs, and add a note pointing
      out that pg_dumpall's output can't be expected to load without any errors.
      (Someday we might want to fix that, but this is not that patch.)
      
      Haribabu Kommi, reviewed at various times by Andreas Karlsson,
      Vaishnavi Prabakaran, and Robert Haas; further hacking by me.
      
      Discussion: https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com
      b3f84012
    • Tom Lane's avatar
      Reorder code in pg_dump to dump comments etc in a uniform order. · d6c84667
      Tom Lane authored
      Most of the code in pg_dump dumps an object's comment, security label,
      and ACL auxiliary TOC entries, in that order, immediately after the
      object's main TOC entry, and at least dumpComment's API spec says this
      isn't optional.  dumpDatabase was significantly violating that when
      in binary-upgrade mode, by inserting totally unrelated stuff between.
      Also, dumpForeignDataWrapper and dumpForeignServer were being randomly
      inconsistent.  Reorder code so everybody does it the same.
      
      This may be future-proofing us against some code growing a requirement for
      such auxiliary entries to be adjacent to their main entry.  But for now
      it's just neatnik-ism, so I see no need for back-patch.
      
      Discussion: https://postgr.es/m/21714.1516553459@sss.pgh.pa.us
      d6c84667
    • Peter Eisentraut's avatar
      PL/Python: Fix tests for older Python versions · f4987043
      Peter Eisentraut authored
      Commit 8561e484 neglected to handle
      older Python versions that don't support the "with" statement.  So write
      the tests in a way that older versions can handle as well.
      f4987043
    • Tom Lane's avatar
      Make pg_dump's ACL, sec label, and comment entries reliably identifiable. · 2b792ab0
      Tom Lane authored
      _tocEntryRequired() expects that it can identify ACL, SECURITY LABEL,
      and COMMENT TOC entries that are for large objects by seeing whether
      the tag for them starts with "LARGE OBJECT ".  While that works fine
      for actual large objects, which are indeed tagged that way, it's
      subject to false positives unless every such entry's tag starts with an
      appropriate type ID.  And in fact it does not work for ACLs, because
      up to now we customarily tagged those entries with just the bare name
      of the object.  This means that an ACL for an object named
      "LARGE OBJECT something" would be misclassified as data not schema,
      with undesirable results in a schema-only or data-only dump ---
      although pg_upgrade seems unaffected, due to the special case for
      binary-upgrade mode further down in _tocEntryRequired().
      
      We can fix this by changing all the dumpACL calls to use the label
      strings already in use for comments and security labels, which do
      follow the convention of starting with an object type indicator.
      
      Well, mostly they follow it.  dumpDatabase() got it wrong, using
      just the bare database name for those purposes, so that a database
      named "LARGE OBJECT something" would similarly be subject to having
      its comment or security label dropped or included when not wanted.
      Bring that into line too.  (Note that up to now, database ACLs have
      not been processed by pg_dump, so that this issue doesn't affect them.)
      
      _tocEntryRequired() itself is not free of fault: it was overly liberal
      about matching object tags to "LARGE OBJECT " in binary-upgrade mode.
      This looks like it is probably harmless because there would be no data
      component to strip anyway in that mode, but at best it's trouble
      waiting to happen, so tighten that up too.
      
      The possible misclassification of SECURITY LABEL entries for databases is
      in principle a security problem, but the opportunities for actual exploits
      seem too narrow to be interesting.  The other cases seem like just bugs,
      since an object owner can change its ACL or comment for himself, he needn't
      try to trick someone else into doing it by choosing a strange name.
      
      This has been broken since per-large-object TOC entries were introduced
      in 9.0, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/21714.1516553459@sss.pgh.pa.us
      2b792ab0
    • Peter Eisentraut's avatar
      Transaction control in PL procedures · 8561e484
      Peter Eisentraut authored
      In each of the supplied procedural languages (PL/pgSQL, PL/Perl,
      PL/Python, PL/Tcl), add language-specific commit and rollback
      functions/commands to control transactions in procedures in that
      language.  Add similar underlying functions to SPI.  Some additional
      cleanup so that transaction commit or abort doesn't blow away data
      structures still used by the procedure call.  Add execution context
      tracking to CALL and DO statements so that transaction control commands
      can only be issued in top-level procedure and block calls, not function
      calls or other procedure or block calls.
      
      - SPI
      
      Add a new function SPI_connect_ext() that is like SPI_connect() but
      allows passing option flags.  The only option flag right now is
      SPI_OPT_NONATOMIC.  A nonatomic SPI connection can execute transaction
      control commands, otherwise it's not allowed.  This is meant to be
      passed down from CALL and DO statements which themselves know in which
      context they are called.  A nonatomic SPI connection uses different
      memory management.  A normal SPI connection allocates its memory in
      TopTransactionContext.  For nonatomic connections we use PortalContext
      instead.  As the comment in SPI_connect_ext() (previously SPI_connect())
      indicates, one could potentially use PortalContext in all cases, but it
      seems safest to leave the existing uses alone, because this stuff is
      complicated enough already.
      
      SPI also gets new functions SPI_start_transaction(), SPI_commit(), and
      SPI_rollback(), which can be used by PLs to implement their transaction
      control logic.
      
      - portalmem.c
      
      Some adjustments were made in the code that cleans up portals at
      transaction abort.  The portal code could already handle a command
      *committing* a transaction and continuing (e.g., VACUUM), but it was not
      quite prepared for a command *aborting* a transaction and continuing.
      
      In AtAbort_Portals(), remove the code that marks an active portal as
      failed.  As the comment there already predicted, this doesn't work if
      the running command wants to keep running after transaction abort.  And
      it's actually not necessary, because pquery.c is careful to run all
      portal code in a PG_TRY block and explicitly runs MarkPortalFailed() if
      there is an exception.  So the code in AtAbort_Portals() is never used
      anyway.
      
      In AtAbort_Portals() and AtCleanup_Portals(), we need to be careful not
      to clean up active portals too much.  This mirrors similar code in
      PreCommit_Portals().
      
      - PL/Perl
      
      Gets new functions spi_commit() and spi_rollback()
      
      - PL/pgSQL
      
      Gets new commands COMMIT and ROLLBACK.
      
      Update the PL/SQL porting example in the documentation to reflect that
      transactions are now possible in procedures.
      
      - PL/Python
      
      Gets new functions plpy.commit and plpy.rollback.
      
      - PL/Tcl
      
      Gets new commands commit and rollback.
      Reviewed-by: default avatarAndrew Dunstan <andrew.dunstan@2ndquadrant.com>
      8561e484
    • Magnus Hagander's avatar
      Fix docs typo · b9ff79b8
      Magnus Hagander authored
      Spotted by Thomas Munro
      b9ff79b8
  4. 21 Jan, 2018 3 commits
    • Magnus Hagander's avatar
      Support huge pages on Windows · 1cc4f536
      Magnus Hagander authored
      Add support for huge pages (called large pages on Windows) to the
      Windows build.
      
      This (probably) breaks compatibility with Windows versions prior to
      Windows 2003 or Windows Vista.
      
      Authors: Takayuki Tsunakawa and Thomas Munro
      Reviewed by: Magnus Hagander, Amit Kapila
      1cc4f536
    • Magnus Hagander's avatar
      Fix wording of "hostaddrs" · 5c15a54e
      Magnus Hagander authored
      The field is still called "hostaddr", so make sure references use
      "hostaddr values" instead.
      
      Author: Michael Paquier <michael.paquier@gmail.com>
      5c15a54e
    • Bruce Momjian's avatar
      doc: update intermediate certificate instructions · 815f84aa
      Bruce Momjian authored
      Document how to properly create root and intermediate certificates using
      v3_ca extensions and where to place intermediate certificates so they
      are properly transferred to the remote side with the leaf certificate to
      link to the remote root certificate.  This corrects docs that used to
      say that intermediate certificates must be stored with the root
      certificate.
      
      Also add instructions on how to create root, intermediate, and leaf
      certificates.
      
      Discussion: https://postgr.es/m/20180116002238.GC12724@momjian.us
      
      Reviewed-by: Michael Paquier
      
      Backpatch-through: 9.3
      815f84aa
  5. 20 Jan, 2018 2 commits
  6. 19 Jan, 2018 12 commits
  7. 18 Jan, 2018 2 commits