forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This new feature let users select actions they want to receive. Actions supported are insert, update, delete, and truncate. This actions are similar to PUBLICATION command. Format version 1 won't enable truncate by default (to maintain backward compatibility). Format version 2 will enable all options by default. A new test was added (run only on Postgres v11 or later). That's because test includes truncate and it will only supported by v11 or later.
- Loading branch information
Euler Taveira
committed
Dec 20, 2019
1 parent
b93fb62
commit aa431a9
Showing
5 changed files
with
287 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
\set VERBOSITY terse | ||
-- predictability | ||
SET synchronous_commit = on; | ||
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); | ||
?column? | ||
---------- | ||
init | ||
(1 row) | ||
|
||
-- actions | ||
CREATE TABLE actions (a integer primary key); | ||
INSERT INTO actions (a) VALUES(1); | ||
UPDATE actions SET a = 2 WHERE a = 1; | ||
DELETE FROM actions WHERE a = 2; | ||
TRUNCATE TABLE actions; | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert, foo, delete'); | ||
ERROR: could not parse value "foo" for parameter "actions" | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); | ||
data | ||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"change":[]} | ||
{"change":[{"kind":"insert","schema":"public","table":"actions","columnnames":["a"],"columntypes":["integer"],"columnvalues":[1]}]} | ||
{"change":[{"kind":"update","schema":"public","table":"actions","columnnames":["a"],"columntypes":["integer"],"columnvalues":[2],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} | ||
{"change":[{"kind":"delete","schema":"public","table":"actions","oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[2]}}]} | ||
{"change":[]} | ||
(5 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); | ||
data | ||
------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"I","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":1}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"D","schema":"public","table":"actions","identity":[{"name":"a","type":"integer","value":2}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"T","schema":"public","table":"actions"} | ||
{"action":"C"} | ||
(14 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert'); | ||
data | ||
-------------------------------------------------------------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"I","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":1}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
(11 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update'); | ||
data | ||
------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
(11 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'delete'); | ||
data | ||
--------------------------------------------------------------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"D","schema":"public","table":"actions","identity":[{"name":"a","type":"integer","value":2}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
(11 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'truncate'); | ||
data | ||
---------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"T","schema":"public","table":"actions"} | ||
{"action":"C"} | ||
(11 rows) | ||
|
||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update, truncate'); | ||
data | ||
------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"C"} | ||
{"action":"B"} | ||
{"action":"T","schema":"public","table":"actions"} | ||
{"action":"C"} | ||
(12 rows) | ||
|
||
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); | ||
?column? | ||
---------- | ||
stop | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
\set VERBOSITY terse | ||
|
||
-- predictability | ||
SET synchronous_commit = on; | ||
|
||
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); | ||
|
||
-- actions | ||
CREATE TABLE actions (a integer primary key); | ||
INSERT INTO actions (a) VALUES(1); | ||
UPDATE actions SET a = 2 WHERE a = 1; | ||
DELETE FROM actions WHERE a = 2; | ||
TRUNCATE TABLE actions; | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert, foo, delete'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'delete'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'truncate'); | ||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update, truncate'); | ||
|
||
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters