mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 19:13:16 +08:00
Rename add_hypertable() -> create_hypertable()
This commit is contained in:
parent
38f0468faf
commit
a27f71b614
@ -10,7 +10,7 @@
|
||||
-- associated_schema_name - (Optional) Schema for internal hypertable tables
|
||||
-- associated_table_prefix - (Optional) Prefix for internal hypertable table names
|
||||
-- hypertable_name - (Optional) Name for the hypertable, if different than the main table name
|
||||
CREATE OR REPLACE FUNCTION add_hypertable(
|
||||
CREATE OR REPLACE FUNCTION create_hypertable(
|
||||
main_table REGCLASS,
|
||||
time_field_name NAME,
|
||||
partitioning_field NAME,
|
||||
@ -48,7 +48,7 @@ BEGIN
|
||||
INTO hypertable_row
|
||||
FROM dblink(
|
||||
conn_name,
|
||||
format('SELECT t FROM _meta.add_hypertable(%L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L) t ',
|
||||
format('SELECT t FROM _meta.create_hypertable(%L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L, %L) t ',
|
||||
schema_name,
|
||||
table_name,
|
||||
time_field_name,
|
||||
|
@ -1,7 +1,7 @@
|
||||
CREATE SEQUENCE IF NOT EXISTS default_hypertable_seq;
|
||||
|
||||
-- Creates a hypertable.
|
||||
CREATE OR REPLACE FUNCTION _meta.add_hypertable(
|
||||
CREATE OR REPLACE FUNCTION _meta.create_hypertable(
|
||||
main_schema_name NAME,
|
||||
main_table_name NAME,
|
||||
time_field_name NAME,
|
||||
|
@ -28,7 +28,7 @@ CREATE INDEX ON PUBLIC."testNs" (really_long_field_goes_on_and_on_and_on_and_on_
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on IS NOT NULL;
|
||||
|
||||
|
||||
SELECT * FROM add_hypertable('"public"."testNs"', 'time', 'Device_id', hypertable_name=>'testNs');
|
||||
SELECT * FROM create_hypertable('"public"."testNs"', 'time', 'Device_id', hypertable_name=>'testNs');
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'Device_id', TRUE);
|
||||
|
||||
\c meta
|
||||
|
@ -27,7 +27,7 @@ CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
||||
|
||||
SELECT * FROM add_hypertable('"public"."Hypertable_1"', 'time', 'Device_id');
|
||||
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id');
|
||||
SELECT * FROM hypertable;
|
||||
SELECT * FROM hypertable_index;
|
||||
|
||||
|
@ -51,7 +51,7 @@ CREATE INDEX ON PUBLIC."testNs" ("Device_id", time DESC NULLS LAST) WHERE "Devic
|
||||
CREATE INDEX ON PUBLIC."testNs" (temp, time DESC NULLS LAST) WHERE temp IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" (really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on, time DESC NULLS LAST) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on IS NOT NULL;
|
||||
CREATE INDEX ON PUBLIC."testNs" (time DESC NULLS LAST, really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on) WHERE really_long_field_goes_on_and_on_and_on_and_on_and_on_and_on_and_on_and_on IS NOT NULL;
|
||||
SELECT * FROM add_hypertable('"public"."testNs"', 'time', 'Device_id', hypertable_name=>'testNs');
|
||||
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
|
||||
|
@ -35,7 +35,7 @@ CREATE TABLE PUBLIC."Hypertable_1" (
|
||||
sensor_4 NUMERIC NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
||||
SELECT * FROM add_hypertable('"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
|
||||
|
@ -70,7 +70,7 @@ 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 add_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=>'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 | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | 1 | STICKY | timeCustom | bigint | Test1 | 1073741824
|
||||
@ -110,7 +110,7 @@ CREATE TABLE chunk_closing_test(
|
||||
device_id TEXT
|
||||
);
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM add_hypertable('chunk_closing_test', 'time', 'device_id', chunk_size_bytes => 10000);
|
||||
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
|
||||
|
@ -33,7 +33,7 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
SELECT * FROM add_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=>'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 | testNs | _hyper_1 | testNs | _hyper_1_root | testNs | _hyper_1_distinct | 1 | STICKY | timeCustom | timestamp without time zone | Test1 | 1073741824
|
||||
|
@ -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 add_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=>'testNs' );
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
||||
|
||||
@ -58,7 +58,7 @@ CREATE TABLE chunk_closing_test(
|
||||
);
|
||||
|
||||
-- Test chunk closing/creation
|
||||
SELECT * FROM add_hypertable('chunk_closing_test', 'time', 'device_id', chunk_size_bytes => 10000);
|
||||
SELECT * FROM create_hypertable('chunk_closing_test', 'time', 'device_id', chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_closing_test VALUES(1, 1, 'dev1');
|
||||
INSERT INTO chunk_closing_test VALUES(2, 2, 'dev2');
|
||||
INSERT INTO chunk_closing_test VALUES(3, 3, 'dev3');
|
||||
|
@ -23,7 +23,7 @@ CREATE TABLE PUBLIC."testNs" (
|
||||
series_bool BOOLEAN NULL
|
||||
);
|
||||
CREATE INDEX ON PUBLIC."testNs" (device_id, "timeCustom" DESC NULLS LAST) WHERE device_id IS NOT NULL;
|
||||
SELECT * FROM add_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=>'testNs' );
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."testNs"', 'device_id', TRUE);
|
||||
|
||||
|
@ -36,7 +36,7 @@ CREATE INDEX ON PUBLIC."$NAMESPACE" (time, device_id);
|
||||
CREATE INDEX ON PUBLIC."$NAMESPACE" (device_id, time);
|
||||
CREATE INDEX ON PUBLIC."$NAMESPACE" ("nUm_1", time);
|
||||
|
||||
SELECT * FROM add_hypertable('"public"."$NAMESPACE"', 'time', 'device_id', hypertable_name=>'$NAMESPACE');
|
||||
SELECT * FROM create_hypertable('"public"."$NAMESPACE"', 'time', 'device_id', hypertable_name=>'$NAMESPACE');
|
||||
|
||||
SELECT set_is_distinct_flag('"public"."$NAMESPACE"', 'device_id', TRUE);
|
||||
SELECT set_is_distinct_flag('"public"."$NAMESPACE"', 'string_1', TRUE);
|
||||
|
@ -9,5 +9,5 @@ CREATE TABLE "public"."chunk_test"(
|
||||
device_id TEXT
|
||||
);
|
||||
|
||||
SELECT * FROM add_hypertable('"public"."chunk_test"', 'time', 'device_id', chunk_size_bytes => 10000);
|
||||
SELECT * FROM create_hypertable('"public"."chunk_test"', 'time', 'device_id', chunk_size_bytes => 10000);
|
||||
INSERT INTO chunk_test VALUES(1, 1, 'dev1');
|
||||
|
@ -25,6 +25,6 @@ CREATE TABLE test_hypertable (
|
||||
CREATE INDEX ON test_hypertable (time DESC NULLS LAST, device_id);
|
||||
CREATE INDEX ON test_hypertable (time DESC NULLS LAST, temp);
|
||||
|
||||
SELECT * FROM add_hypertable('"test_hypertable"', 'time', 'device_id');
|
||||
SELECT * FROM create_hypertable('"test_hypertable"', 'time', 'device_id');
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user