Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d900e192
Commit
d900e192
authored
May 16, 2014
by
Heikki Linnakangas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test case for logical decoding of prepared transactions.
Andres Freund
parent
afd0fcbc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
1 deletion
+133
-1
contrib/test_decoding/Makefile
contrib/test_decoding/Makefile
+1
-1
contrib/test_decoding/expected/prepared.out
contrib/test_decoding/expected/prepared.out
+82
-0
contrib/test_decoding/sql/prepared.sql
contrib/test_decoding/sql/prepared.sql
+50
-0
No files found.
contrib/test_decoding/Makefile
View file @
d900e192
...
...
@@ -37,7 +37,7 @@ submake-isolation:
submake-test_decoding
:
$(MAKE)
-C
$(top_builddir)
/contrib/test_decoding
REGRESSCHECKS
=
ddl rewrite toast permissions decoding_in_xact binary
REGRESSCHECKS
=
ddl rewrite toast permissions decoding_in_xact binary
prepared
regresscheck
:
all | submake-regress submake-test_decoding
$(MKDIR_P)
regression_output
...
...
contrib/test_decoding/expected/prepared.out
0 → 100644
View file @
d900e192
-- 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)
contrib/test_decoding/sql/prepared.sql
0 → 100644
View file @
d900e192
-- 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'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment