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
The regression tests for contrib/test_decoding regularly failed on postgres instances that were very slow. Either because the hardware itself was slow or because very expensive debugging options like CLOBBER_CACHE_ALWAYS were used. The reason they failed was just that some additional transactions were decoded. Analyze and vacuum, triggered by autovac. To fix just add a option to test_decoding to only display transactions in which a change was actually displayed. That's not pretty because it removes information from the tests; but better than constantly failing tests in very likely harmless ways. Backpatch to 9.4 where logical decoding was introduced. Discussion: 20140629142511.GA26930@awork2.anarazel.de
51 lines
1.5 KiB
PL/PgSQL
51 lines
1.5 KiB
PL/PgSQL
-- predictability
|
|
SET synchronous_commit = on;
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
|
|
CREATE TABLE test_prepared1(id int);
|
|
CREATE TABLE test_prepared2(id int);
|
|
|
|
-- test simple successful use of a prepared xact
|
|
BEGIN;
|
|
INSERT INTO test_prepared1 VALUES (1);
|
|
PREPARE TRANSACTION 'test_prepared#1';
|
|
COMMIT PREPARED 'test_prepared#1';
|
|
INSERT INTO test_prepared1 VALUES (2);
|
|
|
|
-- test abort of a prepared xact
|
|
BEGIN;
|
|
INSERT INTO test_prepared1 VALUES (3);
|
|
PREPARE TRANSACTION 'test_prepared#2';
|
|
ROLLBACK PREPARED 'test_prepared#2';
|
|
|
|
INSERT INTO test_prepared1 VALUES (4);
|
|
|
|
-- test prepared xact containing ddl
|
|
BEGIN;
|
|
INSERT INTO test_prepared1 VALUES (5);
|
|
ALTER TABLE test_prepared1 ADD COLUMN data text;
|
|
INSERT INTO test_prepared1 VALUES (6, 'frakbar');
|
|
PREPARE TRANSACTION 'test_prepared#3';
|
|
|
|
-- test that we decode correctly while an uncommitted prepared xact
|
|
-- with ddl exists.
|
|
|
|
-- separate table because of the lock from the ALTER
|
|
-- this will come before the '5' row above, as this commits before it.
|
|
INSERT INTO test_prepared2 VALUES (7);
|
|
|
|
COMMIT PREPARED 'test_prepared#3';
|
|
|
|
-- make sure stuff still works
|
|
INSERT INTO test_prepared1 VALUES (8);
|
|
INSERT INTO test_prepared2 VALUES (9);
|
|
|
|
-- cleanup
|
|
DROP TABLE test_prepared1;
|
|
DROP TABLE test_prepared2;
|
|
|
|
-- show results
|
|
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
|
|
|
SELECT pg_drop_replication_slot('regression_slot');
|