pgsql: Improve validation of recovery_target_xid GUC values.

2026-03-05 Thread Fujii Masao
Improve validation of recovery_target_xid GUC values. Previously, the recovery_target_xid GUC values were not sufficiently validated. As a result, clearly invalid inputs such as the string "bogus", a decimal value like "1.1", or 0 (a transaction ID smaller than the minimum valid value of 3) were u

pgsql: Add system view pg_stat_recovery

2026-03-05 Thread Michael Paquier
Add system view pg_stat_recovery This commit introduces pg_stat_recovery, that exposes at SQL level the state of recovery as tracked by XLogRecoveryCtlData in shared memory, maintained by the startup process. This new view includes the following fields, that are useful for monitoring purposes on

pgsql: Fix inconsistent elevel in pg_sync_replication_slots() retry log

2026-03-05 Thread Amit Kapila
Fix inconsistent elevel in pg_sync_replication_slots() retry logic. The commit 0d2d4a0ec3 allowed pg_sync_replication_slots() to retry sync attempts, but missed a case, when WAL prior to a slot's confirmed_flush_lsn is not yet flushed locally. By changing the elevel from ERROR to LOG, we allow th

pgsql: Fix order of columns in pg_stat_recovery

2026-03-05 Thread Michael Paquier
Fix order of columns in pg_stat_recovery recovery_last_xact_time is listed before current_chunk_start_time in the documentation, the function definition and the view definition, but their order was reversed in the code. Thinko in 01d485b142e4. Mea culpa. Author: Shinya Kato Discussion: https:

pgsql: Fix inconsistency with HeapTuple freeing in extended_stats_funcs

2026-03-05 Thread Michael Paquier
Fix inconsistency with HeapTuple freeing in extended_stats_funcs.c heap_freetuple() is a thin wrapper doing a pfree(), and the function import_pg_statistic(), introduced by ba97bf9cb7b4, had the idea to call directly pfree() rather than the "dedicated" heap tuple routine. upsert_pg_statistic_ext_

pgsql: Improve tests for recovery_target_timeline GUC.

2026-03-05 Thread Fujii Masao
Improve tests for recovery_target_timeline GUC. Commit fd7d7b71913 added regression tests to verify recovery_target_timeline settings. To confirm that invalid values are rejected, those tests started the server with an invalid setting and then verified that startup failed. While functionally corre

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix publisher shutdown hang caused by logical walsender busy loo

2026-03-05 Thread Fujii Masao
Fix publisher shutdown hang caused by logical walsender busy loop. Previously, when logical replication was running, shutting down the publisher could cause the logical walsender to enter a busy loop and prevent the publisher from completing shutdown. During shutdown, the logical walsender waits

pgsql: Fix handling of updated tuples in the MERGE statement

2026-03-05 Thread Alexander Korotkov
Fix handling of updated tuples in the MERGE statement This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on repeatable read and serializable isolation levels. This commit fixes the issue and provides a simple isolation check for that. Backpatch through v15 where MERGE sta

pgsql: oauth: Add TLS support for oauth_validator tests

2026-03-05 Thread Jacob Champion
oauth: Add TLS support for oauth_validator tests The oauth_validator tests don't currently support HTTPS, which makes testing PGOAUTHCAFILE difficult. Add a localhost certificate to src/test/ssl and make use of it in oauth_server.py. In passing, explain the hardcoded use of IPv4 in our issuer ide

pgsql: oauth: Report cleanup errors as warnings on stderr

2026-03-05 Thread Jacob Champion
oauth: Report cleanup errors as warnings on stderr Using conn->errorMessage for these "shouldn't-happen" cases will only work if the connection itself fails. Our SSL and password callbacks print WARNINGs when they find themselves in similar situations, so follow their lead. Reviewed-by: Zsolt Par

pgsql: libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock()

2026-03-05 Thread Jacob Champion
libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock() Allow libpq clients to retrieve the current pg_g_threadlock pointer with PQgetThreadLock(). Single-threaded applications could already do this in a convoluted way: pgthreadlock_t tlock; tlock = PQregisterThreadLock(NULL);

pgsql: Fix handling of updated tuples in the MERGE statement

2026-03-05 Thread Alexander Korotkov
Fix handling of updated tuples in the MERGE statement This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on repeatable read and serializable isolation levels. This commit fixes the issue and provides a simple isolation check for that. Backpatch through v15 where MERGE sta

pgsql: Fix handling of updated tuples in the MERGE statement

2026-03-05 Thread Alexander Korotkov
Fix handling of updated tuples in the MERGE statement This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on repeatable read and serializable isolation levels. This commit fixes the issue and provides a simple isolation check for that. Backpatch through v15 where MERGE sta

pgsql: Add PageGetPruneXid() helper

2026-03-05 Thread Melanie Plageman
Add PageGetPruneXid() helper This is similar to the other page accessors in bufpage.h. It improves readability and avoids long lines. Author: Melanie Plageman Reviewed-by: Chao Li Discussion: https://postgr.es/m/BD8B69E7-26D8-4706-9164-597C6AE57812%40gmail.com Branch -- master Details ---

pgsql: Exit after fatal errors in client-side compression code.

2026-03-05 Thread Tom Lane
Exit after fatal errors in client-side compression code. It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression

pgsql: Exit after fatal errors in client-side compression code.

2026-03-05 Thread Tom Lane
Exit after fatal errors in client-side compression code. It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression

pgsql: Exit after fatal errors in client-side compression code.

2026-03-05 Thread Tom Lane
Exit after fatal errors in client-side compression code. It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression

pgsql: Exit after fatal errors in client-side compression code.

2026-03-05 Thread Tom Lane
Exit after fatal errors in client-side compression code. It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression

pgsql: Exit after fatal errors in client-side compression code.

2026-03-05 Thread Tom Lane
Exit after fatal errors in client-side compression code. It looks like whoever wrote the astreamer (nee bbstreamer) code thought that pg_log_error() is equivalent to elog(ERROR), but it's not; it just prints a message. So all these places tried to continue on after a compression or decompression

pgsql: Move commonly used context into PruneState and simplify helpers

2026-03-05 Thread Melanie Plageman
Move commonly used context into PruneState and simplify helpers heap_page_prune_and_freeze() and many of its helpers use the heap buffer, block number, and page. Other helpers took the heap page and didn't use it. Initializing these values once during prune_freeze_setup() simplifies the helpers' i

pgsql: Fix handling of updated tuples in the MERGE statement

2026-03-05 Thread Alexander Korotkov
Fix handling of updated tuples in the MERGE statement This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on repeatable read and serializable isolation levels. This commit fixes the issue and provides a simple isolation check for that. Backpatch through v15 where MERGE sta

pgsql: Fix handling of updated tuples in the MERGE statement

2026-03-05 Thread Alexander Korotkov
Fix handling of updated tuples in the MERGE statement This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on repeatable read and serializable isolation levels. This commit fixes the issue and provides a simple isolation check for that. Backpatch through v15 where MERGE sta

pgsql: Prefix PruneState->all_{visible,frozen} with set_

2026-03-05 Thread Melanie Plageman
Prefix PruneState->all_{visible,frozen} with set_ The PruneState had members called "all_visible" and "all_frozen" which reflect not the current state of the page but the state it could be in once pruning and freezing have been executed. These are then saved in the PruneFreezeResult so the caller

pgsql: Simplify creation of built-in functions with non-default ACLs.

2026-03-05 Thread Tom Lane
Simplify creation of built-in functions with non-default ACLs. Up to now, to create such a function, one had to make a pg_proc.dat entry and then modify it with GRANT/REVOKE commands, which we put in system_functions.sql. That seems a little ugly though, because it violates the idea of having a s

pgsql: Be more wary of false matches in initdb's replace_token().

2026-03-05 Thread Tom Lane
Be more wary of false matches in initdb's replace_token(). Do not replace the target string unless the occurrence is surrounded by whitespace or line start/end. This avoids potential false match to a substring of a field. While we've not had trouble with that up to now, the next patch creates ha

pgsql: Refactor code retrieving string for RecoveryPauseState

2026-03-05 Thread Michael Paquier
Refactor code retrieving string for RecoveryPauseState This refactoring is going to be useful in an upcoming commit, to avoid some code duplication with the function pg_get_wal_replay_pause_state(), that returns a string for the recovery pause state. Refactoring opportunity noticed while hacking