summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-01-06 16:46:46 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-01-06 16:46:46 -0500
commite5b044c84e8a8c0a3bfca66a245b08316532110c (patch)
tree2ae237c63e1b3d16d6ad00db081cfd23ba57a4dc /src/backend
parent4a8282425f6b6db19a07dcb634b5a670d0289c95 (diff)
Prevent altering partitioned table's rowtype, if it's used elsewhere.
We disallow altering a column datatype within a regular table, if the table's rowtype is used as a column type elsewhere, because we lack code to go around and rewrite the other tables. This restriction should apply to partitioned tables as well, but it was not checked because ATRewriteTables and ATPrepAlterColumnType were not on the same page about who should do it for which relkinds. Per bug #17351 from Alexander Lakhin. Back-patch to all supported branches. Discussion: https://postgr.es/m/17351-6db1870f3f4f612a@postgresql.org
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/tablecmds.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ef88a10f017..b0a7e3221f1 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8847,11 +8847,12 @@ ATPrepAlterColumnType(List **wqueue,
RelationGetRelationName(rel))));
if (tab->relkind == RELKIND_COMPOSITE_TYPE ||
- tab->relkind == RELKIND_FOREIGN_TABLE)
+ tab->relkind == RELKIND_FOREIGN_TABLE ||
+ tab->relkind == RELKIND_PARTITIONED_TABLE)
{
/*
- * For composite types, do this check now. Tables will check it later
- * when the table is being rewritten.
+ * For relations without storage, do this check now. Regular tables
+ * will check it later when the table is being rewritten.
*/
find_composite_type_dependencies(rel->rd_rel->reltype, rel, NULL);
}