pgsql: Fix issue in recovery test 041_checkpoint_at_promote

2025-02-12 Thread Michael Paquier
Fix issue in recovery test 041_checkpoint_at_promote The phase of the test waiting for a restartpoint to complete was not working as intended, due to a log_contains() call incorrectly written. The problem reported by the author could be simply reproduced by removing the injection_points_wakeup()

pgsql: Fix issue in recovery test 041_checkpoint_at_promote

2025-02-12 Thread Michael Paquier
Fix issue in recovery test 041_checkpoint_at_promote The phase of the test waiting for a restartpoint to complete was not working as intended, due to a log_contains() call incorrectly written. The problem reported by the author could be simply reproduced by removing the injection_points_wakeup()

pgsql: ci: Collect core files on NetBSD and OpenBSD

2025-02-12 Thread Andres Freund
ci: Collect core files on NetBSD and OpenBSD Support for NetBSD and OpenBSD operating systems have been added to CI in the prior commit. Now add support for collect core files and generating backtraces using for all core files. Author: Nazir Bilal Yavuz Discussion: https://postgr.es/m/can55fz32

pgsql: meson: Fix failure to detect bsd_auth.h presence

2025-02-12 Thread Andres Freund
meson: Fix failure to detect bsd_auth.h presence bsd_auth.h file needs to be included after 'sys/types.h', as documented in https://man.openbsd.org/authenticate.3 The reason a similar looking stanza works for autoconf is that autoconf automatically adds AC_INCLUDES_DEFAULT, which in turn includes

pgsql: meson: Fix failure to detect bsd_auth.h presence

2025-02-12 Thread Andres Freund
meson: Fix failure to detect bsd_auth.h presence bsd_auth.h file needs to be included after 'sys/types.h', as documented in https://man.openbsd.org/authenticate.3 The reason a similar looking stanza works for autoconf is that autoconf automatically adds AC_INCLUDES_DEFAULT, which in turn includes

pgsql: meson: Fix failure to detect bsd_auth.h presence

2025-02-12 Thread Andres Freund
meson: Fix failure to detect bsd_auth.h presence bsd_auth.h file needs to be included after 'sys/types.h', as documented in https://man.openbsd.org/authenticate.3 The reason a similar looking stanza works for autoconf is that autoconf automatically adds AC_INCLUDES_DEFAULT, which in turn includes

pgsql: ci: Test NetBSD and OpenBSD

2025-02-12 Thread Andres Freund
ci: Test NetBSD and OpenBSD NetBSD and OpenBSD Postgres CI images are now generated [1], but aren't yet utilized for Postgres' CI. This commit adds CI support for them. For now the tasks will be manually triggered, to save on CI credits. [1] https://github.com/anarazel/pg-vm-images Author: Nazi

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Fix MakeTransitionCaptureState() to return a consistent result

2025-02-12 Thread Michael Paquier
Fix MakeTransitionCaptureState() to return a consistent result When an UPDATE trigger referencing a new table and a DELETE trigger referencing an old table are both present, MakeTransitionCaptureState() returns an inconsistent result for UPDATE commands in its set of flags and tuplestores holding

pgsql: Clean up impenetrable logic in pg_basebackup/receivelog.c.

2025-02-12 Thread Tom Lane
Clean up impenetrable logic in pg_basebackup/receivelog.c. Coverity complained about possible double free of HandleCopyStream's "copybuf". AFAICS it's mistaken, but it is easy to see why it's confused, because management of that buffer is impossibly confusing. It's unreasonable that HandleEndOfCo

pgsql: Fix minor memory leaks in pg_dump.

2025-02-12 Thread Tom Lane
Fix minor memory leaks in pg_dump. Coverity reported the two oversights in getPublicationTables. Valgrind found the one in determineNotNullFlags. The mistakes in getPublicationTables seem too minor to be worth back-patching. determineNotNullFlags could be run enough times to matter, but that cod

pgsql: Remove unnecessary (char *) casts [checksum]

2025-02-12 Thread Peter Eisentraut
Remove unnecessary (char *) casts [checksum] Remove some (char *) casts related to uses of the pg_checksum_page() function. These casts are useless, because everything involved already has the right type. Moreover, these casts actually silently discarded a const qualifier. The declaration of a

pgsql: Fix some inconsistencies with memory freeing in pg_createsubscri

2025-02-12 Thread Michael Paquier
Fix some inconsistencies with memory freeing in pg_createsubscriber The correct function documented to free the memory allocated for the result returned by PQescapeIdentifier() and PQescapeLiteral() is PQfreemem(). pg_createsubscriber.c relied on pg_free() instead, which is not incorrect as both

pgsql: Fix some inconsistencies with memory freeing in pg_createsubscri

2025-02-12 Thread Michael Paquier
Fix some inconsistencies with memory freeing in pg_createsubscriber The correct function documented to free the memory allocated for the result returned by PQescapeIdentifier() and PQescapeLiteral() is PQfreemem(). pg_createsubscriber.c relied on pg_free() instead, which is not incorrect as both

pgsql: Skip logical decoding of already-aborted transactions.

2025-02-12 Thread Masahiko Sawada
Skip logical decoding of already-aborted transactions. Previously, transaction aborts were detected concurrently only during system catalog scans while replaying a transaction in streaming mode. This commit adds an additional CLOG lookup to check the transaction status, allowing the logical decod

pgsql: Remove unneeded volatile qualifier in fmgr.c.

2025-02-12 Thread Nathan Bossart
Remove unneeded volatile qualifier in fmgr.c. Currently, the save_nestlevel variable in fmgr_security_definer() is marked volatile. While this may have been necessary when it was used in a PG_CATCH section (as explained in the comment for PG_TRY in elog.h), it appears to have been unnecessary sin

pgsql: Rename RBTXN_PREPARE to RBTXN_IS_PREPARE for better clarificatio

2025-02-12 Thread Masahiko Sawada
Rename RBTXN_PREPARE to RBTXN_IS_PREPARE for better clarification. RBTXN_PREPARE flag and rbtxn_prepared macro could be misinterpreted as either indicating the transaction type (e.g. a prepared transaction or a normal transaction) or its currentstate (e.g. skipped or its prepare message is sent),