1. 17 Nov, 2021 1 commit
  2. 16 Nov, 2021 1 commit
  3. 12 Nov, 2021 3 commits
    • Tom Lane's avatar
      Make psql's \password default to CURRENT_USER, not PQuser(conn). · 99389cb6
      Tom Lane authored
      The documentation says plainly that \password acts on "the current user"
      by default.  What it actually acted on, or tried to, was the username
      used to log into the current session.  This is not the same thing if
      one has since done SET ROLE or SET SESSION AUTHENTICATION.  Aside from
      the possible surprise factor, it's quite likely that the current role
      doesn't have permissions to set the password of the original role.
      
      To fix, use "SELECT CURRENT_USER" to get the role name to act on.
      (This syntax works with servers at least back to 7.0.)  Also, in
      hopes of reducing confusion, include the role name that will be
      acted on in the password prompt.
      
      The discrepancy from the documentation makes this a bug, so
      back-patch to all supported branches.
      
      Patch by me; thanks to Nathan Bossart for review.
      
      Discussion: https://postgr.es/m/747443.1635536754@sss.pgh.pa.us
      99389cb6
    • Michael Paquier's avatar
      Fix memory overrun when querying pg_stat_slru · 5f81a480
      Michael Paquier authored
      pg_stat_get_slru() in pgstatfuncs.c would point to one element after the
      end of the array PgStat_SLRUStats when finishing to scan its entries.
      This had no direct consequences as no data from the extra memory area
      was read, but static analyzers would rightfully complain here.  So let's
      be clean.
      
      While on it, this adds one regression test in the area reserved for
      system views.
      
      Reported-by: Alexander Kozhemyakin, via AddressSanitizer
      Author: Kyotaro Horiguchi
      Discussion: https://postgr.es/m/17280-37da556e86032070@postgresql.org
      Backpatch-through: 13
      5f81a480
    • Noah Misch's avatar
      Report any XLogReadRecord() error in XlogReadTwoPhaseData(). · 675cd765
      Noah Misch authored
      Buildfarm members kittiwake and tadarida have witnessed errors at this
      site.  The site discarded key facts.  Back-patch to v10 (all supported
      versions).
      
      Reviewed by Michael Paquier and Tom Lane.
      
      Discussion: https://postgr.es/m/20211107013157.GB790288@rfd.leadboat.com
      675cd765
  4. 11 Nov, 2021 3 commits
    • Alvaro Herrera's avatar
      Restore lock level to set vacuum flags · 9aa91cb3
      Alvaro Herrera authored
      Commit 27838981 mistakenly reduced the lock level from exclusive to
      shared that is acquired to set PGPROC->statusFlags; this was reverted
      by dcfff74f, but failed to do so in one spot.  Fix it.
      
      Backpatch to 14.
      
      Noted by Andres Freund.
      
      Discussion: https://postgr.es/m/20211111020724.ggsfhcq3krq5r4hb@alap3.anarazel.de
      9aa91cb3
    • Michael Paquier's avatar
      Fix buffer overrun in unicode string normalization with empty input · b609db71
      Michael Paquier authored
      PostgreSQL 13 and newer versions are directly impacted by that through
      the SQL function normalize(), which would cause a call of this function
      to write one byte past its allocation if using in input an empty
      string after recomposing the string with NFC and NFKC.  Older versions
      (v10~v12) are not directly affected by this problem as the only code
      path using normalization is SASLprep in SCRAM authentication that
      forbids the case of an empty string, but let's make the code more robust
      anyway there so as any out-of-core callers of this function are covered.
      
      The solution chosen to fix this issue is simple, with the addition of a
      fast-exit path if the decomposed string is found as empty.  This would
      only happen for an empty string as at its lowest level a codepoint would
      be decomposed as itself if it has no entry in the decomposition table or
      if it has a decomposition size of 0.
      
      Some tests are added to cover this issue in v13~.  Note that an empty
      string has always been considered as normalized (grammar "IS NF[K]{C,D}
      NORMALIZED", through the SQL function is_normalized()) for all the
      operations allowed (NFC, NFD, NFKC and NFKD) since this feature has been
      introduced as of 2991ac5f.  This behavior is unchanged but some tests are
      added in v13~ to check after that.
      
      I have also checked "make normalization-check" in src/common/unicode/,
      while on it (works in 13~, and breaks in older stable branches
      independently of this commit).
      
      The release notes should just mention this commit for v13~.
      
      Reported-by: Matthijs van der Vleuten
      Discussion: https://postgr.es/m/17277-0c527a373794e802@postgresql.org
      Backpatch-through: 10
      b609db71
    • Michael Paquier's avatar
      Clean up compilation warnings coming from PL/Perl with clang-12~ · 56eb02ce
      Michael Paquier authored
      clang-12 has introduced -Wcompound-token-split-by-macro, that is causing
      a large amount of warnings when building PL/Perl because of its
      interactions with upstream Perl.  This commit adds one -Wno to CFLAGS at
      ./configure time if the flag is supported by the compiler to silence all
      those warnings.
      
      Upstream perl has fixed this issue, but it is going to take some time
      before this is spread across the buildfarm, and we have noticed that
      some animals would be useful with an extra -Werror to help with the
      detection of incorrect placeholders (see b0cf544), dangomushi being
      one.
      
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/YYr3qYa/R3Gw+Sbg@paquier.xyz
      Backpatch-through: 10
      56eb02ce
  5. 10 Nov, 2021 1 commit
  6. 09 Nov, 2021 1 commit
  7. 08 Nov, 2021 6 commits
    • Tom Lane's avatar
      Stamp 14.1. · 0a455b8d
      Tom Lane authored
      0a455b8d
    • Tom Lane's avatar
      Last-minute updates for release notes. · ddc6917c
      Tom Lane authored
      Security: CVE-2021-23214, CVE-2021-23222
      ddc6917c
    • Tom Lane's avatar
      libpq: reject extraneous data after SSL or GSS encryption handshake. · 30547d79
      Tom Lane authored
      libpq collects up to a bufferload of data whenever it reads data from
      the socket.  When SSL or GSS encryption is requested during startup,
      any additional data received with the server's yes-or-no reply
      remained in the buffer, and would be treated as already-decrypted data
      once the encryption handshake completed.  Thus, a man-in-the-middle
      with the ability to inject data into the TCP connection could stuff
      some cleartext data into the start of a supposedly encryption-protected
      database session.
      
      This could probably be abused to inject faked responses to the
      client's first few queries, although other details of libpq's behavior
      make that harder than it sounds.  A different line of attack is to
      exfiltrate the client's password, or other sensitive data that might
      be sent early in the session.  That has been shown to be possible with
      a server vulnerable to CVE-2021-23214.
      
      To fix, throw a protocol-violation error if the internal buffer
      is not empty after the encryption handshake.
      
      Our thanks to Jacob Champion for reporting this problem.
      
      Security: CVE-2021-23222
      30547d79
    • Tom Lane's avatar
      Reject extraneous data after SSL or GSS encryption handshake. · 9d5a76b8
      Tom Lane authored
      The server collects up to a bufferload of data whenever it reads data
      from the client socket.  When SSL or GSS encryption is requested
      during startup, any additional data received with the initial
      request message remained in the buffer, and would be treated as
      already-decrypted data once the encryption handshake completed.
      Thus, a man-in-the-middle with the ability to inject data into the
      TCP connection could stuff some cleartext data into the start of
      a supposedly encryption-protected database session.
      
      This could be abused to send faked SQL commands to the server,
      although that would only work if the server did not demand any
      authentication data.  (However, a server relying on SSL certificate
      authentication might well not do so.)
      
      To fix, throw a protocol-violation error if the internal buffer
      is not empty after the encryption handshake.
      
      Our thanks to Jacob Champion for reporting this problem.
      
      Security: CVE-2021-23214
      9d5a76b8
    • Peter Eisentraut's avatar
      Translation updates · 5a756120
      Peter Eisentraut authored
      Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
      Source-Git-Hash: f54c1d7c2c97bb2a238a149e407023a9bc007b06
      5a756120
    • David Rowley's avatar
      Fix incorrect hash equality operator bug in Memoize · 1f194ed6
      David Rowley authored
      In v14, because we don't have a field in RestrictInfo to cache both the
      left and right type's hash equality operator, we just restrict the scope
      of Memoize to only when the left and right types of a RestrictInfo are the
      same.
      
      In master we add another field to RestrictInfo and cache both hash
      equality operators.
      
      Reported-by: Jaime Casanova
      Author: David Rowley
      Discussion: https://postgr.es/m/20210929185544.GB24346%40ahch-to
      Backpatch-through: 14
      1f194ed6
  8. 07 Nov, 2021 1 commit
  9. 06 Nov, 2021 4 commits
    • Alexander Korotkov's avatar
      Reset lastOverflowedXid on standby when needed · b0f6bd48
      Alexander Korotkov authored
      Currently, lastOverflowedXid is never reset.  It's just adjusted on new
      transactions known to be overflowed.  But if there are no overflowed
      transactions for a long time, snapshots could be mistakenly marked as
      suboverflowed due to wraparound.
      
      This commit fixes this issue by resetting lastOverflowedXid when needed
      altogether with KnownAssignedXids.
      
      Backpatch to all supported versions.
      
      Reported-by: Stan Hu
      Discussion: https://postgr.es/m/CAMBWrQ%3DFp5UAsU_nATY7EMY7NHczG4-DTDU%3DmCvBQZAQ6wa2xQ%40mail.gmail.com
      Author: Kyotaro Horiguchi, Alexander Korotkov
      Reviewed-by: Stan Hu, Simon Riggs, Nikolay Samokhvalov, Andrey Borodin, Dmitry Dolgov
      b0f6bd48
    • Tom Lane's avatar
      Second-draft release notes for 14.1. · 01a11c77
      Tom Lane authored
      Add latest commits.  Fix some typos and infelicitous wording
      (thanks to Justin Pryzby for proof-reading).
      01a11c77
    • Tomas Vondra's avatar
      Fix handling of NaN values in BRIN minmax multi · f7829feb
      Tomas Vondra authored
      When calculating distance between float4/float8 values, we need to be a
      bit more careful about NaN values in order not to trigger assert. We
      consider NaN values to be equal (distace 0.0) and in infinite distance
      from all other values.
      
      On builds without asserts, this issue is mostly harmless - the ranges
      may be merged in less efficient order, but the index is still correct.
      
      Per report from Andreas Seltenreich. Backpatch to 14, where this new
      BRIN opclass was introduced.
      
      Reported-by: Andreas Seltenreich
      Discussion: https://postgr.es/m/87r1bw9ukm.fsf@credativ.de
      f7829feb
    • Tom Lane's avatar
      First-draft release notes for 14.1. · 39387228
      Tom Lane authored
      As usual, the release notes for other branches will be made by cutting
      these down, but put them up for community review first.
      
      Also as usual for a .1 release, there are some entries here that
      are not really relevant for v14 because they already appeared in 14.0.
      Those'll be removed later.
      39387228
  10. 05 Nov, 2021 2 commits
  11. 03 Nov, 2021 3 commits
  12. 02 Nov, 2021 3 commits
    • Peter Geoghegan's avatar
      Don't overlook indexes during parallel VACUUM. · 61a86ed5
      Peter Geoghegan authored
      Commit b4af70cb, which simplified state managed by VACUUM, performed
      refactoring of parallel VACUUM in passing.  Confusion about the exact
      details of the tasks that the leader process is responsible for led to
      code that made it possible for parallel VACUUM to miss a subset of the
      table's indexes entirely.  Specifically, indexes that fell under the
      min_parallel_index_scan_size size cutoff were missed.  These indexes are
      supposed to be vacuumed by the leader (alongside any parallel unsafe
      indexes), but weren't vacuumed at all.  Affected indexes could easily
      end up with duplicate heap TIDs, once heap TIDs were recycled for new
      heap tuples.  This had generic symptoms that might be seen with almost
      any index corruption involving structural inconsistencies between an
      index and its table.
      
      To fix, make sure that the parallel VACUUM leader process performs any
      required index vacuuming for indexes that happen to be below the size
      cutoff.  Also document the design of parallel VACUUM with these
      below-size-cutoff indexes.
      
      It's unclear how many users might be affected by this bug.  There had to
      be at least three indexes on the table to hit the bug: a smaller index,
      plus at least two additional indexes that themselves exceed the size
      cutoff.  Cases with just one additional index would not run into
      trouble, since the parallel VACUUM cost model requires two
      larger-than-cutoff indexes on the table to apply any parallel
      processing.  Note also that autovacuum was not affected, since it never
      uses parallel processing.
      
      Test case based on tests from a larger patch to test parallel VACUUM by
      Masahiko Sawada.
      
      Many thanks to Kamigishi Rei for her invaluable help with tracking this
      problem down.
      
      Author: Peter Geoghegan <pg@bowt.ie>
      Author: Masahiko Sawada <sawada.mshk@gmail.com>
      Reported-By: default avatarKamigishi Rei <iijima.yun@koumakan.jp>
      Reported-By: default avatarAndrew Gierth <andrew@tao11.riddles.org.uk>
      Diagnosed-By: default avatarAndres Freund <andres@anarazel.de>
      Bug: #17245
      Discussion: https://postgr.es/m/17245-ddf06aaf85735f36@postgresql.org
      Discussion: https://postgr.es/m/20211030023740.qbnsl2xaoh2grq3d@alap3.anarazel.de
      Backpatch: 14-, where the refactoring commit appears.
      61a86ed5
    • Tom Lane's avatar
      Fix variable lifespan in ExecInitCoerceToDomain(). · 16a56774
      Tom Lane authored
      This undoes a mistake in 1ec7679f: domainval and domainnull were
      meant to live across loop iterations, but they were incorrectly
      moved inside the loop.  The effect was only to emit useless extra
      EEOP_MAKE_READONLY steps, so it's not a big deal; nonetheless,
      back-patch to v13 where the mistake was introduced.
      
      Ranier Vilela
      
      Discussion: https://postgr.es/m/CAEudQAqXuhbkaAp-sGH6dR6Nsq7v28_0TPexHOm6FiDYqwQD-w@mail.gmail.com
      16a56774
    • Tom Lane's avatar
      Avoid O(N^2) behavior in SyncPostCheckpoint(). · 08cfa598
      Tom Lane authored
      As in commits 6301c3ada and e9d9ba2a4, avoid doing repetitive
      list_delete_first() operations, since that would be expensive when
      there are many files waiting to be unlinked.  This is a slightly
      larger change than in those cases.  We have to keep the list state
      valid for calls to AbsorbSyncRequests(), so it's necessary to invent a
      "canceled" field instead of immediately deleting PendingUnlinkEntry
      entries.  Also, because we might not be able to process all the
      entries, we need a new list primitive list_delete_first_n().
      
      list_delete_first_n() is almost list_copy_tail(), but it modifies the
      input List instead of making a new copy.  I found a couple of existing
      uses of the latter that could profitably use the new function.  (There
      might be more, but the other callers look like they probably shouldn't
      overwrite the input List.)
      
      As before, back-patch to v13.
      
      Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com
      08cfa598
  13. 01 Nov, 2021 3 commits
  14. 31 Oct, 2021 2 commits
    • Tom Lane's avatar
      Don't try to read a multi-GB pg_stat_statements file in one call. · 7104e0b2
      Tom Lane authored
      Windows fails on a request to read() more than INT_MAX bytes,
      and perhaps other platforms could have similar issues.  Let's
      adjust this code to read at most 1GB per call.
      
      (One would not have thought the file could get that big, but now
      we have a field report of trouble, so it can.  We likely ought to
      add some mechanism to limit the size of the query-texts file
      separately from the size of the hash table.  That is not this
      patch, though.)
      
      Per bug #17254 from Yusuke Egashira.  It's been like this for
      awhile, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/17254-a926c89dc03375c2@postgresql.org
      7104e0b2
    • Tom Lane's avatar
      Avoid O(N^2) behavior when the standby process releases many locks. · 8424dfce
      Tom Lane authored
      When replaying a transaction that held many exclusive locks on the
      primary, a standby server's startup process would expend O(N^2)
      effort on manipulating the list of locks.  This code was fine when
      written, but commit 1cff1b95 made repetitive list_delete_first()
      calls inefficient, as explained in its commit message.  Fix by just
      iterating the list normally, and releasing storage only when done.
      (This'd be inadequate if we needed to recover from an error occurring
      partway through; but we don't.)
      
      Back-patch to v13 where 1cff1b95 came in.
      
      Nathan Bossart
      
      Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com
      8424dfce
  15. 29 Oct, 2021 2 commits
    • Peter Geoghegan's avatar
      Demote pg_unreachable() in heapam to an assertion. · bd9f4cf0
      Peter Geoghegan authored
      Commit d168b666, which overhauled index deletion, added a
      pg_unreachable() to the end of a sort comparator used when sorting heap
      TIDs from an index page.  This allows the compiler to apply
      optimizations that assume that the heap TIDs from the index AM must
      always be unique.
      
      That doesn't seem like a good idea now, given recent reports of
      corruption involving duplicate TIDs in indexes on Postgres 14.  Demote
      to an assertion, just in case.
      
      Backpatch: 14-, where index deletion was overhauled.
      bd9f4cf0
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2021e. · 0c8a40b3
      Tom Lane authored
      DST law changes in Fiji, Jordan, Palestine, and Samoa.  Historical
      corrections for Barbados, Cook Islands, Guyana, Niue, Portugal, and
      Tonga.
      
      Also, the Pacific/Enderbury zone has been renamed to Pacific/Kanton.
      The following zones have been merged into nearby, more-populous zones
      whose clocks have agreed since 1970: Africa/Accra, America/Atikokan,
      America/Blanc-Sablon, America/Creston, America/Curacao,
      America/Nassau, America/Port_of_Spain, Antarctica/DumontDUrville,
      and Antarctica/Syowa.
      0c8a40b3
  16. 28 Oct, 2021 2 commits
    • Tom Lane's avatar
      Improve contrib/amcheck's tests for CREATE INDEX CONCURRENTLY. · b1f943d2
      Tom Lane authored
      Commits fdd965d07 and 3cd9c3b92 tested CREATE INDEX CONCURRENTLY by
      launching two separate pgbench runs concurrently.  This was needed so
      that only a single client thread would run CREATE INDEX CONCURRENTLY,
      avoiding deadlock between two CICs.  However, there's a better way,
      which is to use an advisory lock to prevent concurrent CICs.  That's
      better in part because the test code is shorter and more readable, but
      mostly because it automatically scales things to launch an appropriate
      number of CICs relative to the number of INSERT transactions.
      As committed, typically half to three-quarters of the CIC transactions
      were pointless because the INSERT transactions had already stopped.
      
      In passing, remove background_pgbench, which was added to support
      these tests and isn't needed anymore.  We can always put it back
      if we find a use for it later.
      
      Back-patch to v12; older pgbench versions lack the
      conditional-execution features needed for this method.
      
      Tom Lane and Andrey Borodin
      
      Discussion: https://postgr.es/m/139687.1635277318@sss.pgh.pa.us
      b1f943d2
    • Michael Paquier's avatar
      doc: Fix link to SELinux user guide in sepgsql page · da7d0fb1
      Michael Paquier authored
      Reported-by: Anton Voloshin
      Discussion: https://postgr.es/m/15a86d4e-a237-1acd-18a2-fd69730f1ab9@postgrespro.ru
      Backpatch-through: 10
      da7d0fb1
  17. 27 Oct, 2021 2 commits