diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 3aee2d82ce..fa947e4e01 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13023,6 +13023,17 @@ 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_DATATYPE_MISMATCH), + errmsg("child table \"%s\" has different storage option for column \"%s\" than parent", + RelationGetRelationName(child_rel), + attributeName), + errdetail("%s versus %s", + storage_name(childatt->attstorage), + 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 d621f61c62..6b3eb3c17d 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -4073,3 +4073,15 @@ 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 different storage option for column "a" than parent +DETAIL: EXTENDED versus MAIN +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 8016f8a823..9155731b42 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;