mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
config
contrib
adminpack
amcheck
auth_delay
auto_explain
bloom
btree_gin
btree_gist
citext
cube
dblink
dict_int
dict_xsyn
earthdistance
file_fdw
fuzzystrmatch
hstore
hstore_plperl
hstore_plpython
intagg
intarray
isn
jsonb_plperl
jsonb_plpython
lo
ltree
ltree_plpython
oid2name
pageinspect
passwordcheck
pg_buffercache
pg_freespacemap
pg_prewarm
pg_standby
pg_stat_statements
pg_trgm
pg_visibility
pgcrypto
pgrowlocks
pgstattuple
postgres_fdw
seg
sepgsql
spi
sslinfo
start-scripts
tablefunc
tcn
test_decoding
expected
specs
sql
binary.sql
ddl.sql
decoding_in_xact.sql
decoding_into_rel.sql
messages.sql
permissions.sql
prepared.sql
replorigin.sql
rewrite.sql
slot.sql
spill.sql
time.sql
toast.sql
truncate.sql
xact.sql
.gitignore
Makefile
logical.conf
test_decoding.c
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp
vacuumlo
xml2
Makefile
README
contrib-global.mk
doc
src
.dir-locals.el
.gitattributes
.gitignore
COPYRIGHT
GNUmakefile.in
HISTORY
Makefile
README
README.git
aclocal.m4
configure
configure.in
When adding replication origins in5aa235042
, I somehow managed to set the timestamp of decoded transactions to InvalidXLogRecptr when decoding one made without a replication origin. Fix that, and the wrong type of the new commit_time variable. This didn't trigger a regression test failure because we explicitly don't show commit timestamps in the regression tests, as they obviously are variable. Add a test that checks that a decoded commit's timestamp is within minutes of NOW() from before the commit. Reported-By: Weiping Qu Diagnosed-By: Artur Zakirov Discussion: 56D4197E.9050706@informatik.uni-kl.de, 56D42918.1010108@postgrespro.ru Backpatch: 9.5, where5aa235042
originates.
23 lines
1.0 KiB
SQL
23 lines
1.0 KiB
SQL
SET synchronous_commit = on;
|
|
|
|
CREATE TABLE test_time(data text);
|
|
|
|
-- remember the current time
|
|
SELECT set_config('test.time_before', NOW()::text, false) IS NOT NULL;
|
|
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
|
|
-- a single transaction, to get the commit time
|
|
INSERT INTO test_time(data) VALUES ('');
|
|
|
|
-- parse the commit time from the changeset
|
|
SELECT set_config('test.time_after', regexp_replace(data, '^COMMIT \(at (.*)\)$', '\1'), false) IS NOT NULL
|
|
FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-timestamp', '1')
|
|
WHERE data ~ 'COMMIT' LIMIT 1;
|
|
|
|
-- ensure commit time is sane in relation to the previous time
|
|
SELECT (time_after - time_before) <= '10 minutes'::interval, time_after >= time_before
|
|
FROM (SELECT current_setting('test.time_after')::timestamptz AS time_after, (SELECT current_setting('test.time_before')::timestamptz) AS time_before) AS d;
|
|
|
|
SELECT pg_drop_replication_slot('regression_slot');
|