Move per-attribute version to pg_attribute.attversion

In the back-branches the attribute version could obviously not be stored
in a new pg_attribute column. Nor could we add a tuple descriptor's
aggregate version to TupleDesc and had to resort to some ugliness
instead.

Do it the breaking way now; the reduced per-row overhead and improved
notational clarity make it a clear win.

Due to not needing the TupleDesc workarounds anymore,
TupleDescCopySize() is just the size of the descriptor again. Remove
TupleDescSize() and TupleDescCopy(), so that callers have to use
TupleDescCopySize() / TupleDescCopySized(), which verify the size of the
destination.

Storing an LSN in pg_attribute required teaching bootstrap & genbki
about LSNs.

Note that the mention of the pg_ prefix in attoptions has not been
removed, for the benefit of tool writers that might just read master's
documentation (it also seems not bad to just have that reserved
namespace).

This obviously can only be applied on master.

Bumps catversion.

Reviewed-by: Melanie Plageman <[email protected]>
Reviewed-by: Tomas Vondra <[email protected]>
Security: CVE-2026-6460

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6a3da13d376f5950fd105eedddc4a1e829e6b398
Author: Andres Freund <[email protected]>

Modified Files
--------------
doc/src/sgml/bki.sgml                           |   1 +
doc/src/sgml/catalogs.sgml                      |  20 ++-
src/backend/access/common/reloptions.c          | 110 ------------
src/backend/access/common/tupdesc.c             | 228 ++++--------------------
src/backend/bootstrap/bootstrap.c               |   2 +
src/backend/catalog/README.attver.md            |  34 ++--
src/backend/catalog/genbki.pl                   |  11 ++
src/backend/catalog/heap.c                      |  98 ++--------
src/backend/commands/tablecmds.c                |  10 +-
src/backend/executor/execTuples.c               |   9 +
src/backend/utils/cache/relcache.c              |  14 --
src/bin/pg_dump/pg_dump.c                       |  47 +++--
src/bin/pg_upgrade/t/009_composite_types.pl     |  21 ++-
src/include/access/reloptions.h                 |   4 -
src/include/access/tupdesc.h                    |  25 ++-
src/include/catalog/catversion.h                |   2 +-
src/include/catalog/pg_attribute.h              |  12 +-
src/test/regress/expected/alter_table.out       |  10 +-
src/test/regress/expected/attribute_version.out |  14 +-
src/test/regress/sql/alter_table.sql            |  10 +-
src/test/regress/sql/attribute_version.sql      |  14 +-
src/tools/pgindent/typedefs.list                |   1 -
22 files changed, 199 insertions(+), 498 deletions(-)

Reply via email to