mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 19:13:16 +08:00
The extension now works with PostgreSQL 10, while retaining compatibility with version 9.6. PostgreSQL 10 has numerous internal changes to functions and APIs, which necessitates various glue code and compatibility wrappers to seamlessly retain backwards compatiblity with older versions. Test output might also differ between versions. In particular, the psql client generates version-specific output with `\d` and EXPLAINs might differ due to new query optimizations. The test suite has been modified as follows to handle these issues. First, tests now use version-independent functions to query system catalogs instead of using `\d`. Second, changes have been made to the test suite to be able to verify some test outputs against version-dependent reference files.
62 lines
1.7 KiB
PL/PgSQL
62 lines
1.7 KiB
PL/PgSQL
\o /dev/null
|
|
\ir include/insert_two_partitions.sql
|
|
\o
|
|
|
|
SELECT * FROM _timescaledb_catalog.hypertable;
|
|
SELECT * FROM _timescaledb_catalog.chunk;
|
|
SELECT * FROM test.show_subtables('"two_Partitions"');
|
|
SELECT * FROM "two_Partitions";
|
|
|
|
SET client_min_messages = WARNING;
|
|
TRUNCATE "two_Partitions";
|
|
|
|
SELECT * FROM _timescaledb_catalog.hypertable;
|
|
SELECT * FROM _timescaledb_catalog.chunk;
|
|
|
|
-- should be empty
|
|
SELECT * FROM test.show_subtables('"two_Partitions"');
|
|
SELECT * FROM "two_Partitions";
|
|
|
|
INSERT INTO public."two_Partitions"("timeCustom", device_id, series_0, series_1) VALUES
|
|
(1257987600000000000, 'dev1', 1.5, 1),
|
|
(1257987600000000000, 'dev1', 1.5, 2),
|
|
(1257894000000000000, 'dev2', 1.5, 1),
|
|
(1257894002000000000, 'dev1', 2.5, 3);
|
|
|
|
SELECT * FROM _timescaledb_catalog.chunk;
|
|
|
|
CREATE VIEW dependent_view AS SELECT * FROM _timescaledb_internal._hyper_1_5_chunk;
|
|
|
|
CREATE OR REPLACE FUNCTION test_trigger()
|
|
RETURNS TRIGGER LANGUAGE PLPGSQL AS
|
|
$BODY$
|
|
DECLARE
|
|
cnt INTEGER;
|
|
BEGIN
|
|
RAISE WARNING 'FIRING trigger when: % level: % op: % cnt: % trigger_name %',
|
|
tg_when, tg_level, tg_op, cnt, tg_name;
|
|
IF TG_OP = 'DELETE' THEN
|
|
RETURN OLD;
|
|
END IF;
|
|
RETURN NEW;
|
|
END
|
|
$BODY$;
|
|
|
|
-- test truncate on a chunk
|
|
CREATE TRIGGER _test_truncate_before
|
|
BEFORE TRUNCATE ON _timescaledb_internal._hyper_1_5_chunk
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE test_trigger();
|
|
|
|
CREATE TRIGGER _test_truncate_after
|
|
AFTER TRUNCATE ON _timescaledb_internal._hyper_1_5_chunk
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE test_trigger();
|
|
|
|
\set ON_ERROR_STOP 0
|
|
TRUNCATE "two_Partitions";
|
|
\set ON_ERROR_STOP 1
|
|
|
|
TRUNCATE "two_Partitions" CASCADE;
|
|
-- should be empty
|
|
SELECT * FROM test.show_subtables('"two_Partitions"');
|
|
SELECT * FROM "two_Partitions";
|