pgsql: Fix propagation of persistence to sequences in ALTER TABLE / ADD

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix propagation of persistence to sequences in ALTER TABLE / ADD
Date: 2024-02-09 07:18:18
Message-ID: E1rYL9O-005MFw-U1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix propagation of persistence to sequences in ALTER TABLE / ADD COLUMN

Fix for 344d62fb9a9: That commit introduced unlogged sequences and
made it so that identity/serial sequences automatically get the
persistence level of their owning table. But this works only for
CREATE TABLE and not for ALTER TABLE / ADD COLUMN. The latter would
always create the sequence as logged (default), independent of the
persistence setting of the table. This is fixed here.

Note: It is allowed to change the persistence of identity sequences
directly using ALTER SEQUENCE. So mistakes in existing databases can
be fixed manually.

Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/c4b6e2ed-bcdf-4ea7-965f-e49761094827%40eisentraut.org

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d17a3a4c6a34f61a3d4d9faa7a70c14d8d0c0ffb

Modified Files
--------------
src/backend/parser/parse_utilcmd.c | 11 +++++-
src/test/regress/expected/identity.out | 72 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/identity.sql | 18 +++++++++
3 files changed, 100 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2024-02-09 10:37:42 pgsql: Fix wrong logic in TransactionIdInRecentPast()
Previous Message Michael Paquier 2024-02-09 02:07:11 pgsql: Add previous commit to .git-blame-ignore-revs