postgresql.git
18 hours agoAdd new OID alias type regdatabase.
Nathan Bossart [Mon, 30 Jun 2025 20:38:54 +0000 (15:38 -0500)]
Add new OID alias type regdatabase.

This provides a convenient way to look up a database's OID.  For
example, the query

    SELECT * FROM pg_shdepend
    WHERE dbid = (SELECT oid FROM pg_database
                  WHERE datname = current_database());

can now be simplified to

    SELECT * FROM pg_shdepend
    WHERE dbid = current_database()::regdatabase;

Like the regrole type, regdatabase has cluster-wide scope, so we
disallow regdatabase constants from appearing in stored
expressions.

Bumps catversion.

Author: Ian Lawrence Barwick <[email protected]>
Reviewed-by: Greg Sabino Mullane <[email protected]>
Reviewed-by: Jian He <[email protected]>
Reviewed-by: Fabrízio de Royes Mello <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/aBpjJhyHpM2LYcG0%40nathan

25 hours agoaio: Fix reference to outdated name
Andres Freund [Mon, 30 Jun 2025 14:20:14 +0000 (10:20 -0400)]
aio: Fix reference to outdated name

Reported-by: Antonin Houska <[email protected]>
Author: Antonin Houska <[email protected]>
Discussion: https://postgr.es/m/5250.1751266701@localhost
Backpatch-through: 18, where da7226993fd4 introduced this

25 hours agoAvoid uninitialized value error in TAP tests' Cluster->psql
Andrew Dunstan [Mon, 30 Jun 2025 13:49:31 +0000 (09:49 -0400)]
Avoid uninitialized value error in TAP tests' Cluster->psql

If the method is called in scalar context and we didn't pass in a stderr
handle, one won't be created. However, some error paths assume that it
exists, so in this case create a dummy stderr to avoid the resulting
perl error.

Per gripe from Oleg Tselebrovskiy <[email protected]> and
adapted from his patch.

Discussion: https://postgr.es/m/378eac5de4b8ecb5be7bcdf2db9d2c4d@postgrespro.ru

29 hours agopgflex: propagate environment to flex subprocess
Peter Eisentraut [Mon, 30 Jun 2025 10:23:33 +0000 (12:23 +0200)]
pgflex: propagate environment to flex subprocess

Python's subprocess.run docs say that if the env argument is not None,
it will be used "instead of the default behavior of inheriting the
current process’ environment".  However, the environment should be
preserved, only adding FLEX_TMP_DIR to it.

Author: Javier Maestro <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CABvji06GUpmrTqqiCr6_F9vRL2-JUSVAh8ChgWa6k47FUCvYmA%40mail.gmail.com

29 hours agoRemove unused #include's in src/backend/utils/adt/*
Peter Eisentraut [Mon, 30 Jun 2025 10:00:00 +0000 (12:00 +0200)]
Remove unused #include's in src/backend/utils/adt/*

Author: Aleksander Alekseev <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CAJ7c6TOowVbR-0NEvvDm6a_mag18krR0XJ2FKrc9DHXj7hFRtQ%40mail.gmail.com

29 hours agoFix whitespace
Peter Eisentraut [Mon, 30 Jun 2025 09:38:18 +0000 (11:38 +0200)]
Fix whitespace

29 hours agopsql: Improve tab completion for COPY command.
Fujii Masao [Mon, 30 Jun 2025 09:36:24 +0000 (18:36 +0900)]
psql: Improve tab completion for COPY command.

Previously, tab completion for COPY only suggested plain tables
and partitioned tables, even though materialized views are also
valid for COPY TO (since commit 534874fac0b), and foreign tables
are valid for COPY FROM.

This commit enhances tab completion for COPY to also include
materialized views and foreign tables.

Views with INSTEAD OF INSERT triggers are supported with
COPY FROM but rarely used, so plain views are intentionally
excluded from completion.

Author: jian he <[email protected]>
Co-authored-by: Fujii Masao <[email protected]>
Reviewed-by: Kirill Reshke <[email protected]>
Reviewed-by: David G. Johnston <[email protected]>
Discussion: https://postgr.es/m/CACJufxFxnSkikp+GormAGHcMTX1YH2HRXW1+3dJM9w7yY9hdsg@mail.gmail.com

29 hours agodoc: explain pgstatindex fragmentation
Peter Eisentraut [Mon, 30 Jun 2025 09:28:11 +0000 (11:28 +0200)]
doc: explain pgstatindex fragmentation

It was quite hard to guess what leaf_fragmentation meant without looking
at pgstattuple's code.  This patch aims to give to the user a better
idea of what it means.

Author: Frédéric Yhuel <[email protected]>
Author: Laurenz Albe <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Reviewed-by: Benoit Lobréau <[email protected]>
Discussion: https://postgr.es/m/bf110561-f774-4957-a890-bb6fab6804e0%40dalibo.com
Discussion: https://postgr.es/m/4c5dee3a-8381-4e0f-b882-d1bd950e8972@dalibo.com

30 hours agopgbench: Use standard option handling test routines
Peter Eisentraut [Mon, 30 Jun 2025 08:45:08 +0000 (10:45 +0200)]
pgbench: Use standard option handling test routines

Run program_XXX tests instead of its own tests.  This ensures
consistency with the test suites of other programs and enforces common
policies, such as help line length.

Author: Hayato Kuroda <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/OSCPR01MB14966247015B7E3D8D340D022F56FA@OSCPR01MB14966.jpnprd01.prod.outlook.com

30 hours agodoc: Some copy-editing around prefix operators
Peter Eisentraut [Mon, 30 Jun 2025 08:32:26 +0000 (10:32 +0200)]
doc: Some copy-editing around prefix operators

When postfix operators where dropped in 1ed6b8956, the CREATE OPERATOR
docs were not updated to make the RIGHTARG argument mandatory in the
grammar.

While at it, make the RIGHTARG docs more concise. Also, the operator
docs were mentioning "infix" in the introduction, while using "binary"
everywhere else.

Author: Christoph Berg <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/[email protected]

31 hours agodoc: Fix typo in pg_sync_replication_slots documentation
Daniel Gustafsson [Mon, 30 Jun 2025 08:12:31 +0000 (10:12 +0200)]
doc: Fix typo in pg_sync_replication_slots documentation

Commit 1546e17f9d0 accidentally misspelled additionally as
additionaly.  Backpatch to v17 to match where the original
commit was backpatched.

Author: Daniel Gustafsson <[email protected]>
Backpatch-through: 17

32 hours agoRationalize handling of VacuumParams
Michael Paquier [Mon, 30 Jun 2025 06:42:50 +0000 (15:42 +0900)]
Rationalize handling of VacuumParams

This commit refactors the vacuum routines that rely on VacuumParams,
adding const markers where necessary to force a new policy in the code.
This structure should not use a pointer as it may be used across
multiple relations, and its contents should never be updated.
vacuum_rel() stands as an exception as it touches the "index_cleanup"
and "truncate" options.

VacuumParams has been introduced in 0d831389749a, and 661643dedad9 has
fixed a bug impacting VACUUM operating on multiple relations.  The
changes done in tableam.h break ABI compatibility, so this commit can
only happen on HEAD.

Author: Shihao Zhong <[email protected]>
Co-authored-by: Michael Paquier <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Reviewed-by: Junwang Zhao <[email protected]>
Discussion: https://postgr.es/m/CAGRkXqTo+aK=GTy5pSc-9cy8H2F2TJvcrZ-zXEiNJj93np1UUw@mail.gmail.com

34 hours agoAlign log_line_prefix in CI and TAP tests with pg_regress.c
Michael Paquier [Mon, 30 Jun 2025 04:56:31 +0000 (13:56 +0900)]
Align log_line_prefix in CI and TAP tests with pg_regress.c

log_line_prefix is changed to include "%b", the backend type in the TAP
test configuration.  %v and %x are removed from the CI configuration,
with the format around %b changed.

The lack of backend type in postgresql.conf set by Cluster.pm for the
TAP test configuration was something that has been bugging me, beginning
the discussion that has led to this change.  The change in the CI has
come up during the discussion, to become consistent with pg_regress.c,
%v and %x not being that useful to have.

Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]

37 hours agoStamp HEAD as 19devel.
Joe Conway [Mon, 30 Jun 2025 02:28:10 +0000 (22:28 -0400)]
Stamp HEAD as 19devel.

Let the hacking begin ...

37 hours agoDo pre-release housekeeping on catalog data.
Joe Conway [Mon, 30 Jun 2025 01:43:39 +0000 (21:43 -0400)]
Do pre-release housekeeping on catalog data.

Run renumber_oids.pl to move high-numbered OIDs down, as per pre-beta
tasks specified by RELEASE_CHANGES.  For reference, the command was

./renumber_oids.pl --first-mapped-oid 8000 --target-oid 6300

This should have been done prior to beta1, but it was forgotten. This
will ensure we get the correct numbering for beta2 onward.

38 hours agoRun pgperltidy
Joe Conway [Mon, 30 Jun 2025 01:14:21 +0000 (21:14 -0400)]
Run pgperltidy

This is required before the creation of a new branch.  pgindent is
clean, as well as is reformat-dat-files.

perltidy version is v20230309, as documented in pgindent's README.

44 hours agoFix some new issues with planning of PlaceHolderVars.
Tom Lane [Sun, 29 Jun 2025 19:04:32 +0000 (15:04 -0400)]
Fix some new issues with planning of PlaceHolderVars.

In the wake of commit a16ef313f, we need to deal with more cases
involving PlaceHolderVars in NestLoopParams than we did before.

For one thing, a16ef313f was incorrect to suppose that we could
rely on the required-outer relids of the lefthand path to decide
placement of nestloop-parameter PHVs.  As Richard Guo argued at
the time, we must look at the required-outer relids of the join
path itself.

For another, we have to apply replace_nestloop_params() to such
a PHV's expression, in case it contains references to values that
will be supplied from NestLoopParams of higher-level nestloops.

For another, we need to be more careful about the phnullingrels
of the PHV than we were being.  identify_current_nestloop_params
only bothered to ensure that the phnullingrels didn't contain
"too many" relids, but now it has to be exact, because setrefs.c
will apply both NRM_SUBSET and NRM_SUPERSET checks in different
places.  We can compute the correct relids by determining the
set of outer joins that should be able to null the PHV and then
subtracting whatever's been applied at or below this join.
Do the same for plain Vars, too.  (This should make it possible
to use NRM_EQUAL to process nestloop params in setrefs.c, but
I won't risk making such a change in v18 now.)

Lastly, if a nestloop parameter PHV was pulled up out of a subquery
and it contains a subquery that was originally pushed down from this
query level, then that will still be represented as a SubLink, because
SS_process_sublinks won't recurse into outer PHVs, so it didn't get
transformed during expression preprocessing in the subquery.  We can
substitute the version of the PHV's expression appearing in its
PlaceHolderInfo to ensure that that preprocessing has happened.
(Seems like this processing sequence could stand to be redesigned,
but again, late in v18 development is not the time for that.)

It's not very clear to me why the old have_dangerous_phv join-order
restriction prevented us from seeing the last three of these problems.
But given the lack of field complaints, it must have done so.

Reported-by: Alexander Lakhin <[email protected]>
Author: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/18953-1c9883a9d4afeb30@postgresql.org

45 hours agoObtain required table lock during cross-table constraint updates.
Tom Lane [Sun, 29 Jun 2025 17:56:03 +0000 (13:56 -0400)]
Obtain required table lock during cross-table constraint updates.

Sometimes a table's constraint may depend on a column of another
table, so that we have to update the constraint when changing the
referenced column's type.  We need to have lock on the constraint's
table to do that.  ATPostAlterTypeCleanup believed that this case
was only possible for FOREIGN KEY constraints, but it's wrong at
least for CHECK and EXCLUDE constraints; and in general, we'd
probably need exclusive lock to alter any sort of constraint.
So just remove the contype check and acquire lock for any other
table.  This prevents a "you don't have lock" assertion failure,
though no ill effect is observed in production builds.

We'll error out later anyway because we don't presently support
physically altering column types within stored composite columns.
But the catalog-munging is basically all there, so we may as well
make that part work.

Bug: #18970
Reported-by: Alexander Lakhin <[email protected]>
Diagnosed-by: jian he <[email protected]>
Author: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/18970-a7d1cfe1f8d5d8d9@postgresql.org
Backpatch-through: 13

2 days agopg_recvlogical: Rename --two-phase and --failover options.
Peter Eisentraut [Sun, 29 Jun 2025 15:02:35 +0000 (17:02 +0200)]
pg_recvlogical: Rename --two-phase and --failover options.

This commit renames the pg_recvlogical options --two-phase and
--failover to --enable-two-phase and --enable-failover, respectively.
The new names distinguish these enabling options from action options
like --start and --create-slot, while clearly indicating their purpose
to enable specific logical slot features.

The option --failover is new in PostgreSQL 18 (commit cf2655a9029), so
no compatibility break there.  The option --two-phase has existed
since PostgreSQL 15 (commit cda03cfed6b), so for compatibility we keep
the old option name --two-phase around as deprecated.

Also note that pg_createsubscriber has acquired an --enable-two-phase
option, so this increases consistency across tools.

Co-authored-by: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/a28f66df-1354-4709-8d63-932ded4cac35@eisentraut.org

2 days agoMessage style improvements
Peter Eisentraut [Sat, 28 Jun 2025 17:18:06 +0000 (19:18 +0200)]
Message style improvements

3 days agoUse correct DatumGet*() function in test_shm_mq_main().
Nathan Bossart [Fri, 27 Jun 2025 18:37:26 +0000 (13:37 -0500)]
Use correct DatumGet*() function in test_shm_mq_main().

This is purely cosmetic, as dsm_attach() interprets its argument as
a dsm_handle (i.e., an unsigned integer), but we might as well fix
it.

Oversight in commit 4db3744f1f.

Author: Jianghua Yang <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CAAZLFmRxkUD5jRs0W3K%3DUe4_ZS%2BRcAb0PCE1S0vVJBn3sWH2UQ%40mail.gmail.com
Backpatch-through: 13

4 days agoFix CheckPointReplicationSlots() with max_replication_slots == 0
Alexander Korotkov [Fri, 27 Jun 2025 08:49:00 +0000 (11:49 +0300)]
Fix CheckPointReplicationSlots() with max_replication_slots == 0

ca307d5cec90 made CheckPointReplicationSlots() unconditionally call
ReplicationSlotsComputeRequiredLSN().  It causes an assertion trap when
max_replication_slots equals 0.  This commit makes
CheckPointReplicationSlots() call ReplicationSlotsComputeRequiredLSN() only
when at least one slot gets its last_saved_restart_lsn updated.  That avoids
an assert trap and also saves some cycles when no one slot has
last_saved_restart_lsn updated.

Based on ideas from Dilip Kumar <[email protected]> and
Hayato Kuroda <[email protected]>.

Reported-by: Zhijie Hou <[email protected]>
Discussion: https://postgr.es/m/OS0PR01MB5716BB506AF934376FF3A8BB947BA%40OS0PR01MB5716.jpnprd01.prod.outlook.com

4 days agoCorrect list of files in src/backend/lib/README
Michael Paquier [Fri, 27 Jun 2025 00:31:23 +0000 (09:31 +0900)]
Correct list of files in src/backend/lib/README

binaryheap.c and stringinfo.c have been moved to src/common/ by
respectively 5af0263afd7b and 26aaf97b683d, and the README patched here
still mentioned these two files as available in src/backend/lib/.

Author: Aleksander Alekseev <[email protected]>
Discussion: https://postgr.es/m/CAJ7c6TPg-=tC+fzq0tGTtmL7r79-aWeCmpwAyQiGu0N+sKGj8Q@mail.gmail.com

4 days agolibpq: Message style improvements
Peter Eisentraut [Thu, 26 Jun 2025 20:13:53 +0000 (22:13 +0200)]
libpq: Message style improvements

4 days agoCorrect misleading error messages
Peter Eisentraut [Thu, 26 Jun 2025 20:02:16 +0000 (22:02 +0200)]
Correct misleading error messages

Commit 7d6d2c4bbd7 dropped opcintype from the index AM strategy
translation API.  But some error messages about failed lookups still
mentioned it, even though it was not used for the lookup.  Fix by
removing ipcintype from the error messages as well.

4 days agoRemove unused check in heap_xlog_insert()
Melanie Plageman [Thu, 26 Jun 2025 19:03:48 +0000 (15:03 -0400)]
Remove unused check in heap_xlog_insert()

8e03eb92e9a reverted the commit 39b66a91bd which allowed freezing
in the heap_insert() code path but forgot to remove the corresponding
check in heap_xlog_insert(). This code is extraneous but not harmful.
However, cleaning it up makes it very clear that, as of now, we do not
support any freezing of pages in the heap_insert() path.

Author: Melanie Plageman <[email protected]>
Reviewed-by: Tomas Vondra <[email protected]>
Discussion: https://postgr.es/m/flat/CAAKRu_Zp4Pi-t51OFWm1YZ-cctDfBhHCMZ%3DEx6PKxv0o8y2GvA%40mail.gmail.com
Backpatch-through: 14

4 days agoSimplify vacuum VM update logging counters
Melanie Plageman [Thu, 26 Jun 2025 18:25:45 +0000 (14:25 -0400)]
Simplify vacuum VM update logging counters

We can simplify the VM counters added in dc6acfd910b8 to
lazy_vacuum_heap_page() and lazy_scan_new_or_empty().

We won't invoke lazy_vacuum_heap_page() unless there are dead line
pointers, so we know the page can't be all-visible.

In lazy_scan_new_or_empty(), we only update the VM if the page-level
hint PD_ALL_VISIBLE is clear, and the VM bit cannot be set if the page
level bit is clear because a subsequent page update would fail to clear
the visibility map bit.

Simplify the logic for determining which log counters to increment based
on this knowledge. Doing so is worthwhile because the old logic was
confusing and misguided.

Author: Melanie Plageman <[email protected]>
Reviewed-by: Nazir Bilal Yavuz <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/flat/CAAKRu_a9w_n2mwY%3DG4LjfWTvRTJtjbfvnYAKi4WjO8QXHHrA0g%40mail.gmail.com

4 days agoFix typo in comment
Álvaro Herrera [Thu, 26 Jun 2025 16:33:48 +0000 (18:33 +0200)]
Fix typo in comment

Introduced by c2da1a5d6325

Reported-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/[email protected]

4 days agodocs: fix typo
Álvaro Herrera [Thu, 26 Jun 2025 16:25:05 +0000 (18:25 +0200)]
docs: fix typo

4 days agopg_dump: include comments on valid not-null constraints, too
Álvaro Herrera [Thu, 26 Jun 2025 16:24:12 +0000 (18:24 +0200)]
pg_dump: include comments on valid not-null constraints, too

We were missing collecting comments for not-null constraints that are
dumped inline with the table definition (i.e., valid ones), because they
aren't represented by a separately dumpable object.  Fix by creating
separate TocEntries for the comments.

Co-Authored-By: Jian He <[email protected]>
Co-Authored-By: Álvaro Herrera <[email protected]>
Reported-By: Fujii Masao <[email protected]>
Reviewed-By: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/d50ff977-c728-4e9e-8488-fc2688e08754@oss.nttdata.com

5 days agoMake CREATE TABLE LIKE copy comments on NOT NULL constraints when requested.
Fujii Masao [Thu, 26 Jun 2025 11:25:34 +0000 (20:25 +0900)]
Make CREATE TABLE LIKE copy comments on NOT NULL constraints when requested.

Commit 14e87ffa5c5 introduced support for adding comments to NOT NULL
constraints. However, CREATE TABLE LIKE INCLUDING COMMENTS did not copy
these comments to the new table. This was an oversight in that commit.

This commit corrects the behavior by ensuring CREATE TABLE LIKE to also copy
the comments on NOT NULL constraints when INCLUDING COMMENTS is specified.

Author: Jian He <[email protected]>
Co-authored-by: Álvaro Herrera <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/127debef-e558-4784-9e24-0d5eaf91e2d1@oss.nttdata.com

5 days agodoc: Updates for RETURNING OLD/NEW.
Dean Rasheed [Thu, 26 Jun 2025 09:13:00 +0000 (10:13 +0100)]
doc: Updates for RETURNING OLD/NEW.

Fix a couple of sentences in the documentation that were missed in
commit 80feb727c8.

Author: Dean Rasheed <[email protected]>
Reviewed-by: Robert Treat <[email protected]>
Discussion: https://postgr.es/m/CAEZATCUcqADJuapZSjPf2b6hFJ6AGOUwefRvh8Ht3UZoqqw69Q@mail.gmail.com

5 days agodoc: Fix indentation of MERGE synopsis.
Dean Rasheed [Thu, 26 Jun 2025 08:36:05 +0000 (09:36 +0100)]
doc: Fix indentation of MERGE synopsis.

The convention in the documentation for other SQL commands is to
indent continuation lines and sub-clauses in the "Synopsis" section by
4 spaces, so do the same for MERGE.

Author: Dean Rasheed <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Discussion: https://postgr.es/m/CAEZATCV+9tR9+WM-SCcdBEZ3x7WVxUpADD5jX9WeGX97z4LCGA@mail.gmail.com
Backpatch-through: 15

5 days agoExpand virtual generated columns for ALTER COLUMN TYPE
Richard Guo [Thu, 26 Jun 2025 03:17:12 +0000 (12:17 +0900)]
Expand virtual generated columns for ALTER COLUMN TYPE

For the subcommand ALTER COLUMN TYPE of the ALTER TABLE command, the
USING expression may reference virtual generated columns.  These
columns must be expanded before the expression is fed through
expression_planner and the expression-execution machinery.  Failing to
do so can result in incorrect rewrite decisions, and can also lead to
"ERROR:  unexpected virtual generated column reference".

Reported-by: Alexander Lakhin <[email protected]>
Reviewed-by: jian he <[email protected]>
Discussion: https://postgr.es/m/b5f96b24-ccac-47fd-9e20-14681b894f36@gmail.com

6 days agodoc: Some copy-editing around constraint validation and enforcement
Peter Eisentraut [Wed, 25 Jun 2025 10:44:03 +0000 (12:44 +0200)]
doc: Some copy-editing around constraint validation and enforcement

Author: Robert Treat <[email protected]>
Reviewed-by: jian he <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CACJufxFo4yTwzbSZrP%2BzQiR6_M00skoZMFaUnNJCdY6he%3DuQfA%40mail.gmail.com

6 days agopg_createsubscriber: Rename option --remove to --clean
Peter Eisentraut [Wed, 25 Jun 2025 08:33:23 +0000 (10:33 +0200)]
pg_createsubscriber: Rename option --remove to --clean

After discussion, the name --remove was suboptimally chosen.  --clean
has more precedent in other PostgreSQL tools.

Reviewed-by: Hayato Kuroda (Fujitsu) <[email protected]>
Discussion: https://www.postgresql.org/message-id/84be7ff3-2763-4c0f-ac1e-ca9862077f41@eisentraut.org

6 days agoRestrict virtual columns to use built-in functions and types
Peter Eisentraut [Wed, 25 Jun 2025 07:55:04 +0000 (09:55 +0200)]
Restrict virtual columns to use built-in functions and types

Just like selecting from a view is exploitable (CVE-2024-7348),
selecting from a table with virtual generated columns is exploitable.
Users who are concerned about this can avoid selecting from views, but
telling them to avoid selecting from tables is less practical.

To address this, this changes it so that generation expressions for
virtual generated columns are restricted to using built-in functions
and types, and the columns are restricted to having a built-in type.
We assume that built-in functions and types cannot be exploited for
this purpose.

In the future, this could be expanded by some new mechanism to declare
other functions and types as safe or trusted for this purpose, but
that is to be designed.

(An alternative approach might have been to expand the
restrict_nonsystem_relation_kind GUC to handle this, like the fix for
CVE-2024-7348.  But that is kind of an ugly approach.  That fix had to
fit in the constraints of fixing an ancient vulnerability in all
branches.  Since virtual generated columns are new, we're free from
the constraints of the past, and we can and should use cleaner
options.)

Reported-by: Feike Steenbergen <[email protected]>
Reviewed-by: jian he <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAK_s-G2Q7de8Q0qOYUR%3D_CTB5FzzVBm5iZjOp%2BmeVWpMpmfO0w%40mail.gmail.com

6 days agoDoc: Improve documentation of stream abort.
Amit Kapila [Wed, 25 Jun 2025 04:55:15 +0000 (10:25 +0530)]
Doc: Improve documentation of stream abort.

Protocol v4 introduces parallel streaming, which allows Stream Abort
messages to include additional abort information such as LSN and
timestamp. However, the current documentation only states, "This field is
available since protocol version 4," which may misleadingly suggest that
the fields are always present when using protocol v4.

This patch clarifies that the abort LSN and timestamp are included only
when parallel streaming is enabled, even under protocol v4.

Author: Anthonin Bonnefoy <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Backpatch-through: 16, where it was introduced
Discussion: https://postgr.es/m/CAO6_XqoKteQR1AnaR8iPcegbBE+HkAc2-g12rxN04yOt4-2ORg@mail.gmail.com

6 days agoAvoid scribbling of VACUUM options
Michael Paquier [Wed, 25 Jun 2025 01:03:46 +0000 (10:03 +0900)]
Avoid scribbling of VACUUM options

This fixes two issues with the handling of VacuumParams in vacuum_rel().
This code path has the idea to change the passed-in pointer of
VacuumParams for the "truncate" and "index_cleanup" options for the
relation worked on, impacting the two following scenarios where
incorrect options may be used because a VacuumParams pointer is shared
across multiple relations:
- Multiple relations in a single VACUUM command.
- TOAST relations vacuumed with their main relation.

The problem is avoided by providing to the two callers of vacuum_rel()
copies of VacuumParams, before the pointer is updated for the "truncate"
and "index_cleanup" options.

The refactoring of the VACUUM option and parameters done in 0d831389749a
did not introduce an issue, but it has encouraged the problem we are
dealing with in this commit, with b84dbc8eb80b for "truncate" and
a96c41feec6b for "index_cleanup" that have been added a couple of years
after the initial refactoring.  HEAD will be improved with a different
patch that hardens the uses of VacuumParams across the tree.  This
cannot be backpatched as it introduces an ABI breakage.

The backend portion of the patch has been authored by Nathan, while I
have implemented the tests.  The tests rely on injection points to check
the option values, making them faster, more reliable than the tests
originally proposed by Shihao, and they also provide more coverage.
This part can only be backpatched down to v17.

Reported-by: Shihao Zhong <[email protected]>
Author: Nathan Bossart <[email protected]>
Co-authored-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CAGRkXqTo+aK=GTy5pSc-9cy8H2F2TJvcrZ-zXEiNJj93np1UUw@mail.gmail.com
Backpatch-through: 13

6 days agodoc: Fix type description of io_workers GUC for consistency.
Fujii Masao [Wed, 25 Jun 2025 00:02:31 +0000 (09:02 +0900)]
doc: Fix type description of io_workers GUC for consistency.

The documentation previously described the type of the io_workers GUC
parameter as "int". However, the documentation consistently uses "integer"
for parameters of this type.

This commit updates the type description of io_workers to "integer"
for consistency with other GUC parameter descriptions.

Author: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/e95c899a-2aeb-45b7-8fd3-7a27dcdb475b@oss.nttdata.com

6 days agodoc: Mention ANALYZE VERBOSE in track_cost_delay_timing description.
Fujii Masao [Wed, 25 Jun 2025 00:01:13 +0000 (09:01 +0900)]
doc: Mention ANALYZE VERBOSE in track_cost_delay_timing description.

The documentation for track_cost_delay_timing describes where cost-based
vacuum delay timing information is displayed when the setting is enabled.
While this information is also shown in the output of ANALYZE VERBOSE,
that was previously omitted from the list.

This commit updates the documentation to include ANALYZE VERBOSE in the list,
clarifying that it also reports cost-based delay timing information.

Author: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/e95c899a-2aeb-45b7-8fd3-7a27dcdb475b@oss.nttdata.com

6 days agodoc: Add secondary index entries for vacuum-related parameters.
Fujii Masao [Tue, 24 Jun 2025 23:59:25 +0000 (08:59 +0900)]
doc: Add secondary index entries for vacuum-related parameters.

For parameters that exist as both configuration and storage options,
the documentation typically includes secondary index entries to
help users distinguish and locate the relevant references easily.

However, such index entries were missing for vacuum_truncate and
vacuum_max_eager_freeze_failure_rate, both introduced in v18.

This commit adds appropriate secondary index terms for these parameters
to ensure consistency with other parameters and improve usability of
the documentation index.

Author: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/e95c899a-2aeb-45b7-8fd3-7a27dcdb475b@oss.nttdata.com

6 days agoPrevent excessive delays before launching new logrep workers.
Tom Lane [Tue, 24 Jun 2025 18:14:04 +0000 (14:14 -0400)]
Prevent excessive delays before launching new logrep workers.

The logical replication launcher process would sometimes sleep
for as much as 3 minutes before noticing that it is supposed
to launch a new worker.  This could happen if
(1) WaitForReplicationWorkerAttach absorbed a process latch wakeup
that was meant to cause ApplyLauncherMain to do work, or
(2) logicalrep_worker_launch reported failure, either because of
resource limits or because the new worker terminated immediately.

In case (2), the expected behavior is that we retry the launch after
wal_retrieve_retry_interval, but that didn't reliably happen.

It's not clear how often such conditions would occur in the field,
but in our subscription test suite they are somewhat common,
especially in tests that exercise cases that cause quick worker
failure.  That causes the tests to take substantially longer than
they ought to do on typical setups.

To fix (1), make WaitForReplicationWorkerAttach re-set the latch
before returning if it cleared it while looping.  To fix (2), ensure
that we reduce wait_time to no more than wal_retrieve_retry_interval
when logicalrep_worker_launch reports failure.  In passing, fix a
couple of perhaps-hypothetical race conditions, e.g. examining
worker->in_use without a lock.

Backpatch to v16.  Problem (2) didn't exist before commit 5a3a95385
because the previous code always set wait_time to
wal_retrieve_retry_interval when launching a worker, regardless of
success or failure of the launch.  That behavior also greatly
mitigated problem (1), so I'm not excited about adapting the remainder
of the patch to the substantially-different code in older branches.

Author: Tom Lane <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Reviewed-by: Ashutosh Bapat <[email protected]>
Discussion: https://postgr.es/m/817604.1750723007@sss.pgh.pa.us
Backpatch-through: 16

6 days agoMake query jumbling also squash PARAM_EXTERN params
Álvaro Herrera [Tue, 24 Jun 2025 17:36:32 +0000 (19:36 +0200)]
Make query jumbling also squash PARAM_EXTERN params

Commit 62d712ecfd94 made query jumbling squash lists of Consts as a
single element, but there's no reason not to treat PARAM_EXTERN
parameters the same.  For these purposes, these values are indeed
constants for any particular execution of a query.

In particular, this should make list squashing more useful for
applications using extended query protocol, which would use parameters
extensively.

A complication arises: if a query has both external parameters and
squashable lists, then the parameter number used as placeholder for the
squashed list might be inconsistent with regards to the parameter
numbers used by the query literal.  To reduce the surprise factor, all
parameters are renumbered starting from 1 in that case.

Author: Sami Imseih <[email protected]>
Author: Dmitry Dolgov <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CAA5RZ0tRXoPG2y6bMgBCWNDt0Tn=unRerbzYM=oW0syi1=C1OA@mail.gmail.com

6 days agoImprove jumble squashing through CoerceViaIO and RelabelType
Álvaro Herrera [Tue, 24 Jun 2025 17:36:12 +0000 (19:36 +0200)]
Improve jumble squashing through CoerceViaIO and RelabelType

There's no principled reason for query jumbling to only remove the first
layer of RelabelType and CoerceViaIO.  Change it to see through as many
layers as there are.

7 days agoTest that vacuum removes tuples older than OldestXmin
Melanie Plageman [Tue, 24 Jun 2025 13:20:16 +0000 (09:20 -0400)]
Test that vacuum removes tuples older than OldestXmin

If vacuum fails to prune a tuple killed before OldestXmin, it will
decide to freeze its xmax and later error out in pre-freeze checks.

Add a test reproducing this scenario to the recovery suite which creates
a table on a primary, updates the table to generate dead tuples for
vacuum, and then, during the vacuum, uses a replica to force
GlobalVisState->maybe_needed on the primary to move backwards and
precede the value of OldestXmin set at the beginning of vacuuming the
table.

This test is coverage for a case fixed in 83c39a1f7f3. The test was
originally committed to master in aa607980aee but later reverted in
efcbb76efe4 due to test instability.

The test requires multiple index passes. In Postgres 17+, vacuum uses a
TID store for the dead TIDs that is very space efficient. With the old
minimum maintenance_work_mem of 1 MB, it required a large number of dead
rows to generate enough dead TIDs to force multiple index
vacuuming passes. Once the source code changes were made to allow a
minimum maintenance_work_mem value of 64kB, the test could be made much
faster and more stable.

Author: Melanie Plageman <[email protected]>
Reviewed-by: John Naylor <[email protected]>
Reviewed-by: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/CAAKRu_ZJBkidusDut6i%3DbDCiXzJEp93GC1%2BNFaZt4eqanYF3Kw%40mail.gmail.com
Backpatch-through: 17

7 days agodoc: Remove dead link to NewbieDoc Docbook Guide
Daniel Gustafsson [Tue, 24 Jun 2025 09:49:37 +0000 (11:49 +0200)]
doc: Remove dead link to NewbieDoc Docbook Guide

The link returns 404 and no replacement is available in the project
on Sourceforge where the content once was. Since we already link to
resources for both beginner and experienced docs hackers, remove the
the dead link.

Backpatch to all supported versions as the link was added in 8.1.

Author: Daniel Gustafsson <[email protected]>
Reviewed-by: Magnus Hagander <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Reported-by: jian he <[email protected]>
Discussion: https://postgr.es/m/CACJufxH=YzQPDOe+2WuYZ7seD-BOyjCBmP6JiErpoSiVZWDRnw@mail.gmail.com
Backpatch-through: 13

7 days agoFix virtual generated column type checking for ALTER TABLE
Peter Eisentraut [Tue, 24 Jun 2025 09:30:49 +0000 (11:30 +0200)]
Fix virtual generated column type checking for ALTER TABLE

Virtual generated columns have some special checks in
CheckAttributeType(), mainly to check that domains are not used.  But
this check was only applied during CREATE TABLE, not during ALTER
TABLE.  This fixes that.

Reported-by: jian he <[email protected]>
Discussion: https://www.postgresql.org/message-id/CACJufxE0KHR__-h=zHXbhSNZXMMs4LYo4-dbj8H3YoStYBok1Q@mail.gmail.com

7 days agodoc: Fix incorrect UUID index entry in function documentation.
Fujii Masao [Tue, 24 Jun 2025 05:21:10 +0000 (14:21 +0900)]
doc: Fix incorrect UUID index entry in function documentation.

Previously, the UUID functions documentation defined the "UUID" index entry
to link to the UUID data type page, even though that entry already exists there.
Instead, the UUID functions page should define its own index entry linking
to itself.

This commit updates the UUID index entry in the UUID functions documentation
to point to the correct section, improving navigation and avoiding duplication.

Back-patch to all supported versions.

Author: Fujii Masao <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/f33e0493-5773-4296-87c5-7ce459054cfe@oss.nttdata.com
Backpatch-through: 13

7 days agoFix missing comment update in 1462aad2e4.
Amit Kapila [Tue, 24 Jun 2025 04:21:07 +0000 (09:51 +0530)]
Fix missing comment update in 1462aad2e4.

Remove the part of comment that says we don't allow toggling two_phase
option as that is supported in commit 1462aad2e4.

Author: Hayato Kuroda <[email protected]>
Author: Amit Kapila <[email protected]>
Discussion: https://postgr.es/m/OSCPR01MB1496656725F3951AEE8749EBDF579A@OSCPR01MB14966.jpnprd01.prod.outlook.com

7 days agopsql: Rename meta-command \close to \close_prepared
Michael Paquier [Tue, 24 Jun 2025 04:12:46 +0000 (13:12 +0900)]
psql: Rename meta-command \close to \close_prepared

\close has been introduced in d55322b0da60 to be able to close a
prepared statement using the extended protocol in psql.  Per discussion,
the name "close" is ambiguous.  At the SQL level, CLOSE is used to close
a cursor.  At protocol level, the close message can be used to either
close a statement or a portal.

This patch renames \close to \close_prepared to avoid any ambiguity and
make it clear that this is used to close a prepared statement.  This new
name has been chosen based on the feedback from the author and the
reviewers.

Author: Anthonin Bonnefoy <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: https://postgr.es/m/3e694442-0df5-4f92-a08f-c5d4c4346b85@eisentraut.org

7 days agoTemporarily remove 046_checkpoint_logical_slot.pl
Alexander Korotkov [Mon, 23 Jun 2025 18:33:50 +0000 (21:33 +0300)]
Temporarily remove 046_checkpoint_logical_slot.pl

This new test was intended to check the handling of the replication slot's
restart lsn fixed in ca307d5cec90.  However, it also reveals another issue
related to logical decoding.  This commit temporarily removes this test to
keep the buildfarm and CFbot green and avoid distorting others' work.  This
test will be restored once we investigate and fix the issue.

Discussion: https://postgr.es/m/CAAKRu_ZCOzQpEumLFgG_%2Biw3FTa%2BhJ4SRpxzaQBYxxM_ZAzWcA%40mail.gmail.com

7 days agoRemove excess assert from InvalidatePossiblyObsoleteSlot()
Alexander Korotkov [Mon, 23 Jun 2025 18:27:42 +0000 (21:27 +0300)]
Remove excess assert from InvalidatePossiblyObsoleteSlot()

ca307d5cec90 introduced keeping WAL segments by slot's last saved restart LSN.
It also added an assertion that the slot's restart LSN never goes backward.
However, situations when the restart LSN goes backward have been spotted by
buildfarm animals and investigated in the thread.

When pg_receivewal starts the replication, it sets the last replayed LSN to
the beginning of the segment, which is older than what
ReplicationSlotReserveWal() set for the slot.  A similar situation can happen
to pg_basebackup.  When standby reconnects to the primary, it sends the last
replayed LSN, which might be older than the last confirmed flush LSN.  In
both these situations, a concurrent checkpoint may trigger an assert trap.

Based on ideas from Vitaly Davydov <[email protected]>,
Hayato Kuroda (Fujitsu) <[email protected]>,
Vignesh C <[email protected]>,
Amit Kapila <[email protected]>.

Reported-by: Vignesh C <[email protected]>
Reported-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CALDaNm3s-jpQTe1MshsvQ8GO%3DTLj233JCdkQ7uZ6pwqRVpxAdw%40mail.gmail.com
Reviewed-by: Vignesh C <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
7 days agoInclude _mm512_zextsi128_si512() in AVX-512 configure probes.
Tom Lane [Mon, 23 Jun 2025 15:50:21 +0000 (11:50 -0400)]
Include _mm512_zextsi128_si512() in AVX-512 configure probes.

Commit 43da39430 added a dependency on this intrinsic to our
AVX-512 CRC code.  It turns out this intrinsic was added to
gcc later than the other ones we were using, so that there
are platforms where the new code fails to compile.  Since only
relatively old (pre-gcc-10) compilers are affected, it doesn't
seem worth trying to make the AVX-512 CRC code actually work
on these platforms.  Just add the new intrinsic to the configure
probe, so that we'll conclude the code can't be built.

Author: Tom Lane <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Discussion: https://postgr.es/m/3350336.1750690281@sss.pgh.pa.us

8 days agoProperly fix AVX-512 CRC calculation bug
John Naylor [Mon, 23 Jun 2025 11:03:56 +0000 (18:03 +0700)]
Properly fix AVX-512 CRC calculation bug

The problem that led to the workaround in f83f14881c7 was not in fact
a compiler bug, but a failure to zero the upper bits of the vector
register containing the initial scalar CRC value. Fix that and revert
the workaround.

Diagnosed-by: Nathan Bossart <[email protected]>
Diagnosed-by: Raghuveer Devulapalli <[email protected]>
Tested-by: Andy Fan <[email protected]>
Tested-by: Soumyadeep Chakraborty <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Reviewed-by: Raghuveer Devulapalli <[email protected]>
Discussion: https://postgr.es/m/PH8PR11MB82866B07AA6758D12F699C00FB70A@PH8PR11MB8286.namprd11.prod.outlook.com

9 days agomeson: Fix meson warning
Peter Eisentraut [Sun, 22 Jun 2025 12:13:46 +0000 (14:13 +0200)]
meson: Fix meson warning

    WARNING: You should add the boolean check kwarg to the run_command call.
             It currently defaults to false,
             but it will default to true in meson 2.0.

Introduced by commit bc46104fc9a.

(This only happens in the msvc branch.  All the other run_command
calls are ok.)

Reviewed-by: Andres Freund <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/42e13eb0-862a-441e-8d84-4f0fd5f6def0%40eisentraut.org

9 days agoDoc: improve documentation about width_bucket().
Tom Lane [Sat, 21 Jun 2025 16:52:37 +0000 (12:52 -0400)]
Doc: improve documentation about width_bucket().

Specify whether the bucket bounds are inclusive or exclusive,
and improve some other vague language.  Explain the behavior that
occurs when the "low" bound is greater than the "high" bound.
Make width_bucket_numeric's comment more like that for
width_bucket_float8, in particular noting that infinite
bounds are rejected (since they became possible in v14).

Reported-by: Ben Peachey Higdon <[email protected]>
Author: Robert Treat <[email protected]>
Co-authored-by: Tom Lane <[email protected]>
Reviewed-by: Dean Rasheed <[email protected]>
Discussion: https://postgr.es/m/2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com
Backpatch-through: 13

10 days agodoc PG 18 relnotes: update to current, add one commit
Bruce Momjian [Sat, 21 Jun 2025 03:53:15 +0000 (23:53 -0400)]
doc PG 18 relnotes:  update to current, add one commit

10 days agodoc PG 18 relnotes: indent tag blocks
Bruce Momjian [Sat, 21 Jun 2025 03:37:30 +0000 (23:37 -0400)]
doc PG 18 relnotes:  indent tag blocks

10 days agodoc PG 18 relnotes: add remaining missing link tags
Bruce Momjian [Sat, 21 Jun 2025 02:44:18 +0000 (22:44 -0400)]
doc PG 18 relnotes:  add remaining missing link tags

10 days agoRemove planner's have_dangerous_phv() join-order restriction.
Tom Lane [Fri, 20 Jun 2025 19:55:12 +0000 (15:55 -0400)]
Remove planner's have_dangerous_phv() join-order restriction.

Commit 85e5e222b, which added (a forerunner of) this logic,
argued that

    Adding the necessary complexity to make this work doesn't seem like
    it would be repaid in significantly better plans, because in cases
    where such a PHV exists, there is probably a corresponding join order
    constraint that would allow a good plan to be found without using the
    star-schema exception.

The flaw in this claim is that there may be other join-order
restrictions that prevent us from finding a join order that doesn't
involve a "dangerous" PHV.  In particular we now recognize that
small join_collapse_limit or from_collapse_limit could prevent it.
Therefore, let's bite the bullet and make the case work.

We don't have to extend the executor's support for nestloop parameters
as I thought at the time, because we can instead push the evaluation
of the placeholder's expression into the left-hand input of the
NestLoop node.  So there's not really a lot of downside to this
solution, and giving the planner more join-order flexibility should
have value beyond just avoiding failure.

Having said that, there surely is a nonzero risk of introducing
new bugs.  Since this failure mode escaped detection for ten years,
such cases don't seem common enough to justify a lot of risk.
Therefore, let's put this fix into master but leave the back branches
alone (for now anyway).

Bug: #18953
Reported-by: Alexander Lakhin <[email protected]>
Diagnosed-by: Richard Guo <[email protected]>
Author: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/18953-1c9883a9d4afeb30@postgresql.org

10 days agoUse SnapshotDirty when checking for conflicting index names.
Tom Lane [Fri, 20 Jun 2025 17:41:11 +0000 (13:41 -0400)]
Use SnapshotDirty when checking for conflicting index names.

While choosing an autogenerated name for an index, look for
pre-existing relations using a SnapshotDirty snapshot, instead of the
previous behavior that considered only committed-good pg_class rows.
This allows us to detect and avoid conflicts against indexes that are
still being built.

It's still possible to fail due to a race condition, but the window
is now just the amount of time that it takes DefineIndex to validate
all its parameters, call smgrcreate(), and enter the index's pg_class
row.  Formerly the race window covered the entire time needed to
create and fill an index, which could be very long if the table is
large.  Worse, if the conflicting index creation is part of a larger
transaction, it wouldn't be visible till COMMIT.

So this isn't a complete solution, but it should greatly ameliorate
the problem, and the patch is simple enough to be back-patchable.

It might at some point be useful to do the same for pg_constraint
entries (cf. ChooseConstraintName, ConstraintNameExists, and related
functions).  However, in the absence of field complaints, I'll leave
that alone for now.  The relation-name test should be good enough for
index-based constraints, while foreign-key constraints seem to be okay
since they require exclusive locks to create.

Bug: #18959
Reported-by: Maximilian Chrzan <[email protected]>
Author: Tom Lane <[email protected]>
Reviewed-by: Dilip Kumar <[email protected]>
Discussion: https://postgr.es/m/18959-f63b53b864bb1417@postgresql.org
Backpatch-through: 13

10 days agopgxs.mk: remove unreachable rule for deleting regress.def.
Tom Lane [Fri, 20 Jun 2025 16:12:29 +0000 (12:12 -0400)]
pgxs.mk: remove unreachable rule for deleting regress.def.

We never create regress.def, and if we did this code would fail to
delete it, because "win" is not the correct PORTNAME for Windows.

This thinko seems to have originated in commit 7a6b562fd from 1999,
although it got moved around multiple times since then.

Author: Christoph Berg <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]

11 days agoImprove runtime and output of tests for replication slots checkpointing.
Alexander Korotkov [Thu, 19 Jun 2025 22:41:28 +0000 (01:41 +0300)]
Improve runtime and output of tests for replication slots checkpointing.

The TAP tests that verify logical and physical replication slot behavior
during checkpoints (046_checkpoint_logical_slot.pl and
047_checkpoint_physical_slot.pl) inserted two batches of 2 million rows each,
generating approximately 520 MB of WAL.  On slow machines, or when compiled
with '-DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE', this caused the
tests to run for 8-9 minutes and occasionally time out, as seen on the
buildfarm animal prion.

This commit modifies the mentioned tests to utilize the $node->advance_wal()
function, thereby reducing runtime. Once we do not use the generated data,
the proposed function is a good alternative, which cuts the total wall-clock
run time.

While here, remove superfluous '\n' characters from several note() calls;
these appeared literally in the build-farm logs and looked odd.  Also, remove
excessive 'shared_preload_libraries' GUC from the config and add a check for
'injection_points' extension availability.

Reported-by: Alexander Lakhin <[email protected]>
Reported-by: Tom Lane <[email protected]>
Author: Alexander Korotkov <[email protected]>
Author: Vitaly Davydov <[email protected]>
Reviewed-by: Hayato Kuroda <[email protected]>
Discussion: https://postgr.es/m/fbc5d94e-6fbd-4a64-85d4-c9e284a58eb2%40gmail.com
Backpatch-through: 17

11 days agodoc PG 18 relnotes: add links to command and struct tags
Bruce Momjian [Thu, 19 Jun 2025 21:13:58 +0000 (17:13 -0400)]
doc PG 18 relnotes:  add links to command and struct tags

11 days agoCorrect docs about partitions and EXCLUDE constraints.
Jeff Davis [Thu, 19 Jun 2025 19:43:27 +0000 (12:43 -0700)]
Correct docs about partitions and EXCLUDE constraints.

In version 17 we added support for cross-partition EXCLUDE
constraints, as long as they included all partition key columns and
compared them with equality (see 8c852ba9a4). I updated the docs for
exclusion constraints, but I missed that the docs for CREATE TABLE
still said that they were not supported. This commit fixes that.

Author: Paul A. Jungwirth <[email protected]>
Co-authored-by: Jeff Davis <[email protected]>
Discussion: https://postgr.es/m/c955d292-b92d-42d1-a2a0-1ec6715a2546@illuminatedcomputing.com
Backpatch-through: 17

11 days agodoc PG 18 relnotes: add links for applications
Bruce Momjian [Thu, 19 Jun 2025 15:59:00 +0000 (11:59 -0400)]
doc PG 18 relnotes:  add links for applications

11 days agodoc: add xreflabel text for libpq and PL/Python
Bruce Momjian [Thu, 19 Jun 2025 15:50:50 +0000 (11:50 -0400)]
doc:  add xreflabel text for libpq and PL/Python

to be used for PG 18 release notes

12 days agoImprove pg_dump/pg_dumpall help synopses and terminology
Peter Eisentraut [Thu, 19 Jun 2025 11:53:12 +0000 (13:53 +0200)]
Improve pg_dump/pg_dumpall help synopses and terminology

Increase consistency of --help and man page synopses between pg_dump
and pg_dumpall.  These should now be very similar, as pg_dumpall can
now also produce non-text dump output.  But actually, they had drifted
further apart.

- Use verb "export" consistently, instead of "dump" or "extract".
- Use "SQL script" instead of just "script" or "text file".
- Maintain consistent distinction between SQL script and other
  formats/archives (which is relevant for pg_restore).

Reviewed-by: Robert Treat <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/3f71d8a7-095b-4829-9b0b-fce09e9866b3%40eisentraut.org

12 days agoImprove log messages and docs for slot synchronization.
Amit Kapila [Thu, 19 Jun 2025 04:18:08 +0000 (09:48 +0530)]
Improve log messages and docs for slot synchronization.

Improve the clarity of LOG messages when a failover logical slot
synchronization fails, making the reasons more explicit for easier
debugging.

Update the documentation to outline scenarios where slot synchronization
can fail, especially during the initial sync, and emphasize that
pg_sync_replication_slot() is primarily intended for testing and
debugging purposes.

We also discussed improving the functionality of
pg_sync_replication_slot() so that it can be used reliably, but we would
take up that work for next version after some more discussion and review.

Reported-by: Suraj Kharage <[email protected]>
Author: shveta malik <[email protected]>
Reviewed-by: Zhijie Hou <[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/CAF1DzPWTcg+m+x+oVVB=y4q9=PYYsL_mujVp7uJr-_oUtWNGbA@mail.gmail.com

12 days agodoc PG 18 relnotes: add links for server variables
Bruce Momjian [Thu, 19 Jun 2025 01:19:42 +0000 (21:19 -0400)]
doc PG 18 relnotes:  add links for server variables

12 days agodoc: Mention GIN indexes support parallel builds.
Fujii Masao [Thu, 19 Jun 2025 00:12:34 +0000 (09:12 +0900)]
doc: Mention GIN indexes support parallel builds.

Commit 8492feb98f6 added support for parallel CREATE INDEX on GIN indexes.
However, previously two places in the documentation and two in the source
code comments still stated that only B-tree and BRIN indexes support
parallel builds.

This commit updates those references to correctly include GIN indexes.

Author: Fujii Masao <[email protected]>
Reviewed-by: Robert Treat <[email protected]>
Discussion: https://postgr.es/m/7d27d068-90e2-4022-9bd7-09b0fd3d4f47@oss.nttdata.com

12 days agodoc: Fix incorrect description of INCLUDING COMMENTS in CREATE FOREIGN TABLE.
Fujii Masao [Thu, 19 Jun 2025 00:07:19 +0000 (09:07 +0900)]
doc: Fix incorrect description of INCLUDING COMMENTS in CREATE FOREIGN TABLE.

Commit 302cf157592 added support for LIKE in CREATE FOREIGN TABLE.
In this feature, since indexes are not created for foreign tables,
comments on indexes are not copied either.

However, the documentation incorrectly stated that index comments
would be copied when using INCLUDING COMMENTS. This commit
corrects that by removing the mention of index comments.

Author: Fujii Masao <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/f86cd84f-a6a3-4451-bae7-5cca9e63b06d@oss.nttdata.com

12 days agodoc: fix for commit 09f7d36ba16 in changing "_" to "-".
Bruce Momjian [Wed, 18 Jun 2025 20:48:26 +0000 (16:48 -0400)]
doc:  fix for commit 09f7d36ba16 in changing "_" to "-".

I thought underscores wouldn't even work in "id"s, so I never checked to
see if anything referenced it, but it seems it does work, so adjust the
calling site for the dash syntax.

12 days agodoc config.sgml: use "-" and not "_" for varlistentry "id"s
Bruce Momjian [Wed, 18 Jun 2025 20:43:27 +0000 (16:43 -0400)]
doc config.sgml:  use "-" and not "_" for varlistentry "id"s

Change "id"s of file_copy_method and enable_self_join_elimination for
consistency with the rest of the guc "id"s.  These are new entries for
PG 18.

13 days agopg_dump: Allow pg_dump to dump the statistics for foreign tables.
Fujii Masao [Wed, 18 Jun 2025 05:53:55 +0000 (14:53 +0900)]
pg_dump: Allow pg_dump to dump the statistics for foreign tables.

Commit 1fd1bd87101 introduced support for dumping statistics with
pg_dump and pg_dumpall, covering tables, materialized views, and indexes.
However, it overlooked foreign tables, even though functions like
pg_restore_relation_stats() support them.

This commit fixes that oversight by allowing pg_dump and pg_dumpall
to include statistics for foreign tables.

Author: Fujii Masao <[email protected]>
Reviewed-by: Corey Huinker <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]>
Discussion: https://postgr.es/m/3772e4e4-ef39-4deb-bb76-aa8165f33fb6@oss.nttdata.com

13 days agoDocument "relrewrite" at the top of heap_create_with_catalog()
Michael Paquier [Wed, 18 Jun 2025 02:03:21 +0000 (11:03 +0900)]
Document "relrewrite" at the top of heap_create_with_catalog()

This parameter has been introduced in 325f2ec5557f, and it was not
documented contrary to all the other arguments of
heap_create_with_catalog().

Reviewed-by: Yugo Nagata <[email protected]>
Reviewed-by: Steven Niu <[email protected]>
Discussion: https://postgr.es/m/[email protected]

13 days agodoc: Reorder protocol version option descriptions in libpq docs.
Fujii Masao [Wed, 18 Jun 2025 00:18:40 +0000 (09:18 +0900)]
doc: Reorder protocol version option descriptions in libpq docs.

Commit 285613c60a7 introduced the min_protocol_version and
max_protocol_version connection options for libpq, but their descriptions
were placed in the middle of the unrelated ssl_min_protocol_version and
ssl_max_protocol_version entries.

This commit moves the min_protocol_version and max_protocol_version
descriptions to appear after the SSL-related options. This improves
the logical order and makes it easier for users to locate the relevant
settings in the libpq documentation.

Author: Fujii Masao <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: https://postgr.es/m/a3391f36-30f5-4d4a-825b-232476819de8@oss.nttdata.com

13 days agodoc PG 18 relnotes: add markup, still need to add links
Bruce Momjian [Wed, 18 Jun 2025 00:00:38 +0000 (20:00 -0400)]
doc PG 18 relnotes:  add markup, still need to add links

13 days agoFix allocation check to test the right variable
Daniel Gustafsson [Tue, 17 Jun 2025 20:42:38 +0000 (22:42 +0200)]
Fix allocation check to test the right variable

The memory allocation for cancelConn->be_cancel_key was accidentally
checking the be_cancel_key member in the conn object instead of the
one in cancelConn.

Author: Ranier Vilela <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/CAEudQAq4ySDR6dsg9xwurBXwud02hX7XCOZZAcZx-JMn6A06nA@mail.gmail.com

2 weeks agoamcheck: Fix posting tree checks in gin_index_check()
Tomas Vondra [Tue, 17 Jun 2025 14:48:09 +0000 (16:48 +0200)]
amcheck: Fix posting tree checks in gin_index_check()

Fix two issues in parent_key validation in posting trees:

* It's not enough to check stack->parentblk is valid to determine if the
  parentkey is valid. It's possible parentblk is set to a valid block
  number, but parentkey is invalid. So check parentkey directly.

* We don't need to invalidate parentkey for all child pages of the
  rightmost page. It's enough to invalidate it for the rightmost child
  only, which means we can check more cases (less false negatives).

Issues reported by Arseniy Mukhin, along with a proposed patch. Review
by Andrey M. Borodin, cleanup and improvements by me.

Author: Arseniy Mukhin <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

2 weeks agoamcheck: Fix parent key check in gin_index_check()
Tomas Vondra [Tue, 17 Jun 2025 13:46:26 +0000 (15:46 +0200)]
amcheck: Fix parent key check in gin_index_check()

The checks introduced by commit 14ffaece0fb5 did not get the parent key
checks quite right, missing some data corruption cases. In particular:

* The "rightlink" check was not working as intended, because rightlink
  is a BlockNumber, and InvalidBlockNumber is 0xFFFFFFFF, so

    !GinPageGetOpaque(page)->rightlink

  almost always evaluates to false (except for rightlink=0). So in most
  cases parenttup was left NULL, preventing any checks against parent.

* Use GinGetDownlink() to retrieve child blkno to avoid triggering
  Assert, same as the core GIN code.

Issues reported by Arseniy Mukhin, along with a proposed patch. Review
by Andrey M. Borodin, cleanup and improvements by me.

Author: Arseniy Mukhin <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

2 weeks agoamcheck: Fix checks of entry order for GIN indexes
Tomas Vondra [Tue, 17 Jun 2025 12:55:27 +0000 (14:55 +0200)]
amcheck: Fix checks of entry order for GIN indexes

This tightens a couple checks in checking GIN indexes, which might have
resulted in incorrect results (false positives/negatives).

* The code skipped ordering checks if the entries were for different
  attributes (for multi-column GIN indexes), possibly missing some cases
  of data corruption. But the attribute number is part of the ordering,
  so we can check that.

* The root page was skipped when checking entry order, but that is
  unnecessary. The root page is subject to the same ordering rules, we
  can process it just like any other page.

* The high key on the right-most page was not checked, but that is
  needed only for inner pages (we don't store the high key for those).
  For leaf pages we can check the high key just fine.

* Correct the detection of split pages. If the page gets split, the
  cached parent key is greater than the current child key (not less, as
  the code incorrectly expected).

Issues reported by Arseniy Mukhin, along with a proposed patch. Review
by Andrey M. Borodin, cleanup and improvements by me.

Author: Arseniy Mukhin <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

2 weeks agoamcheck: Remove unused GinScanItem->parentlsn field
Tomas Vondra [Tue, 17 Jun 2025 12:16:35 +0000 (14:16 +0200)]
amcheck: Remove unused GinScanItem->parentlsn field

The field was introduced by commit 14ffaece0fb5, but is unused and
unnecessary. So remove it.

Issues reported by Arseniy Mukhin, along with a proposed patch. Review
by Andrey M. Borodin, cleanup and minor improvements by me.

Author: Arseniy Mukhin <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

2 weeks agoamcheck: Test gin_index_check on a multicolumn index
Tomas Vondra [Tue, 17 Jun 2025 12:14:36 +0000 (14:14 +0200)]
amcheck: Test gin_index_check on a multicolumn index

Adds a regression test with gin_index_check() on a multicolumn index,
to verify it's handled correctly and improve test coverage for code
introduced by 14ffaece0fb5.

Author: Arseniy Mukhin <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

2 weeks agodoc: Mention the default io_method
Peter Eisentraut [Tue, 17 Jun 2025 05:39:43 +0000 (07:39 +0200)]
doc: Mention the default io_method

It was previously not documented.

Author: Daniel Westermann (DWE) <[email protected]>
Reviewed-by: Pavel Stehule <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/ZR0P278MB04279CB0C1D8F49DE68F168ED2AF2%40ZR0P278MB0427.CHEP278.PROD.OUTLOOK.COM

2 weeks agodoc PG 18 relnotes: add author for initdb commit 04bec894a04
Bruce Momjian [Tue, 17 Jun 2025 01:04:14 +0000 (21:04 -0400)]
doc PG 18 relnotes:  add author for initdb commit 04bec894a04

Needed to run src/tools//add_commit_links.pl.

2 weeks agoFix re-distributing previously distributed invalidation messages during logical decoding.
Masahiko Sawada [Tue, 17 Jun 2025 00:36:01 +0000 (17:36 -0700)]
Fix re-distributing previously distributed invalidation messages during logical decoding.

Commit 4909b38af0 introduced logic to distribute invalidation messages
from catalog-modifying transactions to all concurrent in-progress
transactions. However, since each transaction distributes not only its
original invalidation messages but also previously distributed
messages to other transactions, this leads to an exponential increase
in allocation request size for invalidation messages, ultimately
causing memory allocation failure.

This commit fixes this issue by tracking distributed invalidation
messages separately per decoded transaction and not redistributing
these messages to other in-progress transactions. The maximum size of
distributed invalidation messages that one transaction can store is
limited to MAX_DISTR_INVAL_MSG_PER_TXN (8MB). Once the size of the
distributed invalidation messages exceeds this threshold, we
invalidate all caches in locations where distributed invalidation
messages need to be executed.

Back-patch to all supported versions where we introduced the fix by
commit 4909b38af0.

Note that this commit adds two new fields to ReorderBufferTXN to store
the distributed transactions. This change breaks ABI compatibility in
back branches, affecting third-party extensions that depend on the
size of the ReorderBufferTXN struct, though this scenario seems
unlikely.

Additionally, it adds a new flag to the txn_flags field of
ReorderBufferTXN to indicate distributed invalidation message
overflow. This should not affect existing implementations, as it is
unlikely that third-party extensions use unused bits in the txn_flags
field.

Bug: #18938 #18942
Author: vignesh C <[email protected]>
Reported-by: Duncan Sands <[email protected]>
Reported-by: John Hutchins <[email protected]>
Reported-by: Laurence Parry <[email protected]>
Reported-by: Max Madden <[email protected]>
Reported-by: Braulio Fdo Gonzalez <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Reviewed-by: Hayato Kuroda <[email protected]>
Discussion: https://postgr.es/m/680bdaf6-f7d1-4536-b580-05c2760c67c6@deepbluecap.com
Discussion: https://postgr.es/m/18942-0ab1e5ae156613ad@postgresql.org
Discussion: https://postgr.es/m/18938-57c9a1c463b68ce0@postgresql.org
Discussion: https://postgr.es/m/CAD1FGCT2sYrP_70RTuo56QTizyc+J3wJdtn2gtO3VttQFpdMZg@mail.gmail.com
Discussion: https://postgr.es/m/CANO2=B=2BT1hSYCE=nuuTnVTnjidMg0+-FfnRnqM6kd23qoygg@mail.gmail.com
Backpatch-through: 13

2 weeks agoFix possible Assert failure in verify_compact_attribute()
David Rowley [Mon, 16 Jun 2025 22:49:36 +0000 (10:49 +1200)]
Fix possible Assert failure in verify_compact_attribute()

Sometimes the TupleDesc used in verify_compact_attribute() is shared
among backends, and since CompactAttribute.attcacheoff gets updated
during tuple deformation, it was possible that another backend would
set attcacheoff on a given CompactAttribute in the small window of time
from when the attcacheoff from the live CompactAttribute was being set
in the 'tmp' CompactAttribute and before the Assert verifying that the
live and tmp CompactAttributes matched.

Here we adjust the code to make a copy of the live CompactAttribute so
that we're not trying to Assert against a shared copy of it.

Author: David Rowley <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/7195e408-758c-4031-8e61-4f842c716ac0@gmail.com

2 weeks agoaio: Add missing memory barrier when waiting for IO handle
Andres Freund [Mon, 16 Jun 2025 16:36:01 +0000 (12:36 -0400)]
aio: Add missing memory barrier when waiting for IO handle

Previously there was no memory barrier enforcing correct memory ordering when
waiting for a free IO handle. However, in the much more common case of waiting
for IO to complete, memory barriers already were present.

On strongly ordered architectures like x86 this had no negative consequences,
but on some armv8 hardware (observed on Apple hardware), it was possible for
the update, in the IO worker, to PgAioHandle->state to become visible before
->distilled_result becoming visible, leading to rather confusing assertion
failures. The failures were rare enough that the bug sometimes took days to
reproduce when running 027_stream_regress in a loop.

Once finally debugged, it was easy enough to come up with a much quicker
repro: Trigger a lot of very fast IO by limiting io_combine_limit to 1 and
ensure that we always have to wait for a free handle by setting
io_max_concurrency to 1. Triggering lots of concurrent seqscans in that setup
triggers the issue within seconds.

One reason this was hard to debug was that the assertion failure most commonly
happened in WaitReadBuffers(), rather than in the AIO subsystem itself. The
assertions added in this commit make problems like this easier to understand.

Also add a comment to the IO worker explaining that we rely on the lwlock
acquisition for correct memory ordering.

I think it'd be good to add a tap test that stress tests buffer IO, but that's
material for a separate patch.

Thanks a lot to Alexander and Konstantin for all the debugging help.

Reported-by: Tom Lane <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Investigated-by: Andres Freund <[email protected]>
Investigated-by: Alexander Lakhin <[email protected]>
Investigated-by: Konstantin Knizhnik <[email protected]>
Discussion: https://postgr.es/m/2dkz7azclpeiqcmouamdixyn5xhlzy4rvikxrbovyzvi6rnv5c@pz7o7osv2ahf

2 weeks agodoc: Clean up title case use
Peter Eisentraut [Mon, 16 Jun 2025 09:43:52 +0000 (11:43 +0200)]
doc: Clean up title case use

2 weeks agolibpq-oauth: Add exports.list to .gitignore
Peter Eisentraut [Mon, 16 Jun 2025 09:16:52 +0000 (11:16 +0200)]
libpq-oauth: Add exports.list to .gitignore

2 weeks agoMessage style improvements
Peter Eisentraut [Mon, 16 Jun 2025 09:14:39 +0000 (11:14 +0200)]
Message style improvements

Some message style improvements in new code, and some small
refactorings to make translations easier.

2 weeks agoWorkaround code generation bug in clang
John Naylor [Mon, 16 Jun 2025 02:27:15 +0000 (09:27 +0700)]
Workaround code generation bug in clang

At optimization level -O0, builds on recent clang fail to produce the
correct CRC32C with our AVX-512 implementation. For now, just disable
the runtime check for clang at -O0. When this is fixed upstream and we
know the extent of the breakage, we can adjust to be version-specific.

Reported-by: Soumyadeep Chakraborty <[email protected]>
Reported-by: Andy Fan <[email protected]>
Tested-by: Andy Fan <[email protected]>
Discussion: https://postgr.es/m/CAE-ML%2B-OV6p9uvCFBcSQjZUEh__y0h-KjN%2BBseyGJHt7u8EP%2Bw%40mail.gmail.com
Discussion: https://postgr.es/m/87o6uqd3iv.fsf%40163.com

2 weeks agoAdd commit b27644bad to .git-blame-ignore-revs.
Tom Lane [Sun, 15 Jun 2025 17:11:04 +0000 (13:11 -0400)]
Add commit b27644bad to .git-blame-ignore-revs.

2 weeks agoSync typedefs.list with the buildfarm.
Tom Lane [Sun, 15 Jun 2025 17:04:24 +0000 (13:04 -0400)]
Sync typedefs.list with the buildfarm.

Our maintenance of typedefs.list has been a little haphazard
(and apparently we can't alphabetize worth a darn).  Replace
the file with the authoritative list from our buildfarm, and
run pgindent using that.

I also updated the additions/exclusions lists in pgindent where
necessary to keep pgindent from messing things up significantly.
Notably, now that regex_t and some related names are macros not real
typedefs, we have to whitelist them explicitly.  The exclusions list
has also drifted noticeably, presumably due to changes of system
headers on the buildfarm animals that contribute to the list.

Unlike in prior years, I've not manually added typedef names that
are missing from the buildfarm's list because they are not used to
declare any variables or fields.  So there are a few places where
the typedef declaration itself is formatted worse than before,
e.g. typedef enum IoMethod.  I could preserve the names that were
manually added to the list previously, but I'd really prefer to find
a less manual way of dealing with these cases.  A quick grep finds
about 75 such symbols, most of which have never gotten any special
treatment.

Per discussion among pgsql-release, doing this now seems appropriate
even though we're still a week or two away from making the v18 branch.

2 weeks agopsql: Change new \conninfo to use SSL instead of TLS
Peter Eisentraut [Sun, 15 Jun 2025 08:59:30 +0000 (10:59 +0200)]
psql: Change new \conninfo to use SSL instead of TLS

Commit bba2fbc6238 introduced a new implementation of the \conninfo
command in psql.  That new code uses the term "TLS" while the rest of
PostgreSQL, including the rest of psql, consistently uses "SSL".  This
is uselessly confusing.  This changes the new code to use "SSL" as
well.

Reviewed-by: Alvaro Herrera <[email protected]>
Discussion: https://www.postgresql.org/message-id/f4ff9294-b491-4053-83f5-11c10ab8c999@eisentraut.org

2 weeks agoImprove comments for TidRangeEval
David Rowley [Sat, 14 Jun 2025 05:18:31 +0000 (17:18 +1200)]
Improve comments for TidRangeEval

Here we provide a bit more detail on why TidRangeEval() does return false
when trss_mintid is greater than trss_maxtid.

Reported-by: Junwang Zhao <[email protected]>
Author: David Rowley <[email protected]>
Reviewed-by: Junwang Zhao <[email protected]>
Discussion: https://postgr.es/m/CAEG8a3KUbUUqQgfK5X8Sj-%2BppPtGNTU%2BZiep0Rxr7SLjoR%2BB6w%40mail.gmail.com

2 weeks agodoc: Add note about "Client User" and "Superuser" fields in \conninfo output.
Fujii Masao [Sat, 14 Jun 2025 01:39:26 +0000 (10:39 +0900)]
doc: Add note about "Client User" and "Superuser" fields in \conninfo output.

In the \conninfo psql command, the "Client User" column shows the user who
established the connection, while the "Superuser" column reflects whether
the current user in the current execution context is a superuser. This means
the users referred to in these columns can differ, for example, if the current
user was changed with the SET ROLE command.

This commit adds a note to the \conninfo documentation to clarify
this behavior and avoid potential confusion.

Author: Fujii Masao <[email protected]>
Reviewed-by: Robert Treat <[email protected]>
Reviewed-by: David G. Johnston <[email protected]>
Discussion: https://postgr.es/m/685961b8-b6ce-40bb-b2d5-c2ff135d3388@oss.nttdata.com

2 weeks agopsql: Report full protocol version in \conninfo output.
Fujii Masao [Sat, 14 Jun 2025 01:37:12 +0000 (10:37 +0900)]
psql: Report full protocol version in \conninfo output.

Commit bba2fbc6238 modified \conninfo to display the protocol version
used by the current connection, but it only showed the major version (e.g., 3).

This commit updates \conninfo to display the full protocol version (e.g., 3.2).
Since support for new version 3.2 was added in v18, and the server supports
both 3.0 and 3.2, showing the complete version helps users understand
exactly which protocol version the current session is using.

Although this is a minor behavior change, it's considered a fix for
an oversight in the original patch and is included in v18.

Author: Fujii Masao <[email protected]>
Reviewed-by: David G. Johnston <[email protected]>
Discussion: https://postgr.es/m/685961b8-b6ce-40bb-b2d5-c2ff135d3388@oss.nttdata.com