1. 25 Jun, 2022 3 commits
  2. 23 Jun, 2022 1 commit
  3. 22 Jun, 2022 3 commits
    • Bruce Momjian's avatar
      doc: improve wording of plpgsql RAISE format text · f1e3a707
      Bruce Momjian authored
      Reported-by: pg@kirasoft.com
      
      Discussion: https://postgr.es/m/165455351426.573551.7050474465030525109@wrigleys.postgresql.org
      
      Backpatch-through: 10
      f1e3a707
    • Bruce Momjian's avatar
      doc: clarify wording about phantom reads · 1463f22d
      Bruce Momjian authored
      Reported-by: akhilhello@gmail.com
      
      Discussion: https://postgr.es/m/165222922369.669.10475917322916060899@wrigleys.postgresql.org
      
      Backpatch-through: 10
      1463f22d
    • Tom Lane's avatar
      Fix SPI's handling of errors during transaction commit. · 60465188
      Tom Lane authored
      SPI_commit previously left it up to the caller to recover from any error
      occurring during commit.  Since that's complicated and requires use of
      low-level xact.c facilities, it's not too surprising that no caller got
      it right.  Let's move the responsibility for cleanup into spi.c.  Doing
      that requires redefining SPI_commit as starting a new transaction, so
      that it becomes equivalent to SPI_commit_and_chain except that you get
      default transaction characteristics instead of preserving the prior
      transaction's characteristics.  We can make this pretty transparent
      API-wise by redefining SPI_start_transaction() as a no-op.  Callers
      that expect to do something in between might be surprised, but
      available evidence is that no callers do so.
      
      Having made that API redefinition, we can fix this mess by having
      SPI_commit[_and_chain] trap errors and start a new, clean transaction
      before re-throwing the error.  Likewise for SPI_rollback[_and_chain].
      Some cleanup is also needed in AtEOXact_SPI, which was nowhere near
      smart enough to deal with SPI contexts nested inside a committing
      context.
      
      While plperl and pltcl need no changes beyond removing their now-useless
      SPI_start_transaction() calls, plpython needs some more work because it
      hadn't gotten the memo about catching commit/rollback errors in the
      first place.  Such an error resulted in longjmp'ing out of the Python
      interpreter, which leaks Python stack entries at present and is reported
      to crash Python 3.11 altogether.  Add the missing logic to catch such
      errors and convert them into Python exceptions.
      
      This is a back-patch of commit 2e517818f.  That's now aged long enough
      to reduce the concerns about whether it will break something, and we
      do need to ensure that supported branches will work with Python 3.11.
      
      Peter Eisentraut and Tom Lane
      
      Discussion: https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com
      Discussion: https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org
      60465188
  4. 21 Jun, 2022 2 commits
    • Amit Kapila's avatar
      Fix stale values in partition map entries on subscribers. · f0022a77
      Amit Kapila authored
      We build the partition map entries on subscribers while applying the
      changes for update/delete on partitions. The component relation in each
      entry is closed after its use so we need to update it on successive use of
      cache entries.
      
      This problem was there since the original commit f1ac27bf that
      introduced this code but we didn't notice it till the recent commit
      26b3455afa started to use the component relation of partition map cache
      entry.
      
      Reported-by: Tom Lane, as per buildfarm
      Author: Amit Langote, Hou Zhijie
      Reviewed-by: Amit Kapila, Shi Yu
      Backpatch-through: 13, where it was introduced
      Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
      f0022a77
    • Amit Kapila's avatar
      Fix partition table's REPLICA IDENTITY checking on the subscriber. · 52d5ea9a
      Amit Kapila authored
      In logical replication, we will check if the target table on the
      subscriber is updatable by comparing the replica identity of the table on
      the publisher with the table on the subscriber. When the target table is a
      partitioned table, we only check its replica identity but not for the
      partition tables. This leads to assertion failure while applying changes
      for update/delete as we expect those to succeed only when the
      corresponding partition table has a primary key or has a replica
      identity defined.
      
      Fix it by checking the replica identity of the partition table while
      applying changes.
      
      Reported-by: Shi Yu
      Author: Shi Yu, Hou Zhijie
      Reviewed-by: Amit Langote, Amit Kapila
      Backpatch-through: 13, where it was introduced
      Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
      52d5ea9a
  5. 16 Jun, 2022 1 commit
  6. 15 Jun, 2022 1 commit
  7. 14 Jun, 2022 2 commits
    • Tom Lane's avatar
      Avoid ecpglib core dump with out-of-order operations. · 7bc21ed8
      Tom Lane authored
      If an application executed operations like EXEC SQL PREPARE
      without having first established a database connection, it could
      get a core dump instead of the expected clean failure.  This
      occurred because we did "pthread_getspecific(actual_connection_key)"
      without ever having initialized the TSD key actual_connection_key.
      The results of that are probably platform-specific, but at least
      on Linux it often leads to a crash.
      
      To fix, add calls to ecpg_pthreads_init() in the code paths that
      might use actual_connection_key uninitialized.  It's harmless
      (and hopefully inexpensive) to do that more than once.
      
      Per bug #17514 from Okano Naoki.  The problem's ancient, so
      back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/17514-edd4fad547c5692c@postgresql.org
      7bc21ed8
    • Tom Lane's avatar
      Doc: clarify the default collation behavior of domains. · be35a645
      Tom Lane authored
      The previous wording was "the underlying data type's default collation
      is used", which is wrong or at least misleading.  The domain inherits
      the base type's collation behavior, which if "default" actually can
      mean that we use some non-default collation obtained from elsewhere.
      
      Per complaint from Jian He.
      
      Discussion: https://postgr.es/m/CACJufxHMR8_4WooDPjjvEdaxB2hQ5a49qthci8fpKP0MKemVRQ@mail.gmail.com
      be35a645
  8. 13 Jun, 2022 2 commits
  9. 10 Jun, 2022 4 commits
  10. 08 Jun, 2022 3 commits
    • Tom Lane's avatar
      Doc: copy-edit "jsonb Indexing" section. · 0ccef410
      Tom Lane authored
      The patch introducing jsonpath dropped a para about that between
      two related examples, and didn't bother updating the introductory
      sentences that it falsified.  The grammar was pretty shaky as well.
      0ccef410
    • Peter Eisentraut's avatar
      Fix whitespace · 804a5079
      Peter Eisentraut authored
      804a5079
    • David Rowley's avatar
      Harden Memoization code against broken data types · cbcea3b9
      David Rowley authored
      Bug #17512 highlighted that a suitably broken data type could cause the
      backend to crash if either the hash function or equality function were in
      someway non-deterministic based on their input values.  Such a data type
      could cause a crash of the backend due to some code which assumes that
      we'll always find a hash table entry corresponding to an item in the
      Memoize LRU list.
      
      Here we remove the assumption that we'll always find the entry
      corresponding to the given LRU list item and add run-time checks to verify
      we have found the given item in the cache.
      
      This is not a fix for bug #17512, but it will turn the crash reported by
      that bug report into an internal ERROR.
      
      Reported-by: Ales Zeleny
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/CAApHDvpxFSTwvoYWT7kmFVSZ9zLAeHb=S9vrz=RExMgSkQNWqw@mail.gmail.com
      Backpatch-through: 14, where Memoize was added.
      cbcea3b9
  11. 07 Jun, 2022 1 commit
    • Tom Lane's avatar
      Fix off-by-one loop termination condition in pg_stat_get_subscription(). · 5c3b5f7d
      Tom Lane authored
      pg_stat_get_subscription scanned one more LogicalRepWorker array entry
      than is really allocated.  In the worst case this could lead to SIGSEGV,
      if the LogicalRepCtx data structure is near the end of shared memory.
      That seems quite unlikely though (thanks to the ordering of calls in
      CreateSharedMemoryAndSemaphores) and we've heard no field reports of it.
      A more likely misbehavior is one row of garbage data in the function's
      result, but even that is not real likely because of the check that the
      pid field matches some live backend.
      
      Report and fix by Kuntal Ghosh.  This bug is old, so back-patch
      to all supported branches.
      
      Discussion: https://postgr.es/m/CAGz5QCJykEDzW6jQK6Yz7Qh_PMtD=95de_7QoocbVR2Qy8hWZA@mail.gmail.com
      5c3b5f7d
  12. 06 Jun, 2022 3 commits
    • Tom Lane's avatar
      Don't fail on libpq-generated error reports in pg_amcheck. · 32a85ee4
      Tom Lane authored
      An error PGresult generated by libpq itself, such as a report of
      connection loss, won't have broken-down error fields.
      should_processing_continue() blithely assumed that
      PG_DIAG_SEVERITY_NONLOCALIZED would always be present, and would
      dump core if it wasn't.
      
      Per grepping to see if 6d157e7cb's mistake was repeated elsewhere.
      32a85ee4
    • Tom Lane's avatar
      Don't fail on libpq-generated error reports in ecpg_raise_backend(). · a5dbca46
      Tom Lane authored
      An error PGresult generated by libpq itself, such as a report of
      connection loss, won't have broken-down error fields.
      ecpg_raise_backend() blithely assumed that PG_DIAG_MESSAGE_PRIMARY
      would always be present, and would end up passing a NULL string
      pointer to snprintf when it isn't.  That would typically crash
      before 3779ac62d, and it would fail to provide a useful error report
      in any case.  Best practice is to substitute PQerrorMessage(conn)
      in such cases, so do that.
      
      Per bug #17421 from Masayuki Hirose.  Back-patch to all supported
      branches.
      
      Discussion: https://postgr.es/m/17421-790ff887e3188874@postgresql.org
      a5dbca46
    • Michael Paquier's avatar
      Fix psql's single transaction mode on client-side errors with -c/-f switches · a04ccf6d
      Michael Paquier authored
      psql --single-transaction is able to handle multiple -c and -f switches
      in a single transaction since d5563d7d, but this had the surprising
      behavior of forcing a transaction COMMIT even if psql failed with an
      error in the client (for example incorrect path given to \copy), which
      would generate an error, but still commit any changes that were already
      applied in the backend.  This commit makes the behavior more consistent,
      by enforcing a transaction ROLLBACK if any commands fail, both
      client-side and backend-side, so as no changes are applied if one error
      happens in any of them.
      
      Some tests are added on HEAD to provide some coverage about all that.
      Backend-side errors are unreliable as IPC::Run can complain on SIGPIPE
      if psql quits before reading a query result, but that should work
      properly in the case where any errors come from psql itself, which is
      what the original report is about.
      
      Reported-by: Christoph Berg
      Author: Kyotaro Horiguchi, Michael Paquier
      Discussion: https://postgr.es/m/17504-76b68018e130415e@postgresql.org
      Backpatch-through: 10
      a04ccf6d
  13. 03 Jun, 2022 2 commits
  14. 02 Jun, 2022 1 commit
  15. 01 Jun, 2022 4 commits
  16. 31 May, 2022 4 commits
  17. 30 May, 2022 1 commit
  18. 29 May, 2022 2 commits