diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index fb2be10794..33d79a6633 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13050,6 +13050,16 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel) errmsg("column \"%s\" in child table must be marked NOT NULL", attributeName))); + /* No conflicting storage options allowed either. */ + if (attribute->attstorage != childatt->attstorage) + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("child table \"%s\" has storage option \"%s\" for column \"%s\" mismatching \"%s\" on parent", + RelationGetRelationName(child_rel), + storage_name(childatt->attstorage), + attributeName, + storage_name(attribute->attstorage)))); + /* * OK, bump the child column's inheritance count. (If we fail * later on, this change will just roll back.) diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index e5407bbf0f..eeb1bbce81 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -4073,3 +4073,14 @@ alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values drop table at_test_sql_partop; drop operator class at_test_sql_partop using btree; drop function at_test_sql_partop; +-- check the inheritance of attribute storage option +create table attstorage_inh_test (a text); +alter table attstorage_inh_test alter a set storage main; +create table attstorage_inh_test1 (a text); +-- error +alter table attstorage_inh_test1 inherit attstorage_inh_test; +ERROR: child table "attstorage_inh_test1" has storage option "EXTENDED" for column "a" mismatching "MAIN" on parent +alter table attstorage_inh_test1 alter a set storage main; +-- ok +alter table attstorage_inh_test1 inherit attstorage_inh_test; +drop table attstorage_inh_test, attstorage_inh_test1; diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 99af0b851b..9e58c77260 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -2712,3 +2712,14 @@ alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values drop table at_test_sql_partop; drop operator class at_test_sql_partop using btree; drop function at_test_sql_partop; + +-- check the inheritance of attribute storage option +create table attstorage_inh_test (a text); +alter table attstorage_inh_test alter a set storage main; +create table attstorage_inh_test1 (a text); +-- error +alter table attstorage_inh_test1 inherit attstorage_inh_test; +alter table attstorage_inh_test1 alter a set storage main; +-- ok +alter table attstorage_inh_test1 inherit attstorage_inh_test; +drop table attstorage_inh_test, attstorage_inh_test1;