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

18471 Commits

Author SHA1 Message Date
Michael Paquier
6e58d6356f Add support for external on-disk TOAST pointers as oid8
A TOAST table whose chunk_id column is oid8 is now fed a 64-bit object
ID thanks to the introduction of a new vartag_external called
VARTAG_ONDISK_OID8, coupled with a new varatt_external_oid8.  The only
difference between the existing varatt_external_oid and the new
varatt_external_oid8 is an extra 4 bytes to store 8 bytes worth an
object ID, spread across two uint32 to force alignement as memcmp may be
used for TOAST pointer comparison (line varatt_external_oid).

There is a one-one mapping between the vartag_external and the type of a
chunk_id:
- An oid8 chunk_id implies the use of VARTAG_ONDISK_OID8.
- An oid chunk_id implies the use of VARTAG_ONDISK_OID.

There are a couple of changes worth noting:
- In toast_tuple_init(), for the comparison of old and new external
values with a memcmp over VARSIZE_EXTERNAL(old_value).  Now that
multiple types of external on-disk TOAST pointers are possible, we
need to add a check based on the vartag used by an old or new value.
One of the tests added by c68cba09dd cover this case.
- In toast_tuple_find_biggest_attribute(), the initial "biggest_size"
depends on the type of chunk_id.  This needs a change in RelationData to
track the chunk_id type; this cached data is filled on demand.
- In detoast.h, toast_external_info_get() and toast_external_data act as
a translation layer to retrieve all the data associated to an Oid or an
Oid8 TOAST pointer, without the need to worry about the vartag dealt
with.  The introduction of this function and structure has reduced a lot
of code churn that existed in the initial versions of this patch, as per
a suggestion from Bharath Rupireddy.
- amcheck is updated to check the vartag <-> chunk_id type mapping
requirements, handling both vartags depending on the underlying type of
chunk_id on the TOAST table.

Bump catalog version, due to at least the change of VARTAG_SIZE().
(This counts for the bump forgotten in a625fc570c22..)

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz
2026-09-15 15:00:01 +09:00
Michael Paquier
a625fc570c Add support for toast_value_type=oid8
This commit adds the possibility to define TOAST tables with oid8 as
their chunk_id, based on the reloption toast_value_type.  All the
external TOAST pointers still rely on varatt_external_oid and a single
vartag.  The values inserted in the oid8 TOAST tables are fed from the
OID8 value generator, casted to OID for now, as we do not have a
vartag_external able to store Oid8 values yet.

An upcoming commit will add support for a new vartag_external and its
associated structures, with the code being able to use a different
on-disk external TOAST pointer depending on the attribute type of
chunk_id defined in TOAST relations.

All the changes done here are mechanical, mostly around the TOAST code
that needs to be able to do chunk_id lookups based on the two types now
supported.

Bump catalog version.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy
2026-09-15 08:37:06 +09:00
Daniel Gustafsson
2bd7519a81 doc: Documentation updates for online checksums
A set of documentation updates for the online checksums work, found via
manual as well as LLM-guided review.

  * The state diagram was re-done to be improve readability and be
    more in line with the look and feel of other diagrams.
  * Paragraph about mismatched states moved to its own sect2.
  * The documentation for the functions to enable/ disable checksums
    failed to mention that they are superuser only.
  * The documentation for the checksums progress reporting had
    accidentally omitted the work "fork" and for the blocks_* columns.
    The values are per fork but the documentation made it seem they
    were per relation.
  * Add the state image to the meson buildfile

Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reported-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/5b08b4d1-0982-4b77-bac5-3bdffc6583f5@iki.fi
Backpatch-through: 19
2026-09-14 15:33:05 +02:00
Daniel Gustafsson
724477d67e pg_combinebackup: Refuse mixed data checksum states in a backup chain
check_control_files() detected a chain whose backups were taken under
different data checksum states, warned, and proceeded.  The output
directory keeps the last backup's control file, so a full backup taken
with checksums off combined with an incremental taken after an offline
enable produces a cluster whose control file says "on" while most of
its blocks carry no checksums; it starts, and then every connection
dies on the first unchecksummed catalog page.  An offline enable
between two backups of a chain is all it takes, since it rewrites
every page without logging anything, so the incremental backup does
not re-ship the pages.

Turn the warning into an error, matching what pg_rewind does for the
equivalent combinations.  The check stays asymmetric on purpose: when
the last backup was taken with checksums off, stale checksums from an
earlier backup are never verified, and that chain remains usable.

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/anwm6UPxoVS41QA2@bdtpg
Backpatch-through: 19
2026-09-14 15:33:03 +02:00
Daniel Gustafsson
227f8ea19a pg_rewind: Check the data checksum states of source and target
pg_rewind installs the source's control file on the target, but every
block it does not copy keeps the target's content.  With checksums
enabled on the target and disabled on the source, the rewound server
claims enabled checksums while the blocks copied from the source have
none, and fails checksum verification as soon as it reads them; in the
worst case every connection attempt dies on an unverifiable catalog
page.

Comparing the control files is not enough.  Replay on the rewound
server resumes from the last common checkpoint and adopts the data
checksum state recorded there, so an offline disable on the source
after the divergence leaves both control files saying "off" while the
rewound server still resumes with verification enabled.  Check the
state carried by the divergence checkpoint as well, which pg_rewind
already reads.

Refuse both cases, and an interrupted online transition on either
side, same as pg_checksums does.  The opposite mismatch, checksums on
the source only, is allowed with a warning: recovery under the backup
label adopts the divergence state, so the rewound server keeps
checksums disabled (or converges through the replayed WAL if the
source enabled them online), and no page can fail verification.

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/anwm6UPxoVS41QA2@bdtpg
Backpatch-through: 19
2026-09-14 15:33:01 +02:00
Daniel Gustafsson
3e70c527cc pg_checksums: Refuse interrupted transitions, note change is local
An inprogress-on or inprogress-off control file means an online
transition was cut short, running the offline tool on top of it mixes
two procedures.  Refuse it in every mode, with a hint pointing at the
start-stop cycle (or, on a standby, at letting replication finish)
that resets the state.  Also print that the change applies to one
data directory only, with standby-aware wording, since in a
replication setup the same change must be made on every node.

On a primary, inprogress-on cannot survive a graceful stop: the
checksums launcher resolves it from its exit cleanup, and a crashed
primary is already rejected by the existing "cluster must be shut
down" check.  inprogress-off can, however, it is set by the backend
running pg_disable_data_checksums(), and a fast shutdown arriving
between its two barriers leaves it behind in a cleanly shut down
control file, where the next start-stop cycle resolves it at end of
recovery.  A standby can be stopped with either state, since it has
no launcher and only carries forward whatever state the last replayed
WAL record left it in, with a restartpoint persisting that as-is.
The standby is also the deterministic way to reach the new guard,
which is why the test coverage uses one; the primary window would
need an injection point between the two barriers.

The pg_checksums page said the tool still processes all relation files
regardless of an interrupted online transition; describe the refusal
instead.

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/anwm6UPxoVS41QA2@bdtpg
Backpatch-through: 19
2026-09-14 15:32:58 +02:00
Daniel Gustafsson
b52a1c2c8a Do not adopt data checksum state from another node during replay
Offline data checksum changes with pg_checksums are local to one node,
but replay adopted the data checksum state carried by checkpoint record
unconditionally.  After enabling checksums offline on only the primary,
a standby thus started verifying checksums it does not have.  After an
offline change on a standby, the next replayed checkpoint silently
reverted the state.

To fix, make the control file track this node's state alone, and have
replay cross-check the replayed state against it instead of adopting
it, warning once per divergent value and reporting when the states
agree again.  pg_control gains a watermark, normally the end LSN of
the newest XLOG2_CHECKSUMS record the node has written or applied,
and a flag marking that the state was last written by pg_checksums.
Recovery must never overwrite this state with a replayed one.  The
control file is updated when all pages are flushed.  This requires
a PG_CONTROL_VERSION bump.

Recovery from a base backup may be an exception to not adopting: its
control file was copied at an arbitrary moment, so the state carried
by the starting checkpoint is the one the WAL from there on was

Also document the offline procedure for replication setups.

Author: Zsolt Parragi <zsolt.parragi@percona.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reported-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg
Backpatch-through: 19
2026-09-14 15:32:55 +02:00
Alexander Korotkov
a23ab4862c Rename the WAIT FOR command to WAIT in the documentation
The command tag is WAIT, but the reference page called the command
"WAIT FOR" in its title, index entry, psql help name and throughout its
prose, and so did the error messages.  FOR is a noise word that makes the
grammar read like English, exactly as INTO does for INSERT and FROM does
for DELETE; neither of those is part of the command's name.  Settle on
WAIT everywhere the command is named, and keep WAIT FOR LSN wherever the
syntax itself is being shown.

Rename the reference page's id and file name to match, following
cb2c696b1d: v19 is not released, so the URL is not yet baked into a
supported version, and every other page's id matches its title.

Reported-by: Masahiko Sawada sawada.mshk@gmail.com
Author: Xuneng Zhou xunengzhou@gmail.com
Reviewed-by: Alexander Korotkov aekorotkov@gmail.com
Discussion: https://postgr.es/m/CAD21AoBdtiPTbm7T_aNeDON9JpFG9g%3DJDUP4WU-Y8t8_xqvR5Q%40mail.gmail.com
Backpatch-through: 19
2026-09-14 14:49:34 +03:00
Alexander Korotkov
6c44473c2d Fix timeout overflow in WAIT FOR LSN
Commit 447aae13b0 accepted TIMEOUT values up to INT64_MAX
milliseconds, but computing the deadline multiplies by 1000, which
caused an int64 overflow. And the command reported a timeout at once
instead of waiting.

Parse the value as an int instead, which simplifies the code and is
consistent with other timeout values such as the statement_timeout GUC.

The specified values are now rounded to the nearest millisecond, so a
positive timeout below half a millisecond becomes zero and waits
indefinitely.

Backpatch to v19, where the TIMEOUT option was introduced.

Reported-by: ChangAo Chen <cca5507@qq.com>
Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/tencent_86B83240785807077600A1778566B5C12908@qq.com
Backpatch-through: 19
2026-09-14 14:13:04 +03:00
Etsuro Fujita
3ca4abd60c postgres_fdw: Disable attribute statistics import from pre-9.1 servers.
To import attribute statistics, postgres_fdw sent a query wity COLLATE
"C" to remote servers without checking their version.  Since COLLATE is
only supported since v9.1, this could break the import against older
servers; fix by modifying postgres_fdw to check their version and if
older, fall back to sampling.  (This commit still allows importing only
relation statistics from such an older server.)

Also, expand the documentation to mention that attribute statistics are
stored into the local server without applying the foreign table columns'
n_distinct option.

Oversight in commit 28972b6fc.

Reported-by: Fujii Masao <masao.fujii@gmail.com>
Reported-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>
Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwH8%2BuDTwfohpck9v_9L3nwSWACbmC36JYRyqHd5xQN_OA%40mail.gmail.com
Backpatch-through: 19
2026-09-14 19:00:00 +09:00
Michael Paquier
4b4b5eae90 doc: Mention REPACK in description of reloption toast_value_type
The value set in toast_value_type does not affect the underlying TOAST
table across rewrites.  VACUUM FULL and CLUSTER were mentioned, but not
REPACK.

Suggested-by: Marcos Pegoraro <marcos@f10.com.br>
Discussion: https://postgr.es/m/CAB-JLwbsYHxo5qdWyj1WbRDhxfxsKqg9Y2=wQ4Xwjm51wsLVPg@mail.gmail.com
2026-09-14 14:12:00 +09:00
Michael Paquier
4000ab1dec Switch pg_column_toast_chunk_id() return value from oid to oid8
This is required for a follow-up commit that will add support for 8-byte
TOAST values, with this function being changed so as it is able to
support the largest TOAST value type available.

Most of the changes in this commit are in the regression tests that use
pg_column_toast_chunk_id(), that need to use some oid8-ish changes.  The
change is surprisingly not invasive as casts from oid to oid8 are
possible (the opposite cast oid8->oid is not supported).

Bump catalog version.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy
2026-09-14 11:02:21 +09:00
Alexander Korotkov
e0c160c307 Prevent WAIT FOR LSN from deadlocking recovery on held locks
A backend waiting for WAL replay can retain locks acquired by earlier
statements.  If the startup process needs one of those locks, directly or
through another backend, before reaching the target LSN, a deadlock can
arise: startup waits for the backend to release the lock, while the backend
waits for startup to advance replay.  The lock manager records the
backend's held locks, but WAIT FOR LSN does not register its dependency on
replay as a lock wait.  The deadlock detector therefore cannot see the
complete cycle.  With unlimited standby conflict delays and no other
timeout or cancellation, this deadlock can persist indefinitely.

Write and flush waits are restricted as well.  Their positions are floored
by the replay position, so without an active walreceiver the startup
process can be their only source of progress.  If a held lock blocks
replay, these waits can form the same cycle: the backend waits for replay
to advance, while replay waits for the backend to release the lock.

Streaming does advance them independently, but only while WAL keeps
arriving.  If reception stops before the target is reached, a blocked
startup process cannot restart the walreceiver.  It also cannot replay
newer checkpoint records needed to advance restartpoints and recycle WAL,
so continued reception can exhaust available space in pg_wal before the
target is reached.  An active receiver at the start of the wait therefore
does not guarantee that the wait can finish while replay remains blocked.

Reject an unsatisfied standby_replay, standby_write, or standby_flush wait
while recovery is active when the backend already holds a granted
heavyweight lock.  This conservative restriction covers direct
relation-lock cycles and indirect cycles involving advisory locks.  It
also rejects some write and flush waits that an active receiver could
satisfy.  Requests whose target is observed as already reached are exempt
from this check, as are primary_flush requests and requests issued after
recovery has ended.  Existing snapshot and recovery-state checks still
apply.

Report one of the held locks so the user can find it, using the same
description the deadlock report uses.

Add replay-mode tests for relation and advisory locks and for the
already-reached case, and document the restriction along with the
recommended usage pattern.

Author: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CABPTF7U0gW5%2B-4oL7-qdML-yerZxUb7ku4QXp7JxCYo0qyJ_Tw%40mail.gmail.com
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Backpatch-through: 19
2026-09-12 23:29:30 +03:00
Michael Paquier
ce420353fa doc: Fix output column name for pg_stat_get_backend_subxact()
pg_stat_get_backend_subxact()'s second attribute was written as
"subxact_overflow" in the docs, but its name is "subxact_overflowed".
Note that the attribute name is still wrong in the TupleDesc generated
in the function; pg_proc agrees with "overflowed".

Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAGRkXqTBZ+zbVuDC8xGEB6Btj61hsui5H5nGqzFBDyOXc=4bjQ@mail.gmail.com
Backpatch-through: 16
2026-09-12 09:04:00 +09:00
Tom Lane
962e0a723a Revert "Don't try to re-order the subcommands of CREATE SCHEMA".
This reverts commit a9c350d9ee.
While that intentionally changed our semantics for CREATE SCHEMA
subcommands, it's being argued that the functionality gain does
not justify potentially-subtle compatibility breakage.  The most
useful bit of functionality gain came from commit 404db8f9e
("Execute foreign key constraints in CREATE SCHEMA at the end"),
which we're keeping because it's required by SQL spec and doesn't
seem to create a compatibility hazard by itself.

This is not an exact revert, partly because we're keeping 404db8f9e,
and partly because I kept the API changes that allowed passing down
a ParseState (which allows providing an error cursor for many of the
errors thrown in CREATE SCHEMA).

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20260904180712.cc.noahmisch@microsoft.com
Backpatch-through: 19
2026-09-11 11:38:16 -04:00
Tom Lane
f1920437cd Revert "Support more object types within CREATE SCHEMA".
This reverts commit d516974840,
along with parts of commit 049b742daa
("psql: Tighten heuristics for BEGIN/END within CREATE SCHEMA").

While there's nothing particularly wrong with d51697484 in itself,
it depends on a9c350d9e ("Don't try to re-order the subcommands of
CREATE SCHEMA"), and concerns have been raised that the compatibility
impact of that outweighs the benefit of allowing more object types
within CREATE SCHEMA.

It's not possible to revert 049b742da verbatim, because the
CVE-2026-6464 patches 3045a25ba ("Teach psql to skip in-line COPY
... FROM STDIN data after a failure") and cf754f741 ("Save/restore
more lexer state when skipping text due to \if") depend on
infrastructure it added.  Instead, rip out just the bits specifically
needed to parse CREATE FUNCTION within CREATE SCHEMA.  This results in
lexer code that matches v18-and-earlier as modified by CVE-2026-6464.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20260904180712.cc.noahmisch@microsoft.com
Backpatch-through: 19
2026-09-11 11:32:16 -04:00
Michael Paquier
f33844889b Add relation option toast_value_type
This relation option gives the possibility to define the attribute type
that can be used for chunk_id in a TOAST table when it is initially
created.  An update of this parameter has no effect if a TOAST table
already exists under the relation, even on rewrites.  It cannot be set
for TOAST relations.

This new option can be set only to "oid" as of this commit.  This
feature is extracted as a patch of its own to ease the introduction of a
second mode in a follow-up change, related to the introduction of 8-byte
OIDs in external TOAST pointers.

Bump catalog version, as StdRdOptions has changed.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz
2026-09-11 12:26:58 +09:00
Robert Haas
3117cf3882 pg_plan_advice: Document interaction with GEQO.
The general nature of this interaction has been understood (at least
by me) since before the original commit, but I failed to explicitly
document it. I also left behind an XXX in the README which I intended
to remove before commit. Fix those things.

Reported-by: Noah Misch <noah@leadboat.com>
Backpatch-through: 19
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com
2026-09-10 13:54:30 -04:00
Álvaro Herrera
8db08e2522 Rework REPACK's documentation on clustering
Commit ac58465e06 moved the discussion on clustering from CLUSTER's
refpage to REPACK's, but somehow introduced a mistake regarding when
exactly can the seqscan-and-sort strategy be used with respect to btrees
(spoiler: it was 100% backwards).  Fix that, but also restructure and
reword the whole subsection more fully to try and make it more coherent.

Author: Chao Li <li.evan.chao@gmail.com>
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Antonin Houska <ah@cybertec.at>
Backpatch-through: 19
Discussion: https://postgr.es/m/69CA7636-0359-42B6-B971-16A036698187@gmail.com
2026-09-10 17:56:39 +02:00
Etsuro Fujita
9f4bd91a19 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:00 +09:00
Michael Paquier
c8985a09b7 doc: Mention pg_stat_force_next_flush()
pg_stat_force_next_flush() has primarily been used in in-core tests to
force cumulative statistics to be flushed at the end of a transaction
without waiting for the PGSTAT_MIN_INTERVAL throttle, to speed up
things.

It is also useful in tests outside the core tree.  Spoiler: I have used
it myself for some out-of-core work for the same reason as the in-core
tests, and would have unlikely known about it without my work on the
core code.

Author: Sami Imseih <samimseih.pg@gmail.com>
Discussion: https://postgr.es/m/aqEONVuLhgBiqHW6@paquier.xyz
2026-09-10 13:19:11 +09:00
Fujii Masao
4dd037286e 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:54:08 +09:00
Michael Paquier
cb29861646 Widen Object ID counter to 8 bytes
This commit adds a new routine called GetNewObjectId8() in varsup.c,
which is able to retrieve a 8-byte OID, based on the next OID retrieved
from the control file.  GetNewObjectId() is kept compatible with its
origin, where we still check that the lower 32 bits of the counter do
not wraparound, while handling the FirstNormalObjectId case.

This change is combined with an update of the control file, with
CheckPoint.nextOid enlarged from Oid to Oid8.  pg_control_checkpoint(),
pg_resetwal and pg_upgrade are updated to adapt to this change, to make
sure that the value is not truncated due to 32-bit limitations when
used, making an upgrade to a newer version where 8-byte is supported a
transparent operation.

A couple of comments in the xlog redo logic referred to wraparound
issues, which is not the case anymore with this change in place, so
refresh these.

This change is required to be able to support external TOAST pointers
based on Oid8, under discussion, and can be used for other purposes.

Tests are added for pg_upgrade (2^32 value carried across upgrades),
pg_resetwal and pg_control_checkpoint(), hence across all the tools
that need to be covered by this change.

Bump catalog version.
Bump PG_CONTROL_VERSION.
Bump XLOG_PAGE_MAGIC, due to XLOG_NEXTOID.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz
2026-09-10 09:39:18 +09:00
Álvaro Herrera
412ef97d92 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
86f7c82cf1 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:56 -07:00
Masahiko Sawada
e8636f2bed 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:11 -07:00
Álvaro Herrera
25b21c0bb7 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
b1f106c80c 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
  7afa11feca  Prevent dropping the last label from a property graph element
  96418a6da9  Fix handling of dropping a property not associated with the given label
  efd7d8d7d4  Resolve unknown-type literals in GRAPH_TABLE COLUMNS
  e0ff7fd9aa  Make property graph object descriptions better translatable
  0e4f0827f6  Fix properties orphaned by dropping a label
  73dfe79fd6  Remove apparent support for SECURITY LABEL ON PROPERTY GRAPH
  592de8bd21  Fix pg_dump ACL minimization for PROPERTY GRAPH.
  16a4b3ef8e  Fix replace_property_refs() ignoring the root of expression tree
  57f93af36f  Resolve unknown-type literals in property expressions
  2e6578292a  Prohibit locking clauses on GRAPH_TABLE
  2521f9e75e  doc: Fix SQL quoting in example
  0316593146  Restore the ability to use | and -> as prefix operators.
  780fa49746  Fix missing space before WHERE in GRAPH_TABLE deparse
  fa62d4f6ea  Prohibit GRANT ... ON TABLE on a property graph
  63c3bbb39f  doc: Add PROPERTY GRAPH to the access privilege tables
  0a51a06cdb  More tab-completion for DROP PROPERTY GRAPH
  f585671055  Disallow aggregates, window functions, and SRFs in GRAPH_TABLE COLUMNS
  9b917a9311  Report duplicate property and label names with a proper error
  a82e33a83d  Make generate_queries_for_path_pattern_recurse() interruptible
  3c982c9bf1  Add test for view referencing labels shared by vertex and edge tables
  8646d1d590  Fix inferred property graph keys with INCLUDE columns
  0417bf5296  Fix pg_event_trigger_ddl_commands for GRANT ON PROPERTY GRAPH
  a20d3e35f2  doc: reformat GRAPH_TABLE examples
  792094a5ce  Coerce GRAPH_TABLE pattern WHERE clauses to boolean

plus typedefs.list changes.

Discussion: https://www.postgresql.org/message-id/CAAKRu_bEtjWYWhYxSo0o_t3DaZYRQd5PkC0abA0g9Mp4%2BovH0w%40mail.gmail.com
2026-09-07 21:00:55 +02:00
Amit Kapila
6168c65ddc 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:40:59 +05:30
Michael Paquier
c5806f2165 Rename varatt_external to varatt_external_oid
This impacts a few more definitions, related to this structure, as of:
- VARTAG_ONDISK -> VARTAG_ONDISK_OID
- TOAST_POINTER_SIZE -> TOAST_OID_POINTER_SIZE
- TOAST_MAX_CHUNK_SIZE -> TOAST_OID_MAX_CHUNK_SIZE
- Macros in varatt.h for varatt_external_oid.

This rename is part of a conversation to add support for more types of
external TOAST pointers, not only OID.  One of them is to extend the
pointers to use an OID8 variant.  The control file field for the max
chunk size is left out, for now.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CALj2ACVnO6jjs5aRx3dSOBy9LV7=iakPBR1eOvoeB8rL8Q47zg@mail.gmail.com
Discussion: https://postgr.es/m/apoD1Ulet2PtDrRV@paquier.xyz
2026-09-07 08:45:23 +09:00
Daniel Gustafsson
168fa9dd42 doc: Pluralize MXID when referring to Multixact IDs
Reported-by: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>
Discussion: https://postgr.es/m/TY4PR01MB17374866B8EBD3F507AFB1C7C94D12@TY4PR01MB17374.jpnprd01.prod.outlook.com
2026-09-04 16:49:59 +02:00
Etsuro Fujita
6a85715682 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:00 +09:00
Noah Misch
cb2c696b1d 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:27 -07:00
Noah Misch
0976940213 Fix user-facing English grammar introduced in the v19 cycle.
Backpatch-through: 19
2026-09-01 17:03:27 -07:00
Jacob Champion
408a28c49a 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:25:39 -07:00
Jeff Davis
e502f9aa81 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:54:48 -07:00
Fujii Masao
076630cbdb 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:46:10 +09:00
Fujii Masao
a20d3e35f2 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:54:31 +09:00
Nathan Bossart
6885b845b4 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
98cd8d509f 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
92819e5794 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
07fdee7c8a 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:49:38 +03:00
Masahiko Sawada
4581767663 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:01 -07:00
Alexander Korotkov
7612ae8ed8 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 00:56:41 +03:00
Fujii Masao
872b20aa56 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:18:07 +09:00
Etsuro Fujita
5c52858ecd 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:00 +09:00
Daniel Gustafsson
cbc1e24d1b pgcrypto: Consistent spelling of built-in
Consistently use "built-in" instead of "built in" and "builtin".

Author: Erik Rijkers <er@xs4all.nl>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/b6d69f32-253c-43ee-290e-f5f4c051a358@xs4all.nl
2026-08-25 10:41:10 +02:00
Peter Eisentraut
e63961d7c1 doc: Document overflow handling of pg_class.relpages etc.
The pg_class fields relpages, relallvisible, and relallfrozen are
stored as int32 in the catalog but block numbers are internally of
type uint32.  This all works correctly because the values are
implicitly converted back and forth according to C conversion rules.
But this was apparently never explicitly documented, so add this.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/db993f34-e3e1-4e6e-85c3-4f248d2ff29b%40eisentraut.org
2026-08-25 08:39:16 +02:00
Tom Lane
8aa49d34e9 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
e42f1d0f1b 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:48:44 +12:00