postgresql/src
Tom Lane 918e21d251 Repair pg_upgrade for identity sequences with non-default persistence.
Since we introduced unlogged sequences in v15, identity sequences
have defaulted to having the same persistence as their owning table.
However, it is possible to change that with ALTER SEQUENCE, and
pg_dump tries to preserve the logged-ness of sequences when it doesn't
match (as indeed it wouldn't for an unlogged table from before v15).

The fly in the ointment is that ALTER SEQUENCE SET [UN]LOGGED fails
in binary-upgrade mode, because it needs to assign a new relfilenode
which we cannot permit in that mode.  Thus, trying to pg_upgrade a
database containing a mismatching identity sequence failed.

To fix, add syntax to ADD/ALTER COLUMN GENERATED AS IDENTITY to allow
the sequence's persistence to be set correctly at creation, and use
that instead of ALTER SEQUENCE SET [UN]LOGGED in pg_dump.  (I tried to
make SET [UN]LOGGED work without any pg_dump modifications, but that
seems too fragile to be a desirable answer.  This way should be
markedly faster anyhow.)

In passing, document the previously-undocumented SEQUENCE NAME option
that pg_dump also relies on for identity sequences; I see no value
in trying to pretend it doesn't exist.

Per bug #18618 from Anthony Hsu.
Back-patch to v15 where we invented this stuff.

Discussion: https://postgr.es/m/18618-d4eb26d669ed110a@postgresql.org
2024-09-17 15:53:35 -04:00
..
backend Repair pg_upgrade for identity sequences with non-default persistence. 2024-09-17 15:53:35 -04:00
bin Repair pg_upgrade for identity sequences with non-default persistence. 2024-09-17 15:53:35 -04:00
common common/jsonapi: support libpq as a client 2024-09-11 09:01:07 +02:00
fe_utils Prevent mis-encoding of "trailing junk after numeric literal" errors. 2024-09-05 12:42:33 -04:00
include Add temporal FOREIGN KEY contraints 2024-09-17 11:29:30 +02:00
interfaces Add PQfullProtocolVersion() to surface the precise protocol version. 2024-09-09 11:54:55 -04:00
makefiles Add -Wmissing-variable-declarations to the standard compilation flags 2024-08-03 11:51:02 +02:00
pl Don't bother checking the result of SPI_connect[_ext] anymore. 2024-09-09 12:18:34 -04:00
port Only perform pg_strong_random init when required 2024-09-02 13:52:27 +02:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Repair pg_upgrade for identity sequences with non-default persistence. 2024-09-17 15:53:35 -04:00
timezone Update time zone data files to tzdata release 2024a. 2024-02-01 15:57:53 -05:00
tools Introduce framework for parallelizing various pg_upgrade tasks. 2024-09-16 16:10:33 -05:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Add -Wmissing-variable-declarations to the standard compilation flags 2024-08-03 11:51:02 +02:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk