Debian Codegraph @

contrib/test_decoding/expected/time.out

raw
1 SET synchronous_commit = on;
2 CREATE TABLE test_time(data text);
3 -- remember the current time
4 SELECT set_config('test.time_before', NOW()::text, false) IS NOT NULL;
5 ?column?
6 ----------
7 t
8 (1 row)
9
10 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
11 ?column?
12 ----------
13 init
14 (1 row)
15
16 -- a single transaction, to get the commit time
17 INSERT INTO test_time(data) VALUES ('');
18 -- parse the commit time from the changeset
19 SELECT set_config('test.time_after', regexp_replace(data, '^COMMIT \(at (.*)\)$', '\1'), false) IS NOT NULL
20 FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-timestamp', '1')
21 WHERE data ~ 'COMMIT' LIMIT 1;
22 ?column?
23 ----------
24 t
25 (1 row)
26
27 -- ensure commit time is sane in relation to the previous time
28 SELECT (time_after - time_before) <= '10 minutes'::interval, time_after >= time_before
29 FROM (SELECT current_setting('test.time_after')::timestamptz AS time_after, (SELECT current_setting('test.time_before')::timestamptz) AS time_before) AS d;
30 ?column? | ?column?
31 ----------+----------
32 t | t
33 (1 row)
34
35 SELECT pg_drop_replication_slot('regression_slot');
36 pg_drop_replication_slot
37 --------------------------
38
39 (1 row)
40