mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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
This commit is contained in:
@ -12183,12 +12183,11 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
errmsg("\"%s\" is not a table",
|
||||
RelationGetRelationName(rel))));
|
||||
|
||||
if (tab->relkind == RELKIND_COMPOSITE_TYPE ||
|
||||
tab->relkind == RELKIND_FOREIGN_TABLE)
|
||||
if (!RELKIND_HAS_STORAGE(tab->relkind))
|
||||
{
|
||||
/*
|
||||
* For composite types and foreign tables, do this check now. Regular
|
||||
* 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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user