pgsql: Avoid NullTest deduction for clone clauses

2025-03-03 Thread Richard Guo
Avoid NullTest deduction for clone clauses In commit b262ad440, we introduced an optimization that reduces an IS NOT NULL qual on a column defined as NOT NULL to constant true, and an IS NULL qual on a NOT NULL column to constant false, provided we can prove that the input expression of the NullTe

pgsql: Avoid NullTest deduction for clone clauses

2025-03-03 Thread Richard Guo
Avoid NullTest deduction for clone clauses In commit b262ad440, we introduced an optimization that reduces an IS NOT NULL qual on a column defined as NOT NULL to constant true, and an IS NULL qual on a NOT NULL column to constant false, provided we can prove that the input expression of the NullTe

Re: pgsql: Track unpruned relids to avoid processing pruned relations

2025-03-03 Thread Amit Langote
On Mon, Mar 3, 2025 at 6:33 PM Robins Tharakan wrote: > On Fri, 7 Feb 2025 at 18:45, Amit Langote wrote: >> >> Track unpruned relids to avoid processing pruned relations >> > > Since this change, the SQL in the bug-report #18830 [1] segfaults reliably. > > The SQL was tested with commits as recen

pgsql: ecpg: Add TAP test for the ecpg command.

2025-03-03 Thread Fujii Masao
ecpg: Add TAP test for the ecpg command. This commit adds a TAP test to verify that the ecpg command correctly detects unsupported or disallowed statements in input files and reports the appropriate error or warning messages. This test helps catch bugs like the one introduced in commit 3d009e45bd

pgsql: Split pgstat_bestart() into three different routines

2025-03-03 Thread Michael Paquier
Split pgstat_bestart() into three different routines pgstat_bestart(), used post-authentication to set up a backend entry in the PgBackendStatus array, so as its data becomes visible in pg_stat_activity and related catalogs, has its logic divided into three routines with this commit, called in ord

pgsql: Add more assertions in palloc0() and palloc_extended()

2025-03-03 Thread Michael Paquier
Add more assertions in palloc0() and palloc_extended() palloc() includes an assertion checking that an alloc() implementation never returns NULL for all MemoryContextMethods. This commit adds a similar assertion in palloc0(). In palloc_extend(), a different assertion is added, checking that MCXT

pgsql: doc: Convert UUID functions list to table format.

2025-03-03 Thread Masahiko Sawada
doc: Convert UUID functions list to table format. Convert the list of UUID functions into a table for better readability. This commit also adds references to the UUID type section and includes descriptions of different UUID generation algorithm versions. Author: Andy Alsup Reviewed-by: Laurenz A

pgsql: Allow => syntax for named cursor arguments in plpgsql.

2025-03-03 Thread Tom Lane
Allow => syntax for named cursor arguments in plpgsql. We've traditionally accepted "name := value" syntax for cursor arguments in plpgsql. But it turns out that the equivalent statements in Oracle use "name => value". Since we accept both forms of punctuation for function arguments, it makes sen

pgsql: ci: Use a RAM disk for NetBSD and OpenBSD.

2025-03-03 Thread Thomas Munro
ci: Use a RAM disk for NetBSD and OpenBSD. Put the RAM disk setup for all three *BSD CI tasks into a common script, replacing the old FreeBSD-specific one from commit 0265e5c1. This makes them run 3 times and a bit over 2 times faster, respectively. NetBSD and FreeBSD now share the same one-line

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: Remove now-dead code in StoreAttrDefault().

2025-03-03 Thread Tom Lane
Remove now-dead code in StoreAttrDefault(). StoreAttrDefault() is no longer responsible for filling attmissingval, so remove the code for that. Get rid of RawColumnDefault.missingMode, too, as we no longer need that to pass information around. While here, clean up some sloppy coding in StoreAttr

pgsql: Trigger more frequent autovacuums with relallfrozen

2025-03-03 Thread Melanie Plageman
Trigger more frequent autovacuums with relallfrozen Calculate the insert threshold for triggering an autovacuum of a relation based on the number of unfrozen pages. By only considering the unfrozen portion of the table when calculating how many tuples to add to the insert threshold, we can trigge

pgsql: Simplify some logic around setting pg_attribute.atthasdef.

2025-03-03 Thread Tom Lane
Simplify some logic around setting pg_attribute.atthasdef. DefineRelation was of the opinion that it could usefully pre-fill atthasdef flags to eliminate work for StoreAttrDefault. This is not the case, however: the tupledesc that it's filling is not the one that InsertPgAttributeTuples will work

Re: pgsql: Set amcancrosscompare to true for hash

2025-03-03 Thread Tom Lane
Melanie Plageman writes: > Is there a discussion somewhere about why valgrind has been failing > like this on skink since Saturday? > valgrind: Fatal error at startup: a function redirection > valgrind: which is mandatory for this platform-tool combination > valgrind: cannot be set up. Detail

Re: pgsql: Set amcancrosscompare to true for hash

2025-03-03 Thread Andres Freund
Hi, On 2025-03-03 12:48:27 -0500, Tom Lane wrote: > Melanie Plageman writes: > > Is there a discussion somewhere about why valgrind has been failing > > like this on skink since Saturday? > > > valgrind: Fatal error at startup: a function redirection > > valgrind: which is mandatory for this p

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: Fix broken handling of domains in atthasmissing logic.

2025-03-03 Thread Tom Lane
Fix broken handling of domains in atthasmissing logic. If a domain type has a default, adding a column of that type (without any explicit DEFAULT clause) failed to install the domain's default value in existing rows, instead leaving the new column null. This is unexpected, and it used to work cor

pgsql: postgres_fdw: Extend postgres_fdw_get_connections to return remo

2025-03-03 Thread Fujii Masao
postgres_fdw: Extend postgres_fdw_get_connections to return remote backend PID. This commit adds a new "remote_backend_pid" output column to the postgres_fdw_get_connections function. It returns the process ID of the remote backend, on the foreign server, handling the connection. This enhancement

Re: pgsql: Add relallfrozen to pg_class

2025-03-03 Thread Melanie Plageman
On Mon, Mar 3, 2025 at 11:44 AM Álvaro Herrera wrote: > > On 2025-Mar-03, Melanie Plageman wrote: > > > relallfrozen, together with relallvisible, is useful for estimating the > > outstanding number of all-visible but not all-frozen pages in the > > relation for the purposes of scheduling manual V

Re: pgsql: Add relallfrozen to pg_class

2025-03-03 Thread Melanie Plageman
On Mon, Mar 3, 2025 at 11:48 AM Melanie Plageman wrote: > > On Mon, Mar 3, 2025 at 11:44 AM Álvaro Herrera > wrote: > > > > I'm confused about this. Why was the new value added to pg_class > > instead of to the pgstat system? I don't think relallvisible is a good > > precedent, because as you

Re: pgsql: Add relallfrozen to pg_class

2025-03-03 Thread Andres Freund
Hi, On 2025-03-03 17:44:54 +0100, Álvaro Herrera wrote: > On 2025-Mar-03, Melanie Plageman wrote: > > > Add relallfrozen to pg_class > > > > Add relallfrozen, an estimate of the number of pages marked all-frozen > > in the visibility map. > > > > pg_class already has relallvisible, an estimate

Re: pgsql: Add relallfrozen to pg_class

2025-03-03 Thread Álvaro Herrera
On 2025-Mar-03, Melanie Plageman wrote: > Add relallfrozen to pg_class > > Add relallfrozen, an estimate of the number of pages marked all-frozen > in the visibility map. > > pg_class already has relallvisible, an estimate of the number of pages > in the relation marked all-visible in the visibi

Re: pgsql: Set amcancrosscompare to true for hash

2025-03-03 Thread Melanie Plageman
Is there a discussion somewhere about why valgrind has been failing like this on skink since Saturday? valgrind: Fatal error at startup: a function redirection valgrind: which is mandatory for this platform-tool combination valgrind: cannot be set up. Details of the redirection are: It doesn'

pgsql: Add relallfrozen to pg_class

2025-03-03 Thread Melanie Plageman
Add relallfrozen to pg_class Add relallfrozen, an estimate of the number of pages marked all-frozen in the visibility map. pg_class already has relallvisible, an estimate of the number of pages in the relation marked all-visible in the visibility map. This is used primarily for planning. relallf

pgsql: Allow parallel CREATE INDEX for GIN indexes

2025-03-03 Thread Tomas Vondra
Allow parallel CREATE INDEX for GIN indexes Allow using parallel workers to build a GIN index, similarly to BTREE and BRIN. For large tables this may result in significant speedup when the build is CPU-bound. The work is divided so that each worker builds index entries on a subset of the table, d

Re: pgsql: Trial fix for old cross-version upgrades.

2025-03-03 Thread Tom Lane
Sami Imseih writes: >> Just noting here that \s{1} is simply the same as /s > Correct. But I do like the explicitness of it though. Yeah. I like mine better though because it's not dependent on the amount of whitespace at the start of the line. regards, tom lane

Re: pgsql: Track unpruned relids to avoid processing pruned relations

2025-03-03 Thread Robins Tharakan
Hi Amit, On Fri, 7 Feb 2025 at 18:45, Amit Langote wrote: > Track unpruned relids to avoid processing pruned relations > > Since this change, the SQL in the bug-report #18830 [1] segfaults reliably. The SQL was tested with commits as recent as 15a79c7311 (2nd March), so it appears unrelated to

pgsql: Handle auxiliary processes in SQL functions of backend statistic

2025-03-03 Thread Michael Paquier
Handle auxiliary processes in SQL functions of backend statistics This commit impacts the following SQL functions, authorizing the access to the PGPROC entries of auxiliary processes when attempting to fetch or reset backend-level pgstats entries: - pg_stat_reset_backend_stats() - pg_stat_get_back