PostgreSQL
Check-in [96f4eeef2c]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:96f4eeef2c2c8ae14a25acdb313100c8087fa871
Date: 2014-05-16 08:34:50
User: heikki.linnakangas@iki.fi
Comment:Add test case for logical decoding of prepared transactions. Andres Freund
Tags And Properties
Context
2014-05-16
19:11
[d05b3130ac] Fix valgrind warning for btree_gist indexes on macaddr. The macaddr opclass stores two macaddr structs (each of size 6) in an index column that's declared as being of type gbtreekey16, ie 16 bytes. I... (user: tgl@sss.pgh.pa.us, tags: trunk, WIN32_DEV, REL9_0_ALPHA4_BRANCH)
08:34
[96f4eeef2c] Add test case for logical decoding of prepared transactions. Andres Freund (user: heikki.linnakangas@iki.fi, tags: trunk, WIN32_DEV, REL9_0_ALPHA4_BRANCH)
08:34
[21141da95f] Fix test_decoding test case's check that slot has been dropped. pg_stat_replication shows connected replication clients. The ddl test case never has any replication clients connected, so querying pg_... (user: heikki.linnakangas@iki.fi, tags: trunk, WIN32_DEV, REL9_0_ALPHA4_BRANCH)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to contrib/test_decoding/Makefile

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

submake-isolation:
	$(MAKE) -C $(top_builddir)/src/test/isolation all

submake-test_decoding:
	$(MAKE) -C $(top_builddir)/contrib/test_decoding

REGRESSCHECKS=ddl rewrite toast permissions decoding_in_xact binary

regresscheck: all | submake-regress submake-test_decoding
	$(MKDIR_P) regression_output
	$(pg_regress_check) \
	    --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf \
	    --temp-install=./tmp_check \
	    --extra-install=contrib/test_decoding \







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

submake-isolation:
	$(MAKE) -C $(top_builddir)/src/test/isolation all

submake-test_decoding:
	$(MAKE) -C $(top_builddir)/contrib/test_decoding

REGRESSCHECKS=ddl rewrite toast permissions decoding_in_xact binary prepared

regresscheck: all | submake-regress submake-test_decoding
	$(MKDIR_P) regression_output
	$(pg_regress_check) \
	    --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf \
	    --temp-install=./tmp_check \
	    --extra-install=contrib/test_decoding \

Added contrib/test_decoding/expected/prepared.out





































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- predictability
SET synchronous_commit = on;
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
 ?column? 
----------
 init
(1 row)

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');
                                  data                                   
-------------------------------------------------------------------------
 BEGIN
 COMMIT
 BEGIN
 COMMIT
 BEGIN
 table public.test_prepared1: INSERT: id[integer]:1
 COMMIT
 BEGIN
 table public.test_prepared1: INSERT: id[integer]:2
 COMMIT
 BEGIN
 table public.test_prepared1: INSERT: id[integer]:4
 COMMIT
 BEGIN
 table public.test_prepared2: INSERT: id[integer]:7
 COMMIT
 BEGIN
 table public.test_prepared1: INSERT: id[integer]:5
 table public.test_prepared1: INSERT: id[integer]:6 data[text]:'frakbar'
 COMMIT
 BEGIN
 table public.test_prepared1: INSERT: id[integer]:8 data[text]:null
 COMMIT
 BEGIN
 table public.test_prepared2: INSERT: id[integer]:9
 COMMIT
 BEGIN
 COMMIT
 BEGIN
 COMMIT
(30 rows)

SELECT pg_drop_replication_slot('regression_slot');
 pg_drop_replication_slot 
--------------------------
 
(1 row)

Added contrib/test_decoding/sql/prepared.sql





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- 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');

SELECT pg_drop_replication_slot('regression_slot');