Skip to content

Commit 6594018

Browse files
jwdeitchRobAtticus
authored andcommitted
Handle when create_hypertable is invoked on partitioned table
- create_hypertable will raise exception on invocation
1 parent 818bdbc commit 6594018

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sql/ddl_api.sql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ DECLARE
3838
tablespace_name NAME;
3939
main_table_has_items BOOLEAN;
4040
is_hypertable BOOLEAN;
41+
is_partitioned BOOLEAN;
4142
chunk_time_interval_actual BIGINT;
4243
time_type REGTYPE;
4344
BEGIN
44-
SELECT relname, nspname, reltablespace
45-
INTO STRICT table_name, schema_name, tablespace_oid
45+
SELECT relname, nspname, reltablespace, relkind = 'p'
46+
INTO STRICT table_name, schema_name, tablespace_oid, is_partitioned
4647
FROM pg_class c
4748
INNER JOIN pg_namespace n ON (n.OID = c.relnamespace)
4849
WHERE c.OID = main_table;
4950

51+
IF is_partitioned THEN
52+
RAISE EXCEPTION 'table % is already partitioned', main_table
53+
USING ERRCODE = 'IO110';
54+
END IF;
55+
5056
SELECT tableowner
5157
INTO STRICT table_owner
5258
FROM pg_catalog.pg_tables

0 commit comments

Comments
 (0)