Skip to content

Commit

Permalink
Stabilize timestamp_limits test output
Browse files Browse the repository at this point in the history
Remove the chunk name completely from output as the name might have
different length leading to different output as table headers are
adjusted to the length of the field values.
  • Loading branch information
svenklemm committed Jun 23, 2021
1 parent 77e8f01 commit 41261e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
40 changes: 14 additions & 26 deletions tsl/test/shared/expected/timestamp_limits.out
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,13 @@ NOTICE: adding not-null constraint to column "time"
table_name | smallint_table

INSERT INTO smallint_table VALUES (-32768), (32767);
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('smallint_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
-[ RECORD 1 ]--------+-----------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+--------------------------------------
pg_get_constraintdef | CHECK (("time" < '-32760'::smallint))
-[ RECORD 2 ]--------+-----------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
-[ RECORD 2 ]--------+--------------------------------------
pg_get_constraintdef | CHECK (("time" >= '32760'::smallint))

CREATE TABLE int_table(time int);
Expand All @@ -127,15 +125,13 @@ NOTICE: adding not-null constraint to column "time"
table_name | int_table

INSERT INTO int_table VALUES (-2147483648), (2147483647);
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('int_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" < '-2147483640'::integer))
-[ RECORD 2 ]--------+------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" >= 2147483640))

CREATE TABLE bigint_table(time bigint);
Expand All @@ -145,15 +141,13 @@ NOTICE: adding not-null constraint to column "time"
table_name | bigint_table

INSERT INTO bigint_table VALUES (-9223372036854775808), (9223372036854775807);
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('bigint_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+--------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" < '-9223372036854775800'::bigint))
-[ RECORD 2 ]--------+--------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" >= '9223372036854775800'::bigint))

CREATE TABLE date_table(time date);
Expand All @@ -170,15 +164,13 @@ ERROR: timestamp out of range
INSERT INTO date_table VALUES (test.end_ts_date());
ERROR: timestamp out of range
\set ON_ERROR_STOP 1
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('date_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+-----------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" < '4714-11-27 BC'::date))
-[ RECORD 2 ]--------+-----------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" >= '294246-12-31'::date))

CREATE TABLE timestamp_table(time timestamp);
Expand All @@ -196,15 +188,13 @@ ERROR: timestamp out of range
INSERT INTO timestamp_table VALUES (test.end_ts_timestamp());
ERROR: timestamp out of range
\set ON_ERROR_STOP 1
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('timestamp_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+-------------------------------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" < '4714-11-27 00:00:00 BC'::timestamp without time zone))
-[ RECORD 2 ]--------+-------------------------------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" >= '294246-12-31 00:00:00'::timestamp without time zone))

CREATE TABLE timestamptz_table(time timestamp);
Expand All @@ -223,15 +213,13 @@ ERROR: timestamp out of range
INSERT INTO timestamptz_table VALUES (test.end_ts_timestamptz());
ERROR: timestamp out of range
\set ON_ERROR_STOP 1
SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('timestamptz_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;
-[ RECORD 1 ]--------+-------------------------------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" < '4714-11-27 00:00:00 BC'::timestamp without time zone))
-[ RECORD 2 ]--------+-------------------------------------------------------------------------
chunk | _timescaledb_internal._hyper_X_X_chunk
pg_get_constraintdef | CHECK (("time" >= '294246-12-31 00:00:00'::timestamp without time zone))

RESET datestyle;
Expand Down
24 changes: 12 additions & 12 deletions tsl/test/shared/sql/timestamp_limits.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,28 @@ CREATE TABLE smallint_table(time smallint);
SELECT table_name FROM create_hypertable('smallint_table', 'time', chunk_time_interval=>10);
INSERT INTO smallint_table VALUES (-32768), (32767);

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('smallint_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

CREATE TABLE int_table(time int);
SELECT table_name FROM create_hypertable('int_table', 'time', chunk_time_interval=>10);
INSERT INTO int_table VALUES (-2147483648), (2147483647);

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('int_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

CREATE TABLE bigint_table(time bigint);
SELECT table_name FROM create_hypertable('bigint_table', 'time', chunk_time_interval=>10);
INSERT INTO bigint_table VALUES (-9223372036854775808), (9223372036854775807);

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('bigint_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

CREATE TABLE date_table(time date);
SELECT table_name FROM create_hypertable('date_table', 'time');
Expand All @@ -138,10 +138,10 @@ INSERT INTO date_table VALUES (test.min_ts_date() - INTERVAL '1 day');
INSERT INTO date_table VALUES (test.end_ts_date());
\set ON_ERROR_STOP 1

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('date_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

CREATE TABLE timestamp_table(time timestamp);
SELECT table_name FROM create_hypertable('timestamp_table', 'time');
Expand All @@ -155,10 +155,10 @@ INSERT INTO timestamp_table VALUES (test.min_ts_timestamp() - INTERVAL '1 micros
INSERT INTO timestamp_table VALUES (test.end_ts_timestamp());
\set ON_ERROR_STOP 1

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('timestamp_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

CREATE TABLE timestamptz_table(time timestamp);
SELECT table_name FROM create_hypertable('timestamptz_table', 'time');
Expand All @@ -173,10 +173,10 @@ INSERT INTO timestamptz_table VALUES (test.min_ts_timestamptz() - INTERVAL '1 mi
INSERT INTO timestamptz_table VALUES (test.end_ts_timestamptz());
\set ON_ERROR_STOP 1

SELECT chunk, pg_get_constraintdef(c.oid)
SELECT pg_get_constraintdef(c.oid)
FROM show_chunks('timestamptz_table') chunk, pg_constraint c
WHERE c.conrelid = chunk
AND c.contype = 'c' ORDER BY 1;
AND c.contype = 'c' ORDER BY chunk;

RESET datestyle;
RESET timezone;

0 comments on commit 41261e4

Please sign in to comment.