pgsql: pg_createsubscriber: Improve error messages.

2025-04-03 Thread Amit Kapila
pg_createsubscriber: Improve error messages. Consistently, an option name is used in the error messages where applicable. Also, change the code to use pg_fatal() instead of a combination of pg_log_error() and exit(). Author: vignesh C Reviewed-by: Hayato Kuroda Reviewed-by: Amit Kapila Discuss

pgsql: Fix logical decoding test to correctly check slot removal on sta

2025-04-03 Thread Fujii Masao
Fix logical decoding test to correctly check slot removal on standby. The regression test for logical decoding verifies whether a logical slot is correctly dropped on a standby when its associated database is dropped. However, the test mistakenly retrieved slot information from the primary instead

pgsql: Fix logical decoding test to correctly check slot removal on sta

2025-04-03 Thread Fujii Masao
Fix logical decoding test to correctly check slot removal on standby. The regression test for logical decoding verifies whether a logical slot is correctly dropped on a standby when its associated database is dropped. However, the test mistakenly retrieved slot information from the primary instead

pgsql: Fix logical decoding test to correctly check slot removal on sta

2025-04-03 Thread Fujii Masao
Fix logical decoding test to correctly check slot removal on standby. The regression test for logical decoding verifies whether a logical slot is correctly dropped on a standby when its associated database is dropped. However, the test mistakenly retrieved slot information from the primary instead

pgsql: Fix logical decoding test to correctly check slot removal on sta

2025-04-03 Thread Fujii Masao
Fix logical decoding test to correctly check slot removal on standby. The regression test for logical decoding verifies whether a logical slot is correctly dropped on a standby when its associated database is dropped. However, the test mistakenly retrieved slot information from the primary instead

pgsql: Fix logical decoding test to correctly check slot removal on sta

2025-04-03 Thread Fujii Masao
Fix logical decoding test to correctly check slot removal on standby. The regression test for logical decoding verifies whether a logical slot is correctly dropped on a standby when its associated database is dropped. However, the test mistakenly retrieved slot information from the primary instead

pgsql: Fix logical decoding regression tests to correctly check slot ex

2025-04-03 Thread Fujii Masao
Fix logical decoding regression tests to correctly check slot existence. The regression tests for logical decoding verify whether a logical slot exists or has been dropped. Previously, these tests attempted to retrieve "slot_name" from the result of slot(), but since "slot_name" was not included i

pgsql: Fix logical decoding regression tests to correctly check slot ex

2025-04-03 Thread Fujii Masao
Fix logical decoding regression tests to correctly check slot existence. The regression tests for logical decoding verify whether a logical slot exists or has been dropped. Previously, these tests attempted to retrieve "slot_name" from the result of slot(), but since "slot_name" was not included i

pgsql: Fix logical decoding regression tests to correctly check slot ex

2025-04-03 Thread Fujii Masao
Fix logical decoding regression tests to correctly check slot existence. The regression tests for logical decoding verify whether a logical slot exists or has been dropped. Previously, these tests attempted to retrieve "slot_name" from the result of slot(), but since "slot_name" was not included i

pgsql: Fix logical decoding regression tests to correctly check slot ex

2025-04-03 Thread Fujii Masao
Fix logical decoding regression tests to correctly check slot existence. The regression tests for logical decoding verify whether a logical slot exists or has been dropped. Previously, these tests attempted to retrieve "slot_name" from the result of slot(), but since "slot_name" was not included i

pgsql: Fix logical decoding regression tests to correctly check slot ex

2025-04-03 Thread Fujii Masao
Fix logical decoding regression tests to correctly check slot existence. The regression tests for logical decoding verify whether a logical slot exists or has been dropped. Previously, these tests attempted to retrieve "slot_name" from the result of slot(), but since "slot_name" was not included i

Re: pgsql: Improve accounting for memory used by shared hash tables

2025-04-03 Thread Tomas Vondra
On 4/4/25 02:41, Tomas Vondra wrote: > On 4/4/25 01:43, Tomas Vondra wrote: >> On 4/4/25 00:57, David Rowley wrote: >>> On Thu, 3 Apr 2025 at 04:16, Tomas Vondra >>> wrote: Improve accounting for memory used by shared hash tables >>> >>> I've not looked into why, but this is causing an issue

pgsql: Revert "Improve accounting for memory used by shared hash tables

2025-04-03 Thread Tomas Vondra
Revert "Improve accounting for memory used by shared hash tables" This reverts commit f5930f9a98ea65d659d41600a138e608988ad122. This broke the expansion of private hash tables, which reallocates the directory. But that's impossible when it's allocated together with the other fields, and dir_reall

pgsql: Add assertion to verify derived clause has constant RHS

2025-04-03 Thread Amit Langote
Add assertion to verify derived clause has constant RHS find_derived_clause_for_ec_member() searches for a previously-derived clause that equates a non-constant EquivalenceMember to a constant. It is only called for EquivalenceClasses with ec_has_const set, and with a non-constant member the Equiv

pgsql: Make derived clause lookup in EquivalenceClass more efficient

2025-04-03 Thread Amit Langote
Make derived clause lookup in EquivalenceClass more efficient Derived clauses are stored in ec_derives, a List of RestrictInfos. These clauses are later looked up by matching the left and right EquivalenceMembers along with the clause's parent EC. This linear search becomes expensive in queries w

Re: pgsql: Improve accounting for memory used by shared hash tables

2025-04-03 Thread Tomas Vondra
On 4/4/25 00:57, David Rowley wrote: > On Thu, 3 Apr 2025 at 04:16, Tomas Vondra wrote: >> Improve accounting for memory used by shared hash tables > > I've not looked into why, but this is causing an issue in the > join_rel_hash during add_join_rel(). See the attached script. > > ERROR: pfree

Re: pgsql: Improve accounting for memory used by shared hash tables

2025-04-03 Thread David Rowley
On Thu, 3 Apr 2025 at 04:16, Tomas Vondra wrote: > Improve accounting for memory used by shared hash tables I've not looked into why, but this is causing an issue in the join_rel_hash during add_join_rel(). See the attached script. ERROR: pfree called with invalid pointer 0x60a15edc44e0 (header

pgsql: libpq: Add support for dumping SSL key material to file

2025-04-03 Thread Daniel Gustafsson
libpq: Add support for dumping SSL key material to file This adds a new connection parameter which instructs libpq to write out keymaterial clientside into a file in order to make connection debugging with Wireshark and similar tools possible. The file format used is the standardized NSS format.

pgsql: Remove misleading read stream asserts in a few users

2025-04-03 Thread Melanie Plageman
Remove misleading read stream asserts in a few users Several read stream users asserted that the read stream was exhausted after looping on that very condition. It was pointed out in an a review of an as-of-yet uncommitted read stream user [1] that this was confusing and could lead the reader to t

pgsql: Use AIO batchmode for bitmap heap scans

2025-04-03 Thread Melanie Plageman
Use AIO batchmode for bitmap heap scans Previously bitmap heap scan was not AIO batchmode safe because of the visibility map reads potentially done for the "skip fetch" optimization (which skipped fetching tuples from the heap if the pages were all visible and none of the columns were used in the

pgsql: Fix oversight in commit 0dca5d68d.

2025-04-03 Thread Tom Lane
Fix oversight in commit 0dca5d68d. As coded, fmgr_sql() would get an assertion failure for a SQL function that has an empty body and is declared to return some type other than VOID. Typically you'd never get that far because fmgr_sql_validator() would reject such a definition (I suspect that's ho

pgsql: Remove duplicate set of print_notnull

2025-04-03 Thread Álvaro Herrera
Remove duplicate set of print_notnull I inserted the second one by mistake in commit 14e87ffa5c54. Reported-by: jian he Confirmed-by: Ashutosh Bapat Discussion: https://postgr.es/m/cacjufxfqckbfxpfcixhhbor0zmlksvitj2m3o12-terfx_p...@mail.gmail.com Branch -- master Details --- https:/

pgsql: oauth: Remove timeout from t/002_client when not needed

2025-04-03 Thread Daniel Gustafsson
oauth: Remove timeout from t/002_client when not needed The connect_timeout=1 setting for the --hang-forever test was left in place and used by later tests, causing unexpected timeouts on slower buildfarm animals. Remove it when no longer needed. Per buildfarm member skink, reported by Andres on

pgsql: oauth: Fix build on platforms without epoll/kqueue

2025-04-03 Thread Daniel Gustafsson
oauth: Fix build on platforms without epoll/kqueue register_socket() missed a variable declaration if neither HAVE_SYS_EPOLL_H nor HAVE_SYS_EVENT_H was defined. While we're fixing that, adjust the tests to check pg_config.h for one of the multiplexer implementations, rather than assuming that Win

pgsql: Fix unintentional 'NULL' string literal in pg_upgrade.

2025-04-03 Thread Jeff Davis
Fix unintentional 'NULL' string literal in pg_upgrade. Introduced in 2a083ab807. Discussion: https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.ca...@j-davis.com Reviewed-by: Michael Paquier Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/945126234bbc03

pgsql: pg_upgrade check for Unicode-dependent relations.

2025-04-03 Thread Jeff Davis
pg_upgrade check for Unicode-dependent relations. This check will not cause an upgrade failure, only a warning. Discussion: https://postgr.es/m/ef03d678b39a64392f4b12e0f59d1495c740969e.camel%40j-davis.com Reviewed-by: Peter Eisentraut Branch -- master Details --- https://git.postgresq

pgsql: Restrict copying of invalidated replication slots.

2025-04-03 Thread Masahiko Sawada
Restrict copying of invalidated replication slots. Previously, invalidated logical and physical replication slots could be copied using the pg_copy_logical_replication_slot and pg_copy_physical_replication_slot functions. Replication slots that were invalidated for reasons other than WAL removal r

pgsql: Restrict copying of invalidated replication slots.

2025-04-03 Thread Masahiko Sawada
Restrict copying of invalidated replication slots. Previously, invalidated logical and physical replication slots could be copied using the pg_copy_logical_replication_slot and pg_copy_physical_replication_slot functions. Replication slots that were invalidated for reasons other than WAL removal r

pgsql: Make dblink interruptible, via new libpqsrv APIs.

2025-04-03 Thread Noah Misch
Make dblink interruptible, via new libpqsrv APIs. This replaces dblink's blocking libpq calls, allowing cancellation and allowing DROP DATABASE (of a database not involved in the query). Apart from explicit dblink_cancel_query() calls, dblink still doesn't cancel the remote side. The replacement

pgsql: Add helper library for use of libpq inside the server environmen

2025-04-03 Thread Noah Misch
Add helper library for use of libpq inside the server environment Currently dblink and postgres_fdw don't process interrupts during connection establishment. Besides preventing query cancellations etc, this can lead to undetected deadlocks, as global barriers are not processed. Libpqwalreceiver i

pgsql: Make dblink interruptible, via new libpqsrv APIs.

2025-04-03 Thread Noah Misch
Make dblink interruptible, via new libpqsrv APIs. This replaces dblink's blocking libpq calls, allowing cancellation and allowing DROP DATABASE (of a database not involved in the query). Apart from explicit dblink_cancel_query() calls, dblink still doesn't cancel the remote side. The replacement

pgsql: Make dblink interruptible, via new libpqsrv APIs.

2025-04-03 Thread Noah Misch
Make dblink interruptible, via new libpqsrv APIs. This replaces dblink's blocking libpq calls, allowing cancellation and allowing DROP DATABASE (of a database not involved in the query). Apart from explicit dblink_cancel_query() calls, dblink still doesn't cancel the remote side. The replacement

pgsql: Make dblink interruptible, via new libpqsrv APIs.

2025-04-03 Thread Noah Misch
Make dblink interruptible, via new libpqsrv APIs. This replaces dblink's blocking libpq calls, allowing cancellation and allowing DROP DATABASE (of a database not involved in the query). Apart from explicit dblink_cancel_query() calls, dblink still doesn't cancel the remote side. The replacement

pgsql: Add helper library for use of libpq inside the server environmen

2025-04-03 Thread Noah Misch
Add helper library for use of libpq inside the server environment Currently dblink and postgres_fdw don't process interrupts during connection establishment. Besides preventing query cancellations etc, this can lead to undetected deadlocks, as global barriers are not processed. Libpqwalreceiver i

pgsql: Add helper library for use of libpq inside the server environmen

2025-04-03 Thread Noah Misch
Add helper library for use of libpq inside the server environment Currently dblink and postgres_fdw don't process interrupts during connection establishment. Besides preventing query cancellations etc, this can lead to undetected deadlocks, as global barriers are not processed. Libpqwalreceiver i

pgsql: Update code comment

2025-04-03 Thread Peter Eisentraut
Update code comment Commit 4e7f62bc386 added a new input file to a script but didn't update the comment listing the input files. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/bbf24fe2f19a426097c208c355e61e257cd76bac Modified Files -- src/common/unicod

pgsql: Add support for sorted gist index builds to btree_gist

2025-04-03 Thread Heikki Linnakangas
Add support for sorted gist index builds to btree_gist This enables sortsupport in the btree_gist extension for faster builds of gist indexes. Sorted gist index build strategy is the new default now. Regression tests are unchanged (except for one small change in the 'enum' test to add coverage fo

pgsql: Fix boilerplate comments in btree_gist

2025-04-03 Thread Heikki Linnakangas
Fix boilerplate comments in btree_gist A few of these were copy-pasted wrong, like the comment "Bytea ops" in btree_numeric.c. Instead of fixing the incorrect ones, replace them all with generic comment "GiST support functions". Also tidy up the inconsistent newlines between various functions whi

Re: pgsql: Doc: Improve -R option added in e5aeed4b80.

2025-04-03 Thread Amit Kapila
On Thu, Apr 3, 2025 at 2:37 PM Amit Kapila wrote: > > Doc: Improve -R option added in e5aeed4b80. > > Author: Reviewed-by: Peter Smith > Oops, messed up the Author tag. Sorry. -- With Regards, Amit Kapila.

pgsql: plpython: Add test for returning Python set from SETOF function

2025-04-03 Thread Peter Eisentraut
plpython: Add test for returning Python set from SETOF function This is claimed in the documentation but there was a no test case for it. Reported-by: Bogdan Grigorenko Discussion: https://www.postgresql.org/message-id/flat/173543330569.680.6706329879058172623%40wrigleys.postgresql.org Branch

pgsql: Doc: Improve -R option added in e5aeed4b80.

2025-04-03 Thread Amit Kapila
Doc: Improve -R option added in e5aeed4b80. Author: Reviewed-by: Peter Smith Reviewed-by: vignesh C Discussion: https://postgr.es/m/CAHut+PvJPnaL=70SbBe3fYg2nq74Z=Yv4X=zRpUWYfOi-q6=2...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/d1d83827ba4d8c

pgsql: 002_pg_upgrade.pl: Move pg_dump test code for better stability

2025-04-03 Thread Álvaro Herrera
002_pg_upgrade.pl: Move pg_dump test code for better stability The alleged "statistics pg_dump bug" that prevented us from enabling stats dumping in commit 172259afb563 wasn't a pg_dump bug after all: it was just a side effect of not running pg_dump at the right time (namely, before giving autovac

pgsql: 002_pg_upgrade.pl: rename some variables for clarity

2025-04-03 Thread Álvaro Herrera
002_pg_upgrade.pl: rename some variables for clarity This renames %node_params to %old_node_params, @initdb_params to @old_initdb_params, and adds separate @new_initdb_params and %new_node_params rather than reusing the former in confusing ways. Extracted from a larger patch from the same author.

pgsql: Fix update-unicode make target

2025-04-03 Thread Peter Eisentraut
Fix update-unicode make target The addition of SpecialCasing.txt by commit 286a365b9c2 was not added to the make target dependencies, so the invoked script would fail because the required file wasn't downloaded first. (The meson version appears to work correctly.) Branch -- master Details -