Fix assorted bugs related to identity column in partitioned tables
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 7 May 2024 20:42:32 +0000 (22:42 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 7 May 2024 20:50:00 +0000 (22:50 +0200)
commit509199587df73f06eda898ae13284292f4ae573a
treec5f80e6c68075ff1aeff5635a05c2c0cbff6170f
parent832c4f657fc5d578dc821e9b5175b6ee341e18a8
Fix assorted bugs related to identity column in partitioned tables

When changing the data type of a column of a partitioned table, craft
the ALTER SEQUENCE command only once.  Partitions do not have identity
sequences of their own and thus do not need a ALTER SEQUENCE command
for each partition.

Fix getIdentitySequence() to fetch the identity sequence associated
with the top-level partitioned table when a Relation of a partition is
passed to it.  While doing so, translate the attribute number of the
partition into the attribute number of the partitioned table.

Author: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Discussion: https://www.postgresql.org/message-id/3b8a9dc1-bbc7-0ef5-6863-c432afac7d59@gmail.com
src/backend/catalog/pg_depend.c
src/backend/commands/tablecmds.c
src/backend/parser/parse_utilcmd.c
src/backend/rewrite/rewriteHandler.c
src/include/catalog/dependency.h
src/test/regress/expected/identity.out
src/test/regress/sql/identity.sql