| 1 |
-- predictability |
| 2 |
SET synchronous_commit = on; |
| 3 |
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); |
| 4 |
?column? |
| 5 |
---------- |
| 6 |
init |
| 7 |
(1 row) |
| 8 |
|
| 9 |
CREATE TABLE xact_test(data text); |
| 10 |
INSERT INTO xact_test VALUES ('before-test'); |
| 11 |
-- bug #13844, xids in non-decoded records need to be inspected |
| 12 |
BEGIN; |
| 13 |
-- perform operation in xact that creates and logs xid, but isn't decoded |
| 14 |
SELECT * FROM xact_test FOR UPDATE; |
| 15 |
data |
| 16 |
------------- |
| 17 |
before-test |
| 18 |
(1 row) |
| 19 |
|
| 20 |
SAVEPOINT foo; |
| 21 |
-- and now actually insert in subxact, xid is expected to be known |
| 22 |
INSERT INTO xact_test VALUES ('after-assignment'); |
| 23 |
COMMIT; |
| 24 |
-- and now show those changes |
| 25 |
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); |
| 26 |
data |
| 27 |
--------------------------------------------------------------- |
| 28 |
BEGIN |
| 29 |
table public.xact_test: INSERT: data[text]:'before-test' |
| 30 |
COMMIT |
| 31 |
BEGIN |
| 32 |
table public.xact_test: INSERT: data[text]:'after-assignment' |
| 33 |
COMMIT |
| 34 |
(6 rows) |
| 35 |
|
| 36 |
-- bug #14279, do not propagate null snapshot from subtransaction |
| 37 |
BEGIN; |
| 38 |
-- first insert |
| 39 |
INSERT INTO xact_test VALUES ('main-txn'); |
| 40 |
SAVEPOINT foo; |
| 41 |
-- now perform operation in subxact that creates and logs xid, but isn't decoded |
| 42 |
SELECT 1 FROM xact_test FOR UPDATE LIMIT 1; |
| 43 |
?column? |
| 44 |
---------- |
| 45 |
1 |
| 46 |
(1 row) |
| 47 |
|
| 48 |
COMMIT; |
| 49 |
-- and now show those changes |
| 50 |
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); |
| 51 |
data |
| 52 |
------------------------------------------------------- |
| 53 |
BEGIN |
| 54 |
table public.xact_test: INSERT: data[text]:'main-txn' |
| 55 |
COMMIT |
| 56 |
(3 rows) |
| 57 |
|
| 58 |
DROP TABLE xact_test; |
| 59 |
SELECT pg_drop_replication_slot('regression_slot'); |
| 60 |
pg_drop_replication_slot |
| 61 |
-------------------------- |
| 62 |
|
| 63 |
(1 row) |
| 64 |
|