diff --git a/extension/sql/common/extensions.sql b/extension/sql/common/extensions.sql deleted file mode 100644 index 43ee15ece..000000000 --- a/extension/sql/common/extensions.sql +++ /dev/null @@ -1,3 +0,0 @@ --- CREATE EXTENSION IF NOT EXISTS dblink; --- CREATE EXTENSION IF NOT EXISTS postgres_fdw; --- CREATE EXTENSION IF NOT EXISTS hashlib; diff --git a/extension/sql/common/tables.sql b/extension/sql/common/tables.sql index c7fa81768..e99b83c68 100644 --- a/extension/sql/common/tables.sql +++ b/extension/sql/common/tables.sql @@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS hypertable ( -- Parent: hypertable's `distinct root table` -- Children: created by `distinct_replica_node` table CREATE TABLE IF NOT EXISTS hypertable_replica ( - hypertable_name NAME NOT NULL REFERENCES hypertable (name), + hypertable_name NAME NOT NULL REFERENCES hypertable (name) ON DELETE CASCADE, replica_id SMALLINT NOT NULL CHECK (replica_id >= 0), schema_name NAME NOT NULL, table_name NAME NOT NULL, @@ -96,7 +96,7 @@ CREATE TABLE IF NOT EXISTS hypertable_replica ( -- (Postgres RULES cannot be used, unfortunately) CREATE TABLE IF NOT EXISTS default_replica_node ( database_name NAME NOT NULL REFERENCES node (database_name), - hypertable_name NAME NOT NULL REFERENCES hypertable (name), + hypertable_name NAME NOT NULL REFERENCES hypertable (name) ON DELETE CASCADE, replica_id SMALLINT NOT NULL CHECK (replica_id >= 0), PRIMARY KEY (database_name, hypertable_name), FOREIGN KEY (hypertable_name, replica_id) REFERENCES hypertable_replica (hypertable_name, replica_id) @@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS distinct_replica_node ( table_name NAME NOT NULL, PRIMARY KEY (hypertable_name, replica_id, database_name), UNIQUE (schema_name, table_name), - FOREIGN KEY (hypertable_name, replica_id) REFERENCES hypertable_replica (hypertable_name, replica_id) + FOREIGN KEY (hypertable_name, replica_id) REFERENCES hypertable_replica (hypertable_name, replica_id) ON DELETE CASCADE ); -- A partition_epoch represents a different partitioning of the data. @@ -133,7 +133,7 @@ CREATE TABLE IF NOT EXISTS distinct_replica_node ( -- INFREQUENTLY as it's expensive operation. CREATE TABLE IF NOT EXISTS partition_epoch ( id SERIAL NOT NULL PRIMARY KEY, - hypertable_name NAME NOT NULL REFERENCES hypertable (name), + hypertable_name NAME NOT NULL REFERENCES hypertable (name) ON DELETE CASCADE, start_time BIGINT NULL CHECK (start_time > 0), end_time BIGINT NULL CHECK (end_time > 0), partitioning_func NAME NOT NULL, --function name of a function of the form func(data_value, partitioning_mod) -> [0, partitioning_mod) @@ -150,7 +150,7 @@ CREATE TABLE IF NOT EXISTS partition_epoch ( -- keyspace, i.e. from [0, partition_epoch.partitioning_mod]. CREATE TABLE IF NOT EXISTS partition ( id SERIAL NOT NULL PRIMARY KEY, - epoch_id INT NOT NULL REFERENCES partition_epoch (id), + epoch_id INT NOT NULL REFERENCES partition_epoch (id) ON DELETE CASCADE, keyspace_start SMALLINT NOT NULL CHECK (keyspace_start >= 0), --start inclusive keyspace_end SMALLINT NOT NULL CHECK (keyspace_end > 0), --end inclusive; compatible with between operator UNIQUE (epoch_id, keyspace_start), @@ -164,14 +164,14 @@ CREATE TABLE IF NOT EXISTS partition ( --TODO: trigger to verify partition_epoch hypertable name matches this hypertable_name CREATE TABLE IF NOT EXISTS partition_replica ( id SERIAL NOT NULL PRIMARY KEY, - partition_id INT NOT NULL REFERENCES partition (id), + partition_id INT NOT NULL REFERENCES partition (id) ON DELETE CASCADE, hypertable_name NAME NOT NULL, replica_id SMALLINT NOT NULL, schema_name NAME NOT NULL, table_name NAME NOT NULL, UNIQUE (schema_name, table_name), UNIQUE (partition_id, replica_id), - FOREIGN KEY (hypertable_name, replica_id) REFERENCES hypertable_replica (hypertable_name, replica_id) + FOREIGN KEY (hypertable_name, replica_id) REFERENCES hypertable_replica (hypertable_name, replica_id) ON DELETE CASCADE ); -- Represent a (replicated) chunk of data, which is data in a hypertable that is @@ -187,7 +187,7 @@ CREATE TABLE IF NOT EXISTS partition_replica ( -- TODO(erik) - Describe conditions of closure. CREATE TABLE IF NOT EXISTS chunk ( id SERIAL NOT NULL PRIMARY KEY, - partition_id INT NOT NULL REFERENCES partition (id), + partition_id INT NOT NULL REFERENCES partition (id) ON DELETE CASCADE, start_time BIGINT NULL CHECK (start_time >= 0), end_time BIGINT NULL CHECK (end_time >= 0), UNIQUE (partition_id, start_time), @@ -202,8 +202,8 @@ CREATE TABLE IF NOT EXISTS chunk ( -- Each row represents a table: -- Parent table: "partition_replica.schema_name"."partition_replica.table_name" CREATE TABLE IF NOT EXISTS chunk_replica_node ( - chunk_id INT NOT NULL REFERENCES chunk (id), - partition_replica_id INT NOT NULL REFERENCES partition_replica (id), + chunk_id INT NOT NULL REFERENCES chunk (id) ON DELETE CASCADE, + partition_replica_id INT NOT NULL REFERENCES partition_replica (id) ON DELETE CASCADE, database_name NAME NOT NULL REFERENCES node (database_name), schema_name NAME NOT NULL, table_name NAME NOT NULL, @@ -214,7 +214,7 @@ CREATE TABLE IF NOT EXISTS chunk_replica_node ( -- Represents a hypertable field. CREATE TABLE IF NOT EXISTS field ( - hypertable_name NAME NOT NULL REFERENCES hypertable (name), + hypertable_name NAME NOT NULL REFERENCES hypertable (name) ON DELETE CASCADE, name NAME NOT NULL, attnum INT2 NOT NULL, --MUST match pg_attribute.attnum on main table. SHOULD match on root/hierarchy table as well. data_type REGTYPE NOT NULL, @@ -234,7 +234,7 @@ CREATE TABLE IF NOT EXISTS deleted_field ( ); CREATE TABLE IF NOT EXISTS hypertable_index ( - hypertable_name NAME NOT NULL REFERENCES hypertable (name), + hypertable_name NAME NOT NULL REFERENCES hypertable (name) ON DELETE CASCADE, main_schema_name NAME NOT NULL, --schema name of main table (needed for a uniqueness constraint) main_index_name NAME NOT NULL, --index name on main table definition TEXT NOT NULL, --def with /*INDEX_NAME*/ and /*TABLE_NAME*/ placeholders diff --git a/extension/sql/main/chunk_replica_node_index_triggers.sql b/extension/sql/main/chunk_replica_node_index_triggers.sql index 5862221f8..9373ff864 100644 --- a/extension/sql/main/chunk_replica_node_index_triggers.sql +++ b/extension/sql/main/chunk_replica_node_index_triggers.sql @@ -16,7 +16,7 @@ BEGIN EXECUTE NEW.definition; RETURN NEW; ELSIF TG_OP = 'DELETE' THEN - EXECUTE format('DROP INDEX %I.%I', OLD.schema_name, OLD.index_name); + EXECUTE format('DROP INDEX IF EXISTS %I.%I', OLD.schema_name, OLD.index_name); RETURN OLD; END IF; END diff --git a/extension/sql/main/chunk_replica_node_triggers.sql b/extension/sql/main/chunk_replica_node_triggers.sql index 019fdd093..cfd115542 100644 --- a/extension/sql/main/chunk_replica_node_triggers.sql +++ b/extension/sql/main/chunk_replica_node_triggers.sql @@ -8,39 +8,44 @@ DECLARE partition_replica_row partition_replica; chunk_row chunk; BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on % table', TG_TABLE_NAME - USING ERRCODE = 'IO101'; + IF TG_OP = 'INSERT' THEN + SELECT * + INTO STRICT partition_replica_row + FROM partition_replica AS p + WHERE p.id = NEW.partition_replica_id; + + SELECT * + INTO STRICT chunk_row + FROM chunk AS c + WHERE c.id = NEW.chunk_id; + + IF NEW.database_name = current_database() THEN + PERFORM _sysinternal.create_local_data_table(NEW.schema_name, NEW.table_name, + partition_replica_row.schema_name, + partition_replica_row.table_name); + + PERFORM _sysinternal.create_chunk_replica_node_index(NEW.schema_name, NEW.table_name, + h.main_schema_name, h.main_index_name, h.definition) + FROM hypertable_index h + WHERE h.hypertable_name = partition_replica_row.hypertable_name; + ELSE + PERFORM _sysinternal.create_remote_table(NEW.schema_name, NEW.table_name, + partition_replica_row.schema_name, partition_replica_row.table_name, + NEW.database_name); + END IF; + + PERFORM _sysinternal.set_time_constraint(NEW.schema_name, NEW.table_name, chunk_row.start_time, chunk_row.end_time); + + RETURN NEW; END IF; - SELECT * - INTO STRICT partition_replica_row - FROM partition_replica AS p - WHERE p.id = NEW.partition_replica_id; - - SELECT * - INTO STRICT chunk_row - FROM chunk AS c - WHERE c.id = NEW.chunk_id; - - IF NEW.database_name = current_database() THEN - PERFORM _sysinternal.create_local_data_table(NEW.schema_name, NEW.table_name, - partition_replica_row.schema_name, - partition_replica_row.table_name); - - PERFORM _sysinternal.create_chunk_replica_node_index(NEW.schema_name, NEW.table_name, - h.main_schema_name, h.main_index_name, h.definition) - FROM hypertable_index h - WHERE h.hypertable_name = partition_replica_row.hypertable_name; - ELSE - PERFORM _sysinternal.create_remote_table(NEW.schema_name, NEW.table_name, - partition_replica_row.schema_name, partition_replica_row.table_name, - NEW.database_name); + IF TG_OP = 'DELETE' THEN + RETURN OLD; END IF; - PERFORM _sysinternal.set_time_constraint(NEW.schema_name, NEW.table_name, chunk_row.start_time, chunk_row.end_time); + RAISE EXCEPTION 'Only inserts and deletes supported on % table', TG_TABLE_NAME + USING ERRCODE = 'IO101'; - RETURN NEW; END $BODY$ SET SEARCH_PATH = 'public'; diff --git a/extension/sql/main/chunk_triggers.sql b/extension/sql/main/chunk_triggers.sql index 3369de624..15ba75023 100644 --- a/extension/sql/main/chunk_triggers.sql +++ b/extension/sql/main/chunk_triggers.sql @@ -3,8 +3,8 @@ CREATE OR REPLACE FUNCTION _sysinternal.on_create_chunk() $BODY$ DECLARE BEGIN - IF TG_OP <> 'INSERT' AND TG_OP <> 'UPDATE' THEN - RAISE EXCEPTION 'Only inserts and updates supported on % table', TG_TABLE_NAME + IF TG_OP <> 'INSERT' AND TG_OP <> 'UPDATE' AND TG_OP <> 'DELETE' THEN + RAISE EXCEPTION 'Only inserts, updates, and deletes supported on % table', TG_TABLE_NAME USING ERRCODE = 'IO101'; END IF; @@ -14,6 +14,9 @@ BEGIN WHERE crn.chunk_id = NEW.id; END IF; + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; RETURN NEW; END $BODY$ diff --git a/extension/sql/main/ddl_triggers.sql b/extension/sql/main/ddl_triggers.sql index 5d1ac057b..926b2a0d7 100644 --- a/extension/sql/main/ddl_triggers.sql +++ b/extension/sql/main/ddl_triggers.sql @@ -245,14 +245,54 @@ BEGIN USING ERRCODE = 'IO101'; END LOOP; - IF NOT found_action THEN RAISE EXCEPTION 'Unknown alter table action on %', info.objid::regclass USING ERRCODE = 'IO101'; - END IF; + END IF; END LOOP; END $BODY$; +--Handles drop table command +CREATE OR REPLACE FUNCTION _sysinternal.ddl_process_drop_table() + RETURNS event_trigger LANGUAGE plpgsql AS $BODY$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + IF tg_tag = 'DROP TABLE' AND obj.object_name IS NOT NULL THEN + PERFORM _sysinternal.drop_hypertable(obj.schema_name, obj.object_name); + END IF; + END LOOP; + +END +$BODY$; + +-- Removes a hypertable. +CREATE OR REPLACE FUNCTION _sysinternal.drop_hypertable( + schema_name TEXT, + hypertable_name TEXT + ) + RETURNS void LANGUAGE PLPGSQL VOLATILE AS +$BODY$ +BEGIN + + PERFORM dblink_connect('meta_conn', get_meta_server_name()); + PERFORM dblink_exec('meta_conn', 'BEGIN'); + + PERFORM 1 + FROM dblink( + 'meta_conn', + format('SELECT _meta.drop_hypertable(%L::text, %L::text, %L::text)', + schema_name, + hypertable_name, + current_database() + )) AS t(r TEXT); + + PERFORM dblink_exec('meta_conn', 'COMMIT'); + PERFORM dblink_disconnect('meta_conn'); +END +$BODY$; diff --git a/extension/sql/main/distinct_replica_node_triggers.sql b/extension/sql/main/distinct_replica_node_triggers.sql index 25a79101f..d5fa46c8a 100644 --- a/extension/sql/main/distinct_replica_node_triggers.sql +++ b/extension/sql/main/distinct_replica_node_triggers.sql @@ -7,27 +7,32 @@ $BODY$ DECLARE hypertable_replica_row hypertable_replica; BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on % table', TG_TABLE_NAME - USING ERRCODE = 'IO101'; + IF TG_OP = 'INSERT' THEN + SELECT * + INTO STRICT hypertable_replica_row + FROM hypertable_replica AS h + WHERE h.hypertable_name = NEW.hypertable_name AND + h.replica_id = NEW.replica_id; + + IF NEW.database_name = current_database() THEN + PERFORM _sysinternal.create_local_distinct_table(NEW.schema_name, NEW.table_name, + hypertable_replica_row.distinct_schema_name, + hypertable_replica_row.distinct_table_name); + ELSE + PERFORM _sysinternal.create_remote_table(NEW.schema_name, NEW.table_name, + hypertable_replica_row.distinct_schema_name, + hypertable_replica_row.distinct_table_name, NEW.database_name); + END IF; + RETURN NEW; END IF; - SELECT * - INTO STRICT hypertable_replica_row - FROM hypertable_replica AS h - WHERE h.hypertable_name = NEW.hypertable_name AND - h.replica_id = NEW.replica_id; - - IF NEW.database_name = current_database() THEN - PERFORM _sysinternal.create_local_distinct_table(NEW.schema_name, NEW.table_name, - hypertable_replica_row.distinct_schema_name, - hypertable_replica_row.distinct_table_name); - ELSE - PERFORM _sysinternal.create_remote_table(NEW.schema_name, NEW.table_name, - hypertable_replica_row.distinct_schema_name, - hypertable_replica_row.distinct_table_name, NEW.database_name); + IF TG_OP = 'DELETE' THEN + RETURN OLD; END IF; + RAISE EXCEPTION 'Only inserts and deletes supported on % table', TG_TABLE_NAME + USING ERRCODE = 'IO101'; + RETURN NEW; END $BODY$ diff --git a/extension/sql/main/field_triggers.sql b/extension/sql/main/field_triggers.sql index c08d79914..41e2c5928 100644 --- a/extension/sql/main/field_triggers.sql +++ b/extension/sql/main/field_triggers.sql @@ -307,10 +307,15 @@ BEGIN END IF; SELECT * - INTO STRICT hypertable_row + INTO hypertable_row FROM hypertable AS h WHERE h.name = NEW.hypertable_name; + IF hypertable_row IS NULL THEN + --presumably hypertable has been dropped and this is part of cascade + RETURN NEW; + END IF; + -- update root table PERFORM _sysinternal.drop_field_on_table(hypertable_row.root_schema_name, hypertable_row.root_table_name, NEW.name); diff --git a/extension/sql/main/hypertable_replica_triggers.sql b/extension/sql/main/hypertable_replica_triggers.sql index c82de07b7..59fc42ae4 100644 --- a/extension/sql/main/hypertable_replica_triggers.sql +++ b/extension/sql/main/hypertable_replica_triggers.sql @@ -4,21 +4,25 @@ $BODY$ DECLARE hypertable_row hypertable; BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on hypertable_replica table' - USING ERRCODE = 'IO101'; + IF TG_OP = 'INSERT' THEN + SELECT * + INTO STRICT hypertable_row + FROM hypertable AS h + WHERE h.name = NEW.hypertable_name; + + PERFORM _sysinternal.create_replica_table(NEW.schema_name, NEW.table_name, hypertable_row.root_schema_name, + hypertable_row.root_table_name); + PERFORM _sysinternal.create_replica_table(NEW.distinct_schema_name, NEW.distinct_table_name, + hypertable_row.distinct_schema_name, hypertable_row.distinct_table_name); + RETURN NEW; END IF; - SELECT * - INTO STRICT hypertable_row - FROM hypertable AS h - WHERE h.name = NEW.hypertable_name; + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; - - PERFORM _sysinternal.create_replica_table(NEW.schema_name, NEW.table_name, hypertable_row.root_schema_name, - hypertable_row.root_table_name); - PERFORM _sysinternal.create_replica_table(NEW.distinct_schema_name, NEW.distinct_table_name, - hypertable_row.distinct_schema_name, hypertable_row.distinct_table_name); + RAISE EXCEPTION 'Only inserts and deletets supported on hypertable_replica table, got %', TG_OP + USING ERRCODE = 'IO101'; RETURN NEW; END diff --git a/extension/sql/main/hypertable_triggers.sql b/extension/sql/main/hypertable_triggers.sql index b9958980d..7bfb7a605 100644 --- a/extension/sql/main/hypertable_triggers.sql +++ b/extension/sql/main/hypertable_triggers.sql @@ -42,37 +42,52 @@ $BODY$ DECLARE remote_node node; BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on namespace table' + + IF TG_OP = 'INSERT' THEN + + EXECUTE format( + $$ + CREATE SCHEMA IF NOT EXISTS %I + $$, NEW.associated_schema_name); + + PERFORM _sysinternal.create_table(NEW.root_schema_name, NEW.root_table_name); + PERFORM _sysinternal.create_root_distinct_table(NEW.distinct_schema_name, NEW.distinct_table_name); + + IF NEW.created_on <> current_database() THEN + PERFORM _sysinternal.create_table(NEW.main_schema_name, NEW.main_table_name); + END IF; + + -- UPDATE not supported, so do them before action + EXECUTE format( + $$ + CREATE TRIGGER modify_trigger BEFORE UPDATE OR DELETE ON %I.%I + FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table(); + $$, NEW.main_schema_name, NEW.main_table_name); + EXECUTE format( + $$ + CREATE TRIGGER insert_trigger AFTER INSERT ON %I.%I + FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table(); + $$, NEW.main_schema_name, NEW.main_table_name); + + RETURN NEW; + END IF; + + IF TG_OP = 'DELETE' THEN + + PERFORM _sysinternal.drop_root_table(OLD.root_schema_name, OLD.root_table_name); + PERFORM _sysinternal.drop_root_distinct_table(OLD.distinct_schema_name, OLD.distinct_table_name); + + if current_setting('io.iobeam_drop', true) <> 'true' THEN + PERFORM set_config('io.iobeam_drop', 'true', true); + PERFORM _sysinternal.drop_table(OLD.main_schema_name, OLD.main_table_name); + END IF; + + RETURN OLD; + END IF; + + RAISE EXCEPTION 'Only inserts and delete supported on hypertable metadata table' USING ERRCODE = 'IO101'; - END IF; - PERFORM _sysinternal.create_schema(NEW.main_schema_name); - PERFORM _sysinternal.create_schema(NEW.associated_schema_name); - PERFORM _sysinternal.create_schema(NEW.root_schema_name); - PERFORM _sysinternal.create_schema(NEW.distinct_schema_name); - - PERFORM _sysinternal.create_table(NEW.root_schema_name, NEW.root_table_name); - PERFORM _sysinternal.create_root_distinct_table(NEW.distinct_schema_name, NEW.distinct_table_name); - - IF NEW.created_on <> current_database() THEN - PERFORM _sysinternal.create_table(NEW.main_schema_name, NEW.main_table_name); - END IF; - - -- UPDATE not supported, so do them before action - EXECUTE format( - $$ - CREATE TRIGGER modify_trigger BEFORE UPDATE OR DELETE ON %I.%I - FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table(); - $$, NEW.main_schema_name, NEW.main_table_name); - EXECUTE format( - $$ - CREATE TRIGGER insert_trigger AFTER INSERT ON %I.%I - FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table(); - $$, NEW.main_schema_name, NEW.main_table_name); - - - RETURN NEW; END $BODY$ SET SEARCH_PATH = 'public'; diff --git a/extension/sql/main/partition_replica_triggers.sql b/extension/sql/main/partition_replica_triggers.sql index 81f753c35..391959adf 100644 --- a/extension/sql/main/partition_replica_triggers.sql +++ b/extension/sql/main/partition_replica_triggers.sql @@ -2,23 +2,28 @@ CREATE OR REPLACE FUNCTION _sysinternal.on_create_partition_replica_table() RETURNS TRIGGER LANGUAGE PLPGSQL AS $BODY$ BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on % table', TG_TABLE_NAME - USING ERRCODE = 'IO101'; + IF TG_OP = 'INSERT' THEN + PERFORM _sysinternal.create_data_partition_table( + NEW.schema_name, NEW.table_name, + hr.schema_name, hr.table_name, + p.keyspace_start, p.keyspace_end, + p.epoch_id) + FROM hypertable_replica hr + CROSS JOIN partition p + WHERE hr.hypertable_name = NEW.hypertable_name AND + hr.replica_id = NEW.replica_id AND + p.id = NEW.partition_id; + + RETURN NEW; END IF; - PERFORM _sysinternal.create_data_partition_table( - NEW.schema_name, NEW.table_name, - hr.schema_name, hr.table_name, - p.keyspace_start, p.keyspace_end, - p.epoch_id) - FROM hypertable_replica hr - CROSS JOIN partition p - WHERE hr.hypertable_name = NEW.hypertable_name AND - hr.replica_id = NEW.replica_id AND - p.id = NEW.partition_id; + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + + RAISE EXCEPTION 'Only inserts and deletes supported on % table', TG_TABLE_NAME + USING ERRCODE = 'IO101'; - RETURN NEW; END $BODY$ SET SEARCH_PATH = 'public'; diff --git a/extension/sql/main/setup_main.sql b/extension/sql/main/setup_main.sql index fdd0799fc..2a12f8c2f 100644 --- a/extension/sql/main/setup_main.sql +++ b/extension/sql/main/setup_main.sql @@ -91,5 +91,9 @@ BEGIN WHEN tag IN ('alter table') EXECUTE PROCEDURE _sysinternal.ddl_process_alter_table(); + CREATE EVENT TRIGGER ddl_check_drop_command + ON sql_drop + EXECUTE PROCEDURE _sysinternal.ddl_process_drop_table(); + END $BODY$; diff --git a/extension/sql/main/table_creation.sql b/extension/sql/main/table_creation.sql index 291b4c5d0..128b9a156 100644 --- a/extension/sql/main/table_creation.sql +++ b/extension/sql/main/table_creation.sql @@ -31,6 +31,36 @@ BEGIN END $BODY$; +-- Drop main table if it exists. +CREATE OR REPLACE FUNCTION _sysinternal.drop_main_table( + schema_name NAME, + table_name NAME +) + RETURNS VOID LANGUAGE PLPGSQL VOLATILE AS +$BODY$ +BEGIN + EXECUTE format( + $$ + DROP TABLE IF EXISTS %I.%I; + $$, schema_name, table_name); +END +$BODY$; + +-- Drops root table +CREATE OR REPLACE FUNCTION _sysinternal.drop_root_table( + schema_name NAME, + table_name NAME +) + RETURNS VOID LANGUAGE PLPGSQL VOLATILE AS +$BODY$ +BEGIN + EXECUTE format( + $$ + DROP TABLE %I.%I CASCADE; + $$, schema_name, table_name); +END +$BODY$; + -- Creates a root distinct table for a hypertable. CREATE OR REPLACE FUNCTION _sysinternal.create_root_distinct_table( schema_name NAME, @@ -50,6 +80,22 @@ BEGIN END $BODY$; +-- Drops root distinct table +CREATE OR REPLACE FUNCTION _sysinternal.drop_root_distinct_table( + schema_name NAME, + table_name NAME +) + RETURNS VOID LANGUAGE PLPGSQL VOLATILE AS +$BODY$ +BEGIN + EXECUTE format( + $$ + DROP TABLE %1$I.%2$I CASCADE; + $$, schema_name, table_name); +END +$BODY$; + + CREATE OR REPLACE FUNCTION _sysinternal.create_local_distinct_table( schema_name NAME, table_name NAME, diff --git a/extension/sql/main/tables.sql b/extension/sql/main/tables.sql index ceda736c2..fd42f0f6d 100644 --- a/extension/sql/main/tables.sql +++ b/extension/sql/main/tables.sql @@ -12,5 +12,5 @@ CREATE TABLE IF NOT EXISTS chunk_replica_node_index ( definition TEXT NOT NULL, PRIMARY KEY (schema_name, table_name, index_name), FOREIGN KEY (schema_name, table_name) REFERENCES chunk_replica_node (schema_name, table_name), - FOREIGN KEY (main_schema_name, main_index_name) REFERENCES hypertable_index (main_schema_name, main_index_name) + FOREIGN KEY (main_schema_name, main_index_name) REFERENCES hypertable_index (main_schema_name, main_index_name) ON DELETE CASCADE ); diff --git a/extension/sql/meta/chunk_replica_node_triggers.sql b/extension/sql/meta/chunk_replica_node_triggers.sql index e95f739ba..a4ac51016 100644 --- a/extension/sql/meta/chunk_replica_node_triggers.sql +++ b/extension/sql/meta/chunk_replica_node_triggers.sql @@ -3,11 +3,7 @@ CREATE OR REPLACE FUNCTION _meta.on_create_chunk_replica_node_meta() $BODY$ DECLARE BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on % table', TG_TABLE_NAME - USING ERRCODE = 'IO101'; - END IF; - + IF TG_OP = 'INSERT' THEN INSERT INTO distinct_replica_node (hypertable_name, replica_id, database_name, schema_name, table_name) SELECT pr.hypertable_name, @@ -22,6 +18,15 @@ BEGIN ON CONFLICT DO NOTHING; RETURN NEW; + END IF; + + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + + RAISE EXCEPTION 'Only inserts and deletes supported on % table', TG_TABLE_NAME + USING ERRCODE = 'IO101'; + END $BODY$ SET SEARCH_PATH = 'public'; diff --git a/extension/sql/meta/chunk_triggers.sql b/extension/sql/meta/chunk_triggers.sql index 9f1800180..ec2d99004 100644 --- a/extension/sql/meta/chunk_triggers.sql +++ b/extension/sql/meta/chunk_triggers.sql @@ -47,6 +47,10 @@ DECLARE field_row field; schema_name NAME; BEGIN + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + IF TG_OP = 'UPDATE' THEN IF ( (OLD.start_time IS NULL AND new.start_time IS NOT NULL) diff --git a/extension/sql/meta/ddl.sql b/extension/sql/meta/ddl.sql index 483004a3d..3b215514e 100644 --- a/extension/sql/meta/ddl.sql +++ b/extension/sql/meta/ddl.sql @@ -26,8 +26,8 @@ BEGIN id := nextval('default_hypertable_seq'); IF associated_schema_name IS NULL THEN - associated_schema_name = format('_sys_%s_%s', id, hypertable_name); - END IF; + associated_schema_name = '_sysinternal'; + END IF; IF associated_table_prefix IS NULL THEN associated_table_prefix = format('_hyper_%s', id); @@ -191,3 +191,15 @@ SELECT set_config('io.deleting_node', modified_on, true); DELETE FROM hypertable_index i WHERE i.main_index_name = drop_index.main_index_name AND i.main_schema_name = drop_index.main_schema_name; $BODY$; + +-- Drops a hypertable +CREATE OR REPLACE FUNCTION _meta.drop_hypertable( + schema_name NAME, + hypertable_name NAME, + modified_on NAME +) + RETURNS VOID LANGUAGE SQL VOLATILE AS +$BODY$ + SELECT set_config('io.deleting_node', modified_on, true); + DELETE FROM hypertable h WHERE h.main_schema_name = schema_name AND h.main_table_name = hypertable_name +$BODY$; diff --git a/extension/sql/meta/hypertable_triggers.sql b/extension/sql/meta/hypertable_triggers.sql index b2dfc1760..bafe1d645 100644 --- a/extension/sql/meta/hypertable_triggers.sql +++ b/extension/sql/meta/hypertable_triggers.sql @@ -3,12 +3,8 @@ CREATE OR REPLACE FUNCTION _meta.on_create_hypertable() RETURNS TRIGGER LANGUAGE PLPGSQL AS $BODY$ BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on hypertable name ' - USING ERRCODE = 'IO101'; - END IF; - - INSERT INTO hypertable_replica + IF TG_OP = 'INSERT' THEN + INSERT INTO hypertable_replica SELECT NEW.name, replica_id, @@ -17,10 +13,19 @@ BEGIN NEW.associated_schema_name, format('%s_%s_distinct', NEW.associated_table_prefix, replica_id) FROM generate_series(0, NEW.replication_factor - 1) AS replica_id - ON CONFLICT DO NOTHING; + ON CONFLICT DO NOTHING; - PERFORM _meta.assign_default_replica_node(n.database_name, NEW.name) - FROM node n; + PERFORM _meta.assign_default_replica_node(n.database_name, NEW.name) + FROM node n; + RETURN NEW; + END IF; + + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + + RAISE EXCEPTION 'Only inserts and deletes supported on hypertable name ' + USING ERRCODE = 'IO101'; RETURN NEW; END diff --git a/extension/sql/meta/partition_triggers.sql b/extension/sql/meta/partition_triggers.sql index 9c9563dc8..e52482a0c 100644 --- a/extension/sql/meta/partition_triggers.sql +++ b/extension/sql/meta/partition_triggers.sql @@ -2,11 +2,8 @@ CREATE OR REPLACE FUNCTION _meta.on_create_partition() RETURNS TRIGGER LANGUAGE PLPGSQL AS $BODY$ BEGIN - IF TG_OP <> 'INSERT' THEN - RAISE EXCEPTION 'Only inserts supported on % name ', TG_TABLE_NAME - USING ERRCODE = 'IO101'; - END IF; - + IF TG_OP = 'INSERT' THEN + INSERT INTO partition_replica (partition_id, hypertable_name, replica_id, schema_name, table_name) SELECT NEW.id, @@ -23,7 +20,14 @@ BEGIN ); RETURN NEW; + END IF; + + IF TG_OP = 'DELETE' THEN + RETURN OLD; + END IF; + + RAISE EXCEPTION 'Only inserts and deletes supported on % name ', TG_TABLE_NAME + USING ERRCODE = 'IO101'; + END $BODY$; - - diff --git a/extension/sql/meta/setup_meta.sql b/extension/sql/meta/setup_meta.sql index 08abf6a37..76b7dd351 100644 --- a/extension/sql/meta/setup_meta.sql +++ b/extension/sql/meta/setup_meta.sql @@ -62,7 +62,7 @@ BEGIN FOREACH table_name IN ARRAY ARRAY ['field', 'hypertable_index'] :: NAME [] LOOP EXECUTE format( $$ - DROP TRIGGER IF EXISTS trigger_0_deleted_%1$s ON %1$s + DROP TRIGGER IF EXISTS trigger_0_deleted_%1$s ON %1$s $$, table_name); EXECUTE format( diff --git a/extension/sql/tests/regression/cluster.sql b/extension/sql/tests/regression/cluster.sql index 301cc9354..e7f1d86f5 100644 --- a/extension/sql/tests/regression/cluster.sql +++ b/extension/sql/tests/regression/cluster.sql @@ -92,8 +92,7 @@ FROM field; \des+ \deu+ - -\d+ "_sys_1_testNs".* +\d+ "_sysinternal".* --\d+ "_sys_1_testNs"."_sys_1_testNs_1_0_partition" --\d+ "_sys_1_testNs"."_sys_1_testNs_2_0_partition" @@ -105,7 +104,7 @@ FROM field; SELECT * FROM _meta.get_or_create_chunk(1, 1257894000000000000 :: BIGINT); \c Test1 -\d+ "_sys_1_testNs".* +\d+ "_sysinternal".* \c meta SELECT _meta.close_chunk_end(1); @@ -120,6 +119,6 @@ SELECT * FROM chunk; \c Test1 -\d+ "_sys_1_testNs".* +\d+ "_sysinternal".* diff --git a/extension/sql/tests/regression/ddl.sql b/extension/sql/tests/regression/ddl.sql index b35fd90d0..b388fb804 100644 --- a/extension/sql/tests/regression/ddl.sql +++ b/extension/sql/tests/regression/ddl.sql @@ -51,15 +51,15 @@ SELECT * FROM ONLY PUBLIC."Hypertable_1"; EXPLAIN SELECT * FROM ONLY PUBLIC."Hypertable_1"; \d+ PUBLIC."Hypertable_1" -\d+ "_sys_1_"."_hyper_1_root" -\d+ _sys_1_._hyper_1_1_0_1_data +\d+ "_sysinternal"."_hyper_1_root" +\d+ _sysinternal._hyper_1_1_0_1_data SELECT * FROM PUBLIC.default_replica_node; \c test2 \d+ PUBLIC."Hypertable_1" -\d+ "_sys_1_"."_hyper_1_root" +\d+ "_sysinternal"."_hyper_1_root" SELECT set_is_distinct_flag('"public"."Hypertable_1"', 'sensor_2', FALSE); SELECT set_is_distinct_flag('"public"."Hypertable_1"', 'Device_id', TRUE); @@ -88,13 +88,13 @@ ALTER TABLE PUBLIC."Hypertable_1" ADD COLUMN sensor_4 BIGINT NOT NULL DEFAULT 13 \d+ PUBLIC."Hypertable_1" -\d+ "_sys_1_"."_hyper_1_root" -SELECT * FROM _sys_1_._hyper_1_0_1_distinct_data; +\d+ "_sysinternal"."_hyper_1_root" +SELECT * FROM _sysinternal._hyper_1_0_1_distinct_data; \c Test1 \d+ PUBLIC."Hypertable_1" -\d+ "_sys_1_"."_hyper_1_root" -\d+ _sys_1_._hyper_1_1_0_1_data +\d+ "_sysinternal"."_hyper_1_root" +\d+ _sysinternal._hyper_1_1_0_1_data SELECT * FROM PUBLIC."Hypertable_1"; diff --git a/extension/sql/tests/regression/drop_hypertable.sql b/extension/sql/tests/regression/drop_hypertable.sql new file mode 100644 index 000000000..8e273f102 --- /dev/null +++ b/extension/sql/tests/regression/drop_hypertable.sql @@ -0,0 +1,23 @@ +\set ON_ERROR_STOP 1 +\o /dev/null +\ir include/insert.sql +\o +\set ECHO ALL + +\c Test1 +\d+ "_sysinternal".* + +\c test2 +SELECT * +FROM "_sysinternal"._hyper_1_0_replica; +SELECT * +FROM "_sysinternal"._hyper_1_0_distinct; + +SELECT * FROM hypertable; +DROP TABLE "testNs"; +SELECT * FROM hypertable; +\dt+ "_sysinternal".* + +\c Test1 + +\dt+ "_sysinternal".* \ No newline at end of file diff --git a/extension/sql/tests/regression/expected/cluster.out b/extension/sql/tests/regression/expected/cluster.out index cd41c7b92..cefd42eb0 100644 --- a/extension/sql/tests/regression/expected/cluster.out +++ b/extension/sql/tests/regression/expected/cluster.out @@ -54,7 +54,7 @@ CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, really_long_field_goes_on SELECT * FROM create_hypertable('"public"."testNs"', 'time', 'Device_id', hypertable_name=>'testNs'); name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes --------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 + testNs | public | testNs | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 (1 row) SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE); @@ -66,10 +66,10 @@ SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE); \c meta SELECT * FROM partition_replica; - id | partition_id | hypertable_name | replica_id | schema_name | table_name -----+--------------+-----------------+------------+---------------+------------------------ - 1 | 1 | testNs | 0 | _sys_1_testNs | _hyper_1_1_0_partition - 2 | 2 | testNs | 0 | _sys_1_testNs | _hyper_1_2_0_partition + id | partition_id | hypertable_name | replica_id | schema_name | table_name +----+--------------+-----------------+------------+--------------+------------------------ + 1 | 1 | testNs | 0 | _sysinternal | _hyper_1_1_0_partition + 2 | 2 | testNs | 0 | _sysinternal | _hyper_1_2_0_partition (2 rows) SELECT * @@ -98,21 +98,21 @@ SELECT * FROM hypertable; name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes --------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 + testNs | public | testNs | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 (1 row) SELECT * FROM hypertable_replica; - hypertable_name | replica_id | schema_name | table_name | distinct_schema_name | distinct_table_name ------------------+------------+---------------+--------------------+----------------------+--------------------- - testNs | 0 | _sys_1_testNs | _hyper_1_0_replica | _sys_1_testNs | _hyper_1_0_distinct + hypertable_name | replica_id | schema_name | table_name | distinct_schema_name | distinct_table_name +-----------------+------------+--------------+--------------------+----------------------+--------------------- + testNs | 0 | _sysinternal | _hyper_1_0_replica | _sysinternal | _hyper_1_0_distinct (1 row) SELECT * FROM distinct_replica_node; - hypertable_name | replica_id | database_name | schema_name | table_name ------------------+------------+---------------+---------------+---------------------------- - testNs | 0 | Test1 | _sys_1_testNs | _hyper_1_0_1_distinct_data + hypertable_name | replica_id | database_name | schema_name | table_name +-----------------+------------+---------------+--------------+---------------------------- + testNs | 0 | Test1 | _sysinternal | _hyper_1_0_1_distinct_data (1 row) SELECT * @@ -132,10 +132,10 @@ FROM partition; SELECT * FROM partition_replica; - id | partition_id | hypertable_name | replica_id | schema_name | table_name -----+--------------+-----------------+------------+---------------+------------------------ - 1 | 1 | testNs | 0 | _sys_1_testNs | _hyper_1_1_0_partition - 2 | 2 | testNs | 0 | _sys_1_testNs | _hyper_1_2_0_partition + id | partition_id | hypertable_name | replica_id | schema_name | table_name +----+--------------+-----------------+------------+--------------+------------------------ + 1 | 1 | testNs | 0 | _sysinternal | _hyper_1_1_0_partition + 2 | 2 | testNs | 0 | _sysinternal | _hyper_1_2_0_partition (2 rows) SELECT * @@ -147,9 +147,9 @@ FROM chunk; SELECT * FROM chunk_replica_node; - chunk_id | partition_replica_id | database_name | schema_name | table_name -----------+----------------------+---------------+---------------+--------------------- - 1 | 1 | Test1 | _sys_1_testNs | _hyper_1_1_0_1_data + chunk_id | partition_replica_id | database_name | schema_name | table_name +----------+----------------------+---------------+--------------+--------------------- + 1 | 1 | Test1 | _sysinternal | _hyper_1_1_0_1_data (1 row) SELECT * @@ -202,21 +202,21 @@ SELECT * FROM hypertable; name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes --------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - testNs | public | testNs | _sys_1_testNs | _hyper_1 | _sys_1_testNs | _hyper_1_root | _sys_1_testNs | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 + testNs | public | testNs | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 (1 row) SELECT * FROM hypertable_replica; - hypertable_name | replica_id | schema_name | table_name | distinct_schema_name | distinct_table_name ------------------+------------+---------------+--------------------+----------------------+--------------------- - testNs | 0 | _sys_1_testNs | _hyper_1_0_replica | _sys_1_testNs | _hyper_1_0_distinct + hypertable_name | replica_id | schema_name | table_name | distinct_schema_name | distinct_table_name +-----------------+------------+--------------+--------------------+----------------------+--------------------- + testNs | 0 | _sysinternal | _hyper_1_0_replica | _sysinternal | _hyper_1_0_distinct (1 row) SELECT * FROM distinct_replica_node; - hypertable_name | replica_id | database_name | schema_name | table_name ------------------+------------+---------------+---------------+---------------------------- - testNs | 0 | Test1 | _sys_1_testNs | _hyper_1_0_1_distinct_data + hypertable_name | replica_id | database_name | schema_name | table_name +-----------------+------------+---------------+--------------+---------------------------- + testNs | 0 | Test1 | _sysinternal | _hyper_1_0_1_distinct_data (1 row) SELECT * @@ -236,10 +236,10 @@ FROM partition; SELECT * FROM partition_replica; - id | partition_id | hypertable_name | replica_id | schema_name | table_name -----+--------------+-----------------+------------+---------------+------------------------ - 1 | 1 | testNs | 0 | _sys_1_testNs | _hyper_1_1_0_partition - 2 | 2 | testNs | 0 | _sys_1_testNs | _hyper_1_2_0_partition + id | partition_id | hypertable_name | replica_id | schema_name | table_name +----+--------------+-----------------+------------+--------------+------------------------ + 1 | 1 | testNs | 0 | _sysinternal | _hyper_1_1_0_partition + 2 | 2 | testNs | 0 | _sysinternal | _hyper_1_2_0_partition (2 rows) SELECT * @@ -251,9 +251,9 @@ FROM chunk; SELECT * FROM chunk_replica_node; - chunk_id | partition_replica_id | database_name | schema_name | table_name -----------+----------------------+---------------+---------------+--------------------- - 1 | 1 | Test1 | _sys_1_testNs | _hyper_1_1_0_1_data + chunk_id | partition_replica_id | database_name | schema_name | table_name +----------+----------------------+---------------+--------------+--------------------- + 1 | 1 | Test1 | _sysinternal | _hyper_1_1_0_1_data (1 row) SELECT * @@ -284,60 +284,60 @@ FROM field; test2 | postgres | ("user" 'postgres', password '') (2 rows) -\d+ "_sys_1_testNs".* -Index "_sys_1_testNs.1-testNs_Device_id_time_idx" +\d+ "_sysinternal".* +Index "_sysinternal.1-testNs_Device_id_time_idx" Column | Type | Definition | Storage -----------+--------+-------------+---------- Device_id | text | "Device_id" | extended time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) - Index "_sys_1_testNs.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" + Index "_sysinternal.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Index "_sys_1_testNs.3-testNs_temp_time_idx" + Index "_sysinternal.3-testNs_temp_time_idx" Column | Type | Definition | Storage --------+------------------+------------+--------- temp | double precision | temp | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) - Index "_sys_1_testNs.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" + Index "_sysinternal.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- time | bigint | "time" | plain really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Table "_sys_1_testNs._hyper_1_0_1_distinct_data" + Table "_sysinternal._hyper_1_0_1_distinct_data" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) -Inherits: "_sys_1_testNs"._hyper_1_0_distinct +Inherits: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_0_1_distinct_data_pkey" +Index "_sysinternal._hyper_1_0_1_distinct_data_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_0_1_distinct_data" +primary key, btree, for table "_sysinternal._hyper_1_0_1_distinct_data" - Table "_sys_1_testNs._hyper_1_0_distinct" + Table "_sysinternal._hyper_1_0_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | -Inherits: "_sys_1_testNs"._hyper_1_distinct -Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data - Table "_sys_1_testNs._hyper_1_0_replica" + Table "_sysinternal._hyper_1_0_replica" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -346,11 +346,11 @@ Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Inherits: "_sys_1_testNs"._hyper_1_root -Child tables: "_sys_1_testNs"._hyper_1_1_0_partition, - "_sys_1_testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition - Table "_sys_1_testNs._hyper_1_1_0_1_data" + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -366,9 +366,9 @@ Indexes: "4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" btree ("time" DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition - Table "_sys_1_testNs._hyper_1_1_0_partition" + Table "_sysinternal._hyper_1_1_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -379,10 +379,10 @@ Inherits: "_sys_1_testNs"._hyper_1_1_0_partition really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica -Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data - Table "_sys_1_testNs._hyper_1_2_0_partition" + Table "_sysinternal._hyper_1_2_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -393,25 +393,25 @@ Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '16384'::smallint AND get_partition_for_key("Device_id", 32768) <= '32767'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica +Inherits: _sysinternal._hyper_1_0_replica - Table "_sys_1_testNs._hyper_1_distinct" + Table "_sysinternal._hyper_1_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) -Child tables: "_sys_1_testNs"._hyper_1_0_distinct +Child tables: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_distinct_pkey" +Index "_sysinternal._hyper_1_distinct_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" +primary key, btree, for table "_sysinternal._hyper_1_distinct" - Table "_sys_1_testNs._hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -420,7 +420,7 @@ primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Child tables: "_sys_1_testNs"._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica --\d+ "_sys_1_testNs"."_sys_1_testNs_1_0_partition" --\d+ "_sys_1_testNs"."_sys_1_testNs_2_0_partition" @@ -436,60 +436,60 @@ FROM _meta.get_or_create_chunk(1, 1257894000000000000 :: BIGINT); (1 row) \c Test1 -\d+ "_sys_1_testNs".* -Index "_sys_1_testNs.1-testNs_Device_id_time_idx" +\d+ "_sysinternal".* +Index "_sysinternal.1-testNs_Device_id_time_idx" Column | Type | Definition | Storage -----------+--------+-------------+---------- Device_id | text | "Device_id" | extended time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) - Index "_sys_1_testNs.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" + Index "_sysinternal.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Index "_sys_1_testNs.3-testNs_temp_time_idx" + Index "_sysinternal.3-testNs_temp_time_idx" Column | Type | Definition | Storage --------+------------------+------------+--------- temp | double precision | temp | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) - Index "_sys_1_testNs.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" + Index "_sysinternal.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- time | bigint | "time" | plain really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Table "_sys_1_testNs._hyper_1_0_1_distinct_data" + Table "_sysinternal._hyper_1_0_1_distinct_data" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) -Inherits: "_sys_1_testNs"._hyper_1_0_distinct +Inherits: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_0_1_distinct_data_pkey" +Index "_sysinternal._hyper_1_0_1_distinct_data_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_0_1_distinct_data" +primary key, btree, for table "_sysinternal._hyper_1_0_1_distinct_data" - Table "_sys_1_testNs._hyper_1_0_distinct" + Table "_sysinternal._hyper_1_0_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | -Inherits: "_sys_1_testNs"._hyper_1_distinct -Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data - Table "_sys_1_testNs._hyper_1_0_replica" + Table "_sysinternal._hyper_1_0_replica" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -498,11 +498,11 @@ Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Inherits: "_sys_1_testNs"._hyper_1_root -Child tables: "_sys_1_testNs"._hyper_1_1_0_partition, - "_sys_1_testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition - Table "_sys_1_testNs._hyper_1_1_0_1_data" + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -518,9 +518,9 @@ Indexes: "4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" btree ("time" DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition - Table "_sys_1_testNs._hyper_1_1_0_partition" + Table "_sysinternal._hyper_1_1_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -531,10 +531,10 @@ Inherits: "_sys_1_testNs"._hyper_1_1_0_partition really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica -Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data - Table "_sys_1_testNs._hyper_1_2_0_partition" + Table "_sysinternal._hyper_1_2_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -545,25 +545,25 @@ Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '16384'::smallint AND get_partition_for_key("Device_id", 32768) <= '32767'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica +Inherits: _sysinternal._hyper_1_0_replica - Table "_sys_1_testNs._hyper_1_distinct" + Table "_sysinternal._hyper_1_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) -Child tables: "_sys_1_testNs"._hyper_1_0_distinct +Child tables: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_distinct_pkey" +Index "_sysinternal._hyper_1_distinct_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" +primary key, btree, for table "_sysinternal._hyper_1_distinct" - Table "_sys_1_testNs._hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -572,7 +572,7 @@ primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Child tables: "_sys_1_testNs"._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica \c meta SELECT _meta.close_chunk_end(1); @@ -610,60 +610,60 @@ FROM chunk; (1 row) \c Test1 -\d+ "_sys_1_testNs".* -Index "_sys_1_testNs.1-testNs_Device_id_time_idx" +\d+ "_sysinternal".* +Index "_sysinternal.1-testNs_Device_id_time_idx" Column | Type | Definition | Storage -----------+--------+-------------+---------- Device_id | text | "Device_id" | extended time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate ("Device_id" IS NOT NULL) - Index "_sys_1_testNs.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" + Index "_sysinternal.2-testNs_really_long_field_goes_on_and_on_and_on_and_on_and_o_i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Index "_sys_1_testNs.3-testNs_temp_time_idx" + Index "_sysinternal.3-testNs_temp_time_idx" Column | Type | Definition | Storage --------+------------------+------------+--------- temp | double precision | temp | plain time | bigint | "time" | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (temp IS NOT NULL) - Index "_sys_1_testNs.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" + Index "_sysinternal.4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" Column | Type | Definition | Storage -----------------------------------------------------------------+--------+-----------------------------------------------------------------+--------- time | bigint | "time" | plain really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | plain -btree, for table "_sys_1_testNs._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL) - Table "_sys_1_testNs._hyper_1_0_1_distinct_data" + Table "_sysinternal._hyper_1_0_1_distinct_data" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) -Inherits: "_sys_1_testNs"._hyper_1_0_distinct +Inherits: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_0_1_distinct_data_pkey" +Index "_sysinternal._hyper_1_0_1_distinct_data_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_0_1_distinct_data" +primary key, btree, for table "_sysinternal._hyper_1_0_1_distinct_data" - Table "_sys_1_testNs._hyper_1_0_distinct" + Table "_sysinternal._hyper_1_0_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | -Inherits: "_sys_1_testNs"._hyper_1_distinct -Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data - Table "_sys_1_testNs._hyper_1_0_replica" + Table "_sysinternal._hyper_1_0_replica" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -672,11 +672,11 @@ Child tables: "_sys_1_testNs"._hyper_1_0_1_distinct_data occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Inherits: "_sys_1_testNs"._hyper_1_root -Child tables: "_sys_1_testNs"._hyper_1_1_0_partition, - "_sys_1_testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition - Table "_sys_1_testNs._hyper_1_1_0_1_data" + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -692,9 +692,9 @@ Indexes: "4-testNs_time_really_long_field_goes_on_and_on_and_on_and_on__i" btree ("time" DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an IS NOT NULL Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition - Table "_sys_1_testNs._hyper_1_1_0_partition" + Table "_sysinternal._hyper_1_1_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -705,10 +705,10 @@ Inherits: "_sys_1_testNs"._hyper_1_1_0_partition really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica -Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data - Table "_sys_1_testNs._hyper_1_2_0_partition" + Table "_sysinternal._hyper_1_2_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -719,25 +719,25 @@ Child tables: "_sys_1_testNs"._hyper_1_1_0_1_data really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '16384'::smallint AND get_partition_for_key("Device_id", 32768) <= '32767'::smallint) -Inherits: "_sys_1_testNs"._hyper_1_0_replica +Inherits: _sysinternal._hyper_1_0_replica - Table "_sys_1_testNs._hyper_1_distinct" + Table "_sysinternal._hyper_1_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) -Child tables: "_sys_1_testNs"._hyper_1_0_distinct +Child tables: _sysinternal._hyper_1_0_distinct -Index "_sys_1_testNs._hyper_1_distinct_pkey" +Index "_sysinternal._hyper_1_distinct_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" +primary key, btree, for table "_sysinternal._hyper_1_distinct" - Table "_sys_1_testNs._hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -----------------------------------------------------------------+------------------+-----------+----------+--------------+------------- time | bigint | not null | plain | | @@ -746,5 +746,5 @@ primary key, btree, for table "_sys_1_testNs._hyper_1_distinct" occupied | boolean | | plain | | latitude | bigint | | plain | | really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_an | bigint | | plain | | -Child tables: "_sys_1_testNs"._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica diff --git a/extension/sql/tests/regression/expected/ddl.out b/extension/sql/tests/regression/expected/ddl.out index a7cd206dc..76b62c56b 100644 --- a/extension/sql/tests/regression/expected/ddl.out +++ b/extension/sql/tests/regression/expected/ddl.out @@ -38,13 +38,13 @@ CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id"); SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id'); name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes -----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 + public."Hypertable_1" | public | Hypertable_1 | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 (1 row) SELECT * FROM hypertable; name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes -----------------------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - public."Hypertable_1" | public | Hypertable_1 | _sys_1_ | _hyper_1 | _sys_1_ | _hyper_1_root | _sys_1_ | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 + public."Hypertable_1" | public | Hypertable_1 | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | time | bigint | Test1 | 1073741824 (1 row) SELECT * FROM hypertable_index; @@ -123,8 +123,8 @@ Triggers: insert_trigger AFTER INSERT ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table() modify_trigger BEFORE DELETE OR UPDATE ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table() -\d+ "_sys_1_"."_hyper_1_root" - Table "_sys_1_._hyper_1_root" +\d+ "_sysinternal"."_hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -----------+---------+--------------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -135,10 +135,10 @@ Triggers: sensor_2 | numeric | not null default 1 | main | | sensor_3 | numeric | not null default 1 | main | | sensor_4 | numeric | not null default 1 | main | | -Child tables: _sys_1_._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica -\d+ _sys_1_._hyper_1_1_0_1_data - Table "_sys_1_._hyper_1_1_0_1_data" +\d+ _sysinternal._hyper_1_1_0_1_data + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description -----------+---------+--------------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -156,7 +156,7 @@ Indexes: "4-ind_sensor_1" btree ("time", sensor_1) Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: _sys_1_._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition SELECT * FROM PUBLIC.default_replica_node; database_name | hypertable_name | replica_id @@ -187,8 +187,8 @@ Triggers: insert_trigger AFTER INSERT ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table() modify_trigger BEFORE DELETE OR UPDATE ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table() -\d+ "_sys_1_"."_hyper_1_root" - Table "_sys_1_._hyper_1_root" +\d+ "_sysinternal"."_hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -----------+---------+--------------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -199,7 +199,7 @@ Triggers: sensor_2 | numeric | not null default 1 | main | | sensor_3 | numeric | not null default 1 | main | | sensor_4 | numeric | not null default 1 | main | | -Child tables: _sys_1_._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica SELECT set_is_distinct_flag('"public"."Hypertable_1"', 'sensor_2', FALSE); set_is_distinct_flag @@ -253,8 +253,8 @@ Triggers: insert_trigger AFTER INSERT ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table() modify_trigger BEFORE DELETE OR UPDATE ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table() -\d+ "_sys_1_"."_hyper_1_root" - Table "_sys_1_._hyper_1_root" +\d+ "_sysinternal"."_hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description ------------------+---------+------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -266,9 +266,9 @@ Triggers: temp_f | integer | not null default 31 | plain | | sensor_3 | bigint | not null default 131 | plain | | sensor_4 | bigint | not null default 131 | plain | | -Child tables: _sys_1_._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica -SELECT * FROM _sys_1_._hyper_1_0_1_distinct_data; +SELECT * FROM _sysinternal._hyper_1_0_1_distinct_data; field | value -----------+------- sensor_1 | 1 @@ -296,8 +296,8 @@ Triggers: insert_trigger AFTER INSERT ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_modify_main_table() modify_trigger BEFORE DELETE OR UPDATE ON "Hypertable_1" FOR EACH STATEMENT EXECUTE PROCEDURE _sysinternal.on_unsupported_main_table() -\d+ "_sys_1_"."_hyper_1_root" - Table "_sys_1_._hyper_1_root" +\d+ "_sysinternal"."_hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description ------------------+---------+------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -309,10 +309,10 @@ Triggers: temp_f | integer | not null default 31 | plain | | sensor_3 | bigint | not null default 131 | plain | | sensor_4 | bigint | not null default 131 | plain | | -Child tables: _sys_1_._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica -\d+ _sys_1_._hyper_1_1_0_1_data - Table "_sys_1_._hyper_1_1_0_1_data" +\d+ _sysinternal._hyper_1_1_0_1_data + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description ------------------+---------+------------------------+----------+--------------+------------- time | bigint | not null | plain | | @@ -329,7 +329,7 @@ Indexes: "3-ind_humidity" btree ("time", humidity) Check constraints: "partition" CHECK (get_partition_for_key("Device_id", 32768) >= '0'::smallint AND get_partition_for_key("Device_id", 32768) <= '16383'::smallint) -Inherits: _sys_1_._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition SELECT * FROM PUBLIC."Hypertable_1"; time | Device_id | humidity | sensor_1 | sensor_2_renamed | sensor_3_renamed | temp_f | sensor_3 | sensor_4 diff --git a/extension/sql/tests/regression/expected/drop_hypertable.out b/extension/sql/tests/regression/expected/drop_hypertable.out new file mode 100644 index 000000000..b1fd22e02 --- /dev/null +++ b/extension/sql/tests/regression/expected/drop_hypertable.out @@ -0,0 +1,441 @@ +\c Test1 +\d+ "_sysinternal".* +Index "_sysinternal.1-testNs_device_id_timeCustom_idx" + Column | Type | Definition | Storage +------------+--------+--------------+---------- + device_id | text | device_id | extended + timeCustom | bigint | "timeCustom" | plain +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL) + +Index "_sysinternal.10-testNs_timeCustom_series_bool_idx" + Column | Type | Definition | Storage +-------------+---------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_bool | boolean | series_bool | plain +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL) + +Index "_sysinternal.11-testNs_device_id_timeCustom_idx" + Column | Type | Definition | Storage +------------+--------+--------------+---------- + device_id | text | device_id | extended + timeCustom | bigint | "timeCustom" | plain +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (device_id IS NOT NULL) + + Index "_sysinternal.12-testNs_timeCustom_series_0_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_0 | double precision | series_0 | plain +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_0 IS NOT NULL) + + Index "_sysinternal.13-testNs_timeCustom_series_1_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_1 | double precision | series_1 | plain +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_1 IS NOT NULL) + + Index "_sysinternal.14-testNs_timeCustom_series_2_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_2 | double precision | series_2 | plain +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_2 IS NOT NULL) + +Index "_sysinternal.15-testNs_timeCustom_series_bool_idx" + Column | Type | Definition | Storage +-------------+---------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_bool | boolean | series_bool | plain +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_bool IS NOT NULL) + + Index "_sysinternal.2-testNs_timeCustom_series_0_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_0 | double precision | series_0 | plain +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL) + + Index "_sysinternal.3-testNs_timeCustom_series_1_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_1 | double precision | series_1 | plain +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL) + + Index "_sysinternal.4-testNs_timeCustom_series_2_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_2 | double precision | series_2 | plain +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL) + +Index "_sysinternal.5-testNs_timeCustom_series_bool_idx" + Column | Type | Definition | Storage +-------------+---------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_bool | boolean | series_bool | plain +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL) + +Index "_sysinternal.6-testNs_device_id_timeCustom_idx" + Column | Type | Definition | Storage +------------+--------+--------------+---------- + device_id | text | device_id | extended + timeCustom | bigint | "timeCustom" | plain +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL) + + Index "_sysinternal.7-testNs_timeCustom_series_0_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_0 | double precision | series_0 | plain +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL) + + Index "_sysinternal.8-testNs_timeCustom_series_1_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_1 | double precision | series_1 | plain +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_1 IS NOT NULL) + + Index "_sysinternal.9-testNs_timeCustom_series_2_idx" + Column | Type | Definition | Storage +------------+------------------+--------------+--------- + timeCustom | bigint | "timeCustom" | plain + series_2 | double precision | series_2 | plain +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL) + + Table "_sysinternal._hyper_1_0_1_distinct_data" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_1_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) +Inherits: _sysinternal._hyper_1_0_distinct + +Index "_sysinternal._hyper_1_0_1_distinct_data_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_1_0_1_distinct_data" + + Table "_sysinternal._hyper_1_0_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data + + Table "_sysinternal._hyper_1_0_replica" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition + + Table "_sysinternal._hyper_1_1_0_1_data" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Indexes: + "1-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL + "2-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL + "3-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL + "4-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL + "5-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) +Inherits: _sysinternal._hyper_1_1_0_partition + + Table "_sysinternal._hyper_1_1_0_2_data" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Indexes: + "10-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL + "6-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL + "7-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL + "8-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL + "9-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) +Inherits: _sysinternal._hyper_1_1_0_partition + + Table "_sysinternal._hyper_1_1_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data, + _sysinternal._hyper_1_1_0_2_data + + Table "_sysinternal._hyper_1_2_0_3_data" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Indexes: + "11-testNs_device_id_timeCustom_idx" btree (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL + "12-testNs_timeCustom_series_0_idx" btree ("timeCustom" DESC NULLS LAST, series_0) WHERE series_0 IS NOT NULL + "13-testNs_timeCustom_series_1_idx" btree ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL + "14-testNs_timeCustom_series_2_idx" btree ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL + "15-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) +Inherits: _sysinternal._hyper_1_2_0_partition + + Table "_sysinternal._hyper_1_2_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_2_0_3_data + + Table "_sysinternal._hyper_1_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) +Child tables: _sysinternal._hyper_1_0_distinct + +Index "_sysinternal._hyper_1_distinct_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_1_distinct" + + Table "_sysinternal._hyper_1_root" + Column | Type | Modifiers | Storage | Stats target | Description +-------------+------------------+-----------+----------+--------------+------------- + timeCustom | bigint | not null | plain | | + device_id | text | not null | extended | | + series_0 | double precision | | plain | | + series_1 | double precision | | plain | | + series_2 | double precision | | plain | | + series_bool | boolean | | plain | | +Child tables: _sysinternal._hyper_1_0_replica + + Table "_sysinternal._hyper_2_0_1_distinct_data" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_2_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) +Inherits: _sysinternal._hyper_2_0_distinct + +Index "_sysinternal._hyper_2_0_1_distinct_data_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_2_0_1_distinct_data" + + Table "_sysinternal._hyper_2_0_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Inherits: _sysinternal._hyper_2_distinct +Child tables: _sysinternal._hyper_2_0_1_distinct_data + + Table "_sysinternal._hyper_2_0_replica" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Inherits: _sysinternal._hyper_2_root +Child tables: _sysinternal._hyper_2_3_0_partition, + _sysinternal._hyper_2_4_0_partition + + Table "_sysinternal._hyper_2_3_0_4_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" <= '1'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_5_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '2'::bigint AND "time" <= '2'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_6_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '3'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) +Inherits: _sysinternal._hyper_2_0_replica +Child tables: _sysinternal._hyper_2_3_0_4_data, + _sysinternal._hyper_2_3_0_5_data, + _sysinternal._hyper_2_3_0_6_data + + Table "_sysinternal._hyper_2_4_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) +Inherits: _sysinternal._hyper_2_0_replica + + Table "_sysinternal._hyper_2_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_2_distinct_pkey" PRIMARY KEY, btree (field, value) +Child tables: _sysinternal._hyper_2_0_distinct + +Index "_sysinternal._hyper_2_distinct_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_2_distinct" + + Table "_sysinternal._hyper_2_root" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Child tables: _sysinternal._hyper_2_0_replica + +\c test2 +SELECT * +FROM "_sysinternal"._hyper_1_0_replica; + timeCustom | device_id | series_0 | series_1 | series_2 | series_bool +---------------------+-----------+----------+----------+----------+------------- + 1257894000000000000 | dev1 | 1.5 | 1 | 2 | t + 1257894000000000000 | dev1 | 1.5 | 2 | | + 1257894000000001000 | dev1 | 2.5 | 3 | | + 1257894001000000000 | dev1 | 3.5 | 4 | | + 1257897600000000000 | dev1 | 4.5 | 5 | | f + 1257894002000000000 | dev1 | 2.5 | 3 | | + 1257987600000000000 | dev1 | 1.5 | 1 | | + 1257987600000000000 | dev1 | 1.5 | 2 | | + 1257894000000000000 | dev20 | 1.5 | 1 | | + 1257894000000000000 | dev20 | 1.5 | 2 | | +(10 rows) + +SELECT * +FROM "_sysinternal"._hyper_1_0_distinct; + field | value +-----------+------- + device_id | dev1 + device_id | dev20 +(2 rows) + +SELECT * FROM hypertable; + name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes +---------------------------+------------------+--------------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ + testNs | public | testNs | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | timeCustom | bigint | Test1 | 1073741824 + public.chunk_closing_test | public | chunk_closing_test | _sysinternal | _hyper_2 | _sysinternal | _hyper_2_root | _sysinternal | _hyper_2_distinct | 1 | STICKY | time | bigint | Test1 | 10000 +(2 rows) + +DROP TABLE "testNs"; +SELECT * FROM hypertable; + name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes +---------------------------+------------------+--------------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ + public.chunk_closing_test | public | chunk_closing_test | _sysinternal | _hyper_2 | _sysinternal | _hyper_2_root | _sysinternal | _hyper_2_distinct | 1 | STICKY | time | bigint | Test1 | 10000 +(1 row) + +\dt+ "_sysinternal".* + List of relations + Schema | Name | Type | Owner | Size | Description +--------------+------------------------+-------+----------+------------+------------- + _sysinternal | _hyper_2_0_distinct | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_0_replica | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_3_0_partition | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_4_0_partition | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_distinct | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_root | table | postgres | 8192 bytes | +(6 rows) + +\c Test1 +\dt+ "_sysinternal".* + List of relations + Schema | Name | Type | Owner | Size | Description +--------------+----------------------------+-------+----------+------------+------------- + _sysinternal | _hyper_2_0_1_distinct_data | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_0_distinct | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_0_replica | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_3_0_4_data | table | postgres | 16 kB | + _sysinternal | _hyper_2_3_0_5_data | table | postgres | 16 kB | + _sysinternal | _hyper_2_3_0_6_data | table | postgres | 16 kB | + _sysinternal | _hyper_2_3_0_partition | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_4_0_partition | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_distinct | table | postgres | 8192 bytes | + _sysinternal | _hyper_2_root | table | postgres | 8192 bytes | +(10 rows) + diff --git a/extension/sql/tests/regression/expected/insert.out b/extension/sql/tests/regression/expected/insert.out index 27a4ba15a..0234752dc 100644 --- a/extension/sql/tests/regression/expected/insert.out +++ b/extension/sql/tests/regression/expected/insert.out @@ -70,10 +70,10 @@ CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_0) WHERE s CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE series_1 IS NOT NULL; CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL; CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL; -SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'testNs' ); +SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'_sysinternal' ); name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes --------+------------------+-----------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - testNs | public | testNs | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | 1 | STICKY | timeCustom | bigint | Test1 | 1073741824 + testNs | public | testNs | _sysinternal | _hyper_1 | _sysinternal | _hyper_1_root | _sysinternal | _hyper_1_distinct | 1 | STICKY | timeCustom | bigint | Test1 | 1073741824 (1 row) SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE); @@ -113,7 +113,7 @@ CREATE TABLE chunk_closing_test( SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', chunk_size_bytes => 10000); name | main_schema_name | main_table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | distinct_schema_name | distinct_table_name | replication_factor | placement | time_field_name | time_field_type | created_on | chunk_size_bytes ---------------------------+------------------+--------------------+------------------------+-------------------------+------------------+-----------------+----------------------+---------------------+--------------------+-----------+-----------------+-----------------+------------+------------------ - public.chunk_closing_test | public | chunk_closing_test | _sys_2_ | _hyper_2 | _sys_2_ | _hyper_2_root | _sys_2_ | _hyper_2_distinct | 1 | STICKY | time | bigint | Test1 | 10000 + public.chunk_closing_test | public | chunk_closing_test | _sysinternal | _hyper_2 | _sysinternal | _hyper_2_root | _sysinternal | _hyper_2_distinct | 1 | STICKY | time | bigint | Test1 | 10000 (1 row) INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1'); @@ -131,145 +131,145 @@ SELECT * FROM chunk c LEFT JOIN chunk_replica_node crn ON (c.id = crn.chunk_id) LEFT JOIN partition_replica pr ON (crn.partition_replica_id = pr.id) WHERE hypertable_name = 'public.chunk_closing_test'; - id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_name | replica_id | schema_name | table_name -----+--------------+------------+----------+----------+----------------------+---------------+-------------+---------------------+----+--------------+---------------------------+------------+-------------+------------------------ - 4 | 3 | | 1 | 4 | 3 | Test1 | _sys_2_ | _hyper_2_3_0_4_data | 3 | 3 | public.chunk_closing_test | 0 | _sys_2_ | _hyper_2_3_0_partition - 5 | 3 | 2 | 2 | 5 | 3 | Test1 | _sys_2_ | _hyper_2_3_0_5_data | 3 | 3 | public.chunk_closing_test | 0 | _sys_2_ | _hyper_2_3_0_partition - 6 | 3 | 3 | | 6 | 3 | Test1 | _sys_2_ | _hyper_2_3_0_6_data | 3 | 3 | public.chunk_closing_test | 0 | _sys_2_ | _hyper_2_3_0_partition + id | partition_id | start_time | end_time | chunk_id | partition_replica_id | database_name | schema_name | table_name | id | partition_id | hypertable_name | replica_id | schema_name | table_name +----+--------------+------------+----------+----------+----------------------+---------------+--------------+---------------------+----+--------------+---------------------------+------------+--------------+------------------------ + 4 | 3 | | 1 | 4 | 3 | Test1 | _sysinternal | _hyper_2_3_0_4_data | 3 | 3 | public.chunk_closing_test | 0 | _sysinternal | _hyper_2_3_0_partition + 5 | 3 | 2 | 2 | 5 | 3 | Test1 | _sysinternal | _hyper_2_3_0_5_data | 3 | 3 | public.chunk_closing_test | 0 | _sysinternal | _hyper_2_3_0_partition + 6 | 3 | 3 | | 6 | 3 | Test1 | _sysinternal | _hyper_2_3_0_6_data | 3 | 3 | public.chunk_closing_test | 0 | _sysinternal | _hyper_2_3_0_partition (3 rows) \c Test1 -\d+ "testNs".* -Index "testNs.1-testNs_device_id_timeCustom_idx" +\d+ "_sysinternal".* +Index "_sysinternal.1-testNs_device_id_timeCustom_idx" Column | Type | Definition | Storage ------------+--------+--------------+---------- device_id | text | device_id | extended timeCustom | bigint | "timeCustom" | plain -btree, for table "testNs._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (device_id IS NOT NULL) -Index "testNs.10-testNs_timeCustom_series_bool_idx" +Index "_sysinternal.10-testNs_timeCustom_series_bool_idx" Column | Type | Definition | Storage -------------+---------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_bool | boolean | series_bool | plain -btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_bool IS NOT NULL) -Index "testNs.11-testNs_device_id_timeCustom_idx" +Index "_sysinternal.11-testNs_device_id_timeCustom_idx" Column | Type | Definition | Storage ------------+--------+--------------+---------- device_id | text | device_id | extended timeCustom | bigint | "timeCustom" | plain -btree, for table "testNs._hyper_1_2_0_3_data", predicate (device_id IS NOT NULL) +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (device_id IS NOT NULL) - Index "testNs.12-testNs_timeCustom_series_0_idx" + Index "_sysinternal.12-testNs_timeCustom_series_0_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_0 | double precision | series_0 | plain -btree, for table "testNs._hyper_1_2_0_3_data", predicate (series_0 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_0 IS NOT NULL) - Index "testNs.13-testNs_timeCustom_series_1_idx" + Index "_sysinternal.13-testNs_timeCustom_series_1_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_1 | double precision | series_1 | plain -btree, for table "testNs._hyper_1_2_0_3_data", predicate (series_1 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_1 IS NOT NULL) - Index "testNs.14-testNs_timeCustom_series_2_idx" + Index "_sysinternal.14-testNs_timeCustom_series_2_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_2 | double precision | series_2 | plain -btree, for table "testNs._hyper_1_2_0_3_data", predicate (series_2 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_2 IS NOT NULL) -Index "testNs.15-testNs_timeCustom_series_bool_idx" +Index "_sysinternal.15-testNs_timeCustom_series_bool_idx" Column | Type | Definition | Storage -------------+---------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_bool | boolean | series_bool | plain -btree, for table "testNs._hyper_1_2_0_3_data", predicate (series_bool IS NOT NULL) +btree, for table "_sysinternal._hyper_1_2_0_3_data", predicate (series_bool IS NOT NULL) - Index "testNs.2-testNs_timeCustom_series_0_idx" + Index "_sysinternal.2-testNs_timeCustom_series_0_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_0 | double precision | series_0 | plain -btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_0 IS NOT NULL) - Index "testNs.3-testNs_timeCustom_series_1_idx" + Index "_sysinternal.3-testNs_timeCustom_series_1_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_1 | double precision | series_1 | plain -btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_1 IS NOT NULL) - Index "testNs.4-testNs_timeCustom_series_2_idx" + Index "_sysinternal.4-testNs_timeCustom_series_2_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_2 | double precision | series_2 | plain -btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_2 IS NOT NULL) -Index "testNs.5-testNs_timeCustom_series_bool_idx" +Index "_sysinternal.5-testNs_timeCustom_series_bool_idx" Column | Type | Definition | Storage -------------+---------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_bool | boolean | series_bool | plain -btree, for table "testNs._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_1_data", predicate (series_bool IS NOT NULL) -Index "testNs.6-testNs_device_id_timeCustom_idx" +Index "_sysinternal.6-testNs_device_id_timeCustom_idx" Column | Type | Definition | Storage ------------+--------+--------------+---------- device_id | text | device_id | extended timeCustom | bigint | "timeCustom" | plain -btree, for table "testNs._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (device_id IS NOT NULL) - Index "testNs.7-testNs_timeCustom_series_0_idx" + Index "_sysinternal.7-testNs_timeCustom_series_0_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_0 | double precision | series_0 | plain -btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_0 IS NOT NULL) - Index "testNs.8-testNs_timeCustom_series_1_idx" + Index "_sysinternal.8-testNs_timeCustom_series_1_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_1 | double precision | series_1 | plain -btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_1 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_1 IS NOT NULL) - Index "testNs.9-testNs_timeCustom_series_2_idx" + Index "_sysinternal.9-testNs_timeCustom_series_2_idx" Column | Type | Definition | Storage ------------+------------------+--------------+--------- timeCustom | bigint | "timeCustom" | plain series_2 | double precision | series_2 | plain -btree, for table "testNs._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL) +btree, for table "_sysinternal._hyper_1_1_0_2_data", predicate (series_2 IS NOT NULL) - Table "testNs._hyper_1_0_1_distinct_data" + Table "_sysinternal._hyper_1_0_1_distinct_data" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) -Inherits: "testNs"._hyper_1_0_distinct +Inherits: _sysinternal._hyper_1_0_distinct -Index "testNs._hyper_1_0_1_distinct_data_pkey" +Index "_sysinternal._hyper_1_0_1_distinct_data_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "testNs._hyper_1_0_1_distinct_data" +primary key, btree, for table "_sysinternal._hyper_1_0_1_distinct_data" - Table "testNs._hyper_1_0_distinct" + Table "_sysinternal._hyper_1_0_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | -Inherits: "testNs"._hyper_1_distinct -Child tables: "testNs"._hyper_1_0_1_distinct_data +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data - Table "testNs._hyper_1_0_replica" + Table "_sysinternal._hyper_1_0_replica" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -278,11 +278,11 @@ Child tables: "testNs"._hyper_1_0_1_distinct_data series_1 | double precision | | plain | | series_2 | double precision | | plain | | series_bool | boolean | | plain | | -Inherits: "testNs"._hyper_1_root -Child tables: "testNs"._hyper_1_1_0_partition, - "testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition - Table "testNs._hyper_1_1_0_1_data" + Table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -300,9 +300,9 @@ Indexes: Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) "time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) -Inherits: "testNs"._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition - Table "testNs._hyper_1_1_0_2_data" + Table "_sysinternal._hyper_1_1_0_2_data" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -320,9 +320,9 @@ Indexes: Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) "time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) -Inherits: "testNs"._hyper_1_1_0_partition +Inherits: _sysinternal._hyper_1_1_0_partition - Table "testNs._hyper_1_1_0_partition" + Table "_sysinternal._hyper_1_1_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -333,11 +333,11 @@ Inherits: "testNs"._hyper_1_1_0_partition series_bool | boolean | | plain | | Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) -Inherits: "testNs"._hyper_1_0_replica -Child tables: "testNs"._hyper_1_1_0_1_data, - "testNs"._hyper_1_1_0_2_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data, + _sysinternal._hyper_1_1_0_2_data - Table "testNs._hyper_1_2_0_3_data" + Table "_sysinternal._hyper_1_2_0_3_data" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -354,9 +354,9 @@ Indexes: "15-testNs_timeCustom_series_bool_idx" btree ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) -Inherits: "testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_2_0_partition - Table "testNs._hyper_1_2_0_partition" + Table "_sysinternal._hyper_1_2_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -367,26 +367,26 @@ Inherits: "testNs"._hyper_1_2_0_partition series_bool | boolean | | plain | | Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) -Inherits: "testNs"._hyper_1_0_replica -Child tables: "testNs"._hyper_1_2_0_3_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_2_0_3_data - Table "testNs._hyper_1_distinct" + Table "_sysinternal._hyper_1_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) -Child tables: "testNs"._hyper_1_0_distinct +Child tables: _sysinternal._hyper_1_0_distinct - Index "testNs._hyper_1_distinct_pkey" +Index "_sysinternal._hyper_1_distinct_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "testNs._hyper_1_distinct" +primary key, btree, for table "_sysinternal._hyper_1_distinct" - Table "testNs._hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -395,28 +395,142 @@ primary key, btree, for table "testNs._hyper_1_distinct" series_1 | double precision | | plain | | series_2 | double precision | | plain | | series_bool | boolean | | plain | | -Child tables: "testNs"._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica -\c test2 -\d+ "testNs".* - Foreign table "testNs._hyper_1_0_1_distinct_data" + Table "_sysinternal._hyper_2_0_1_distinct_data" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_2_0_1_distinct_data_pkey" PRIMARY KEY, btree (field, value) +Inherits: _sysinternal._hyper_2_0_distinct + +Index "_sysinternal._hyper_2_0_1_distinct_data_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_2_0_1_distinct_data" + + Table "_sysinternal._hyper_2_0_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Inherits: _sysinternal._hyper_2_distinct +Child tables: _sysinternal._hyper_2_0_1_distinct_data + + Table "_sysinternal._hyper_2_0_replica" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Inherits: _sysinternal._hyper_2_root +Child tables: _sysinternal._hyper_2_3_0_partition, + _sysinternal._hyper_2_4_0_partition + + Table "_sysinternal._hyper_2_3_0_4_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" <= '1'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_5_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '2'::bigint AND "time" <= '2'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_6_data" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '3'::bigint) +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) +Inherits: _sysinternal._hyper_2_0_replica +Child tables: _sysinternal._hyper_2_3_0_4_data, + _sysinternal._hyper_2_3_0_5_data, + _sysinternal._hyper_2_3_0_6_data + + Table "_sysinternal._hyper_2_4_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) +Inherits: _sysinternal._hyper_2_0_replica + + Table "_sysinternal._hyper_2_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_2_distinct_pkey" PRIMARY KEY, btree (field, value) +Child tables: _sysinternal._hyper_2_0_distinct + +Index "_sysinternal._hyper_2_distinct_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_2_distinct" + + Table "_sysinternal._hyper_2_root" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Child tables: _sysinternal._hyper_2_0_replica + +\c test2 +\d+ "_sysinternal".* + Foreign table "_sysinternal._hyper_1_0_1_distinct_data" Column | Type | Modifiers | FDW Options | Storage | Stats target | Description --------+------+-----------+-------------+----------+--------------+------------- field | text | not null | | extended | | value | text | not null | | extended | | Server: Test1 -FDW Options: (schema_name 'testNs', table_name '_hyper_1_0_1_distinct_data') -Inherits: "testNs"._hyper_1_0_distinct +FDW Options: (schema_name '_sysinternal', table_name '_hyper_1_0_1_distinct_data') +Inherits: _sysinternal._hyper_1_0_distinct - Table "testNs._hyper_1_0_distinct" + Table "_sysinternal._hyper_1_0_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | -Inherits: "testNs"._hyper_1_distinct -Child tables: "testNs"._hyper_1_0_1_distinct_data +Inherits: _sysinternal._hyper_1_distinct +Child tables: _sysinternal._hyper_1_0_1_distinct_data - Table "testNs._hyper_1_0_replica" + Table "_sysinternal._hyper_1_0_replica" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -425,11 +539,11 @@ Child tables: "testNs"._hyper_1_0_1_distinct_data series_1 | double precision | | plain | | series_2 | double precision | | plain | | series_bool | boolean | | plain | | -Inherits: "testNs"._hyper_1_root -Child tables: "testNs"._hyper_1_1_0_partition, - "testNs"._hyper_1_2_0_partition +Inherits: _sysinternal._hyper_1_root +Child tables: _sysinternal._hyper_1_1_0_partition, + _sysinternal._hyper_1_2_0_partition - Foreign table "testNs._hyper_1_1_0_1_data" + Foreign table "_sysinternal._hyper_1_1_0_1_data" Column | Type | Modifiers | FDW Options | Storage | Stats target | Description -------------+------------------+-----------+-------------+----------+--------------+------------- timeCustom | bigint | not null | | plain | | @@ -442,10 +556,10 @@ Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) "time_range" CHECK ("timeCustom" <= '1257897600000000000'::bigint) Server: Test1 -FDW Options: (schema_name 'testNs', table_name '_hyper_1_1_0_1_data') -Inherits: "testNs"._hyper_1_1_0_partition +FDW Options: (schema_name '_sysinternal', table_name '_hyper_1_1_0_1_data') +Inherits: _sysinternal._hyper_1_1_0_partition - Foreign table "testNs._hyper_1_1_0_2_data" + Foreign table "_sysinternal._hyper_1_1_0_2_data" Column | Type | Modifiers | FDW Options | Storage | Stats target | Description -------------+------------------+-----------+-------------+----------+--------------+------------- timeCustom | bigint | not null | | plain | | @@ -458,10 +572,10 @@ Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) "time_range" CHECK ("timeCustom" >= '1257897600000000001'::bigint) Server: Test1 -FDW Options: (schema_name 'testNs', table_name '_hyper_1_1_0_2_data') -Inherits: "testNs"._hyper_1_1_0_partition +FDW Options: (schema_name '_sysinternal', table_name '_hyper_1_1_0_2_data') +Inherits: _sysinternal._hyper_1_1_0_partition - Table "testNs._hyper_1_1_0_partition" + Table "_sysinternal._hyper_1_1_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -472,11 +586,11 @@ Inherits: "testNs"._hyper_1_1_0_partition series_bool | boolean | | plain | | Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) -Inherits: "testNs"._hyper_1_0_replica -Child tables: "testNs"._hyper_1_1_0_1_data, - "testNs"._hyper_1_1_0_2_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_1_0_1_data, + _sysinternal._hyper_1_1_0_2_data - Foreign table "testNs._hyper_1_2_0_3_data" + Foreign table "_sysinternal._hyper_1_2_0_3_data" Column | Type | Modifiers | FDW Options | Storage | Stats target | Description -------------+------------------+-----------+-------------+----------+--------------+------------- timeCustom | bigint | not null | | plain | | @@ -488,10 +602,10 @@ Child tables: "testNs"._hyper_1_1_0_1_data, Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) Server: Test1 -FDW Options: (schema_name 'testNs', table_name '_hyper_1_2_0_3_data') -Inherits: "testNs"._hyper_1_2_0_partition +FDW Options: (schema_name '_sysinternal', table_name '_hyper_1_2_0_3_data') +Inherits: _sysinternal._hyper_1_2_0_partition - Table "testNs._hyper_1_2_0_partition" + Table "_sysinternal._hyper_1_2_0_partition" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -502,26 +616,26 @@ Inherits: "testNs"._hyper_1_2_0_partition series_bool | boolean | | plain | | Check constraints: "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) -Inherits: "testNs"._hyper_1_0_replica -Child tables: "testNs"._hyper_1_2_0_3_data +Inherits: _sysinternal._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_2_0_3_data - Table "testNs._hyper_1_distinct" + Table "_sysinternal._hyper_1_distinct" Column | Type | Modifiers | Storage | Stats target | Description --------+------+-----------+----------+--------------+------------- field | text | not null | extended | | value | text | not null | extended | | Indexes: "_hyper_1_distinct_pkey" PRIMARY KEY, btree (field, value) -Child tables: "testNs"._hyper_1_0_distinct +Child tables: _sysinternal._hyper_1_0_distinct - Index "testNs._hyper_1_distinct_pkey" +Index "_sysinternal._hyper_1_distinct_pkey" Column | Type | Definition | Storage --------+------+------------+---------- field | text | field | extended value | text | value | extended -primary key, btree, for table "testNs._hyper_1_distinct" +primary key, btree, for table "_sysinternal._hyper_1_distinct" - Table "testNs._hyper_1_root" + Table "_sysinternal._hyper_1_root" Column | Type | Modifiers | Storage | Stats target | Description -------------+------------------+-----------+----------+--------------+------------- timeCustom | bigint | not null | plain | | @@ -530,10 +644,123 @@ primary key, btree, for table "testNs._hyper_1_distinct" series_1 | double precision | | plain | | series_2 | double precision | | plain | | series_bool | boolean | | plain | | -Child tables: "testNs"._hyper_1_0_replica +Child tables: _sysinternal._hyper_1_0_replica + + Foreign table "_sysinternal._hyper_2_0_1_distinct_data" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +--------+------+-----------+-------------+----------+--------------+------------- + field | text | not null | | extended | | + value | text | not null | | extended | | +Server: Test1 +FDW Options: (schema_name '_sysinternal', table_name '_hyper_2_0_1_distinct_data') +Inherits: _sysinternal._hyper_2_0_distinct + + Table "_sysinternal._hyper_2_0_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Inherits: _sysinternal._hyper_2_distinct +Child tables: _sysinternal._hyper_2_0_1_distinct_data + + Table "_sysinternal._hyper_2_0_replica" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Inherits: _sysinternal._hyper_2_root +Child tables: _sysinternal._hyper_2_3_0_partition, + _sysinternal._hyper_2_4_0_partition + + Foreign table "_sysinternal._hyper_2_3_0_4_data" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +-----------+---------+-----------+-------------+----------+--------------+------------- + time | bigint | | | plain | | + metric | integer | | | plain | | + device_id | text | | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" <= '1'::bigint) +Server: Test1 +FDW Options: (schema_name '_sysinternal', table_name '_hyper_2_3_0_4_data') +Inherits: _sysinternal._hyper_2_3_0_partition + + Foreign table "_sysinternal._hyper_2_3_0_5_data" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +-----------+---------+-----------+-------------+----------+--------------+------------- + time | bigint | | | plain | | + metric | integer | | | plain | | + device_id | text | | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '2'::bigint AND "time" <= '2'::bigint) +Server: Test1 +FDW Options: (schema_name '_sysinternal', table_name '_hyper_2_3_0_5_data') +Inherits: _sysinternal._hyper_2_3_0_partition + + Foreign table "_sysinternal._hyper_2_3_0_6_data" + Column | Type | Modifiers | FDW Options | Storage | Stats target | Description +-----------+---------+-----------+-------------+----------+--------------+------------- + time | bigint | | | plain | | + metric | integer | | | plain | | + device_id | text | | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) + "time_range" CHECK ("time" >= '3'::bigint) +Server: Test1 +FDW Options: (schema_name '_sysinternal', table_name '_hyper_2_3_0_6_data') +Inherits: _sysinternal._hyper_2_3_0_partition + + Table "_sysinternal._hyper_2_3_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '0'::smallint AND get_partition_for_key(device_id, 32768) <= '16383'::smallint) +Inherits: _sysinternal._hyper_2_0_replica +Child tables: _sysinternal._hyper_2_3_0_4_data, + _sysinternal._hyper_2_3_0_5_data, + _sysinternal._hyper_2_3_0_6_data + + Table "_sysinternal._hyper_2_4_0_partition" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Check constraints: + "partition" CHECK (get_partition_for_key(device_id, 32768) >= '16384'::smallint AND get_partition_for_key(device_id, 32768) <= '32767'::smallint) +Inherits: _sysinternal._hyper_2_0_replica + + Table "_sysinternal._hyper_2_distinct" + Column | Type | Modifiers | Storage | Stats target | Description +--------+------+-----------+----------+--------------+------------- + field | text | not null | extended | | + value | text | not null | extended | | +Indexes: + "_hyper_2_distinct_pkey" PRIMARY KEY, btree (field, value) +Child tables: _sysinternal._hyper_2_0_distinct + +Index "_sysinternal._hyper_2_distinct_pkey" + Column | Type | Definition | Storage +--------+------+------------+---------- + field | text | field | extended + value | text | value | extended +primary key, btree, for table "_sysinternal._hyper_2_distinct" + + Table "_sysinternal._hyper_2_root" + Column | Type | Modifiers | Storage | Stats target | Description +-----------+---------+-----------+----------+--------------+------------- + time | bigint | | plain | | + metric | integer | | plain | | + device_id | text | | extended | | +Child tables: _sysinternal._hyper_2_0_replica SELECT * -FROM "testNs"._hyper_1_0_replica; +FROM "_sysinternal"._hyper_1_0_replica; timeCustom | device_id | series_0 | series_1 | series_2 | series_bool ---------------------+-----------+----------+----------+----------+------------- 1257894000000000000 | dev1 | 1.5 | 1 | 2 | t @@ -549,7 +776,7 @@ FROM "testNs"._hyper_1_0_replica; (10 rows) SELECT * -FROM "testNs"._hyper_1_0_distinct; +FROM "_sysinternal"._hyper_1_0_distinct; field | value -----------+------- device_id | dev1 diff --git a/extension/sql/tests/regression/expected/sql_query.out b/extension/sql/tests/regression/expected/sql_query.out index ef0ac74d8..6177eeb43 100644 --- a/extension/sql/tests/regression/expected/sql_query.out +++ b/extension/sql/tests/regression/expected/sql_query.out @@ -18,17 +18,17 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs"; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Append - -> Seq Scan on "testNs"._hyper_1_0_replica + -> Seq Scan on _sysinternal._hyper_1_0_replica Output: _hyper_1_0_replica."timeCustom", _hyper_1_0_replica.device_id, _hyper_1_0_replica.series_0, _hyper_1_0_replica.series_1, _hyper_1_0_replica.series_2, _hyper_1_0_replica.series_bool - -> Seq Scan on "testNs"._hyper_1_1_0_partition + -> Seq Scan on _sysinternal._hyper_1_1_0_partition Output: _hyper_1_1_0_partition."timeCustom", _hyper_1_1_0_partition.device_id, _hyper_1_1_0_partition.series_0, _hyper_1_1_0_partition.series_1, _hyper_1_1_0_partition.series_2, _hyper_1_1_0_partition.series_bool - -> Seq Scan on "testNs"._hyper_1_2_0_partition + -> Seq Scan on _sysinternal._hyper_1_2_0_partition Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool - -> Seq Scan on "testNs"._hyper_1_1_0_1_data + -> Seq Scan on _sysinternal._hyper_1_1_0_1_data Output: _hyper_1_1_0_1_data."timeCustom", _hyper_1_1_0_1_data.device_id, _hyper_1_1_0_1_data.series_0, _hyper_1_1_0_1_data.series_1, _hyper_1_1_0_1_data.series_2, _hyper_1_1_0_1_data.series_bool - -> Seq Scan on "testNs"._hyper_1_1_0_2_data + -> Seq Scan on _sysinternal._hyper_1_1_0_2_data Output: _hyper_1_1_0_2_data."timeCustom", _hyper_1_1_0_2_data.device_id, _hyper_1_1_0_2_data.series_0, _hyper_1_1_0_2_data.series_1, _hyper_1_1_0_2_data.series_2, _hyper_1_1_0_2_data.series_bool - -> Seq Scan on "testNs"._hyper_1_2_0_3_data + -> Seq Scan on _sysinternal._hyper_1_2_0_3_data Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool (13 rows) @@ -38,13 +38,13 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs" WHERE device_id = 'dev20' QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Append - -> Seq Scan on "testNs"._hyper_1_0_replica + -> Seq Scan on _sysinternal._hyper_1_0_replica Output: _hyper_1_0_replica."timeCustom", _hyper_1_0_replica.device_id, _hyper_1_0_replica.series_0, _hyper_1_0_replica.series_1, _hyper_1_0_replica.series_2, _hyper_1_0_replica.series_bool Filter: ((_hyper_1_0_replica.device_id = 'dev20'::text) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_0_replica.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Seq Scan on "testNs"._hyper_1_2_0_partition + -> Seq Scan on _sysinternal._hyper_1_2_0_partition Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool Filter: ((_hyper_1_2_0_partition.device_id = 'dev20'::text) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_partition.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Bitmap Heap Scan on "testNs"._hyper_1_2_0_3_data + -> Bitmap Heap Scan on _sysinternal._hyper_1_2_0_3_data Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool Recheck Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text) Filter: ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_3_data.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint) @@ -56,13 +56,13 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs" WHERE device_id = 'dev'|| QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Append - -> Seq Scan on "testNs"._hyper_1_0_replica + -> Seq Scan on _sysinternal._hyper_1_0_replica Output: _hyper_1_0_replica."timeCustom", _hyper_1_0_replica.device_id, _hyper_1_0_replica.series_0, _hyper_1_0_replica.series_1, _hyper_1_0_replica.series_2, _hyper_1_0_replica.series_bool Filter: ((_hyper_1_0_replica.device_id = 'dev20'::text) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_0_replica.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Seq Scan on "testNs"._hyper_1_2_0_partition + -> Seq Scan on _sysinternal._hyper_1_2_0_partition Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool Filter: ((_hyper_1_2_0_partition.device_id = 'dev20'::text) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_partition.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Bitmap Heap Scan on "testNs"._hyper_1_2_0_3_data + -> Bitmap Heap Scan on _sysinternal._hyper_1_2_0_3_data Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool Recheck Cond: (_hyper_1_2_0_3_data.device_id = 'dev20'::text) Filter: ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_3_data.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint) @@ -74,13 +74,13 @@ EXPLAIN (verbose ON, costs off) SELECT * FROM "testNs" WHERE 'dev'||'20' = devic QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Append - -> Seq Scan on "testNs"._hyper_1_0_replica + -> Seq Scan on _sysinternal._hyper_1_0_replica Output: _hyper_1_0_replica."timeCustom", _hyper_1_0_replica.device_id, _hyper_1_0_replica.series_0, _hyper_1_0_replica.series_1, _hyper_1_0_replica.series_2, _hyper_1_0_replica.series_bool Filter: (('dev20'::text = _hyper_1_0_replica.device_id) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_0_replica.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Seq Scan on "testNs"._hyper_1_2_0_partition + -> Seq Scan on _sysinternal._hyper_1_2_0_partition Output: _hyper_1_2_0_partition."timeCustom", _hyper_1_2_0_partition.device_id, _hyper_1_2_0_partition.series_0, _hyper_1_2_0_partition.series_1, _hyper_1_2_0_partition.series_2, _hyper_1_2_0_partition.series_bool Filter: (('dev20'::text = _hyper_1_2_0_partition.device_id) AND ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_partition.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint)) - -> Bitmap Heap Scan on "testNs"._hyper_1_2_0_3_data + -> Bitmap Heap Scan on _sysinternal._hyper_1_2_0_3_data Output: _hyper_1_2_0_3_data."timeCustom", _hyper_1_2_0_3_data.device_id, _hyper_1_2_0_3_data.series_0, _hyper_1_2_0_3_data.series_1, _hyper_1_2_0_3_data.series_2, _hyper_1_2_0_3_data.series_bool Recheck Cond: ('dev20'::text = _hyper_1_2_0_3_data.device_id) Filter: ((((_sysinternal.murmur3_hash_string(_hyper_1_2_0_3_data.device_id, 1) & 2147483647) % 32768))::smallint = '28646'::smallint) diff --git a/extension/sql/tests/regression/include/insert.sql b/extension/sql/tests/regression/include/insert.sql index e0ba7549f..dc7d7c572 100644 --- a/extension/sql/tests/regression/include/insert.sql +++ b/extension/sql/tests/regression/include/insert.sql @@ -25,7 +25,7 @@ CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_1) WHERE CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_2) WHERE series_2 IS NOT NULL; CREATE INDEX ON PUBLIC."testNs" ("timeCustom" DESC NULLS LAST, series_bool) WHERE series_bool IS NOT NULL; -SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'testNs' ); +SELECT * FROM create_hypertable('"public"."testNs"', 'timeCustom', 'device_id', hypertable_name=>'testNs', associated_schema_name=>'_sysinternal' ); SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE); diff --git a/extension/sql/tests/regression/insert.sql b/extension/sql/tests/regression/insert.sql index 514190a76..433639452 100644 --- a/extension/sql/tests/regression/insert.sql +++ b/extension/sql/tests/regression/insert.sql @@ -3,13 +3,12 @@ \set ECHO ALL \ir include/insert.sql - \c Test1 -\d+ "testNs".* +\d+ "_sysinternal".* -\c test2 -\d+ "testNs".* +\c test2 +\d+ "_sysinternal".* SELECT * -FROM "testNs"._hyper_1_0_replica; +FROM "_sysinternal"._hyper_1_0_replica; SELECT * -FROM "testNs"._hyper_1_0_distinct; +FROM "_sysinternal"._hyper_1_0_distinct; diff --git a/extension/sql/tests/regression/run.sh b/extension/sql/tests/regression/run.sh index d1d88952e..0d8073f88 100755 --- a/extension/sql/tests/regression/run.sh +++ b/extension/sql/tests/regression/run.sh @@ -16,7 +16,7 @@ golden_test() { mv actual/$2 expected/$2 else echo "ERROR: golden file doesn't match: $2" - exit 1 + exit 1 fi fi } @@ -30,4 +30,6 @@ golden_test ioql_query.sql ioql_query.out golden_test sql_query.sql sql_query.out golden_test ddl.sql ddl.out golden_test timestamp.sql timestamp.out +golden_test drop_hypertable.sql drop_hypertable.out + echo "Success" diff --git a/extension/sql/tests/unit/tests/ioql_nonexisting_test.sql b/extension/sql/tests/unit/tests/ioql_nonexisting_test.sql index 2e6b4a450..d46213dd0 100644 --- a/extension/sql/tests/unit/tests/ioql_nonexisting_test.sql +++ b/extension/sql/tests/unit/tests/ioql_nonexisting_test.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION unit_tests.test_unknown_hyper_table() +CREATE OR REPLACE FUNCTION unit_tests.test_unknown_hypertable() RETURNS test_result AS $$