pgsql: psql: Fix memory leak with \gx used within a pipeline

2025-03-04 Thread Michael Paquier
psql: Fix memory leak with \gx used within a pipeline While inside a pipeline, \gx is currently forbidden and will make exec_command_g() exit early. There was a memory leak in this code path, so let's fix it. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/cao6_xqqfvqjljzqil7xdwlpzze

pgsql: Fix some gaps in pg_stat_io with WAL receiver and WAL summarizer

2025-03-04 Thread Michael Paquier
Fix some gaps in pg_stat_io with WAL receiver and WAL summarizer The WAL receiver and WAL summarizer processes gain each one a call to pgstat_report_wal(), to make sure that they report their WAL statistics to pgstats, gathering data for pg_stat_io. In the WAL receiver, the stats reports are time

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: Enforce memory limit during parallel GIN builds

2025-03-04 Thread Tomas Vondra
Enforce memory limit during parallel GIN builds Index builds are expected to respect maintenance_work_mem, just like other maintenance operations. For serial builds this is done simply by flushing the buffer in ginBuildCallback() into the index. But with parallel builds it's more complicated, beca

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: pg_upgrade: Check for the expected error message in TAP tests.

2025-03-04 Thread Masahiko Sawada
pg_upgrade: Check for the expected error message in TAP tests. Since pg_upgrade prints its error messages on stdout, we can't use command_fails_like() to check if it fails for the right reason. This commit uses command_checks_all() in pg_upgrade TAP tests to check the exit status and stdout, enabl

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: Fix ALTER TABLE error message

2025-03-04 Thread Álvaro Herrera
Fix ALTER TABLE error message This bogus error message was introduced in 2013 by commit f177cbfe676d, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c415e2fc was one added (along with a couple of typos

pgsql: Refactor Copy{From|To}GetRoutine() to use pass-by-reference argu

2025-03-04 Thread Masahiko Sawada
Refactor Copy{From|To}GetRoutine() to use pass-by-reference argument. The change improves efficiency by eliminating unnecessary copying of CopyFormatOptions. The coverity also complained about inefficiencies caused by pass-by-value. Oversight in 7717f6300 and 2e4127b6d. Reported-by: Junwang Zha

pgsql: Compress TID lists when writing GIN tuples to disk

2025-03-04 Thread Tomas Vondra
Compress TID lists when writing GIN tuples to disk When serializing GIN tuples to tuplesorts during parallel index builds, we can significantly reduce the amount of data by compressing the TID lists. The GIN opclasses may produce a lot of data (depending on how many keys are extracted from each ro

pgsql: Add .gitignore entry for ecpg test detritus.

2025-03-04 Thread Tom Lane
Add .gitignore entry for ecpg test detritus. Oversight in commit 28f04984f. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/9b4bdf876a2e4fc9db80cb0137911a8d53bdbe1e Modified Files -- src/interfaces/ecpg/preproc/.gitignore | 1 + 1 file changed, 1 inserti

Re: pgsql: Generalize hash and ordering support in amapi

2025-03-04 Thread Tom Lane
Peter Eisentraut writes: > On 27.02.25 23:17, Mark Dilger wrote: >> The logic in equality_ops_are_compatible() was trusting that equality >> operators found in an opfamily for btree or hash were ok, but not >> trusting operators found in opfamilies of other AMs. Now, after the >> patch, other

pgsql: Make FP_LOCK_SLOTS_PER_BACKEND look like a function

2025-03-04 Thread Tomas Vondra
Make FP_LOCK_SLOTS_PER_BACKEND look like a function The FP_LOCK_SLOTS_PER_BACKEND macro looks like a constant, but it depends on the max_locks_per_transaction GUC, and thus can change. This is non-obvious and confusing, so make it look more like a function by renaming it to FastPathLockSlotsPerBac

Re: pgsql: Generalize hash and ordering support in amapi

2025-03-04 Thread Mark Dilger
On Tue, Mar 4, 2025 at 8:46 AM Peter Eisentraut wrote: > On 27.02.25 23:17, Mark Dilger wrote: > > The logic in equality_ops_are_compatible() was trusting that equality > > operators found in an opfamily for btree or hash were ok, but not > > trusting operators found in opfamilies of other AMs.

Re: pgsql: Generalize hash and ordering support in amapi

2025-03-04 Thread Peter Eisentraut
On 27.02.25 23:17, Mark Dilger wrote: The logic in equality_ops_are_compatible() was trusting that equality operators found in an opfamily for btree or hash were ok, but not trusting operators found in opfamilies of other AMs.  Now, after the patch, other AMs can be marked as suitable.  That's

pgsql: Add regression tests for pg_stat_progress_copy.tuples_skipped.

2025-03-04 Thread Fujii Masao
Add regression tests for pg_stat_progress_copy.tuples_skipped. This commit adds tests to verify that tuples_skipped in pg_stat_progress_copy works as expected. While existing tests checked other fields, tuples_skipped was previously untested. This improves test coverage and ensures accurate track

pgsql: Fix outdated comment

2025-03-04 Thread Heikki Linnakangas
Fix outdated comment Commit bc971f4025 replaced the latch-setting mechanism that the comment talked about with a condition variable. And before that, commit 2258e76f90 moved the code so that the comment got detached from the loop that it talked about, so move the comment closer to the loop. Branc

pgsql: doc: Expand version compatibility for pg_basebackup features

2025-03-04 Thread Daniel Gustafsson
doc: Expand version compatibility for pg_basebackup features This updates the paragraph on backwards compatitibility for server features to include --incremental which only works on servers with v17 or newer. Backpatch down to v17 where incremental backup was added. Author: David G. Johnston Re

pgsql: doc: Expand version compatibility for pg_basebackup features

2025-03-04 Thread Daniel Gustafsson
doc: Expand version compatibility for pg_basebackup features This updates the paragraph on backwards compatitibility for server features to include --incremental which only works on servers with v17 or newer. Backpatch down to v17 where incremental backup was added. Author: David G. Johnston Re

pgsql: Fix accidental use of = instead of ==

2025-03-04 Thread Peter Eisentraut
Fix accidental use of = instead of == Fix for commit 630f9a43cec. It used = instead of ==. The result would be an incorrect error message. Author: Jacob Brazeal Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/flat/CA%2BCOZaC-JMbhQ4O0Q8V1Bxa0R%2BNex_RN9D6UyuLPiE

pgsql: Fix ALTER TABLE ADD VIRTUAL GENERATED COLUMN when table rewrite

2025-03-04 Thread Peter Eisentraut
Fix ALTER TABLE ADD VIRTUAL GENERATED COLUMN when table rewrite demo: CREATE TABLE gtest20a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) VIRTUAL); ALTER TABLE gtest20a ADD COLUMN c float8 DEFAULT RANDOM() CHECK (b < 60); ERROR: no generation expression found for column number 2 of table