mirror of
https://github.com/timescale/timescaledb.git
synced 2025-04-20 13:53:19 +08:00
Block replica identity usage with hypertables
This commit is contained in:
parent
657a12f6f2
commit
122f5f15a4
@ -830,6 +830,13 @@ table_is_logged(Oid table_relid)
|
||||
return get_rel_persistence(table_relid) == RELPERSISTENCE_PERMANENT;
|
||||
}
|
||||
|
||||
static bool
|
||||
table_has_replica_identity(Relation rel)
|
||||
{
|
||||
return rel->rd_rel->relreplident != REPLICA_IDENTITY_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
hypertable_has_tuples(Oid table_relid, LOCKMODE lockmode)
|
||||
{
|
||||
@ -1051,6 +1058,12 @@ hypertable_create(PG_FUNCTION_ARGS)
|
||||
errmsg("table \"%s\" has to be logged", get_rel_name(table_relid)),
|
||||
errdetail("It is not possible to turn temporary or unlogged tables into hypertables.")));
|
||||
|
||||
if (table_has_replica_identity(rel))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("table \"%s\" has replica identity set", get_rel_name(table_relid)),
|
||||
errdetail("Logical replication is not supported on hypertables.")));
|
||||
|
||||
/*
|
||||
* Create the associated schema where chunks are stored, or, check
|
||||
* permissions if it already exists
|
||||
|
@ -1575,6 +1575,10 @@ process_altertable_end_subcmd(Hypertable *ht, Node *parsetree, ObjectAddress *ob
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("logging cannot be turned off for hypertables")));
|
||||
case AT_ReplicaIdentity:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("hypertables do not support logical replication")));
|
||||
break;
|
||||
case AT_SetRelOptions:
|
||||
case AT_ResetRelOptions:
|
||||
|
@ -81,3 +81,15 @@ ALTER TABLE "Hypertable_1" SET UNLOGGED;
|
||||
ERROR: logging cannot be turned off for hypertables
|
||||
\set ON_ERROR_STOP 1
|
||||
ALTER TABLE "Hypertable_1" SET LOGGED;
|
||||
CREATE TABLE PUBLIC."Hypertable_1_replica_ident" (
|
||||
time BIGINT NOT NULL,
|
||||
"Device_id" TEXT NOT NULL,
|
||||
temp_c int NOT NULL DEFAULT -1
|
||||
);
|
||||
ALTER TABLE "Hypertable_1_replica_ident" REPLICA IDENTITY FULL;
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1_replica_ident"', 'time', chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
||||
ERROR: table "Hypertable_1_replica_ident" has replica identity set
|
||||
ALTER TABLE "Hypertable_1" REPLICA IDENTITY FULL;
|
||||
ERROR: hypertables do not support logical replication
|
||||
\set ON_ERROR_STOP 1
|
||||
|
@ -75,3 +75,14 @@ ALTER TABLE "Hypertable_1" SET UNLOGGED;
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
ALTER TABLE "Hypertable_1" SET LOGGED;
|
||||
CREATE TABLE PUBLIC."Hypertable_1_replica_ident" (
|
||||
time BIGINT NOT NULL,
|
||||
"Device_id" TEXT NOT NULL,
|
||||
temp_c int NOT NULL DEFAULT -1
|
||||
);
|
||||
ALTER TABLE "Hypertable_1_replica_ident" REPLICA IDENTITY FULL;
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1_replica_ident"', 'time', chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
||||
ALTER TABLE "Hypertable_1" REPLICA IDENTITY FULL;
|
||||
\set ON_ERROR_STOP 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user