mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 03:23:37 +08:00
Handle when create_hypertable is invoked on partitioned table
- create_hypertable will raise exception on invocation
This commit is contained in:
parent
818bdbc31b
commit
6594018e32
@ -38,15 +38,21 @@ DECLARE
|
|||||||
tablespace_name NAME;
|
tablespace_name NAME;
|
||||||
main_table_has_items BOOLEAN;
|
main_table_has_items BOOLEAN;
|
||||||
is_hypertable BOOLEAN;
|
is_hypertable BOOLEAN;
|
||||||
|
is_partitioned BOOLEAN;
|
||||||
chunk_time_interval_actual BIGINT;
|
chunk_time_interval_actual BIGINT;
|
||||||
time_type REGTYPE;
|
time_type REGTYPE;
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT relname, nspname, reltablespace
|
SELECT relname, nspname, reltablespace, relkind = 'p'
|
||||||
INTO STRICT table_name, schema_name, tablespace_oid
|
INTO STRICT table_name, schema_name, tablespace_oid, is_partitioned
|
||||||
FROM pg_class c
|
FROM pg_class c
|
||||||
INNER JOIN pg_namespace n ON (n.OID = c.relnamespace)
|
INNER JOIN pg_namespace n ON (n.OID = c.relnamespace)
|
||||||
WHERE c.OID = main_table;
|
WHERE c.OID = main_table;
|
||||||
|
|
||||||
|
IF is_partitioned THEN
|
||||||
|
RAISE EXCEPTION 'table % is already partitioned', main_table
|
||||||
|
USING ERRCODE = 'IO110';
|
||||||
|
END IF;
|
||||||
|
|
||||||
SELECT tableowner
|
SELECT tableowner
|
||||||
INTO STRICT table_owner
|
INTO STRICT table_owner
|
||||||
FROM pg_catalog.pg_tables
|
FROM pg_catalog.pg_tables
|
||||||
|
Loading…
x
Reference in New Issue
Block a user