Skip to content

Commit 4d89805

Browse files
Don't create hypertable for implicitly published tables
Previously, only explicitly published tables were blocked from creating hypertables. Logical Replication of hypertables is not supported (for implementation reasons). We do not allow creation of hypertables with publications and now throw an error if attempted.
1 parent ff80788 commit 4d89805

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

.unreleased/pr_7928

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixes: #7928 Don't create hypertable for implicitly published tables
2+
Thanks: @arajkumar for reporting that implicitly published tables were still able to create hypertables

src/hypertable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ ts_hypertable_create_from_info(Oid table_relid, int32 hypertable_id, uint32 flag
18671867
/*
18681868
* Check that the table is not part of any publication
18691869
*/
1870-
if (GetRelationPublications(table_relid) != NIL)
1870+
if (GetRelationPublications(table_relid) != NIL || GetAllTablesPublications() != NIL)
18711871
{
18721872
ereport(ERROR,
18731873
(errcode(ERRCODE_TS_OPERATION_NOT_SUPPORTED),

test/expected/create_hypertable.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ ERROR: cannot create a unique index without the column "time" (used in partitio
11381138
HINT: If you're creating a hypertable on a table with a primary key, ensure the partitioning column is part of the primary or composite key.
11391139
\set ON_ERROR_STOP 1
11401140
DROP TABLE test_schema.partition_not_pk;
1141-
-- test hypertable is not created for a table that is a part of a publication
1141+
-- test hypertable is not created for a table that is a part of a publication explicitly
11421142
SET client_min_messages = ERROR;
11431143
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
11441144
CREATE PUBLICATION publication_test;
@@ -1166,4 +1166,21 @@ ALTER PUBLICATION publication_test2 DROP TABLE test;
11661166
DROP PUBLICATION publication_test1;
11671167
DROP PUBLICATION publication_test2;
11681168
DROP TABLE test;
1169+
-- test hypertable is not created for a table that is a part of a publication implicitly
1170+
CREATE PUBLICATION publication_test FOR ALL tables;
1171+
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
1172+
\set ON_ERROR_STOP 0
1173+
SELECT create_hypertable('test', 'timestamp');
1174+
ERROR: cannot create hypertable for table "test" because it is part of a publication
1175+
\set ON_ERROR_STOP 1
1176+
DROP PUBLICATION publication_test;
1177+
DROP TABLE test;
1178+
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
1179+
CREATE PUBLICATION publication_test FOR ALL tables;
1180+
\set ON_ERROR_STOP 0
1181+
SELECT create_hypertable('test', 'timestamp');
1182+
ERROR: cannot create hypertable for table "test" because it is part of a publication
1183+
\set ON_ERROR_STOP 1
1184+
DROP PUBLICATION publication_test;
1185+
DROP TABLE test;
11691186
RESET client_min_messages;

test/sql/create_hypertable.sql

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ select create_hypertable ('test_schema.partition_not_pk', 'time');
682682
\set ON_ERROR_STOP 1
683683
DROP TABLE test_schema.partition_not_pk;
684684

685-
-- test hypertable is not created for a table that is a part of a publication
685+
-- test hypertable is not created for a table that is a part of a publication explicitly
686686
SET client_min_messages = ERROR;
687687
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
688688
CREATE PUBLICATION publication_test;
@@ -709,4 +709,21 @@ ALTER PUBLICATION publication_test2 DROP TABLE test;
709709
DROP PUBLICATION publication_test1;
710710
DROP PUBLICATION publication_test2;
711711
DROP TABLE test;
712-
RESET client_min_messages;
712+
713+
-- test hypertable is not created for a table that is a part of a publication implicitly
714+
CREATE PUBLICATION publication_test FOR ALL tables;
715+
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
716+
\set ON_ERROR_STOP 0
717+
SELECT create_hypertable('test', 'timestamp');
718+
\set ON_ERROR_STOP 1
719+
DROP PUBLICATION publication_test;
720+
DROP TABLE test;
721+
722+
CREATE TABLE test (timestamp TIMESTAMPTZ NOT NULL);
723+
CREATE PUBLICATION publication_test FOR ALL tables;
724+
\set ON_ERROR_STOP 0
725+
SELECT create_hypertable('test', 'timestamp');
726+
\set ON_ERROR_STOP 1
727+
DROP PUBLICATION publication_test;
728+
DROP TABLE test;
729+
RESET client_min_messages;

0 commit comments

Comments
 (0)