1. 08 Dec, 2020 3 commits
  2. 07 Dec, 2020 4 commits
    • Tom Lane's avatar
      Add a couple of regression test cases related to array subscripting. · 0a665bbc
      Tom Lane authored
      Exercise some error cases that were never reached in the existing
      regression tests.  This is partly for code-coverage reasons, and
      partly to memorialize the current behavior in advance of planned
      changes for generic subscripting.
      
      Also, I noticed that type_sanity's check to verify that all standard
      types have array types was never extended when we added arrays for
      all system catalog rowtypes (f7f70d5e), nor when we added arrays
      over domain types (c12d570f).  So do that.  Also, since the query's
      expected output isn't empty, it seems like a good idea to add an
      ORDER BY to make sure the result stays stable.
      0a665bbc
    • Heikki Linnakangas's avatar
      Fix more race conditions in the newly-added pg_rewind test. · 6ba581cf
      Heikki Linnakangas authored
      pg_rewind looks at the control file to check what timeline a server is on.
      But promotion doesn't immediately write a checkpoint, it merely writes
      an end-of-recovery WAL record. If pg_rewind runs immediately after
      promotion, before the checkpoint has completed, it will think think that
      the server is still on the earlier timeline. We ran into this issue a long
      time ago already, see commit 484a848a.
      
      It's a bit bogus that pg_rewind doesn't determine the timeline correctly
      until the end-of-recovery checkpoint has completed. We probably should
      fix that. But for now work around it by waiting for the checkpoint
      to complete before running pg_rewind, like we did in commit 484a848a.
      
      In the passing, tidy up the new test a little bit. Rerder the INSERTs so
      that the comments make more sense, remove a spurious CHECKPOINT call after
      pg_rewind has already run, and add --debug option, so that if this fails
      again, we'll have more data.
      
      Per buildfarm failure at https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=rorqual&dt=2020-12-06%2018%3A32%3A19&stg=pg_rewind-check.
      Backpatch to all supported versions.
      
      Discussion: https://www.postgresql.org/message-id/1713707e-e318-761c-d287-5b6a4aa807e8@iki.fi
      6ba581cf
    • Tom Lane's avatar
      pg_dump: Reorganize dumpBaseType() · 04732962
      Tom Lane authored
      Along the same lines as ed2c7f65 and daa9fe8a, reduce code duplication
      by having just one copy of the parts of the query that are the same
      across all server versions; and make the conditionals control the
      smallest possible amount of code.  This is in preparation for adding
      another dumpable field to pg_type.
      04732962
    • Michael Paquier's avatar
      Fix fd leak in pg_verifybackup · 51c38898
      Michael Paquier authored
      An error code path newly-introduced by 87ae9691 forgot to close a file
      descriptor when verifying a file's checksum.
      
      Per report from Coverity, via Tom Lane.
      51c38898
  3. 05 Dec, 2020 1 commit
  4. 04 Dec, 2020 6 commits
    • Heikki Linnakangas's avatar
      Fix race conditions in newly-added test. · 36a4ac20
      Heikki Linnakangas authored
      Buildfarm has been failing sporadically on the new test.  I was able to
      reproduce this by adding a random 0-10 s delay in the walreceiver, just
      before it connects to the primary. There's a race condition where node_3
      is promoted before it has fully caught up with node_1, leading to diverged
      timelines. When node_1 is later reconfigured as standby following node_3,
      it fails to catch up:
      
      LOG:  primary server contains no more WAL on requested timeline 1
      LOG:  new timeline 2 forked off current database system timeline 1 before current recovery point 0/30000A0
      
      That's the situation where you'd need to use pg_rewind, but in this case
      it happens already when we are just setting up the actual pg_rewind
      scenario we want to test, so change the test so that it waits until
      node_3 is connected and fully caught up before promoting it, so that you
      get a clean, controlled failover.
      
      Also rewrite some of the comments, for clarity. The existing comments
      detailed what each step in the test did, but didn't give a good overview
      of the situation the steps were trying to create.
      
      For reasons I don't understand, the test setup had to be written slightly
      differently in 9.6 and 9.5 than in later versions. The 9.5/9.6 version
      needed node 1 to be reinitialized from backup, whereas in later versions
      it could be shut down and reconfigured to be a standby. But even 9.5 should
      support "clean switchover", where primary makes sure that pending WAL is
      replicated to standby on shutdown. It would be nice to figure out what's
      going on there, but that's independent of pg_rewind and the scenario that
      this test tests.
      
      Discussion: https://www.postgresql.org/message-id/b0a3b95b-82d2-6089-6892-40570f8c5e60%40iki.fi
      36a4ac20
    • Peter Eisentraut's avatar
      Convert elog(LOG) calls to ereport() where appropriate · eb93f3a0
      Peter Eisentraut authored
      User-visible log messages should go through ereport(), so they are
      subject to translation.  Many remaining elog(LOG) calls are really
      debugging calls.
      Reviewed-by: default avatarAlvaro Herrera <alvherre@alvh.no-ip.org>
      Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
      Reviewed-by: default avatarNoah Misch <noah@leadboat.com>
      Discussion: https://www.postgresql.org/message-id/flat/92d6f545-5102-65d8-3c87-489f71ea0a37%40enterprisedb.com
      eb93f3a0
    • Peter Eisentraut's avatar
      Remove unnecessary grammar symbols · a6964bc1
      Peter Eisentraut authored
      Instead of publication_name_list, we can use name_list.  We already
      refer to publications everywhere else by the 'name' or 'name_list'
      symbols, so this only improves consistency.
      
      Reviewed-by: https://www.postgresql.org/message-id/flat/3e3ccddb-41bd-ecd8-29fe-195e34d9886f%40enterprisedb.com
      Discussion: Tom Lane <tgl@sss.pgh.pa.us>
      a6964bc1
    • Amit Kapila's avatar
      Remove incorrect assertion in reorderbuffer.c. · 8ae4ef4f
      Amit Kapila authored
      We start recording changes in ReorderBufferTXN even before we reach
      SNAPBUILD_CONSISTENT state so that if the commit is encountered after
      reaching that we should be able to send the changes of the entire transaction.
      Now, while recording changes if the reorder buffer memory has exceeded
      logical_decoding_work_mem then we can start streaming if it is allowed and
      we haven't yet streamed that data. However, we must not allow streaming to
      start unless the snapshot has reached SNAPBUILD_CONSISTENT state.
      
      In passing, improve the comments atop ReorderBufferResetTXN to mention the
      case when we need to continue streaming after getting an error.
      
      Author: Amit Kapila
      Reviewed-by: Dilip Kumar
      Discussion: https://postgr.es/m/CAA4eK1KoOH0byboyYY40NBcC7Fe812trwTa+WY3jQF7WQWZbQg@mail.gmail.com
      8ae4ef4f
    • Michael Paquier's avatar
      Rename cryptohashes.c to cryptohashfuncs.c · bd94a9c0
      Michael Paquier authored
      87ae9691 has created two new files called cryptohash{_openssl}.c in
      src/common/, whose names overlap with the existing backend file called
      cryptohashes.c dedicated to the SQL wrappers for SHA2 and MD5.  This
      file is renamed to cryptohashfuncs.c to be more consistent with the
      surroundings and reduce the confusion with the new cryptohash interface
      of src/common/.
      
      Author: Michael Paquier
      Reviewed-by: Daniel Gustafsson
      Discussion: https://postgr.es/m/X8hHhaQgbMbW+aGU@paquier.xyz
      bd94a9c0
    • Michael Paquier's avatar
      Change SHA2 implementation based on OpenSSL to use EVP digest routines · 4f48a6fb
      Michael Paquier authored
      The use of low-level hash routines is not recommended by upstream
      OpenSSL since 2000, and pgcrypto already switched to EVP as of 5ff4a67f.
      This takes advantage of the refactoring done in 87ae9691 that has
      introduced the allocation and free routines for cryptographic hashes.
      
      Since 1.1.0, OpenSSL does not publish the contents of the cryptohash
      contexts, forcing any consumers to rely on OpenSSL for all allocations.
      Hence, the resource owner callback mechanism gains a new set of routines
      to track and free cryptohash contexts when using OpenSSL, preventing any
      risks of leaks in the backend.  Nothing is needed in the frontend thanks
      to the refactoring of 87ae9691, and the resowner knowledge is isolated
      into cryptohash_openssl.c.
      
      Note that this also fixes a failure with SCRAM authentication when using
      FIPS in OpenSSL, but as there have been few complaints about this
      problem and as this causes an ABI breakage, no backpatch is done.
      
      Author: Michael Paquier
      Reviewed-by: Daniel Gustafsson, Heikki Linnakangas
      Discussion: https://postgr.es/m/20200924025314.GE7405@paquier.xyz
      Discussion: https://postgr.es/m/20180911030250.GA27115@paquier.xyz
      4f48a6fb
  5. 03 Dec, 2020 6 commits
    • Bruce Momjian's avatar
      doc: remove unnecessary blank before command option text · 3f8971d9
      Bruce Momjian authored
      Backpatch-through: 11
      3f8971d9
    • Bruce Momjian's avatar
      docs: list single-letter options first in command-line summary · a659e789
      Bruce Momjian authored
      In a few places, the long-version options were listed before the
      single-letter ones in the command summary of a few commands.  This
      didn't match other commands, and didn't match the option ordering later
      in the same reference page.
      
      Backpatch-through: 9.5
      a659e789
    • Heikki Linnakangas's avatar
      Fix pg_rewind bugs when rewinding a standby server. · 2b4f3130
      Heikki Linnakangas authored
      If the target is a standby server, its WAL doesn't end at the last
      checkpoint record, but at minRecoveryPoint. We must scan all the
      WAL from the last common checkpoint all the way up to minRecoveryPoint
      for modified pages, and also consider that portion when determining
      whether the server needs rewinding.
      
      Backpatch to all supported versions.
      
      Author: Ian Barwick and me
      Discussion: https://www.postgresql.org/message-id/CABvVfJU-LDWvoz4-Yow3Ay5LZYTuPD7eSjjE4kGyNZpXC6FrVQ%40mail.gmail.com
      2b4f3130
    • Peter Eisentraut's avatar
      Small code simplifications · 61140407
      Peter Eisentraut authored
      strVal() can be used in a couple of places instead of coding the same
      thing by hand.
      61140407
    • Dean Rasheed's avatar
      Improve estimation of OR clauses using extended statistics. · 25a9e54d
      Dean Rasheed authored
      Formerly we only applied extended statistics to an OR clause as part
      of the clauselist_selectivity() code path for an OR clause appearing
      in an implicitly-ANDed list of clauses. This meant that it could only
      use extended statistics if all sub-clauses of the OR clause were
      covered by a single extended statistics object.
      
      Instead, teach clause_selectivity() how to apply extended statistics
      to an OR clause by handling its ORed list of sub-clauses in a similar
      manner to an implicitly-ANDed list of sub-clauses, but with different
      combination rules. This allows one or more extended statistics objects
      to be used to estimate all or part of the list of sub-clauses. Any
      remaining sub-clauses are then treated as if they are independent.
      
      Additionally, to avoid double-application of extended statistics, this
      introduces "extended" versions of clause_selectivity() and
      clauselist_selectivity(), which include an option to ignore extended
      statistics. This replaces the old clauselist_selectivity_simple()
      function which failed to completely ignore extended statistics when
      called from the extended statistics code.
      
      A known limitation of the current infrastructure is that an AND clause
      under an OR clause is not treated as compatible with extended
      statistics (because we don't build RestrictInfos for such sub-AND
      clauses). Thus, for example, "(a=1 AND b=1) OR (a=2 AND b=2)" will
      currently be treated as two independent AND clauses (each of which may
      be estimated using extended statistics), but extended statistics will
      not currently be used to account for any possible overlap between
      those clauses. Improving that is left as a task for the future.
      
      Original patch by Tomas Vondra, with additional improvements by me.
      
      Discussion: https://postgr.es/m/20200113230008.g67iyk4cs3xbnjju@development
      25a9e54d
    • Michael Paquier's avatar
      Refactor CLUSTER and REINDEX grammar to use DefElem for option lists · b5913f61
      Michael Paquier authored
      This changes CLUSTER and REINDEX so as a parenthesized grammar becomes
      possible for options, while unifying the grammar parsing rules for
      option lists with the existing ones.
      
      This is a follow-up of the work done in 873ea9ee for VACUUM, ANALYZE and
      EXPLAIN.  This benefits REINDEX for a potential backend-side filtering
      for collatable-sensitive indexes and TABLESPACE, while CLUSTER would
      benefit from the latter.
      
      Author: Alexey Kondratov, Justin Pryzby
      Discussion: https://postgr.es/m/8a8f5f73-00d3-55f8-7583-1375ca8f6a91@postgrespro.ru
      b5913f61
  6. 02 Dec, 2020 6 commits
    • Stephen Frost's avatar
      Add GSS information to connection authorized log message · dc11f31a
      Stephen Frost authored
      GSS information (if used) such as if the connection was authorized using
      GSS or if it was encrypted using GSS, and perhaps most importantly, what
      the GSS principal used for the authentication was, is extremely useful
      but wasn't being included in the connection authorized log message.
      
      Therefore, add to the connection authorized log message that
      information, in a similar manner to how we log SSL information when SSL
      is used for a connection.
      
      Author: Vignesh C
      Reviewed-by: Bharath Rupireddy
      Discussion: https://www.postgresql.org/message-id/CALDaNm2N1385_Ltoo%3DS7VGT-ESu_bRQa-sC1wg6ikrM2L2Z49w%40mail.gmail.com
      dc11f31a
    • Fujii Masao's avatar
      Track total number of WAL records, FPIs and bytes generated in the cluster. · 01469241
      Fujii Masao authored
      Commit 6b466bf5 allowed pg_stat_statements to track the number of
      WAL records, full page images and bytes that each statement generated.
      Similarly this commit allows us to track the cluster-wide WAL statistics
      counters.
      
      New columns wal_records, wal_fpi and wal_bytes are added into the
      pg_stat_wal view, and reports the total number of WAL records,
      full page images and bytes generated in the , respectively.
      
      Author: Masahiro Ikeda
      Reviewed-by: Amit Kapila, Movead Li, Kyotaro Horiguchi, Fujii Masao
      Discussion: https://postgr.es/m/35ef960128b90bfae3b3fdf60a3a860f@oss.nttdata.com
      01469241
    • Michael Paquier's avatar
      Fix compilation warnings in cryptohash_openssl.c · 91624c2f
      Michael Paquier authored
      These showed up with -O2.  Oversight in 87ae9691.
      
      Author: Fujii Masao
      Discussion: https://postgr.es/m/cee3df00-566a-400c-1252-67c3701f918a@oss.nttdata.com
      91624c2f
    • Fujii Masao's avatar
      Allow restore_command parameter to be changed with reload. · 942305a3
      Fujii Masao authored
      This commit changes restore_command from PGC_POSTMASTER to PGC_SIGHUP.
      
      As the side effect of this commit, restore_command can be reset to
      empty during archive recovery. In this setting, archive recovery
      tries to replay only WAL files available in pg_wal directory. This is
      the same behavior as when the command that always fails is specified
      in restore_command.
      
      Note that restore_command still must be specified (not empty) when
      starting archive recovery, even after applying this commit. This is
      necessary as the safeguard to prevent users from forgetting to
      specify restore_command and starting archive recovery.
      
      Thanks to Peter Eisentraut, Michael Paquier, Andres Freund,
      Robert Haas and Anastasia Lubennikova for discussion.
      
      Author: Sergei Kornilov
      Reviewed-by: Kyotaro Horiguchi, Fujii Masao
      Discussion: https://postgr.es/m/2317771549527294@sas2-985f744271ca.qloud-c.yandex.net
      942305a3
    • Michael Paquier's avatar
      Move SHA2 routines to a new generic API layer for crypto hashes · 87ae9691
      Michael Paquier authored
      Two new routines to allocate a hash context and to free it are created,
      as these become necessary for the goal behind this refactoring: switch
      the all cryptohash implementations for OpenSSL to use EVP (for FIPS and
      also because upstream does not recommend the use of low-level cryptohash
      functions for 20 years).  Note that OpenSSL hides the internals of
      cryptohash contexts since 1.1.0, so it is necessary to leave the
      allocation to OpenSSL itself, explaining the need for those two new
      routines.  This part is going to require more work to properly track
      hash contexts with resource owners, but this not introduced here.
      Still, this refactoring makes the move possible.
      
      This reduces the number of routines for all SHA2 implementations from
      twelve (SHA{224,256,386,512} with init, update and final calls) to five
      (create, free, init, update and final calls) by incorporating the hash
      type directly into the hash context data.
      
      The new cryptohash routines are moved to a new file, called cryptohash.c
      for the fallback implementations, with SHA2 specifics becoming a part
      internal to src/common/.  OpenSSL specifics are part of
      cryptohash_openssl.c.  This infrastructure is usable for more hash
      types, like MD5 or HMAC.
      
      Any code paths using the internal SHA2 routines are adapted to report
      correctly errors, which are most of the changes of this commit.  The
      zones mostly impacted are checksum manifests, libpq and SCRAM.
      
      Note that e21cbb4b was a first attempt to switch SHA2 to EVP, but it
      lacked the refactoring needed for libpq, as done here.
      
      This patch has been tested on Linux and Windows, with and without
      OpenSSL, and down to 1.0.1, the oldest version supported on HEAD.
      
      Author: Michael Paquier
      Reviewed-by: Daniel Gustafsson
      Discussion: https://postgr.es/m/20200924025314.GE7405@paquier.xyz
      87ae9691
    • Bruce Momjian's avatar
      pg_checksums: data_checksum_version is unsigned so use %u not %d · 888671a8
      Bruce Momjian authored
      While the previous behavior didn't generate a warning, we might as well
      use an accurate *printf specification.
      
      Backpatch-through: 12
      888671a8
  7. 01 Dec, 2020 7 commits
  8. 30 Nov, 2020 7 commits