1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00
Commit Graph

18423 Commits

Author SHA1 Message Date
Etsuro Fujita
683ce2329c postgres_fdw: Adjust warning message in statistics import.
The previous warning message when falling back to sampling in a certain
case failed to properly mention the reason for that.

Also, for clarity, rewrite a comment about the fallback and add a note
about it to postgres-fdw.sgml.

Follow-up to commit 6a8571568.

Reported-by: Fujii Masao <masao.fujii@gmail.com>
Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHq1VuXwxeDU8N4dd9U4RFEW982qQ9C26mRQDs3nu_Naw%40mail.gmail.com
Backpatch-through: 19
2026-09-10 17:30:01 +09:00
Amit Langote
25649d6e79 Remove batching from RI fast-path checks
Commit b7b27eb41a added batching to the direct-index fast path for
foreign key checks introduced by 2da86c1ef9. Instead of probing the
referenced index once per row, it accumulated referencing rows and
checked them in groups, using SK_SEARCHARRAY for single-column foreign
keys.

The batching requires state to survive across trigger invocations and
to be flushed at the end of each trigger-firing cycle. Follow-up work
has had to define how that state interacts with nested trigger firing,
subtransactions, deferred constraints, and SET CONSTRAINTS.

Failure to handle one of those cases can leave a buffered check
unperformed, allowing a transaction to commit a permanent foreign key
violation without reporting an error. With PostgreSQL 19 close to
release, there is not enough time to gain confidence that all relevant
trigger and transaction states have been covered.

Remove the batching and its after-trigger callback infrastructure,
including the per-batch RI cache and associated subtransaction cleanup.
Restore the early exit in AfterTriggerFireDeferred(), since batch
callbacks can no longer queue additional deferred triggers after
afterTriggerInvokeEvents() returns.

Remove tests that exercise only the batching implementation and its
callback and cache lifetime machinery. Retain tests that continue to
exercise the underlying per-row fast path, including validation,
scan-key construction, cross-type rechecks, deferred checks, and
metadata invalidation.

Keep the underlying per-row fast path. It performs each check
synchronously and retains no pending checks across trigger invocations.
Also retain the fixes made to the per-row probe path, including support
for domain-typed referencing columns, restriction to btree referenced
indexes, concurrent index replacement, metadata invalidation, and
nullable referenced keys.

This removal applies only to REL_19_STABLE.

Discussion: https://postgr.es/m/CA+HiwqEDcCSDoYTtoXH4Ta_BpGN+revMZSLLj6GRz2_5ybwE1g@mail.gmail.com
2026-09-10 14:41:54 +09:00
Fujii Masao
e418e8eb92 Fix REPACK command reporting in pg_stat_progress_cluster
pg_stat_progress_cluster translates REPACK into VACUUM FULL when
pg_stat_progress_repack.repack_index_relid is zero, and into CLUSTER
otherwise.

Previously, repack_index_relid was set only when an index scan was used.
When REPACK used a sequential scan and sort to order the table by an index,
the field remained zero even though index ordering had been requested. As a
result, pg_stat_progress_cluster incorrectly reported the command as
VACUUM FULL instead of CLUSTER.

Fix this by setting repack_index_relid to the OID of the requested ordering
index when progress reporting starts, regardless of the scan method. This
allows pg_stat_progress_cluster to correctly report REPACK as CLUSTER when
index ordering is requested.

Also update the documentation to clarify the meaning of the index columns
and how REPACK is translated into CLUSTER or VACUUM FULL.

Suggested-by: Fujii Masao <masao.fujii@gmail.com>
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAN4CZFMzy2V_wvRCBW5K8=wVCk1-C7nq=8otXO=u+s_1KZHqyA@mail.gmail.com
Backpatch-through: 19
2026-09-10 11:55:13 +09:00
Álvaro Herrera
40d811540a Fix error message for concurrent repack on materialized views
Previously, running REPACK (CONCURRENTLY) on a materialized view failed
with a confusing "has no identity index" error.

REPACK (CONCURRENTLY) replays changes decoded from WAL, but a
materialized view produces none, since it cannot be modified by DML and
REFRESH rewrites it through a transient heap that is not logically
decoded.

Fix this by reporting a clear error for materialized views upfront,
alongside the existing checks for system catalogs and TOAST tables, and
document the limitation.

Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Kiran Kaki <itskkpg@gmail.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CALj2ACXPvy4_LkQ0nHKgbZjAGK9fkDqRYUvXA3hgwxPm_X7Eng@mail.gmail.com
2026-09-09 12:58:00 +02:00
Masahiko Sawada
04bb150025 Restrict REPACK (CONCURRENTLY) on user catalog tables.
REPACK (CONCURRENTLY) is not an MVCC-safe operation; it doesn't
preserve the visibility information, which logical decoding needs
because it reads user catalog tables under a historic snapshot.

Disallow REPACK (CONCURRENTLY) on user catalog tables. Removing this
check requires making it MVCC-safe and logical rewrite mappings.

Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.

Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
2026-09-08 13:04:59 -07:00
Masahiko Sawada
fe7b607234 Restrict REPACK (CONCURRENTLY) to the heap access method.
REPACK (CONCURRENTLY) didn't check the table AM of the table being
repacked, so if the table AM doesn't support logical decoding, the
concurrent changes are never decoded and are silently lost from the
rewritten table.

Fix by erroring out for tables that use a non-heap access method.

Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/apBkixO4xAGFoiT3@nathan
Backpatch-through: 19
2026-09-08 11:49:14 -07:00
Álvaro Herrera
24dd8c369e Reject REPACK (ANALYZE) in a transaction block
The current implementation doesn't support it correctly, leading to
mysterious warnings and some worse problems.  Have the combination throw
an error.

This is intended as a temporary stopgap until we can implement it in a
future release, as it's a useful feature.

Author: Fujii Masao <masao.fujii@gmail.com>
Author: Antonin Houska <ah@cybertec.at>
Author: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/apBCEl4hBHlq0axm@nathan
2026-09-08 14:06:06 +02:00
Peter Eisentraut
2b9e1aff4d Revert SQL Property Graph Queries (SQL/PGQ)
List of commits reverted:

  2f094e7ac6  SQL Property Graph Queries (SQL/PGQ)
  cd8844e7db  Make some tests more stable by adding more explicit ordering
  182cdf5aea  pg_dump: Add appropriate version check
  c9babbc881  Dump labels in reproducible order
  040a56be4b  Cleanup users and roles in graph_table_rls test
  5282bf535e  Fix some typos and make small stylistic improvements
  720f0f89d6  Reject consecutive element patterns of same kind
  288ae96872  Add a graph pattern variable only once
  c5b3253b8a  Property references are preferred over regular column references
  a0dd0702e4  Fix cross variable references in graph pattern causing segfault
  2ff289d039  Check for stack overflow when rewriting graph queries
  9082680c34  Fix typos and grammar in graph table rewrite code
  ac3bcc041c  Fix collation of expressions in GRAPH_TABLE COLUMNS clause
  9d2979dd68  pg_get_viewdef() and lateral references in COLUMNS of GRAPH_TABLE
  891a57c739  Do not define type for a property graph
  dc9e7c9ed9  Handle nodes that may appear in GraphPattern expression trees
  f6edd8ed70  Add ORDER BY to test query to stabilize test
  1190f858ea  doc: Small synopsis wording change for consistency
  d0eac3cafb  Make spelling consistent
  6827de95ee  Simplify code in objectaddress.c for some property graph objects
  5778fb3eaf  Fix typo in error message
  72498a8698  Handle element label and label property objects in object address functions
  4cb2a9863d  Fix LATERAL references in GRAPH_TABLE with multi-label pattern
  9d8cdcbe0c  Record dependencies on graph labels and properties
  2a7e95b659  Readable identity strings for property graph objects
  ac0ad6a7c9  Prevent dropping the last label from a property graph element
  36aae3d029  Fix handling of dropping a property not associated with the given label
  cc9aa7f3a9  Resolve unknown-type literals in GRAPH_TABLE COLUMNS
  d868736830  Make property graph object descriptions better translatable
  45d4c917ff  Fix properties orphaned by dropping a label
  33bfad0f3c  Remove apparent support for SECURITY LABEL ON PROPERTY GRAPH
  ccca2cd81b  Fix pg_dump ACL minimization for PROPERTY GRAPH.
  7883ea13ff  Fix replace_property_refs() ignoring the root of expression tree
  b820c623dd  Resolve unknown-type literals in property expressions
  01c544e1af  Prohibit locking clauses on GRAPH_TABLE
  8d2beee027  Restore the ability to use | and -> as prefix operators.
  d2ac26eb9b  Fix missing space before WHERE in GRAPH_TABLE deparse
  4054ec5b4f  Prohibit GRANT ... ON TABLE on a property graph
  77964322d6  doc: Add PROPERTY GRAPH to the access privilege tables
  c5e11de2f3  More tab-completion for DROP PROPERTY GRAPH
  8ce749f8f6  Disallow aggregates, window functions, and SRFs in GRAPH_TABLE COLUMNS
  22d0eebfef  Report duplicate property and label names with a proper error
  41a300ae3d  Make generate_queries_for_path_pattern_recurse() interruptible
  58af213874  Fix inferred property graph keys with INCLUDE columns
  63f8e9773a  Fix pg_event_trigger_ddl_commands for GRANT ON PROPERTY GRAPH
  07df2b2532  doc: reformat GRAPH_TABLE examples
  1c8c790ec1  Coerce GRAPH_TABLE pattern WHERE clauses to boolean

plus release notes entries and typedefs.list changes.

Discussion: https://www.postgresql.org/message-id/CAAKRu_bEtjWYWhYxSo0o_t3DaZYRQd5PkC0abA0g9Mp4%2BovH0w%40mail.gmail.com
2026-09-07 21:03:10 +02:00
Amit Kapila
9186ffd633 Reset conflict slot's xmin when a subscription (re)starts retention.
Since the retain_dead_tuples feature uses a single cluster-wide
replication slot across all subscriptions, adding a new subscription on a
database with an older active transaction can require
conflict_detection_slot.xmin to move backward to avoid missing dead tuples
needed for update_deleted conflict detection.

Previously, if a newly created subscription had an older active
transaction than the slot's current xmin, the slot update occurred during
worker apply, leading to an assertion failure.

Fix this by having the launcher track the set of databases with active
tuple-retaining subscriptions. When a database joins this set (either via
a new subscription or when retention restarts), the launcher resets the
slot's xmin to the cluster-wide safe decoding horizon before starting any
workers. Because this horizon accounts for all active transactions across
the entire cluster, it serves as a safe seed without requiring retroactive
backward movement by individual apply workers.

In passing, update the retain_dead_tuples documentation to clarify two
operational boundary cases:
(a) Conflict data continues to accumulate even when a subscription is
disabled or its apply worker is stopped.
(b) track_commit_timestamp must be enabled for conflict detection to
function properly.

Reported-by: Nisha Moond <nisha.moond412@gmail.com>
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Author: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/TY4PR01MB177182F547A62FC2666EC04EC94B72@TY4PR01MB17718.jpnprd01.prod.outlook.com
Backpatch-through: 19, where it was introduced
2026-09-07 14:34:15 +05:30
Etsuro Fujita
f4012672bb postgres_fdw: Fix issues with statistics import.
When analyzing a foreign table pointing to a partitioned or inherited
table on the remote server, this method just imported relpages and
reltuples for the parent table from the remote pg_class, causing a
discrepancy or an error in results compared to the sampling method.

* In the partitioning case, while the sampling method sets relpages=0,
  this method set relpages=-1.  (For reltuples, the results of both
  methods match.)
* In the inheritance case, while the sampling method sets
  reltuples=(# of rows in the parent and child tables), this method set
  reltuples=(# of rows in the parent table).  (For relpages, the results
  of both methods match.)

As relpages and reltuples are used for costing foreign paths, these
would lead to incorrect plans or plan changes depending on the method.
To fix, do the following:

* For the partitioning case, modify postgres_fdw to set relpages=0 to
  match the sampling method.
* For the inheritance case, we could also modify it to set the correct
  reltuples value by fetching reltuples for the child tables as well,
  but 1) the change isn't small, and 2) table inheritance hasn't been
  used that much these days, so fix by disabling this method.

While at it, adjust comments and docs slightly.

Oversight in commit 28972b6fc.

Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/CAPmGK173b2Xvyoeq%3DY7L09H%2BajgMgxC2fYe%3D7CCunZz8tGTfFA%40mail.gmail.com
Backpatch-through: 19
2026-09-04 18:40:01 +09:00
Noah Misch
c586a5336a Fix nonstandard SQL command doc id= values introduced in the v19 cycle.
While some <refentry> instances of supported PostgreSQL versions use the
sql-alter-table style, sql-altertable is the dominant style.  Change
these before they're baked into the doc URLs of a supported version.

Backpatch-through: 19
2026-09-01 17:03:30 -07:00
Noah Misch
6dbc931a39 Fix user-facing English grammar introduced in the v19 cycle.
Backpatch-through: 19
2026-09-01 17:03:30 -07:00
Jacob Champion
ef67d599ef libpq: Stop greasing protocol connections
This reverts commit 4966bd3ed9, which
introduced the 19beta grease campaign, now that Beta 3 has been stamped.
(The reservation and documentation for the grease version code, done in
d8d7c5dc8f, remains.)

Discussion: https://postgr.es/m/CAOYmi%2Bkqt_gn-wvUjJG1j3MM4LDDsRMURSPz2eMxfABu0iGtpw%40mail.gmail.com
Backpatch-through: 19
2026-09-01 10:26:10 -07:00
Jeff Davis
1956251afa Revert "Force LC_COLLATE to C in postmaster."
Out of an abundance of caution.

This reverts commit 5e6e42e44f.

Requested-by: Daniel Verite <daniel@manitou-mail.org>
Requested-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/20260826232534.13.noahmisch@microsoft.com
Backpatch-through: 19
2026-09-01 09:55:14 -07:00
Fujii Masao
a4da804193 doc: clarify aliasing of VALUES in FROM clauses
The VALUES reference page said that an AS clause was required when
VALUES is used in a FROM clause. This was imprecise because AS is
optional when specifying an alias.

In v14 and v15, a table alias is still required in this case, so state
that explicitly instead. In v16 and later, commit bcedd8f5fc made table
aliases for subqueries in FROM clauses optional, so state that the
table alias is optional there. In all branches, continue to recommend
explicit column aliases as good practice.

Backpatch to all supported versions.

Author: Ian Barwick <barwick@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAB8KJ=jrvZdNLLhYSiCgbjLTz2LKEjYw+-HVQkaF+kgk61KtHA@mail.gmail.com
Backpatch-through: 14
2026-09-01 22:48:24 +09:00
Fujii Masao
07df2b2532 doc: reformat GRAPH_TABLE examples
The GRAPH_TABLE examples in ddl.sgml and queries.sgml were written
as single long lines, making their structure harder to read in the
generated documentation.

Reformat these examples so that the graph name, MATCH clause, and
COLUMNS clause appear on separate lines, making them easier to read.

Author: Koshino Taiki <koshino@sraoss.co.jp>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OS9P286MB64860BD6CD6D4B4B0E1CEDE894A32@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM
Backpatch-through: 19
2026-09-01 12:55:24 +09:00
Nathan Bossart
3474867758 doc: Fix link on pg_dsm_registry_allocations page.
Oversight in commit 283e823f9d.

Backpatch-through: 19
2026-08-31 12:34:24 -05:00
Nathan Bossart
4186d7169b doc: Drop stale note about extension LWLock names.
Oversight in commit 38b602b028.

Backpatch-through: 19
2026-08-31 12:07:07 -05:00
Nathan Bossart
59335b5e71 doc: Fix the data type named in the regdatabase entry.
Oversight in commit b45137f315.

Backpatch-through: 19 only
2026-08-30 09:40:40 -05:00
Nathan Bossart
efc3db99c4 doc: Mark up "option" in the CHECKPOINT synopsis.
Oversight in commit a4f126516e.

Backpatch-through: 19
2026-08-30 09:13:09 -05:00
Heikki Linnakangas
9d888cd3f3 Track which shmem areas have been fully initialized
If SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP is used to allocate shared
memory after startup, but the initialization fails half-way through,
the shmem area is left in an indeterminate state.  Furthermore, if
multiple shmem areas are registered in one RegisterShmemCallbacks()
call, some might be allocated while others are not.

This commit adds an explicit 'initialized' flag to each shmem area.
We still leave behind an uninitialized area on error, but at least
they are now clearly marked, and you get a slightly nicer error
message if you try to re-register them.  It'd be nice to clean up more
thoroughly and support actually retrying the allocations, but in
practice, the most likely reason for a shmem allocation or
initialization to fail is that you are out of shared memory and
retrying wouldn't help with that.

This isn't exactly a new problem, the old ShmemInitStruct() interface
had similar issues if the initialization code failed, or if you
allocated multiple structs and some allocations failed.  It was just
left to the calling code to deal with it.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail.com
Backpatch-through: 19
2026-08-28 17:53:12 +03:00
Bruce Momjian
da8da39102 doc PG 19 relnotes: move replication items to logical replicat.
Reported-by: Masahiko Sawada

Author: Masahiko Sawada

Discussion: https://postgr.es/m/CAD21AoC1dJGqngg_cdT_ayQjOdw6gmSBfVOTtAWOq-5C+XeLZQ@mail.gmail.com

Backpatch-through: 19 only
2026-08-28 10:04:58 -04:00
Masahiko Sawada
3fcb716719 Report next_multi_offset as bigint in pg_control_checkpoint().
Commit bd8d9c9bdf widened MultiXactOffset to 64 bits, but
pg_control_checkpoint() still handle checkPointCopy.nextMultiOffset as
xid type and declared next_multi_offset column as xid. Since xid is 32
bits wide, an offset above 2^32 was reported truncated, while
pg_controldata printed the full value of the same field.

This commit reports the column as bigint instead. That matches
pg_get_multixact_stats(), which already reports num_members and
members_size, both derived from these same offsets, as int8.

Backpatch to v19, where MultiXactOffset was widened.

Bump catalog version.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAD21AoCvzerscfU8o4ARQ793yAGHpQ72r2x5apeC_W2-k=SLCQ@mail.gmail.com
Backpatch-through: 19
2026-08-27 12:25:04 -07:00
Alexander Korotkov
3e8bcc8644 Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands
This commit reverts f2e4cc4279 and 4b3d173629, and the subsequent fixes and
improvements c5ae07a90a, 713e553e32, 52e629be95, ecb2508aaf, 9354896920,
971017c495, 83df16f1fa, e64a9ba2b4, ff8bec8c46, cdae794af3, 57f19774d6, and
881033ae8b.  d8af730100 and 0392fb900e cancelled each other out and are not
reverted separately.

The feature is reverted due to multiple design issues which are too late to
address in this release cycle.

Discussion: https://postgr.es/m/CAN4CZFNCU%3Dt09M%3D%2Br2t9hHLJuujdM4oQ8hCK_Sx-GpfiwMAicw%40mail.gmail.com
2026-08-27 10:03:53 +03:00
Fujii Masao
dc8628e55d doc: Update REPACK-related table rewrite documentation
Adding REPACK introduced table-rewrite behavior that overlaps with
VACUUM FULL and CLUSTER, but some documentation still mentioned only one
of these commands or described the progress and locking behavior
imprecisely.

Clarify that table-rewriting operations, including REPACK, can change
CTIDs.  Also describe VACUUM FULL, CLUSTER, and REPACK consistently as
table-rewriting operations for disk-space recovery where appropriate,
document the pg_stat_progress_repack and compatibility
pg_stat_progress_cluster views consistently, and clarify the ACCESS
EXCLUSIVE locking behavior of REPACK, including CONCURRENTLY.

Backpatch to v19, where REPACK was introduced.

Author: Marcos Pegoraro <marcos@f10.com.br>
Author: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAB-JLwaLcHyf=OnLnBsJEbdd57WjWPpK5T7iGFJvAQphjTZj_A@mail.gmail.com
Backpatch-through: 19
2026-08-26 10:37:13 +09:00
Etsuro Fujita
77027b347c Further cleanup related to statistics import support in postgres_fdw.
* Reorder the conditions in an if-else block for efficiency.
* Reorder struct definitions for readability.
* Reorder arguments for some functions for consistency.
* Move variables to the required scope.
* Rename a variable to match an input argument.
* Add/Tweak some comments/docs for clarity.

Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CAPmGK14otpa7XZyBO5GxDABUK9OPWFLsAwoQP3ugNdXq%3DK4J1g%40mail.gmail.com
Backpatch-through: 19
2026-08-25 17:50:01 +09:00
Tom Lane
165aa5040a Allow an aggregate's planner support function to be set via CREATE AGGREGATE.
Commit 42473b3b3 implemented SupportRequestSimplifyAggref, but failed
to think about what infrastructure would be required for an extension
to use that: there is no SQL-level mechanism for attaching a planner
support function to an aggregate.  That seems pretty critical for a
feature that's primarily intended to be used by extensions.

To fix, add a SUPPORT clause to CREATE AGGREGATE, and teach pg_dump
(and thereby pg_upgrade) about dumping this aggregate property.
We don't need to touch ALTER AGGREGATE, because it's already the case
that you're supposed to use CREATE OR REPLACE AGGREGATE if you want
to alter any aggregate-specific properties set by CREATE AGGREGATE.
(Maybe at some point we'll think that that policy ought to change,
but I don't think this one feature moves the needle enough.)

Per report from Andrei Lepikhov, who also provided some of the
new documentation text.

Reported-by: Andrei Lepikhov <lepihov@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Discussion: https://postgr.es/m/8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com
Backpatch-through: 19
2026-08-23 12:42:55 -04:00
David Rowley
051be721d0 Doc: fix typo
Author: Jochen Bandhauer <jb@jbitc.de>
Discussion: https://postgr.es/m/69ecfa04-9177-42fd-8d5d-9f375669fc5b@jbitc.de
Backpatch-through: 14
2026-08-22 12:49:17 +12:00
Daniel Gustafsson
0907112d38 basebackup: do not verify checksums on pages from before enabling
Enabling data checksums in a running cluster changes the state to "on"
before the checkpoint which flushes the pages the worker rewrote.  A
base backup which started before that transition absorbs the barrier
mid-run and starts verifying pages whose on-disk copies legitimately
lack checksums, and whose LSNs predate the backup start, so the LSN
check does not skip them either.  The backup fails with bogus
corruption warnings.  The same applies to checksums being disabled and
re-enabled while the backup runs: hint bits set while checksums were
off reach disk without a checksum update and without moving the page
LSN, tripping verification once the re-enabling completes.

To fix, verify checksums only while they have been continuously
enabled since the checkpoint the backup started from: track the
location of the last XLOG2_CHECKSUMS record inserted or replayed, and
verify only when the state is "on" and the last change predates the
backup start.  The starting checkpoint then guarantees that every page
flushed before it has a checksum written, and any later change
disables verification for the rest of the backup.

A standby loses the tracked location when restarting, while pg_control
already carries the new state, so it could reach consistency below the
record and serve base backups with the location unknown.  To prevent
this, replaying XLOG2_CHECKSUMS advances minRecoveryPoint to the
record, like XLOG_PARAMETER_CHANGE does.

The tests hold the enabling between the state change and its final
checkpoint with injection points, straddling it with backups on the
primary and across a standby crash-restart.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAN4CZFP=-cVVVPue+e8qqPtDfuLuQn=ZB4Mw_C9-Ncru2wqAsQ@mail.gmail.com
Backpatch-through: 19
2026-08-18 22:25:52 +02:00
Daniel Gustafsson
397f0fd06e Add data_page_checksum_version to pg_control_checkpoint
Commit f19c0eccae added the data_checksum_version to the pg_controldata
output, but omitted a corresponding change to the pg_control_checkpoint
SQL function, which reports the same checkpoint information.  The field
is named to match what pg_control_init already reports for consistency.

The integer version reported is an implementation detail which bleeds
through, but it is quite widely used and a more holistic approach to
improving this is left as an excercise for the next major version. The
mapping between states and versions is added to the documentation to
make it easier for users.

Backpatch to v19 where online checksums were introduced.

Author: Ian Barwick <barwick@gmail.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/CAB8KJ=hb765sE8bKC-6sh=Yp3sCjN8xs474yuBrkwyoTM2pgZA@mail.gmail.com
Backpatch-through: 19
2026-08-18 22:25:49 +02:00
Bruce Momjian
ffb7e3af79 doc PG 19: update to current
Backpatch-through:  19 only
2026-08-18 10:43:33 -04:00
Alexander Korotkov
d2eb714c7a Fix WAIT FOR LSN documentation examples
Pad example LSNs to match pg_lsn_out() output, and use
"standby_replay LSN" in the timeout error to match the server message.

Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com
Backpatch-through: 19
2026-08-18 14:25:27 +03:00
Tom Lane
2d893fd926 Doc: clean up documentation about text search datatype limits.
textsearch.sgml neglected to mention that the MAXSTRPOS total-length
limit applies to tsquery as well as tsvector.  It also claims that
there is a 32K limit on the total number of nodes in a tsquery, which
is wrong.  (I suspect that QueryOperator.left may once have been
int16, which would give rise to such a limit.  But it's uint32 now,
so you'd hit the 1GB varlena limit well before overflowing that.)

While at it, re-order the bullet points into an order that makes
more sense, to me anyway.

Reported-by: Claude Code (via Noah Misch)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/455079.1786897319@sss.pgh.pa.us
Backpatch-through: 14
2026-08-17 18:17:51 -04:00
Nathan Bossart
16742849a3 doc: Clarify the logging collector's guarantees.
Presently, the documentation for logging_collector says that the
collector "is designed to never lose messages," which reads as a
stronger promise than we actually make.  The collector does not
fsync the log file or retry failed writes, so log messages can go
missing after an operating system crash, power loss, or a write
error.  Reword that sentence and add a note about what is not
guaranteed.

Author: Daniel Bauman <danielbaniel@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Zhenwei Shang <a934172442@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/CAMtj0_a86DdDKkW-ReVpQpqjndVS6GMrwXVpQY4G3-SGY7saMQ%40mail.gmail.com
Backpatch-through: 14
2026-08-14 15:27:16 -05:00
Peter Eisentraut
f3a116a26f Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers
DELETE FOR PORTION OF inserts temporal leftovers through ExecInsert(),
but the rewriter only attached view WCOs for INSERT/UPDATE.  Leftover
rows could therefore silently escape a WITH CHECK OPTION view, while
the equivalent UPDATE correctly raised an error.

This commit fixes it by attaching the WCOs for FOR PORTION OF deletes
too.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Co-authored-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: solai v <solai.cdac@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAN4CZFOuTyhGspG0Nyits8PiK2keoNXkLj-u3APzc66aRcWY9A%40mail.gmail.com
2026-08-14 13:31:55 +02:00
Etsuro Fujita
48965e1465 postgres_fdw: Rename option "restore_stats" to "import_stats".
The option added by commit 28972b6fc was named "restore_stats", because
it was calling pg_restore_relation_stats()/pg_restore_attribute_stats()
in place of fetching a remote rowsample.  However, those code paths have
been replaced with calls to
import_relation_statistics()/import_attribute_statistics() (cf. commit
54cd6fc83), so the option is now slightly misnamed.

Switch the option to "import_stats", which more closely reflects both
the functions being called internally, and the user's perception of what
the operation is doing.

Back-patch to v19 where commit 28972b6fc went in.

Suggested-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CADkLM%3DezuspTk3VD-2EM6XtFP-Dfz7cJKtnbn0cB6gocsAgu1g%40mail.gmail.com
Backpatch-through: 19
2026-08-14 17:40:01 +09:00
Amit Kapila
dc6c9c540b Doc: Clarify ALTER PUBLICATION's REFRESH PUBLICATION wording.
The note used a confusing "tables/except tables/schemas" slash-list,
omitted DROP from the operations requiring a subscriber refresh, and
called out "unset ALL SEQUENCES" without its symmetric "unset ALL TABLES"
case. Reword for clarity and consistency.

Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CAHut+PuGKrWhVMvuFyf-wSdF-Tai_jPTz2UCSCqsYM-82ATY5w@mail.gmail.com
2026-08-13 10:10:46 +05:30
Fujii Masao
ed23f7ce7f doc: Clarify pgbench reporting with --continue-on-error
Clarify that transactions failed under --continue-on-error are reported
separately and are not counted as transactions actually processed, while
time spent on them can lower reported TPS. Also adjust the latency
description to avoid implying that failed transactions are generally included
in latency measurements.

Backpatch to v19, where pgbench's --continue-on-error option was introduced.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/597C9755-4386-488D-A289-16D50AD81FBF@gmail.com
Backpatch-through: 19
2026-08-13 13:27:35 +09:00
Tomas Vondra
5838806ce6 Change wal_compression=on to the first of zstd, lz4, pglz
Previously, wal_compression=on was an alias for pglz, with the
assumption that users could make an informed choice to pick a better
option. But in practice, users rarely got to that second step.

Many users don't want to be choosing algorithms - they just want WAL
compression, and expect that to work well. The configuration parameter
is set by administrators, who do not control the workload, and so are
not in a position to evaluate the options anyway. Some users may not
even realize there are other options, as previously "on" was the only
choice available.

This change maps "on" to non-pglz options, supported by the build. Both
lz4 and zstd are faster, with a comparable (or better) compression
ratio. We prefer zstd over lz4 - per our testing the better compression
ratio pays for the lower (de)compression speed.

Like for TOAST compression, the value depends on algorithms supported by
the PostgreSQL build, with lz4 and zstd being optional. But most builds
will have at least one of these external libraries. If neither zstd or
lz4 is supported, we fallback to pglz.

This only affects what "on" means. Users can still make the informed
choice and explicitly select a compression algorithm if it works better
for their system. The default value for "wal_compression" remains "off."

Initial proposal and patch by wenhui qiu, reviews and patch adjustments
by Christoph Berg. A number of other people participated in the
discussion. Benchmarks by me.

Backpatch to 19.

Author: wenhui qiu <qiuwenhuifx@gmail.com>
Reviewed-by: Christoph Berg <myon@debian.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAGjGUAL1b=Mwd1SCvLbo+fivEr9KDpFcu4jmqKCZXwT=6CiiGQ@mail.gmail.com
Backpatch-through: 19
2026-08-12 01:15:56 +02:00
Nathan Bossart
0119aa30e0 psql: Don't do backquote expansion in \unrestrict.
This oversight in commit 71ea0d6795 allows a malicious server to
inject shell commands into plain-text dump output that are run at
restore time on the machine running psql.  To fix, interpret all
text after \unrestrict until the end of the line as its argument.

Reported-by: Lucas Velgus <velgusgus599@gmail.com>
Reported-by: Filip Janus <fjanus@redhat.com>
Reported-by: Daniel Bakker <daniel@jackds.nl>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-18408
Backpatch-through: 14
2026-08-10 06:38:06 -07:00
Jacob Champion
d97b3f58c1 pgcrypto: Add option to revert to prior decryption behavior
The previous commit raises an ERROR during PGP operations if OpenSSL
does not support the cipher in use. However, any existing messages
created with faulty encryption will no longer be accessible via
pgp_[sym|pub]_decrypt().

To help users out of this situation, add a new ignore-cipher-failure
option which reverts to the broken behavior during decryption only. A
faulty encryption wrapper, created by an OpenSSL configuration that does
not support the cipher, can then be stripped back off by that same
OpenSSL in order to safely reencrypt it. (Note that when OpenSSL does
support the cipher, corrupted messages will not be decrypted regardless
of the ignore-cipher-failure setting; this is unchanged.)

The new tests add a corrupted Blowfish message for both public- and
symmetric-key decryption, resulting in the following test matrix:

- Blowfish supported, default behavior:      fails to decrypt
- Blowfish supported, ignore-cipher-failure: fails to decrypt
- Blowfish unsupported, default behavior:    fails to load cipher
- Blowfish unsupported, ignore-cipher-failure: strips faulty encryption

The previous commit's change to the pubkey tests is expanded similarly:
correctly encrypted messages cannot be decrypted by an OpenSSL that does
not support the cipher, regardless of the option's setting, though the
failure mode will change.

Suggested-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-14663
Backpatch-through: 14
2026-08-10 06:38:06 -07:00
Daniel Gustafsson
ba207f58f3 Fix errorhandling for PGP encryption
PGP encryption was using px_cipher_encrypt without checking if any
error was returned.  When OpenSSL is running in FIPS mode, or when
the legacy provider hasn't been loaded, not all ciphers which are
supported by the PGP code are available and fail the init step in
px_cipher_encrypt.  Since the PGP encryption failed to notice this
it XORed the non-encrypted block with the plaintext, effectively
disabling the encryption.

This was found due to a report of PGP encryption not respecting
the pgcrypto.builtin_crypto_enabled flag and allowing Blowfish
and DES.  This however turned out to be a false positive, since
the PGP code only use ciphers from OpenSSL and not the built in
ciphers.

Bug: #19457
Reported-by: Shishir Sharma <ansh01072001@gmail.com>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://postgr.es/m/19457-4bab15c17aea36c7@postgresql.org
Security: CVE-2026-14663
Backpatch-through: 14
2026-08-10 06:38:06 -07:00
Nathan Bossart
efdb260728 Check for USAGE privilege on the subtype in CREATE TYPE AS RANGE.
This omission allowed roles without USAGE on a type to create range
types that depend on it, which could prevent the owner from
changing the type later.

Reported-by: Jingzhou Fu <fuboat@outlook.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Security: CVE-2026-6470
Backpatch-through: 14
2026-08-10 06:38:05 -07:00
Jacob Champion
5d47df21e8 Add an output_plugin_libraries GUC to bless trusted output plugins
REPLICATION users were not previously subject to restrictions on output
plugin paths, so they were able to bypass LOAD-time protections during
logical decoding. Unfortunately, adding the standard LOAD restrictions
now would retroactively require all third-party output plugins to be
installed under the $libdir/plugins directory. This would prevent the
use of dynamic_library_path, introduce a wire incompatibility for
clients, and require all plugin authors to check that their libraries
are safe for use by any unprivileged user; we want to avoid that.

Instead, introduce an output_plugin_libraries GUC so that DBAs can
specify the output plugins that are trusted for use in logical decoding.
For simplicity, superusers are subject to the restriction as well
(though they're free to modify the GUC at will during a session, so no
power is actually lost).

The default setting is 'pgoutput, test_decoding'. If other third-party
plugins are in use, DBAs will need to modify this parameter after they
update. Some pointers have been added to the documentation to assist
with this.

Author: Jacob Champion <jacob.champion@enterprisedb.com>
Reported-by: Vladimir Tokarev <vladimirelitokarev@gmail.com>
Reported-by: Yu Kunpeng <yu443940816@live.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-6471
2026-08-10 06:38:05 -07:00
Nathan Bossart
4d192fa168 Use value of scram_iterations in mock_scram_secret().
Presently, mock_scram_secret() always uses
SCRAM_SHA_256_DEFAULT_ITERATIONS, which poses an observable
response discrepancy hazard when scram_iterations is set to
something else.  To fix, use the value of the configuration
parameter instead, and document that unauthenticated users can
discover the existence of roles with passwords created with
different iteration counts.

Reported-by: Radim Marek <radim@boringsql.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Jacob Champion <champion.p@gmail.com>
Security: CVE-2026-14672
Backpatch-through: 16
2026-08-10 06:38:05 -07:00
Jeff Davis
45b479a836 Revert "Validate subscription conninfo on owner change"
This reverts commit 1c9c358904.

Raising errors during OWNER TO can cause problems during restore. An
upcoming commit will avoid other errors that can happen in this path.

Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/e103ae8daf74485e0c0ebde297fae735d38f54d1.camel@j-davis.com
Backpatch-through: 19
2026-08-05 13:25:28 -07:00
Fujii Masao
4642ddc2a5 doc: Update XID wraparound error example
Commit edee0c621d, and the equivalent v17 commit f2353dd717,
changed the runtime XID wraparound messages to use "transaction IDs"
terminology, but one corresponding error example in maintenance.sgml
still used the older XID wording.

Update that documentation example in line with the current runtime
message.

Backpatch to v17, where the runtime messages were changed.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/CAHGQGwHTN-Xc5iDtbzNSjfxuab5Y9qAArw8cB4PrrDJpZ+1fgA@mail.gmail.com
Backpatch-through: 17
2026-08-05 11:37:32 +09:00
Fujii Masao
3d4216d85f Clarify wraparound warning percentage messages
Commit e646450e60 added DETAIL messages for XID and MultiXactId
wraparound warnings that described the reported percentage as the
percentage of IDs available for use.  However, the percentage is actually
calculated from the remaining distance to the wraparound limit, not the
stop limit where new IDs are refused.  As a result, the wording could be
misinterpreted as meaning that the reported percentage of IDs can still
be allocated.

Update the wording to clarify that the reported percentage represents the
remaining transaction ID space or MultiXactId space before wraparound.

Also update the related XID warning hints to use "transaction ID"
terminology consistently.

Backpatch to v19, where the DETAIL messages were added.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/CAHGQGwHWZTsR6bjdfpa+pOkBPjoXXm2LuJ+5nh+CvdyqEASHcQ@mail.gmail.com
Backpatch-through: 19
2026-08-05 11:35:41 +09:00
Fujii Masao
1aaca5ab8f doc: Clarify wal_sender_shutdown_timeout values
Clarify how special wal_sender_shutdown_timeout values affect shutdown
waiting.  A value of -1 disables the shutdown timeout and lets the
WAL sender wait for the receiver to catch up, while 0 causes immediate
termination without waiting for catch-up.  Positive values bound how long
shutdown waits, so document that they should be high enough for WAL data
to be replicated under normal circumstances.

Update the main documentation, the GUC long description, and
postgresql.conf.sample consistently.  While here, fix nearby paragraph
indentation and spacing.

Backpatch to v19, where wal_sender_shutdown_timeout was introduced.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Ian Barwick <barwick@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/AF4FE756-A220-4DA7-87B7-A126F3F307FD@gmail.com
Backpatch-through: 19
2026-08-05 11:31:51 +09:00
Peter Eisentraut
16aba1f9b3 doc: Make synopsis placeholders consistent
Existing text (e.g., create_foreign_table.sgml) uses server_name, not
servername.
2026-08-04 14:56:23 +02:00