mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
The functions for adding and updating dimensions have been refactored in C to: - improve usage of proper error codes - make messages that better conform with the PostgreSQL standard. - improve security by avoiding that lots of code run under SECURITY DEFINER A new if_not_exists option has also been added to add_dimension() and a the number of partitions can now be set using the new set_number_partitions() function. A bug in the validation of smallint time intervals has been fixed. The previous code didn't check for intervals > 0 and smallint intervals accepted values up to UINT16_MAX instead of INT16_MAX.
32 lines
1.6 KiB
SQL
32 lines
1.6 KiB
SQL
CREATE TABLE PUBLIC."Hypertable_1" (
|
|
time BIGINT NOT NULL,
|
|
"Device_id" TEXT NOT NULL,
|
|
temp_c int NOT NULL DEFAULT -1
|
|
);
|
|
CREATE INDEX ON PUBLIC."Hypertable_1" (time, "Device_id");
|
|
|
|
\set ON_ERROR_STOP 0
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1_mispelled"', 'time', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time_mispelled', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'Device_id', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id_mispelled', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
|
|
INSERT INTO PUBLIC."Hypertable_1" VALUES(1,'dev_1', 3);
|
|
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
|
|
DELETE FROM PUBLIC."Hypertable_1" ;
|
|
\set ON_ERROR_STOP 1
|
|
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
|
|
\set ON_ERROR_STOP 0
|
|
SELECT * FROM create_hypertable('"public"."Hypertable_1"', 'time', 'Device_id', 2, chunk_time_interval=>_timescaledb_internal.interval_to_usec('1 month'));
|
|
\set ON_ERROR_STOP 1
|
|
|
|
INSERT INTO "Hypertable_1" VALUES (0, 1, 0);
|
|
|
|
\set ON_ERROR_STOP 0
|
|
ALTER TABLE _timescaledb_internal._hyper_1_1_chunk ALTER COLUMN temp_c DROP NOT NULL;
|
|
\set ON_ERROR_STOP 1
|