File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Fixes: #9982 Reject ALTER TABLE ... INHERIT when the parent is a hypertable
Original file line number Diff line number Diff line change @@ -4921,6 +4921,22 @@ process_altertable_start_table(ProcessUtilityArgs *args)
49214921 }
49224922 break ;
49234923 }
4924+ case AT_AddInherit :
4925+ {
4926+ /* A plain table cannot inherit from a hypertable, since the
4927+ * child would not be a chunk and its rows would be hidden from
4928+ * queries on the hypertable. */
4929+ RangeVar * parent = castNode (RangeVar , cmd -> def );
4930+ Oid parent_relid = RangeVarGetRelid (parent , NoLock , true);
4931+
4932+ if (OidIsValid (parent_relid ) && ts_is_hypertable (parent_relid ))
4933+ {
4934+ ereport (ERROR ,
4935+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
4936+ errmsg ("hypertables do not support inheritance" )));
4937+ }
4938+ break ;
4939+ }
49244940
49254941 case AT_SetRelOptions :
49264942 {
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ CREATE TABLE PUBLIC."Hyper_Child" () INHERITS ("Hypertable_1");
6060ERROR: hypertables do not support inheritance
6161CREATE TABLE PUBLIC."Hyper_Child" (extra int) INHERITS (PUBLIC."Hypertable_1", PUBLIC."Parent");
6262ERROR: hypertables do not support inheritance
63+ -- a plain table cannot inherit from a hypertable
64+ CREATE TABLE PUBLIC."Inherit_Child" (LIKE "Hypertable_1");
65+ ALTER TABLE PUBLIC."Inherit_Child" INHERIT "Hypertable_1";
66+ ERROR: hypertables do not support inheritance
6367\set ON_ERROR_STOP 1
6468CREATE TABLE PUBLIC."Child" () INHERITS ("Parent");
6569\set ON_ERROR_STOP 0
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ ALTER TABLE _timescaledb_internal._hyper_1_1_chunk INHERIT "Parent";
5353ALTER TABLE _timescaledb_internal ._hyper_1_1_chunk NO INHERIT " Parent" ;
5454CREATE TABLE PUBLIC ." Hyper_Child" () INHERITS (" Hypertable_1" );
5555CREATE TABLE PUBLIC ." Hyper_Child" (extra int ) INHERITS (PUBLIC." Hypertable_1" , PUBLIC." Parent" );
56+ -- a plain table cannot inherit from a hypertable
57+ CREATE TABLE PUBLIC ." Inherit_Child" (LIKE " Hypertable_1" );
58+ ALTER TABLE PUBLIC." Inherit_Child" INHERIT " Hypertable_1" ;
5659\set ON_ERROR_STOP 1
5760
5861CREATE TABLE PUBLIC ." Child" () INHERITS (" Parent" );
You can’t perform that action at this time.
0 commit comments