mirror of
https://github.com/postgres/postgres.git
synced 2025-05-29 16:21:20 +03:00
Fix timestamp range handling in regression tests of modules/commit_ts/
Switching the regression tests to use tstzrange() has proved to not be a good idea for environments where the timestamp precision is low, as internal range checks exclude the upper bound. So, if the commit timestamp of a transaction matched with now() from the next query, the test would fail. This changes to use two bound checks instead of the range function, where the upper bound is inclusive. Per buildfarm member jacana. Discussion: https://postgr.es/m/20200712122507.GD21680@paquier.xyz
This commit is contained in:
parent
ea3e15d169
commit
5bfe6a3c48
@ -40,12 +40,13 @@ SELECT pg_xact_commit_timestamp('2'::xid);
|
||||
(1 row)
|
||||
|
||||
SELECT x.xid::text::bigint > 0 as xid_valid,
|
||||
x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
xid_valid | ts_in_range | valid_roident
|
||||
-----------+-------------+---------------
|
||||
t | t | f
|
||||
xid_valid | ts_low | ts_high | valid_roident
|
||||
-----------+--------+---------+---------------
|
||||
t | t | t | f
|
||||
(1 row)
|
||||
|
||||
-- Test non-normal transaction ids.
|
||||
@ -71,20 +72,22 @@ SELECT * FROM pg_xact_commit_timestamp_origin('2'::xid); -- ok, NULL
|
||||
|
||||
-- Test transaction without replication origin
|
||||
SELECT txid_current() as txid_no_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
ts_in_range | valid_roident
|
||||
-------------+---------------
|
||||
t | f
|
||||
ts_low | ts_high | valid_roident
|
||||
--------+---------+---------------
|
||||
t | t | f
|
||||
(1 row)
|
||||
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_no_origin') x;
|
||||
ts_in_range | valid_roident
|
||||
-------------+---------------
|
||||
t | f
|
||||
ts_low | ts_high | valid_roident
|
||||
--------+---------+---------------
|
||||
t | t | f
|
||||
(1 row)
|
||||
|
||||
-- Test transaction with replication origin
|
||||
@ -102,20 +105,24 @@ SELECT pg_replication_origin_session_setup('regress_commit_ts: get_origin');
|
||||
(1 row)
|
||||
|
||||
SELECT txid_current() as txid_with_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_last_committed_xact() x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
ts_in_range | roname
|
||||
-------------+-------------------------------
|
||||
t | regress_commit_ts: get_origin
|
||||
ts_low | ts_high | roname
|
||||
--------+---------+-------------------------------
|
||||
t | t | regress_commit_ts: get_origin
|
||||
(1 row)
|
||||
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_with_origin') x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
ts_in_range | roname
|
||||
-------------+-------------------------------
|
||||
t | regress_commit_ts: get_origin
|
||||
ts_low | ts_high | roname
|
||||
--------+---------+-------------------------------
|
||||
t | t | regress_commit_ts: get_origin
|
||||
(1 row)
|
||||
|
||||
SELECT pg_replication_origin_session_reset();
|
||||
|
@ -35,7 +35,8 @@ SELECT pg_xact_commit_timestamp('2'::xid);
|
||||
(1 row)
|
||||
|
||||
SELECT x.xid::text::bigint > 0 as xid_valid,
|
||||
x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
ERROR: could not get commit timestamp data
|
||||
@ -63,12 +64,14 @@ SELECT * FROM pg_xact_commit_timestamp_origin('2'::xid); -- ok, NULL
|
||||
|
||||
-- Test transaction without replication origin
|
||||
SELECT txid_current() as txid_no_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
ERROR: could not get commit timestamp data
|
||||
HINT: Make sure the configuration parameter "track_commit_timestamp" is set.
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_no_origin') x;
|
||||
ERROR: could not get commit timestamp data
|
||||
@ -88,12 +91,16 @@ SELECT pg_replication_origin_session_setup('regress_commit_ts: get_origin');
|
||||
(1 row)
|
||||
|
||||
SELECT txid_current() as txid_with_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_last_committed_xact() x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
ERROR: could not get commit timestamp data
|
||||
HINT: Make sure the configuration parameter "track_commit_timestamp" is set.
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_with_origin') x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
ERROR: could not get commit timestamp data
|
||||
|
@ -22,7 +22,8 @@ SELECT pg_xact_commit_timestamp('1'::xid);
|
||||
SELECT pg_xact_commit_timestamp('2'::xid);
|
||||
|
||||
SELECT x.xid::text::bigint > 0 as xid_valid,
|
||||
x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
|
||||
@ -34,10 +35,12 @@ SELECT * FROM pg_xact_commit_timestamp_origin('2'::xid); -- ok, NULL
|
||||
|
||||
-- Test transaction without replication origin
|
||||
SELECT txid_current() as txid_no_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_last_committed_xact() x;
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range,
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
roident != 0 AS valid_roident
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_no_origin') x;
|
||||
|
||||
@ -46,10 +49,14 @@ SELECT pg_replication_origin_create('regress_commit_ts: get_origin') != 0
|
||||
AS valid_roident;
|
||||
SELECT pg_replication_origin_session_setup('regress_commit_ts: get_origin');
|
||||
SELECT txid_current() as txid_with_origin \gset
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_last_committed_xact() x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
SELECT x.timestamp <@ tstzrange('-infinity'::timestamptz, now()) AS ts_in_range, r.roname
|
||||
SELECT x.timestamp > '-infinity'::timestamptz AS ts_low,
|
||||
x.timestamp <= now() AS ts_high,
|
||||
r.roname
|
||||
FROM pg_xact_commit_timestamp_origin(:'txid_with_origin') x, pg_replication_origin r
|
||||
WHERE r.roident = x.roident;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user