diff options
| author | Peter Eisentraut | 2024-05-07 20:42:32 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2024-05-07 20:50:00 +0000 |
| commit | 509199587df73f06eda898ae13284292f4ae573a (patch) | |
| tree | c5f80e6c68075ff1aeff5635a05c2c0cbff6170f /src/backend/rewrite | |
| parent | 832c4f657fc5d578dc821e9b5175b6ee341e18a8 (diff) | |
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 <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Reviewed-by: Dmitry Dolgov <[email protected]>
Discussion: https://www.postgresql.org/message-id/[email protected]
Diffstat (limited to 'src/backend/rewrite')
| -rw-r--r-- | src/backend/rewrite/rewriteHandler.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 9fd05b15e73..8a29fbbc465 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -24,7 +24,6 @@ #include "access/sysattr.h" #include "access/table.h" #include "catalog/dependency.h" -#include "catalog/partition.h" #include "commands/trigger.h" #include "executor/executor.h" #include "foreign/fdwapi.h" @@ -1233,24 +1232,8 @@ build_column_default(Relation rel, int attrno) if (att_tup->attidentity) { NextValueExpr *nve = makeNode(NextValueExpr); - Oid reloid; - /* - * The identity sequence is associated with the topmost partitioned - * table. - */ - if (rel->rd_rel->relispartition) - { - List *ancestors = - get_partition_ancestors(RelationGetRelid(rel)); - - reloid = llast_oid(ancestors); - list_free(ancestors); - } - else - reloid = RelationGetRelid(rel); - - nve->seqid = getIdentitySequence(reloid, attrno, false); + nve->seqid = getIdentitySequence(rel, attrno, false); nve->typeId = att_tup->atttypid; return (Node *) nve; |
