timescaledb/test/sql/insert.sql
Erik Nordström 473d743927 Cleanup insert state on error
If an error is generated in any of the insert triggers, the insert
state kept during a batch insert might be left in an undefined state,
breaking the next insert. This patch makes sure errors are captured in
the insert triggers so that the state can be cleaned up.
2017-03-22 15:20:45 +01:00

28 lines
900 B
SQL

\set ON_ERROR_STOP 1
\set ECHO ALL
\ir include/insert_two_partitions.sql
\d+ "_timescaledb_internal".*
SELECT *
FROM "_timescaledb_internal"._hyper_1_0_replica;
SELECT * FROM _timescaledb_catalog.chunk;
SELECT * FROM _timescaledb_catalog.chunk_replica_node;
SELECT * FROM _timescaledb_catalog.partition_replica;
SELECT * FROM chunk_closing_test;
SELECT * FROM ONLY chunk_closing_test;
SELECT * FROM "testNs";
SELECT * FROM ONLY "testNs";
CREATE TABLE error_test(time timestamp, temp float8, device text NOT NULL);
SELECT create_hypertable('error_test', 'time', 'device', 2);
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:20.1 2017', 21.3, 'dev1');
\set ON_ERROR_STOP 0
-- generate insert error
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:22.3 2017', 21.1, NULL);
\set ON_ERROR_STOP 1
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:25.7 2017', 22.4, 'dev2');
SELECT * FROM error_test;