mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Revert "Logical decoding of sequences"
This reverts a sequence of commits, implementing features related to logical decoding and replication of sequences: -0da92dc530
-80901b3291
-b779d7d8fd
-d5ed9da41d
-a180c2b34d
-75b1521dae
-2d2232933b
-002c9dd97a
-05843b1aa4
The implementation has issues, mostly due to combining transactional and non-transactional behavior of sequences. It's not clear how this could be fixed, but it'll require reworking significant part of the patch. Discussion: https://postgr.es/m/95345a19-d508-63d1-860a-f5c2f41e8d40@enterprisedb.com
This commit is contained in:
@ -19,7 +19,7 @@ SELECT pg_drop_replication_slot('regression_slot');
|
||||
|
||||
-- check that we're detecting a streaming rep slot used for logical decoding
|
||||
SELECT 'init' FROM pg_create_physical_replication_slot('repl');
|
||||
SELECT data FROM pg_logical_slot_get_changes('repl', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('repl', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
SELECT pg_drop_replication_slot('repl');
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@ ALTER TABLE replication_example RENAME COLUMN text TO somenum;
|
||||
INSERT INTO replication_example(somedata, somenum) VALUES (4, 1);
|
||||
|
||||
-- collect all changes
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
ALTER TABLE replication_example ALTER COLUMN somenum TYPE int4 USING (somenum::int4);
|
||||
-- check that this doesn't produce any changes from the heap rewrite
|
||||
SELECT count(data) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT count(data) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
INSERT INTO replication_example(somedata, somenum) VALUES (5, 1);
|
||||
|
||||
@ -82,7 +82,7 @@ INSERT INTO replication_example(somedata, somenum, zaphod1) VALUES (6, 4, 2);
|
||||
COMMIT;
|
||||
|
||||
-- show changes
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- ON CONFLICT DO UPDATE support
|
||||
BEGIN;
|
||||
@ -91,7 +91,7 @@ INSERT INTO replication_example(id, somedata, somenum) SELECT i, i, i FROM gener
|
||||
COMMIT;
|
||||
|
||||
/* display results */
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- MERGE support
|
||||
BEGIN;
|
||||
@ -113,14 +113,14 @@ CREATE TABLE tr_unique(id2 serial unique NOT NULL, data int);
|
||||
INSERT INTO tr_unique(data) VALUES(10);
|
||||
ALTER TABLE tr_unique RENAME TO tr_pkey;
|
||||
ALTER TABLE tr_pkey ADD COLUMN id serial primary key;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-rewrites', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-rewrites', '1');
|
||||
|
||||
INSERT INTO tr_pkey(data) VALUES(1);
|
||||
--show deletion with primary key
|
||||
DELETE FROM tr_pkey;
|
||||
|
||||
/* display results */
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
/*
|
||||
* check that disk spooling works (also for logical messages)
|
||||
@ -137,7 +137,7 @@ COMMIT;
|
||||
|
||||
/* display results, but hide most of the output */
|
||||
SELECT count(*), min(data), max(data)
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0')
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
|
||||
GROUP BY substring(data, 1, 24)
|
||||
ORDER BY 1,2;
|
||||
|
||||
@ -152,7 +152,7 @@ DROP TABLE spoolme;
|
||||
COMMIT;
|
||||
|
||||
SELECT data
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0')
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
|
||||
WHERE data ~ 'UPDATE';
|
||||
|
||||
-- check that a large, spooled, upsert works
|
||||
@ -161,7 +161,7 @@ SELECT g.i, -g.i FROM generate_series(8000, 12000) g(i)
|
||||
ON CONFLICT(id) DO UPDATE SET data = EXCLUDED.data;
|
||||
|
||||
SELECT substring(data, 1, 29), count(*)
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0') WITH ORDINALITY
|
||||
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') WITH ORDINALITY
|
||||
GROUP BY 1
|
||||
ORDER BY min(ordinality);
|
||||
|
||||
@ -189,7 +189,7 @@ INSERT INTO tr_sub(path) VALUES ('1-top-2-#1');
|
||||
RELEASE SAVEPOINT b;
|
||||
COMMIT;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- check that we handle xlog assignments correctly
|
||||
BEGIN;
|
||||
@ -218,7 +218,7 @@ RELEASE SAVEPOINT subtop;
|
||||
INSERT INTO tr_sub(path) VALUES ('2-top-#1');
|
||||
COMMIT;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- make sure rollbacked subtransactions aren't decoded
|
||||
BEGIN;
|
||||
@ -231,7 +231,7 @@ ROLLBACK TO SAVEPOINT b;
|
||||
INSERT INTO tr_sub(path) VALUES ('3-top-2-#2');
|
||||
COMMIT;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- test whether a known, but not yet logged toplevel xact, followed by a
|
||||
-- subxact commit is handled correctly
|
||||
@ -250,7 +250,7 @@ INSERT INTO tr_sub(path) VALUES ('5-top-1-#1');
|
||||
COMMIT;
|
||||
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- check that DDL in aborted subtransactions handled correctly
|
||||
CREATE TABLE tr_sub_ddl(data int);
|
||||
@ -263,7 +263,7 @@ ALTER TABLE tr_sub_ddl ALTER COLUMN data TYPE bigint;
|
||||
INSERT INTO tr_sub_ddl VALUES(43);
|
||||
COMMIT;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
|
||||
/*
|
||||
@ -303,7 +303,7 @@ ALTER TABLE replication_metadata SET (user_catalog_table = false);
|
||||
INSERT INTO replication_metadata(relation, options)
|
||||
VALUES ('zaphod', NULL);
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
/*
|
||||
* check whether we handle updates/deletes correct with & without a pkey
|
||||
@ -414,7 +414,7 @@ UPDATE toasttable
|
||||
SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i))
|
||||
WHERE id = 1;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
INSERT INTO toasttable(toasted_col1) SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i);
|
||||
|
||||
@ -426,10 +426,10 @@ WHERE id = 1;
|
||||
-- make sure we decode correctly even if the toast table is gone
|
||||
DROP TABLE toasttable;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- done, free logical replication slot
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
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');
|
||||
|
||||
|
@ -32,10 +32,10 @@ BEGIN;
|
||||
SELECT pg_current_xact_id() = '0';
|
||||
-- don't show yet, haven't committed
|
||||
INSERT INTO nobarf(data) VALUES('2');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
COMMIT;
|
||||
|
||||
INSERT INTO nobarf(data) VALUES('3');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
|
||||
|
@ -15,14 +15,14 @@ CREATE TABLE somechange(id serial primary key);
|
||||
INSERT INTO somechange DEFAULT VALUES;
|
||||
|
||||
CREATE TABLE changeresult AS
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
SELECT * FROM changeresult;
|
||||
|
||||
INSERT INTO changeresult
|
||||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
INSERT INTO changeresult
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
SELECT * FROM changeresult;
|
||||
DROP TABLE changeresult;
|
||||
@ -32,11 +32,11 @@ DROP TABLE somechange;
|
||||
CREATE FUNCTION slot_changes_wrapper(slot_name name) RETURNS SETOF TEXT AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT data FROM pg_logical_slot_peek_changes(slot_name, NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_peek_changes(slot_name, NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
END$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT * FROM slot_changes_wrapper('regression_slot');
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
|
||||
|
@ -41,10 +41,10 @@ SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_d
|
||||
-- origin tx
|
||||
INSERT INTO origin_tbl(data) VALUES ('will be replicated and decoded and decoded again');
|
||||
INSERT INTO target_tbl(data)
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- as is normal, the insert into target_tbl shows up
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded again');
|
||||
|
||||
@ -60,7 +60,7 @@ BEGIN;
|
||||
-- setup transaction origin
|
||||
SELECT pg_replication_origin_xact_setup('0/aabbccdd', '2013-01-01 00:00');
|
||||
INSERT INTO target_tbl(data)
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1');
|
||||
COMMIT;
|
||||
|
||||
-- check replication progress for the session is correct
|
||||
@ -79,11 +79,11 @@ SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot',
|
||||
SELECT pg_replication_origin_session_reset();
|
||||
|
||||
-- and magically the replayed xact will be filtered!
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1');
|
||||
|
||||
--but new original changes still show up
|
||||
INSERT INTO origin_tbl(data) VALUES ('will be replicated');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1');
|
||||
|
||||
SELECT pg_drop_replication_slot('regression_slot');
|
||||
SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot');
|
||||
@ -114,7 +114,7 @@ SELECT local_id, external_id,
|
||||
remote_lsn <> '0/0' AS valid_remote_lsn,
|
||||
local_lsn <> '0/0' AS valid_local_lsn
|
||||
FROM pg_replication_origin_status;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot_no_lsn', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot_no_lsn', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0');
|
||||
-- Clean up
|
||||
SELECT pg_replication_origin_session_reset();
|
||||
SELECT pg_drop_replication_slot('regression_slot_no_lsn');
|
||||
|
@ -35,7 +35,7 @@ SELECT pg_relation_size((SELECT reltoastrelid FROM pg_class WHERE oid = 'pg_shde
|
||||
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
||||
CREATE TABLE replication_example(id SERIAL PRIMARY KEY, somedata int, text varchar(120));
|
||||
INSERT INTO replication_example(somedata) VALUES (1);
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO replication_example(somedata) VALUES (2);
|
||||
@ -90,7 +90,7 @@ COMMIT;
|
||||
-- make old files go away
|
||||
CHECKPOINT;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- trigger repeated rewrites of a system catalog with a toast table,
|
||||
-- that previously was buggy: 20180914021046.oi7dm4ra3ot2g2kt@alap3.anarazel.de
|
||||
@ -98,7 +98,7 @@ VACUUM FULL pg_proc; VACUUM FULL pg_description; VACUUM FULL pg_shdescription; V
|
||||
INSERT INTO replication_example(somedata, testcolumn1, testcolumn3) VALUES (8, 6, 1);
|
||||
VACUUM FULL pg_proc; VACUUM FULL pg_description; VACUUM FULL pg_shdescription; VACUUM FULL iamalargetable;
|
||||
INSERT INTO replication_example(somedata, testcolumn1, testcolumn3) VALUES (9, 7, 1);
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
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');
|
||||
DROP TABLE IF EXISTS replication_example;
|
||||
|
@ -1,119 +0,0 @@
|
||||
-- predictability
|
||||
SET synchronous_commit = on;
|
||||
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
||||
|
||||
CREATE SEQUENCE test_sequence;
|
||||
|
||||
-- test the sequence changes by several nextval() calls
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
|
||||
-- test the sequence changes by several ALTER commands
|
||||
ALTER SEQUENCE test_sequence INCREMENT BY 10;
|
||||
SELECT nextval('test_sequence');
|
||||
|
||||
ALTER SEQUENCE test_sequence START WITH 3000;
|
||||
ALTER SEQUENCE test_sequence MAXVALUE 10000;
|
||||
ALTER SEQUENCE test_sequence RESTART WITH 4000;
|
||||
SELECT nextval('test_sequence');
|
||||
|
||||
-- test the sequence changes by several setval() calls
|
||||
SELECT setval('test_sequence', 3500);
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT setval('test_sequence', 3500, true);
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT setval('test_sequence', 3500, false);
|
||||
SELECT nextval('test_sequence');
|
||||
|
||||
-- show results and drop sequence
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
DROP SEQUENCE test_sequence;
|
||||
|
||||
-- rollback on sequence creation and update
|
||||
BEGIN;
|
||||
CREATE SEQUENCE test_sequence;
|
||||
CREATE TABLE test_table (a INT);
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT setval('test_sequence', 3000);
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT nextval('test_sequence');
|
||||
ALTER SEQUENCE test_sequence RESTART WITH 6000;
|
||||
INSERT INTO test_table VALUES( (SELECT nextval('test_sequence')) );
|
||||
SELECT nextval('test_sequence');
|
||||
ROLLBACK;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- rollback on table creation with serial column
|
||||
BEGIN;
|
||||
CREATE TABLE test_table (a SERIAL, b INT);
|
||||
INSERT INTO test_table (b) VALUES (100);
|
||||
INSERT INTO test_table (b) VALUES (200);
|
||||
INSERT INTO test_table (b) VALUES (300);
|
||||
SELECT setval('test_table_a_seq', 3000);
|
||||
INSERT INTO test_table (b) VALUES (400);
|
||||
INSERT INTO test_table (b) VALUES (500);
|
||||
INSERT INTO test_table (b) VALUES (600);
|
||||
ALTER SEQUENCE test_table_a_seq RESTART WITH 6000;
|
||||
INSERT INTO test_table (b) VALUES (700);
|
||||
INSERT INTO test_table (b) VALUES (800);
|
||||
INSERT INTO test_table (b) VALUES (900);
|
||||
ROLLBACK;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- rollback on table with serial column
|
||||
CREATE TABLE test_table (a SERIAL, b INT);
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO test_table (b) VALUES (100);
|
||||
INSERT INTO test_table (b) VALUES (200);
|
||||
INSERT INTO test_table (b) VALUES (300);
|
||||
SELECT setval('test_table_a_seq', 3000);
|
||||
INSERT INTO test_table (b) VALUES (400);
|
||||
INSERT INTO test_table (b) VALUES (500);
|
||||
INSERT INTO test_table (b) VALUES (600);
|
||||
ALTER SEQUENCE test_table_a_seq RESTART WITH 6000;
|
||||
INSERT INTO test_table (b) VALUES (700);
|
||||
INSERT INTO test_table (b) VALUES (800);
|
||||
INSERT INTO test_table (b) VALUES (900);
|
||||
ROLLBACK;
|
||||
|
||||
-- check table and sequence values after rollback
|
||||
SELECT * from test_table_a_seq;
|
||||
SELECT nextval('test_table_a_seq');
|
||||
|
||||
DROP TABLE test_table;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- savepoint test on table with serial column
|
||||
BEGIN;
|
||||
CREATE TABLE test_table (a SERIAL, b INT);
|
||||
INSERT INTO test_table (b) VALUES (100);
|
||||
INSERT INTO test_table (b) VALUES (200);
|
||||
SAVEPOINT a;
|
||||
INSERT INTO test_table (b) VALUES (300);
|
||||
ROLLBACK TO SAVEPOINT a;
|
||||
DROP TABLE test_table;
|
||||
COMMIT;
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- savepoint test on table with serial column
|
||||
BEGIN;
|
||||
CREATE SEQUENCE test_sequence;
|
||||
SELECT nextval('test_sequence');
|
||||
SELECT setval('test_sequence', 3000);
|
||||
SELECT nextval('test_sequence');
|
||||
SAVEPOINT a;
|
||||
ALTER SEQUENCE test_sequence START WITH 7000;
|
||||
SELECT setval('test_sequence', 5000);
|
||||
ROLLBACK TO SAVEPOINT a;
|
||||
SELECT * FROM test_sequence;
|
||||
DROP SEQUENCE test_sequence;
|
||||
COMMIT;
|
||||
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');
|
@ -50,8 +50,8 @@ SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot2', 'test_
|
||||
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 3);
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 4);
|
||||
INSERT INTO replication_example(somedata, text) VALUES (1, 5);
|
||||
@ -65,8 +65,8 @@ SELECT slot_name FROM pg_replication_slot_advance('regression_slot2', pg_current
|
||||
|
||||
SELECT :'wal_lsn' = :'end_lsn';
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
DROP TABLE replication_example;
|
||||
|
||||
|
@ -264,7 +264,7 @@ ALTER TABLE toasted_copy ALTER COLUMN data SET STORAGE EXTERNAL;
|
||||
202 untoasted199
|
||||
203 untoasted200
|
||||
\.
|
||||
SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- test we can decode "old" tuples bigger than the max heap tuple size correctly
|
||||
DROP TABLE IF EXISTS toasted_several;
|
||||
@ -287,13 +287,13 @@ UPDATE pg_attribute SET attstorage = 'x' WHERE attrelid = 'toasted_several_pkey'
|
||||
INSERT INTO toasted_several(toasted_key) VALUES(repeat('9876543210', 10000));
|
||||
SELECT pg_column_size(toasted_key) > 2^16 FROM toasted_several;
|
||||
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
-- test update of a toasted key without changing it
|
||||
UPDATE toasted_several SET toasted_col1 = toasted_key;
|
||||
UPDATE toasted_several SET toasted_col2 = toasted_col1;
|
||||
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
/*
|
||||
* update with large tuplebuf, in a transaction large enough to force to spool to disk
|
||||
@ -306,7 +306,7 @@ COMMIT;
|
||||
|
||||
DROP TABLE toasted_several;
|
||||
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0')
|
||||
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
|
||||
WHERE data NOT LIKE '%INSERT: %';
|
||||
|
||||
/*
|
||||
@ -322,6 +322,6 @@ INSERT INTO tbl1 VALUES(1, repeat('a', 4000)) ;
|
||||
ALTER TABLE tbl1 ADD COLUMN id serial primary key;
|
||||
INSERT INTO tbl2 VALUES(1);
|
||||
commit;
|
||||
SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
||||
|
||||
SELECT pg_drop_replication_slot('regression_slot');
|
||||
|
@ -10,5 +10,5 @@ TRUNCATE tab1;
|
||||
TRUNCATE tab1, tab1 RESTART IDENTITY CASCADE;
|
||||
TRUNCATE tab1, tab2;
|
||||
|
||||
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-sequences', '0');
|
||||
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');
|
||||
|
Reference in New Issue
Block a user