pgsql: Add slotsync skip statistics.

2025-11-24 Thread Amit Kapila
Add slotsync skip statistics. This patch adds two new columns to the pg_stat_replication_slots view: slotsync_skip_count - the total number of times a slotsync operation was skipped. slotsync_skip_at - the timestamp of the most recent skip. These additions provide better visibility into replicati

pgsql: Remove obsolete comment

2025-11-24 Thread Peter Eisentraut
Remove obsolete comment This comment should probably have been moved to pg_locale_libc.c in commit 66ac94cdc79 (2024), but upon closer examination it was already completely obsolete then. The first part of the comment has been obsolete since commit 85feb77aa09 (2017), which required that the syst

pgsql: Rename routines for write/read of pgstats file

2025-11-24 Thread Michael Paquier
Rename routines for write/read of pgstats file This commit renames write_chunk and read_chunk to respectively pgstat_write_chunk() and pgstat_read_chunk(), along with the *_s convenience macros. These are made available for plug-ins, so as any code that decides to write and/or read stats data can

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: lwlock: Fix, currently harmless, bug in LWLockWakeup()

2025-11-24 Thread Andres Freund
lwlock: Fix, currently harmless, bug in LWLockWakeup() Accidentally the code in LWLockWakeup() checked the list of to-be-woken up processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that HAS_WAITERS would not get unset immediately, but only during the next, unnecessary, call to LWL

pgsql: Avoid global LC_CTYPE dependency in pg_locale_libc.c.

2025-11-24 Thread Jeff Davis
Avoid global LC_CTYPE dependency in pg_locale_libc.c. Call tolower_l() directly instead of through pg_tolower(), because the latter depends on the global LC_CTYPE. Discussion: https://postgr.es/m/[email protected] Branch -- master Details --- ht

pgsql: Improve detection of implicitly-temporary views.

2025-11-24 Thread Tom Lane
Improve detection of implicitly-temporary views. We've long had a practice of making views temporary by default if they reference any temporary tables. However the implementation was pretty incomplete, in that it only searched for RangeTblEntry references to temp relations. Uses of temporary typ

pgsql: Reorganize pqcomm.h a bit

2025-11-24 Thread Jacob Champion
Reorganize pqcomm.h a bit Group the PG_PROTOCOL() codes, add a comment to AuthRequest now that the AUTH_REQ codes live in a different header, and make some small adjustments to spacing and comment style for the sake of scannability. Reviewed-by: Jelte Fennema-Nio Reviewed-by: Heikki Linnakangas

pgsql: postgres: Use pg_{add,mul}_size_overflow()

2025-11-24 Thread Jacob Champion
postgres: Use pg_{add,mul}_size_overflow() The backend implementations of add_size() and mul_size() can now make use of the APIs provided in common/int.h. Reviewed-by: Chao Li Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2B

pgsql: Make some use of anonymous unions [libpq-oauth]

2025-11-24 Thread Jacob Champion
Make some use of anonymous unions [libpq-oauth] Make some use of anonymous unions, which are allowed as of C11, as examples and encouragement for future code, and to test compilers. This commit changes the json_field struct. Reviewed-by: Nathan Bossart Discussion: https://postgr.es/m/CAOYmi%2B

pgsql: Add pg_add_size_overflow() and friends

2025-11-24 Thread Jacob Champion
Add pg_add_size_overflow() and friends Commit 600086f47 added (several bespoke copies of) size_t addition with overflow checks to libpq. Move this to common/int.h, along with its subtraction and multiplication counterparts. pg_neg_size_overflow() is intentionally omitted; I'm not sure we should a

pgsql: Fix infer_arbiter_index during concurrent index operations

2025-11-24 Thread Álvaro Herrera
Fix infer_arbiter_index during concurrent index operations Previously, we would only consider indexes marked indisvalid as usable for INSERT ON CONFLICT. But that's problematic during CREATE INDEX CONCURRENTLY and REINDEX CONCURRENTLY, because concurrent transactions would end up with inconsisten

pgsql: Move isolation test index-killtuples to src/test/modules/index/

2025-11-24 Thread Michael Paquier
Move isolation test index-killtuples to src/test/modules/index/ index-killtuples test depends on the contrib modules btree_gin and btree_gist, which would not be installed in a temporary installation with an execution of the main isolation test suite like this one: make -C src/test/isolation/ chec