1. 27 Oct, 2021 3 commits
  2. 26 Oct, 2021 3 commits
  3. 24 Oct, 2021 2 commits
    • Noah Misch's avatar
      Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions. · a5b9a000
      Noah Misch authored
      The purpose of commit 8a54e12a was to
      fix this, and it sufficed when the PREPARE TRANSACTION completed before
      the CIC looked for lock conflicts.  Otherwise, things still broke.  As
      before, in a cluster having used CIC while having enabled prepared
      transactions, queries that use the resulting index can silently fail to
      find rows.  It may be necessary to reindex to recover from past
      occurrences; REINDEX CONCURRENTLY suffices.  Fix this for future index
      builds by making CIC wait for arbitrarily-recent prepared transactions
      and for ordinary transactions that may yet PREPARE TRANSACTION.  As part
      of that, have PREPARE TRANSACTION transfer locks to its dummy PGPROC
      before it calls ProcArrayClearTransaction().  Back-patch to 9.6 (all
      supported versions).
      
      Andrey Borodin, reviewed (in earlier versions) by Andres Freund.
      
      Discussion: https://postgr.es/m/01824242-AA92-4FE9-9BA7-AEBAFFEA3D0C@yandex-team.ru
      a5b9a000
    • Noah Misch's avatar
      Avoid race in RelationBuildDesc() affecting CREATE INDEX CONCURRENTLY. · dde966ef
      Noah Misch authored
      CIC and REINDEX CONCURRENTLY assume backends see their catalog changes
      no later than each backend's next transaction start.  That failed to
      hold when a backend absorbed a relevant invalidation in the middle of
      running RelationBuildDesc() on the CIC index.  Queries that use the
      resulting index can silently fail to find rows.  Fix this for future
      index builds by making RelationBuildDesc() loop until it finishes
      without accepting a relevant invalidation.  It may be necessary to
      reindex to recover from past occurrences; REINDEX CONCURRENTLY suffices.
      Back-patch to 9.6 (all supported versions).
      
      Noah Misch and Andrey Borodin, reviewed (in earlier versions) by Andres
      Freund.
      
      Discussion: https://postgr.es/m/20210730022548.GA1940096@gust.leadboat.com
      dde966ef
  4. 23 Oct, 2021 1 commit
  5. 22 Oct, 2021 3 commits
  6. 21 Oct, 2021 3 commits
  7. 20 Oct, 2021 2 commits
  8. 19 Oct, 2021 7 commits
    • Alvaro Herrera's avatar
      Ensure correct lock level is used in ALTER ... RENAME · 3ce3fb2f
      Alvaro Herrera authored
      Commit 1b5d797c intended to relax the lock level used to rename
      indexes, but inadvertently allowed *any* relation to be renamed with a
      lowered lock level, as long as the command is spelled ALTER INDEX.
      That's undesirable for other relation types, so retry the operation with
      the higher lock if the relation turns out not to be an index.
      
      After this fix, ALTER INDEX <sometable> RENAME will require access
      exclusive lock, which it didn't before.
      
      Author: Nathan Bossart <bossartn@amazon.com>
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Reported-by: default avatarOnder Kalaci <onderk@microsoft.com>
      Discussion: https://postgr.es/m/PH0PR21MB1328189E2821CDEC646F8178D8AE9@PH0PR21MB1328.namprd21.prod.outlook.com
      3ce3fb2f
    • Andres Freund's avatar
      Adapt src/test/ldap/t/001_auth.pl to work with openldap 2.5. · 533315b6
      Andres Freund authored
      ldapsearch's deprecated -h/-p arguments were removed, need to use -H now -
      which has been around for over 20 years.
      
      As perltidy insists on reflowing the parameters anyway, change order and
      "phrasing" to yield a less confusing layout (per suggestion from Tom Lane).
      
      Discussion: https://postgr.es/m/20211009233850.wvr6apcrw2ai6cnj@alap3.anarazel.de
      Backpatch: 11-, where the tests were added.
      533315b6
    • Tom Lane's avatar
      Fix assignment to array of domain over composite. · 04dae19f
      Tom Lane authored
      An update such as "UPDATE ... SET fld[n].subfld = whatever"
      failed if the array elements were domains rather than plain
      composites.  That's because isAssignmentIndirectionExpr()
      failed to cope with the CoerceToDomain node that would appear
      in the expression tree in this case.  The result would typically
      be a crash, and even if we accidentally didn't crash, we'd not
      correctly preserve other fields of the same array element.
      
      Per report from Onder Kalaci.  Back-patch to v11 where arrays of
      domains came in.
      
      Discussion: https://postgr.es/m/PH0PR21MB132823A46AA36F0685B7A29AD8BD9@PH0PR21MB1328.namprd21.prod.outlook.com
      04dae19f
    • Tom Lane's avatar
      Remove bogus assertion in transformExpressionList(). · f627fd54
      Tom Lane authored
      I think when I added this assertion (in commit 8f889b10), I was only
      thinking of the use of transformExpressionList at top level of INSERT
      and VALUES.  But it's also called by transformRowExpr(), which can
      certainly occur in an UPDATE targetlist, so it's inappropriate to
      suppose that p_multiassign_exprs must be empty.  Besides, since the
      input is not expected to contain ResTargets, there's no reason it
      should contain MultiAssignRefs either.  Hence this code need not
      be concerned about the state of p_multiassign_exprs, and we should
      just drop the assertion.
      
      Per bug #17236 from ocean_li_996.  It's been wrong for years,
      so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/17236-3210de9bcba1d7ca@postgresql.org
      f627fd54
    • Daniel Gustafsson's avatar
      Fix bug in TOC file error message printing · 3e2f32b0
      Daniel Gustafsson authored
      If the blob TOC file cannot be parsed, the error message was failing
      to print the filename as the variable holding it was shadowed by the
      destination buffer for parsing.  When the filename fails to parse,
      the error will print an empty string:
      
       ./pg_restore -d foo -F d dump
       pg_restore: error: invalid line in large object TOC file "": ..
      
      ..instead of the intended error message:
      
       ./pg_restore -d foo -F d dump
       pg_restore: error: invalid line in large object TOC file "dump/blobs.toc": ..
      
      Fix by renaming both variables as the shared name was too generic to
      store either and still convey what the variable held.
      
      Backpatch all the way down to 9.6.
      
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/A2B151F5-B32B-4F2C-BA4A-6870856D9BDE@yesql.se
      Backpatch-through: 9.6
      3e2f32b0
    • Daniel Gustafsson's avatar
      Fix sscanf limits in pg_basebackup and pg_dump · 121be6a6
      Daniel Gustafsson authored
      Make sure that the string parsing is limited by the size of the
      destination buffer.
      
      In pg_basebackup the available values sent from the server
      is limited to two characters so there was no risk of overflow.
      
      In pg_dump the buffer is bounded by MAXPGPATH, and thus the limit
      must be inserted via preprocessor expansion and the buffer increased
      by one to account for the terminator. There is no risk of overflow
      here, since in this case, the buffer scanned is smaller than the
      destination buffer.
      
      Backpatch the pg_basebackup fix to 11 where it was introduced, and
      the pg_dump fix all the way down to 9.6.
      
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/B14D3D7B-F98C-4E20-9459-C122C67647FB@yesql.se
      Backpatch-through: 11 and 9.6
      121be6a6
    • Michael Paquier's avatar
      Block ALTER INDEX/TABLE index_name ALTER COLUMN colname SET (options) · b1b797ec
      Michael Paquier authored
      The grammar of this command run on indexes with column names has always
      been authorized by the parser, and it has never been documented.
      
      Since 911e7020, it is possible to define opclass parameters as of CREATE
      INDEX, which actually broke the old case of ALTER INDEX/TABLE where
      relation-level parameters n_distinct and n_distinct_inherited could be
      defined for an index (see 76a47c0e and its thread where this point has
      been touched, still remained unused).  Attempting to do that in v13~
      would cause the index to become unusable, as there is a new dedicated
      code path to load opclass parameters instead of the relation-level ones
      previously available.  Note that it is possible to fix things with a
      manual catalog update to bring the relation back online.
      
      This commit disables this command for now as the use of column names for
      indexes does not make sense anyway, particularly when it comes to index
      expressions where names are automatically computed.  One way to properly
      support this case properly in the future would be to use column numbers
      when it comes to indexes, in the same way as ALTER INDEX .. ALTER COLUMN
      .. SET STATISTICS.
      
      Partitioned indexes were already blocked, but not indexes.  Some tests
      are added for both cases.
      
      There was some code in ANALYZE to enforce n_distinct to be used for an
      index expression if the parameter was defined, but just remove it for
      now until/if there is support for this (note that index-level parameters
      never had support in pg_dump either, previously), so this was just dead
      code.
      
      Reported-by: Matthijs van der Vleuten
      Author: Nathan Bossart, Michael Paquier
      Reviewed-by: Vik Fearing, Dilip Kumar
      Discussion: https://postgr.es/m/17220-15d684c6c2171a83@postgresql.org
      Backpatch-through: 13
      b1b797ec
  9. 18 Oct, 2021 2 commits
  10. 16 Oct, 2021 2 commits
    • Tom Lane's avatar
      Avoid core dump in pg_dump when dumping from pre-8.3 server. · 3e4c8db9
      Tom Lane authored
      Commit f0e21f2f6 missed adding a tgisinternal output column
      to getTriggers' query for pre-8.3 servers.  Back-patch to v11,
      like that commit.
      3e4c8db9
    • Tom Lane's avatar
      Make pg_dump acquire lock on partitioned tables that are to be dumped. · b5152e3b
      Tom Lane authored
      It was clearly the intent to do so all along, but the original coding
      fat-fingered this by checking the wrong array element.  We fixed it
      in passing in 403a3d91, but that later got reverted, and we forgot
      to keep this bug fix.
      
      Most of the time this'd be relatively harmless, since once we lock
      any of the partitioned table's leaf partitions, that would suffice
      to prevent major DDL on the partitioned table itself.  However, a
      childless partitioned table would get dumped with no relevant lock
      whatsoever, possibly allowing dump failure or inconsistent output.
      
      Unlike 403a3d91, there are no versioning concerns, since every server
      version that has partitioned tables will allow you to lock one.
      
      Back-patch to v10 where partitioned tables were introduced.
      
      Discussion: https://postgr.es/m/1018205.1634346327@sss.pgh.pa.us
      b5152e3b
  11. 15 Oct, 2021 1 commit
  12. 14 Oct, 2021 3 commits
  13. 13 Oct, 2021 5 commits
    • Alvaro Herrera's avatar
      Change recently added test code for stability · 79c7fe1a
      Alvaro Herrera authored
      The test code added with ff9f111bce24 fails under valgrind, and probably
      other slow cases too, because if (say) autovacuum runs in between and
      produces WAL of its own, the large INSERT fails to account for that in
      the LSN calculations.  Rewrite to use a DO loop.
      
      Per complaint from Andres Freund
      
      Backpatch to all branches.
      
      Discussion: https://postgr.es/m/20211013180338.5guyqzpkcisqugrl@alap3.anarazel.de
      79c7fe1a
    • Peter Geoghegan's avatar
      pg_amcheck: avoid unhelpful verification attempts. · dd58194c
      Peter Geoghegan authored
      Avoid calling contrib/amcheck functions with relations that are
      unsuitable for checking.  Specifically, don't attempt verification of
      temporary relations, or indexes whose pg_index entry indicates that the
      index is invalid, or not ready.
      
      These relations are not supported by any of the contrib/amcheck
      functions, for reasons that are pretty fundamental.  For example, the
      implementation of REINDEX CONCURRENTLY can add its own "transient"
      pg_index entries, which has rather unclear implications for the B-Tree
      verification functions, at least in the general case -- so they just
      treat it as an error.  It falls to the amcheck caller (in this case
      pg_amcheck) to deal with the situation at a higher level.
      
      pg_amcheck now simply treats these conditions as additional "visibility
      concerns" when it queries system catalogs.  This is a little arbitrary.
      It seems to have the least problems among any of the available
      alternatives.
      
      Author: Mark Dilger <mark.dilger@enterprisedb.com>
      Reported-By: default avatarAlexander Lakhin <exclusion@gmail.com>
      Reviewed-By: default avatarPeter Geoghegan <pg@bowt.ie>
      Reviewed-By: default avatarRobert Haas <robertmhaas@gmail.com>
      Bug: #17212
      Discussion: https://postgr.es/m/17212-34dd4a1d6bba98bf@postgresql.org
      Backpatch: 14-, where pg_amcheck was introduced.
      dd58194c
    • Etsuro Fujita's avatar
      postgres_fdw: Move comments about elog level in (sub)abort cleanup. · 419d27b1
      Etsuro Fujita authored
      The comments were misplaced when adding postgres_fdw.  Fix that by
      moving the comments to more appropriate functions.
      
      Author: Etsuro Fujita
      Backpatch-through: 9.6
      Discussion: https://postgr.es/m/CAPmGK164sAXQtC46mDFyu6d-T25Mzvh5qaRNkit06VMmecYnOA%40mail.gmail.com
      419d27b1
    • Michael Paquier's avatar
      Fix use-after-free with multirange types in CREATE TYPE · 922e15c4
      Michael Paquier authored
      The code was freeing the name of the multirange type function stored in
      the parse tree but it should not do that.  Event triggers could for
      example look at such a corrupted parsed tree with a ddl_command_end
      event.
      
      Author: Alex Kozhemyakin, Sergey Shinderuk
      Reviewed-by: Peter Eisentraut, Michael Paquier
      Discussion: https://postgr.es/m/d5042d46-b9cd-6efb-219a-71ed0cf45bc8@postgrespro.ru
      Backpatch-through: 14
      922e15c4
    • Michael Paquier's avatar
      Fix tests of pg_upgrade across different major versions · f4e1c889
      Michael Paquier authored
      This fixes a set of issues that cause different breakages or annoyances
      when using pg_upgrade's test.sh to do upgrades across different major
      versions:
      - test.sh is completely broken when using v14 as new version because of
      the removal of testtablespace/ as Makefile rule.  Older versions of
      pg_regress don't support --make-tablespacedir, blocking the creation of
      the tablespace.  In order to fix that, it is simple enough to create
      those directories in the script itself, but only do that when an old
      version is involved.  This fix is needed on HEAD and REL_14_STABLE.
      - The script would fail when using PG <= v11 as old version because of
      WITH OIDS relations not supported in v12.  In order to fix this, this
      steals a method from the buildfarm that uses a DO block to change all
      the relations marked as WITH OIDS, allowing pg_upgrade to pass.  This is
      more portable than using ALTER TABLE queries on the relations causing
      issues.  This is fixed down to v12, and authored originally by Andrew
      Dunstan.
      - Not using --extra-float-digits=0 with v11 as old version causes
      a lot of diffs in the dumps, making the whole unreadable.  This gets
      only done when using v11 as old version.  This is fixed down to v12.
      The buildfarm code uses that already.
      
      Note that the addition of --wal-segsize and --allow-group-access breaks
      the script when using v10 or older at initdb time as these got added in
      11.  10 would be EOL'd next year and nobody has complained about those
      problems yet, so nothing is done about that.  This means that this
      commit fixes upgrade tests using test.sh with v11 as minimum older
      version, up to HEAD, and that it is enough to apply this change down to
      12.  The old and new dumps still generate diffs, still require manual
      checks, and more could be done to reduce the noise, but this allows the
      tests to run with a rather minimal amount of them.
      
      I have tested this commit and test.sh with v11 as minimum across all the
      branches where this is applied.  Note that this commit has no impact on
      the normal pg_upgrade test run with a simple "make check".
      
      Author:  Justin Pryzby, Andrew Dunstan, Michael Paquier
      Discussion: https://postgr.es/m/20201206180248.GI24052@telsasoft.com
      Backpatch-through: 12
      f4e1c889
  14. 12 Oct, 2021 3 commits
    • Peter Geoghegan's avatar
      Doc: normalize vacuum_multixact_failsafe_age ID. · 070c402b
      Peter Geoghegan authored
      Author: Pavel Luzanov <p.luzanov@postgrespro.ru>
      Discussion: https://postgr.es/m/c71a3cfc-a267-3d9f-1b44-fbd668d0ab10@postgrespro.ru
      Backpatch: 14-, where the failsafe was introduced.
      070c402b
    • Michael Paquier's avatar
      Add more $Test::Builder::Level in the TAP tests · d834ebcf
      Michael Paquier authored
      Incrementing the level of the call stack reported is useful for
      debugging purposes as it allows to control which part of the test is
      exactly failing, especially if a test is structured with subroutines
      that call routines from Test::More.
      
      This adds more incrementations of $Test::Builder::Level where debugging
      gets improved (for example it does not make sense for some paths like
      pg_rewind where long subroutines are used).
      
      A note is added to src/test/perl/README about that, based on a
      suggestion from Andrew Dunstan and a wording coming from both of us.
      
      Usage of Test::Builder::Level has spread in 12, so a backpatch down to
      this version is done.
      
      Reviewed-by: Andrew Dunstan, Peter Eisentraut, Daniel Gustafsson
      Discussion: https://postgr.es/m/YV1CCFwgM1RV1LeS@paquier.xyz
      Backpatch-through: 12
      d834ebcf
    • Fujii Masao's avatar
      Make autovacuum launcher more responsive to pg_log_backend_memory_contexts(). · 62e821ad
      Fujii Masao authored
      Previously when pg_log_backend_memory_contexts() sent the request to
      the autovacuum launcher, it could take more than several seconds to
      log its memory contexts. Because the function (HandleAutoVacLauncherInterrupts)
      to process any new interrupts that autovacuum launcher received
      didn't handle the request for logging of memory contexts. This commit changes
      the function so that it handles the request, to make autovacuum launcher
      more responsitve to pg_log_backend_memory_contexts().
      
      Back-patch to v14 where pg_log_backend_memory_contexts() was added.
      
      Author: Koyu Tanigawa
      Reviewed-by: Bharath Rupireddy, Atsushi Torikoshi
      Discussion: https://postgr.es/m/0aae3e074face409b35153451be5cc11@oss.nttdata.com
      62e821ad