REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
decoding_into_rel binary prepared replorigin time messages \
- spill slot truncate stream stats twophase twophase_stream \
- sequence
+ spill slot truncate stream stats twophase twophase_stream
ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \
oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \
twophase_snapshot slot_creation_error
init
(1 row)
-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');
ERROR: cannot use physical replication slot for logical decoding
SELECT pg_drop_replication_slot('repl');
pg_drop_replication_slot
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');
data
---------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
count
-------
0
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');
data
------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
ON CONFLICT (id) DO UPDATE SET somenum = excluded.somenum + 1;
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');
data
--------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
data
-----------------------------------------------------------------------------
BEGIN
--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');
data
----------------------------------------------------------------------------
BEGIN
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;
count | min | max
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';
data
-------------------------------------------------------------------------------------------------------------
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);
substring | count
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');
data
----------------------------------------------------------------------
BEGIN
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');
data
------------------------------------------------------------------------
BEGIN
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');
data
-----------------------------------------------------------------------
BEGIN
SAVEPOINT a;
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');
data
---------------------------------------------------------------------
BEGIN
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');
data
--------------------------------------------------
BEGIN
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');
data
------------------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
data
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
data
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
(6 rows)
-- 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');
data
------
(0 rows)
-- 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');
data
-----------------------------------------------------------
BEGIN
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');
data
-----------------------------------------------------------
BEGIN
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;
data
------------------------------------------------
(3 rows)
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;
data
--------------------------------------------------------------------------------------------------------------------------------------------------
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');
slot_changes_wrapper
COMMIT
(14 rows)
-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');
data
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
init
(1 row)
-step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
----
(0 rows)
(1 row)
step s0w: INSERT INTO do_write DEFAULT VALUES;
-step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
--------------------------------------------
BEGIN
init
(1 row)
-step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
----
(0 rows)
step s0alter: ALTER TABLE do_write ADD column ts timestamptz;
step s0w: INSERT INTO do_write DEFAULT VALUES;
-step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s0start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
------------------------------------------------------------------------------
BEGIN
step s2c: COMMIT;
step s1insert: INSERT INTO do_write DEFAULT VALUES;
step s1checkpoint: CHECKPOINT;
-step s1start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s1start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
--------------------------------------------------------------------
BEGIN
step s1insert: INSERT INTO do_write DEFAULT VALUES;
step s1alter: ALTER TABLE do_write ADD COLUMN addedbys1 int;
step s1insert: INSERT INTO do_write DEFAULT VALUES;
-step s1start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');
+step s1start: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');
data
--------------------------------------------------------------------------------------------
BEGIN
-- 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');
data
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
(1 row)
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
SELECT pg_replication_origin_session_progress(false);
SELECT pg_replication_origin_session_reset();
ERROR: no replication origin is configured
-- 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');
data
------
(0 rows)
--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');
data
--------------------------------------------------------------------------------
BEGIN
1 | regress_test_decoding: regression_slot_no_lsn | f | t
(1 row)
-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');
data
-------------------------------------------------------------------------------------
BEGIN
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');
data
----------------------------------------------------------------------------------------------------------
BEGIN
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');
data
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
data
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
+++ /dev/null
--- predictability
-SET synchronous_commit = on;
-SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
- ?column?
-----------
- init
-(1 row)
-
-CREATE SEQUENCE test_sequence;
--- test the sequence changes by several nextval() calls
-SELECT nextval('test_sequence');
- nextval
----------
- 1
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 2
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 4
-(1 row)
-
--- test the sequence changes by several ALTER commands
-ALTER SEQUENCE test_sequence INCREMENT BY 10;
-SELECT nextval('test_sequence');
- nextval
----------
- 14
-(1 row)
-
-ALTER SEQUENCE test_sequence START WITH 3000;
-ALTER SEQUENCE test_sequence MAXVALUE 10000;
-ALTER SEQUENCE test_sequence RESTART WITH 4000;
-SELECT nextval('test_sequence');
- nextval
----------
- 4000
-(1 row)
-
--- test the sequence changes by several setval() calls
-SELECT setval('test_sequence', 3500);
- setval
---------
- 3500
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3510
-(1 row)
-
-SELECT setval('test_sequence', 3500, true);
- setval
---------
- 3500
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3510
-(1 row)
-
-SELECT setval('test_sequence', 3500, false);
- setval
---------
- 3500
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3500
-(1 row)
-
--- show results and drop sequence
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
- data
-----------------------------------------------------------------------------------------
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 1 log_cnt: 0 is_called:0
- COMMIT
- sequence public.test_sequence: transactional:0 last_value: 33 log_cnt: 0 is_called:1
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 4 log_cnt: 0 is_called:1
- COMMIT
- sequence public.test_sequence: transactional:0 last_value: 334 log_cnt: 0 is_called:1
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 14 log_cnt: 32 is_called:1
- COMMIT
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 14 log_cnt: 0 is_called:1
- COMMIT
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 4000 log_cnt: 0 is_called:0
- COMMIT
- sequence public.test_sequence: transactional:0 last_value: 4320 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:0 last_value: 3500 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:0 last_value: 3830 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:0 last_value: 3500 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:0 last_value: 3830 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:0 last_value: 3500 log_cnt: 0 is_called:0
- sequence public.test_sequence: transactional:0 last_value: 3820 log_cnt: 0 is_called:1
-(24 rows)
-
-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');
- nextval
----------
- 1
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 2
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3
-(1 row)
-
-SELECT setval('test_sequence', 3000);
- setval
---------
- 3000
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3001
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3002
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3003
-(1 row)
-
-ALTER SEQUENCE test_sequence RESTART WITH 6000;
-INSERT INTO test_table VALUES( (SELECT nextval('test_sequence')) );
-SELECT nextval('test_sequence');
- nextval
----------
- 6001
-(1 row)
-
-ROLLBACK;
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
- data
-------
-(0 rows)
-
--- 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);
- setval
---------
- 3000
-(1 row)
-
-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');
- data
-------
-(0 rows)
-
--- 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);
- setval
---------
- 3000
-(1 row)
-
-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;
- last_value | log_cnt | is_called
-------------+---------+-----------
- 3003 | 30 | t
-(1 row)
-
-SELECT nextval('test_table_a_seq');
- nextval
----------
- 3004
-(1 row)
-
-DROP TABLE test_table;
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
- data
--------------------------------------------------------------------------------------------
- BEGIN
- sequence public.test_table_a_seq: transactional:1 last_value: 1 log_cnt: 0 is_called:0
- COMMIT
- sequence public.test_table_a_seq: transactional:0 last_value: 33 log_cnt: 0 is_called:1
- sequence public.test_table_a_seq: transactional:0 last_value: 3000 log_cnt: 0 is_called:1
- sequence public.test_table_a_seq: transactional:0 last_value: 3033 log_cnt: 0 is_called:1
-(6 rows)
-
--- 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');
- data
------------------------------------------------------------------------------------------
- BEGIN
- sequence public.test_table_a_seq: transactional:1 last_value: 1 log_cnt: 0 is_called:0
- sequence public.test_table_a_seq: transactional:1 last_value: 33 log_cnt: 0 is_called:1
- table public.test_table: INSERT: a[integer]:1 b[integer]:100
- table public.test_table: INSERT: a[integer]:2 b[integer]:200
- COMMIT
-(6 rows)
-
--- savepoint test on table with serial column
-BEGIN;
-CREATE SEQUENCE test_sequence;
-SELECT nextval('test_sequence');
- nextval
----------
- 1
-(1 row)
-
-SELECT setval('test_sequence', 3000);
- setval
---------
- 3000
-(1 row)
-
-SELECT nextval('test_sequence');
- nextval
----------
- 3001
-(1 row)
-
-SAVEPOINT a;
-ALTER SEQUENCE test_sequence START WITH 7000;
-SELECT setval('test_sequence', 5000);
- setval
---------
- 5000
-(1 row)
-
-ROLLBACK TO SAVEPOINT a;
-SELECT * FROM test_sequence;
- last_value | log_cnt | is_called
-------------+---------+-----------
- 3001 | 32 | t
-(1 row)
-
-DROP SEQUENCE test_sequence;
-COMMIT;
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
- data
-----------------------------------------------------------------------------------------
- BEGIN
- sequence public.test_sequence: transactional:1 last_value: 1 log_cnt: 0 is_called:0
- sequence public.test_sequence: transactional:1 last_value: 33 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:1 last_value: 3000 log_cnt: 0 is_called:1
- sequence public.test_sequence: transactional:1 last_value: 3033 log_cnt: 0 is_called:1
- COMMIT
-(6 rows)
-
-SELECT pg_drop_replication_slot('regression_slot');
- pg_drop_replication_slot
---------------------------
-
-(1 row)
-
(1 row)
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_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
data
---------------------------------------------------------------------------------------------------------
BEGIN
COMMIT
(7 rows)
-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_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
data
---------------------------------------------------------------------------------------------------------
BEGIN
t
(1 row)
-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_slot1', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
data
---------------------------------------------------------------------------------------------------------
BEGIN
COMMIT
(3 rows)
-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_slot2', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
data
------
(0 rows)
);
ALTER TABLE toasted_copy ALTER COLUMN data SET STORAGE EXTERNAL;
\copy toasted_copy FROM STDIN
-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');
substr
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
t
(1 row)
-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');
regexp_replace
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
-- 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');
regexp_replace
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
DELETE FROM toasted_several WHERE id = 1;
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: %';
regexp_replace
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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');
substr
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BEGIN
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');
data
------------------------------------------------------
BEGIN
session "s0"
setup { SET synchronous_commit=on; }
step "s0init" {SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding');}
-step "s0start" {SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');}
+step "s0start" {SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');}
step "s0alter" {ALTER TABLE do_write ADD column ts timestamptz; }
step "s0w" { INSERT INTO do_write DEFAULT VALUES; }
setup { SET synchronous_commit=on; }
step "s1init" {SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding');}
-step "s1start" {SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false', 'include-sequences', 'false');}
+step "s1start" {SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', 'false');}
step "s1insert" { INSERT INTO do_write DEFAULT VALUES; }
step "s1checkpoint" { CHECKPOINT; }
step "s1alter" { ALTER TABLE do_write ADD COLUMN addedbys1 int; }
-- 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');
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);
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;
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;
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)
/* 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;
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
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);
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;
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;
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
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);
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');
/*
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
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);
-- 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');
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');
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;
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');
-- 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');
-- 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
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');
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');
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);
-- 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,
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;
+++ /dev/null
--- 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');
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);
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;
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;
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
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: %';
/*
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');
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');
bool include_timestamp;
bool skip_empty_xacts;
bool only_local;
- bool include_sequences;
} TestDecodingData;
/*
ReorderBufferTXN *txn, XLogRecPtr message_lsn,
bool transactional, const char *prefix,
Size sz, const char *message);
-static void pg_decode_sequence(LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn, XLogRecPtr sequence_lsn,
- Relation rel, bool transactional,
- int64 last_value, int64 log_cnt, bool is_called);
static bool pg_decode_filter_prepare(LogicalDecodingContext *ctx,
TransactionId xid,
const char *gid);
ReorderBufferTXN *txn, XLogRecPtr message_lsn,
bool transactional, const char *prefix,
Size sz, const char *message);
-static void pg_decode_stream_sequence(LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn, XLogRecPtr sequence_lsn,
- Relation rel, bool transactional,
- int64 last_value, int64 log_cnt, bool is_called);
static void pg_decode_stream_truncate(LogicalDecodingContext *ctx,
ReorderBufferTXN *txn,
int nrelations, Relation relations[],
cb->filter_by_origin_cb = pg_decode_filter;
cb->shutdown_cb = pg_decode_shutdown;
cb->message_cb = pg_decode_message;
- cb->sequence_cb = pg_decode_sequence;
cb->filter_prepare_cb = pg_decode_filter_prepare;
cb->begin_prepare_cb = pg_decode_begin_prepare_txn;
cb->prepare_cb = pg_decode_prepare_txn;
cb->stream_commit_cb = pg_decode_stream_commit;
cb->stream_change_cb = pg_decode_stream_change;
cb->stream_message_cb = pg_decode_stream_message;
- cb->stream_sequence_cb = pg_decode_stream_sequence;
cb->stream_truncate_cb = pg_decode_stream_truncate;
}
data->include_xids = true;
data->include_timestamp = false;
data->skip_empty_xacts = false;
- data->include_sequences = true;
data->only_local = false;
ctx->output_plugin_private = data;
errmsg("could not parse value \"%s\" for parameter \"%s\"",
strVal(elem->arg), elem->defname)));
}
- else if (strcmp(elem->defname, "include-sequences") == 0)
- {
-
- if (elem->arg == NULL)
- data->include_sequences = false;
- else if (!parse_bool(strVal(elem->arg), &data->include_sequences))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("could not parse value \"%s\" for parameter \"%s\"",
- strVal(elem->arg), elem->defname)));
- }
else
{
ereport(ERROR,
OutputPluginWrite(ctx, true);
}
-static void
-pg_decode_sequence(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
- XLogRecPtr sequence_lsn, Relation rel,
- bool transactional,
- int64 last_value, int64 log_cnt, bool is_called)
-{
- TestDecodingData *data = ctx->output_plugin_private;
- TestDecodingTxnData *txndata = txn->output_plugin_private;
-
- if (!data->include_sequences)
- return;
-
- /* output BEGIN if we haven't yet, but only for the transactional case */
- if (transactional)
- {
- if (data->skip_empty_xacts && !txndata->xact_wrote_changes)
- {
- pg_output_begin(ctx, data, txn, false);
- }
- txndata->xact_wrote_changes = true;
- }
-
- OutputPluginPrepareWrite(ctx, true);
- appendStringInfoString(ctx->out, "sequence ");
- appendStringInfoString(ctx->out,
- quote_qualified_identifier(get_namespace_name(get_rel_namespace(RelationGetRelid(rel))),
- RelationGetRelationName(rel)));
- appendStringInfo(ctx->out, ": transactional:%d last_value: " INT64_FORMAT " log_cnt: " INT64_FORMAT " is_called:%d",
- transactional, last_value, log_cnt, is_called);
- OutputPluginWrite(ctx, true);
-}
-
static void
pg_decode_stream_start(LogicalDecodingContext *ctx,
ReorderBufferTXN *txn)
OutputPluginWrite(ctx, true);
}
-static void
-pg_decode_stream_sequence(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
- XLogRecPtr sequence_lsn, Relation rel,
- bool transactional,
- int64 last_value, int64 log_cnt, bool is_called)
-{
- TestDecodingData *data = ctx->output_plugin_private;
- TestDecodingTxnData *txndata = txn->output_plugin_private;
-
- if (!data->include_sequences)
- return;
-
- /* output BEGIN if we haven't yet, but only for the transactional case */
- if (transactional)
- {
- if (data->skip_empty_xacts && !txndata->xact_wrote_changes)
- {
- pg_output_begin(ctx, data, txn, false);
- }
- txndata->xact_wrote_changes = true;
- }
-
- OutputPluginPrepareWrite(ctx, true);
- appendStringInfoString(ctx->out, "streaming sequence ");
- appendStringInfoString(ctx->out,
- quote_qualified_identifier(get_namespace_name(get_rel_namespace(RelationGetRelid(rel))),
- RelationGetRelationName(rel)));
- appendStringInfo(ctx->out, ": transactional:%d last_value: " INT64_FORMAT " log_cnt: " INT64_FORMAT " is_called:%d",
- transactional, last_value, log_cnt, is_called);
- OutputPluginWrite(ctx, true);
-}
-
/*
* In streaming mode, we don't display the detailed information of Truncate.
* See pg_decode_stream_change.
Reference to schema
</para></entry>
</row>
-
- <row>
- <entry role="catalog_table_entry"><para role="column_definition">
- <structfield>pntype</structfield> <type>char</type>
- Determines which object type is included from this schema.
- </para>
- <para>
- Reference to schema
- </para></entry>
- </row>
</tbody>
</tgroup>
</table>
<entry>prepared transactions</entry>
</row>
- <row>
- <entry><link linkend="view-pg-publication-sequences"><structname>pg_publication_sequences</structname></link></entry>
- <entry>publications and their associated sequences</entry>
- </row>
-
<row>
<entry><link linkend="view-pg-publication-tables"><structname>pg_publication_tables</structname></link></entry>
<entry>publications and their associated tables</entry>
</sect1>
- <sect1 id="view-pg-publication-sequences">
- <title><structname>pg_publication_sequences</structname></title>
-
- <indexterm zone="view-pg-publication-sequences">
- <primary>pg_publication_sequences</primary>
- </indexterm>
-
- <para>
- The view <structname>pg_publication_sequences</structname> provides
- information about the mapping between publications and the sequences they
- contain. Unlike the underlying catalog
- <link linkend="catalog-pg-publication-rel"><structname>pg_publication_rel</structname></link>,
- this view expands
- publications defined as <literal>FOR ALL SEQUENCES</literal>, so for such
- publications there will be a row for each eligible sequence.
- </para>
-
- <table>
- <title><structname>pg_publication_sequences</structname> Columns</title>
- <tgroup cols="1">
- <thead>
- <row>
- <entry role="catalog_table_entry"><para role="column_definition">
- Column Type
- </para>
- <para>
- Description
- </para></entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry role="catalog_table_entry"><para role="column_definition">
- <structfield>pubname</structfield> <type>name</type>
- (references <link linkend="catalog-pg-publication"><structname>pg_publication</structname></link>.<structfield>pubname</structfield>)
- </para>
- <para>
- Name of publication
- </para></entry>
- </row>
-
- <row>
- <entry role="catalog_table_entry"><para role="column_definition">
- <structfield>schemaname</structfield> <type>name</type>
- (references <link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.<structfield>nspname</structfield>)
- </para>
- <para>
- Name of schema containing sequence
- </para></entry>
- </row>
-
- <row>
- <entry role="catalog_table_entry"><para role="column_definition">
- <structfield>sequencename</structfield> <type>name</type>
- (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>relname</structfield>)
- </para>
- <para>
- Name of sequence
- </para></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect1>
-
<sect1 id="view-pg-publication-tables">
<title><structname>pg_publication_tables</structname></title>
LogicalDecodeTruncateCB truncate_cb;
LogicalDecodeCommitCB commit_cb;
LogicalDecodeMessageCB message_cb;
- LogicalDecodeSequenceCB sequence_cb;
LogicalDecodeFilterByOriginCB filter_by_origin_cb;
LogicalDecodeShutdownCB shutdown_cb;
LogicalDecodeFilterPrepareCB filter_prepare_cb;
LogicalDecodeStreamCommitCB stream_commit_cb;
LogicalDecodeStreamChangeCB stream_change_cb;
LogicalDecodeStreamMessageCB stream_message_cb;
- LogicalDecodeStreamSequenceCB stream_sequence_cb;
LogicalDecodeStreamTruncateCB stream_truncate_cb;
} OutputPluginCallbacks;
and <function>commit_cb</function> callbacks are required,
while <function>startup_cb</function>,
<function>filter_by_origin_cb</function>, <function>truncate_cb</function>,
- <function>sequence_cb</function>, and <function>shutdown_cb</function> are
- optional. If <function>truncate_cb</function> is not set but a
+ and <function>shutdown_cb</function> are optional.
+ If <function>truncate_cb</function> is not set but a
<command>TRUNCATE</command> is to be decoded, the action will be ignored.
- Similarly, if <function>sequence_cb</function> is not set and a sequence
- change is to be decoded, the action will be ignored.
</para>
<para>
<function>stream_stop_cb</function>, <function>stream_abort_cb</function>,
<function>stream_commit_cb</function>, <function>stream_change_cb</function>,
and <function>stream_prepare_cb</function>
- are required, while <function>stream_message_cb</function>,
- <function>stream_sequence_cb</function>, and
+ are required, while <function>stream_message_cb</function> and
<function>stream_truncate_cb</function> are optional.
</para>
</para>
</sect3>
- <sect3 id="logicaldecoding-output-plugin-sequence">
- <title>Sequence Callback</title>
-
- <para>
- The optional <function>sequence_cb</function> callback is called for
- actions that update a sequence value.
-<programlisting>
-typedef void (*LogicalDecodeSequenceCB) (struct LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn,
- XLogRecPtr sequence_lsn,
- Relation rel,
- bool transactional,
- int64 last_value,
- int64 log_cnt,
- bool is_called);
-</programlisting>
- The <parameter>txn</parameter> parameter contains meta information about
- the transaction the sequence change is part of. Note however that for
- non-transactional increments, the transaction may be either NULL or not
- NULL, depending on if the transaction already has an XID assigned.
- The <parameter>sequence_lsn</parameter> has the WAL location of the
- sequence update. <parameter>transactional</parameter> says if the
- sequence has to be replayed as part of the transaction or directly.
-
- The <parameter>last_value</parameter>, <parameter>log_cnt</parameter> and
- <parameter>is_called</parameter> parameters describe the sequence change.
- </para>
- </sect3>
-
<sect3 id="logicaldecoding-output-plugin-filter-prepare">
<title>Prepare Filter Callback</title>
</para>
</sect3>
- <sect3 id="logicaldecoding-output-plugin-stream-sequence">
- <title>Stream Sequence Callback</title>
- <para>
- The optional <function>stream_sequence_cb</function> callback is called
- for actions that change a sequence in a block of streamed changes
- (demarcated by <function>stream_start_cb</function> and
- <function>stream_stop_cb</function> calls).
-<programlisting>
-typedef void (*LogicalDecodeStreamSequenceCB) (struct LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn,
- XLogRecPtr sequence_lsn,
- Relation rel,
- bool transactional,
- int64 last_value,
- int64 log_cnt,
- bool is_called);
-</programlisting>
- </para>
- </sect3>
-
<sect3 id="logicaldecoding-output-plugin-stream-truncate">
<title>Stream Truncate Callback</title>
<para>
in-progress transactions. There are multiple required streaming callbacks
(<function>stream_start_cb</function>, <function>stream_stop_cb</function>,
<function>stream_abort_cb</function>, <function>stream_commit_cb</function>
- and <function>stream_change_cb</function>) and multiple optional callbacks
- (<function>stream_message_cb</function>, <function>stream_sequence_cb</function>,
- and <function>stream_truncate_cb</function>).
+ and <function>stream_change_cb</function>) and two optional callbacks
+ (<function>stream_message_cb</function> and <function>stream_truncate_cb</function>).
Also, if streaming of two-phase commands is to be supported, then additional
callbacks must be provided. (See <xref linkend="logicaldecoding-two-phase-commits"/>
for details).
</listitem>
</varlistentry>
-<varlistentry id="protocol-logicalrep-message-formats-Sequence">
-<term>
-Sequence
-</term>
-<listitem>
-<para>
-
-<variablelist>
-<varlistentry>
-<term>
- Byte1('X')
-</term>
-<listitem>
-<para>
- Identifies the message as a sequence message.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>
- Int32 (TransactionId)
-</term>
-<listitem>
-<para>
- Xid of the transaction (only present for streamed transactions).
- This field is available since protocol version 2.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>
- Int8(0)
-</term>
-<listitem>
-<para>
- Flags; currently unused.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>
- Int64 (XLogRecPtr)
-</term>
-<listitem>
-<para>
- The LSN of the sequence increment.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>
- String
-</term>
-<listitem>
-<para>
- Namespace (empty string for <literal>pg_catalog</literal>).
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>
- String
-</term>
-<listitem>
-<para>
- Relation name.
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term>
- Int8
-</term>
-<listitem>
-<para>
- 1 if the sequence update is transactional, 0 otherwise.
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term>
- Int64
-</term>
-<listitem>
-<para>
- <structfield>last_value</structfield> value of the sequence.
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term>
- Int64
-</term>
-<listitem>
-<para>
- <structfield>log_cnt</structfield> value of the sequence.
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term>
- Int8
-</term>
-<listitem>
-<para>
- <structfield>is_called</structfield> value of the sequence.
-</para>
-</listitem>
-</varlistentry>
-
-</variablelist>
-</para>
-</listitem>
-</varlistentry>
-
<varlistentry id="protocol-logicalrep-message-formats-Type">
<term>
Type
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
- SEQUENCE <replaceable class="parameter">sequence_name</replaceable> [, ... ]
ALL TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
- ALL SEQUENCES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
</synopsis>
</refsynopsisdiv>
</para>
<para>
- The first three variants change which objects (tables, sequences or schemas)
- are part of the publication. The <literal>SET</literal> clause will replace
- the list of objects in the publication with the specified list; the existing
- objects that were present in the publication will be removed.
- The <literal>ADD</literal> and <literal>DROP</literal> clauses will add and
- remove one or more objects from the publication. Note that adding objects
- to a publication that is already subscribed to will require an
+ The first three variants change which tables/schemas are part of the
+ publication. The <literal>SET</literal> clause will replace the list of
+ tables/schemas in the publication with the specified list; the existing
+ tables/schemas that were present in the publication will be removed. The
+ <literal>ADD</literal> and <literal>DROP</literal> clauses will add and
+ remove one or more tables/schemas from the publication. Note that adding
+ tables/schemas to a publication that is already subscribed to will require an
<literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal> action on the
subscribing side in order to become effective. Note also that the combination
of <literal>DROP</literal> with a <literal>WHERE</literal> clause is not
</listitem>
</varlistentry>
- <varlistentry>
- <term><replaceable class="parameter">sequence_name</replaceable></term>
- <listitem>
- <para>
- Name of an existing sequence.
- </para>
- </listitem>
- </varlistentry>
-
<varlistentry>
<term><replaceable class="parameter">schema_name</replaceable></term>
<listitem>
<listitem>
<para>
Fetch missing table information from publisher. This will start
- replication of tables and sequences that were added to the subscribed-to
- publications since <command>CREATE SUBSCRIPTION</command> or
+ replication of tables that were added to the subscribed-to publications
+ since <command>CREATE SUBSCRIPTION</command> or
the last invocation of <command>REFRESH PUBLICATION</command>.
</para>
The default is <literal>true</literal>.
</para>
<para>
- Previously subscribed tables and sequences are not copied, even if a
- table's row filter <literal>WHERE</literal> clause has since been modified.
+ Previously subscribed tables are not copied, even if a table's row
+ filter <literal>WHERE</literal> clause has since been modified.
</para>
</listitem>
</varlistentry>
<refsynopsisdiv>
<synopsis>
CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
- [ FOR ALL <replaceable class="parameter">object_type</replaceable> [, ...]
+ [ FOR ALL TABLES
| FOR <replaceable class="parameter">publication_object</replaceable> [, ... ] ]
[ WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
-<phrase>where <replaceable class="parameter">object type</replaceable> is one of:</phrase>
-
- TABLES
- SEQUENCES
-
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
- SEQUENCE <replaceable class="parameter">sequence_name</replaceable> [ * ] [, ... ]
ALL TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
- ALL SEQUENCES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
</synopsis>
</refsynopsisdiv>
</listitem>
</varlistentry>
- <varlistentry>
- <term><literal>FOR SEQUENCE</literal></term>
- <listitem>
- <para>
- Specifies a list of sequences to add to the publication.
- </para>
-
- <para>
- Specifying a sequence that is part of a schema specified by <literal>FOR
- ALL SEQUENCES IN SCHEMA</literal> is not supported.
- </para>
- </listitem>
- </varlistentry>
-
<varlistentry>
<term><literal>FOR ALL TABLES</literal></term>
- <term><literal>FOR ALL SEQUENCES</literal></term>
<listitem>
<para>
- Marks the publication as one that replicates changes for all tables/sequences in
- the database, including tables/sequences created in the future.
+ Marks the publication as one that replicates changes for all tables in
+ the database, including tables created in the future.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>FOR ALL TABLES IN SCHEMA</literal></term>
- <term><literal>FOR ALL SEQUENCES IN SCHEMA</literal></term>
<listitem>
<para>
- Marks the publication as one that replicates changes for all sequences/tables in
- the specified list of schemas, including sequences/tables created in the future.
+ Marks the publication as one that replicates changes for all tables in
+ the specified list of schemas, including tables created in the future.
</para>
<para>
- Specifying a schema along with a sequence/table which belongs to the specified
- schema using <literal>FOR SEQUENCE</literal>/<literal>FOR TABLE</literal> is not supported.
+ Specifying a schema along with a table which belongs to the specified
+ schema using <literal>FOR TABLE</literal> is not supported.
</para>
<para>
<title>Notes</title>
<para>
- If <literal>FOR TABLE</literal>, <literal>FOR SEQUENCE</literal>, etc. is
- not specified, then the publication starts out with an empty set of tables
- and sequences. That is useful if objects are to be added later.
+ If <literal>FOR TABLE</literal>, <literal>FOR ALL TABLES</literal> or
+ <literal>FOR ALL TABLES IN SCHEMA</literal> are not specified, then the
+ publication starts out with an empty set of tables. That is useful if
+ tables or schemas are to be added later.
</para>
<para>
</para>
<para>
- To add a table or a sequence to a publication, the invoking user must
- have ownership rights on the object. The <command>FOR ALL ...</command>
- clauses require the invoking user to be a superuser.
+ To add a table to a publication, the invoking user must have ownership
+ rights on the table. The <command>FOR ALL TABLES</command> and
+ <command>FOR ALL TABLES IN SCHEMA</command> clauses require the invoking
+ user to be a superuser.
</para>
<para>
char *pubname;
char *schemaname;
Oid schemaid;
- char *objtype;
ObjectAddressSet(address, PublicationNamespaceRelationId, InvalidOid);
/* Fetch schema name and publication name from input list */
schemaname = strVal(linitial(object));
pubname = strVal(lsecond(object));
- objtype = strVal(lthird(object));
schemaid = get_namespace_oid(schemaname, missing_ok);
if (!OidIsValid(schemaid))
/* Find the publication schema mapping in syscache */
address.objectId =
- GetSysCacheOid3(PUBLICATIONNAMESPACEMAP,
+ GetSysCacheOid2(PUBLICATIONNAMESPACEMAP,
Anum_pg_publication_namespace_oid,
ObjectIdGetDatum(schemaid),
- ObjectIdGetDatum(pub->oid),
- CharGetDatum(objtype[0]));
-
+ ObjectIdGetDatum(pub->oid));
if (!OidIsValid(address.objectId) && !missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
case OBJECT_DOMCONSTRAINT:
case OBJECT_CAST:
case OBJECT_USER_MAPPING:
+ case OBJECT_PUBLICATION_NAMESPACE:
case OBJECT_PUBLICATION_REL:
case OBJECT_DEFACL:
case OBJECT_TRANSFORM:
/* fall through to check args length */
/* FALLTHROUGH */
case OBJECT_OPERATOR:
- case OBJECT_PUBLICATION_NAMESPACE:
if (list_length(args) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
objnode = (Node *) list_make2(name, linitial(args));
break;
case OBJECT_PUBLICATION_NAMESPACE:
- objnode = (Node *) list_make3(linitial(name), linitial(args), lsecond(args));
- break;
case OBJECT_USER_MAPPING:
objnode = (Node *) list_make2(linitial(name), linitial(args));
break;
*
* Get publication name and schema name from the object address into pubname and
* nspname. Both pubname and nspname are palloc'd strings which will be freed by
- * the caller. The last parameter specifies which object type is included from
- * the schema.
+ * the caller.
*/
static bool
getPublicationSchemaInfo(const ObjectAddress *object, bool missing_ok,
- char **pubname, char **nspname, char **objtype)
+ char **pubname, char **nspname)
{
HeapTuple tup;
Form_pg_publication_namespace pnform;
return false;
}
- /*
- * The type is always a single character, but we need to pass it as a string,
- * so allocate two charaters and set the first one. The second one is \0.
- */
- *objtype = palloc0(2);
- *objtype[0] = pnform->pntype;
-
ReleaseSysCache(tup);
return true;
}
{
char *pubname;
char *nspname;
- char *objtype;
if (!getPublicationSchemaInfo(object, missing_ok,
- &pubname, &nspname, &objtype))
+ &pubname, &nspname))
break;
- appendStringInfo(&buffer, _("publication of schema %s in publication %s type %s"),
- nspname, pubname, objtype);
+ appendStringInfo(&buffer, _("publication of schema %s in publication %s"),
+ nspname, pubname);
pfree(pubname);
pfree(nspname);
- pfree(objtype);
break;
}
{
char *pubname;
char *nspname;
- char *objtype;
if (!getPublicationSchemaInfo(object, missing_ok, &pubname,
- &nspname, &objtype))
+ &nspname))
break;
- appendStringInfo(&buffer, "%s in publication %s type %s",
- nspname, pubname, objtype);
+ appendStringInfo(&buffer, "%s in publication %s",
+ nspname, pubname);
if (objargs)
*objargs = list_make1(pubname);
else
pfree(pubname);
- if (objargs)
- *objargs = lappend(*objargs, objtype);
- else
- pfree(objtype);
-
if (objname)
*objname = list_make1(nspname);
else
static void
check_publication_add_relation(Relation targetrel)
{
- /* Must be a regular or partitioned table, or a sequence */
+ /* Must be a regular or partitioned table */
if (RelationGetForm(targetrel)->relkind != RELKIND_RELATION &&
- RelationGetForm(targetrel)->relkind != RELKIND_PARTITIONED_TABLE &&
- RelationGetForm(targetrel)->relkind != RELKIND_SEQUENCE)
+ RelationGetForm(targetrel)->relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add relation \"%s\" to publication",
is_publishable_class(Oid relid, Form_pg_class reltuple)
{
return (reltuple->relkind == RELKIND_RELATION ||
- reltuple->relkind == RELKIND_PARTITIONED_TABLE ||
- reltuple->relkind == RELKIND_SEQUENCE) &&
+ reltuple->relkind == RELKIND_PARTITIONED_TABLE) &&
!IsCatalogRelationOid(relid) &&
reltuple->relpersistence == RELPERSISTENCE_PERMANENT &&
relid >= FirstNormalObjectId;
return result;
}
-/*
- * Check the character is a valid object type for schema publication.
- *
- * This recognizes either 't' for tables or 's' for sequences. Places that
- * need to handle 'u' for unsupported relkinds need to do that explicitlyl
- */
-static void
-AssertObjectTypeValid(char objectType)
-{
-#ifdef USE_ASSERT_CHECKING
- Assert(objectType == PUB_OBJTYPE_SEQUENCE || objectType == PUB_OBJTYPE_TABLE);
-#endif
-}
-
-/*
- * Determine object type matching a given a relkind value.
- */
-char
-pub_get_object_type_for_relkind(char relkind)
-{
- /* sequence maps directly to sequence relkind */
- if (relkind == RELKIND_SEQUENCE)
- return PUB_OBJTYPE_SEQUENCE;
-
- /* for table, we match either regular or partitioned table */
- if (relkind == RELKIND_RELATION ||
- relkind == RELKIND_PARTITIONED_TABLE)
- return PUB_OBJTYPE_TABLE;
-
- return PUB_OBJTYPE_UNSUPPORTED;
-}
-
-/*
- * Determine if publication object type matches the relkind.
- *
- * Returns true if the relation matches object type replicated by this schema,
- * false otherwise.
- */
-static bool
-pub_object_type_matches_relkind(char objectType, char relkind)
-{
- AssertObjectTypeValid(objectType);
-
- return (pub_get_object_type_for_relkind(relkind) == objectType);
-}
-
/*
* Another variant of this, taking a Relation.
*/
ObjectIdGetDatum(pubid));
scan = systable_beginscan(pubschsrel,
- PublicationNamespacePnnspidPnpubidPntypeIndexId,
+ PublicationNamespacePnnspidPnpubidIndexId,
true, NULL, 1, &scankey);
tup = systable_getnext(scan);
result = HeapTupleIsValid(tup);
}
else
{
- /* we only search for ancestors of tables, so PUB_OBJTYPE_TABLE */
- aschemaPubids = GetSchemaPublications(get_rel_namespace(ancestor),
- PUB_OBJTYPE_TABLE);
+ aschemaPubids = GetSchemaPublications(get_rel_namespace(ancestor));
if (list_member_oid(aschemaPubids, puboid))
{
topmost_relid = ancestor;
* Insert new publication / schema mapping.
*/
ObjectAddress
-publication_add_schema(Oid pubid, Oid schemaid, char objectType, bool if_not_exists)
+publication_add_schema(Oid pubid, Oid schemaid, bool if_not_exists)
{
Relation rel;
HeapTuple tup;
ObjectAddress myself,
referenced;
- AssertObjectTypeValid(objectType);
-
rel = table_open(PublicationNamespaceRelationId, RowExclusiveLock);
/*
* duplicates, it's here just to provide nicer error message in common
* case. The real protection is the unique key on the catalog.
*/
- if (SearchSysCacheExists3(PUBLICATIONNAMESPACEMAP,
+ if (SearchSysCacheExists2(PUBLICATIONNAMESPACEMAP,
ObjectIdGetDatum(schemaid),
- ObjectIdGetDatum(pubid),
- CharGetDatum(objectType)))
+ ObjectIdGetDatum(pubid)))
{
table_close(rel, RowExclusiveLock);
ObjectIdGetDatum(pubid);
values[Anum_pg_publication_namespace_pnnspid - 1] =
ObjectIdGetDatum(schemaid);
- values[Anum_pg_publication_namespace_pntype - 1] =
- CharGetDatum(objectType);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
* publication_add_relation for why we need to consider all the
* partitions.
*/
- schemaRels = GetSchemaPublicationRelations(schemaid, objectType,
+ schemaRels = GetSchemaPublicationRelations(schemaid,
PUBLICATION_PART_ALL);
InvalidatePublicationRels(schemaRels);
/*
* Gets list of relation oids for a publication.
*
- * This should only be used FOR TABLE / FOR SEQUENCE publications, the FOR
- * ALL TABLES / SEQUENCES should use GetAllTablesPublicationRelations()
- * and GetAllSequencesPublicationRelations().
- *
- * XXX pub_partopt only matters for tables, not sequences.
+ * This should only be used FOR TABLE publications, the FOR ALL TABLES
+ * should use GetAllTablesPublicationRelations().
*/
List *
-GetPublicationRelations(Oid pubid, char objectType, PublicationPartOpt pub_partopt)
+GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
{
List *result;
Relation pubrelsrel;
SysScanDesc scan;
HeapTuple tup;
- AssertObjectTypeValid(objectType);
-
/* Find all publications associated with the relation. */
pubrelsrel = table_open(PublicationRelRelationId, AccessShareLock);
result = NIL;
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- char relkind;
Form_pg_publication_rel pubrel;
pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
- relkind = get_rel_relkind(pubrel->prrelid);
-
- /*
- * If the relkind does not match the requested object type, ignore the
- * relation. For example we might be interested only in sequences, so
- * we ignore tables.
- */
- if (!pub_object_type_matches_relkind(objectType, relkind))
- continue;
-
- /*
- * We don't have partitioned sequences, so just add them to the list.
- * Otherwise consider adding all child relations, if requested.
- */
- if (relkind == RELKIND_SEQUENCE)
- result = lappend_oid(result, pubrel->prrelid);
- else
- result = GetPubPartitionOptionRelations(result, pub_partopt,
- pubrel->prrelid);
+ result = GetPubPartitionOptionRelations(result, pub_partopt,
+ pubrel->prrelid);
}
systable_endscan(scan);
return result;
}
-/*
- * Gets list of publication oids for publications marked as FOR ALL SEQUENCES.
- */
-List *
-GetAllSequencesPublications(void)
-{
- List *result;
- Relation rel;
- ScanKeyData scankey;
- SysScanDesc scan;
- HeapTuple tup;
-
- /* Find all publications that are marked as for all sequences. */
- rel = table_open(PublicationRelationId, AccessShareLock);
-
- ScanKeyInit(&scankey,
- Anum_pg_publication_puballsequences,
- BTEqualStrategyNumber, F_BOOLEQ,
- BoolGetDatum(true));
-
- scan = systable_beginscan(rel, InvalidOid, false,
- NULL, 1, &scankey);
-
- result = NIL;
- while (HeapTupleIsValid(tup = systable_getnext(scan)))
- {
- Oid oid = ((Form_pg_publication) GETSTRUCT(tup))->oid;
-
- result = lappend_oid(result, oid);
- }
-
- systable_endscan(scan);
- table_close(rel, AccessShareLock);
-
- return result;
-}
-
/*
* Gets list of all relation published by FOR ALL TABLES publication(s).
*
/*
* Gets the list of schema oids for a publication.
*
- * This should only be used FOR ALL TABLES IN SCHEMA and FOR ALL SEQUENCES
- * publications.
- *
- * 'objectType' determines whether to get FOR TABLE or FOR SEQUENCES schemas
+ * This should only be used FOR ALL TABLES IN SCHEMA publications.
*/
List *
-GetPublicationSchemas(Oid pubid, char objectType)
+GetPublicationSchemas(Oid pubid)
{
List *result = NIL;
Relation pubschsrel;
- ScanKeyData scankey[2];
+ ScanKeyData scankey;
SysScanDesc scan;
HeapTuple tup;
- AssertObjectTypeValid(objectType);
-
/* Find all schemas associated with the publication */
pubschsrel = table_open(PublicationNamespaceRelationId, AccessShareLock);
- ScanKeyInit(&scankey[0],
+ ScanKeyInit(&scankey,
Anum_pg_publication_namespace_pnpubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(pubid));
- ScanKeyInit(&scankey[1],
- Anum_pg_publication_namespace_pntype,
- BTEqualStrategyNumber, F_CHAREQ,
- CharGetDatum(objectType));
-
scan = systable_beginscan(pubschsrel,
- PublicationNamespacePnnspidPnpubidPntypeIndexId,
- true, NULL, 2, scankey);
+ PublicationNamespacePnnspidPnpubidIndexId,
+ true, NULL, 1, &scankey);
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
Form_pg_publication_namespace pubsch;
/*
* Gets the list of publication oids associated with a specified schema.
- *
- * objectType specifies whether we're looking for schemas including tables or
- * sequences.
- *
- * Note: relcache calls this for all object types, not just tables and sequences.
- * Which is why we handle the PUB_OBJTYPE_UNSUPPORTED object type too.
*/
List *
-GetSchemaPublications(Oid schemaid, char objectType)
+GetSchemaPublications(Oid schemaid)
{
List *result = NIL;
CatCList *pubschlist;
int i;
- /* unsupported object type */
- if (objectType == PUB_OBJTYPE_UNSUPPORTED)
- return result;
-
- AssertObjectTypeValid(objectType);
-
/* Find all publications associated with the schema */
pubschlist = SearchSysCacheList1(PUBLICATIONNAMESPACEMAP,
ObjectIdGetDatum(schemaid));
{
HeapTuple tup = &pubschlist->members[i]->tuple;
Oid pubid = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pnpubid;
- char pntype = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pntype;
-
- /* Skip schemas publishing a different object type. */
- if (pntype != objectType)
- continue;
result = lappend_oid(result, pubid);
}
/*
* Get the list of publishable relation oids for a specified schema.
- *
- * objectType specifies whether this is FOR ALL TABLES IN SCHEMA or FOR ALL
- * SEQUENCES IN SCHEMA
*/
List *
-GetSchemaPublicationRelations(Oid schemaid, char objectType,
- PublicationPartOpt pub_partopt)
+GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
{
Relation classRel;
ScanKeyData key[1];
List *result = NIL;
Assert(OidIsValid(schemaid));
- AssertObjectTypeValid(objectType);
classRel = table_open(RelationRelationId, AccessShareLock);
continue;
relkind = get_rel_relkind(relid);
-
- /* Skip if the relkind does not match FOR ALL TABLES / SEQUENCES. */
- if (!pub_object_type_matches_relkind(objectType, relkind))
- continue;
-
- /*
- * If the object is a partitioned table, lookup all the child relations
- * (if requested). Otherwise just add the object to the list.
- */
- if (relkind == RELKIND_PARTITIONED_TABLE)
+ if (relkind == RELKIND_RELATION)
+ result = lappend_oid(result, relid);
+ else if (relkind == RELKIND_PARTITIONED_TABLE)
{
List *partitionrels = NIL;
pub_partopt,
relForm->oid);
result = list_concat_unique_oid(result, partitionrels);
- continue;
}
-
- /* non-partitioned tables and sequences */
- result = lappend_oid(result, relid);
}
table_endscan(scan);
/*
* Gets the list of all relations published by FOR ALL TABLES IN SCHEMA
- * or FOR ALL SEQUENCES IN SCHEMA publication.
+ * publication.
*/
List *
-GetAllSchemaPublicationRelations(Oid pubid, char objectType,
- PublicationPartOpt pub_partopt)
+GetAllSchemaPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
{
List *result = NIL;
- List *pubschemalist = GetPublicationSchemas(pubid, objectType);
+ List *pubschemalist = GetPublicationSchemas(pubid);
ListCell *cell;
- AssertObjectTypeValid(objectType);
-
foreach(cell, pubschemalist)
{
Oid schemaid = lfirst_oid(cell);
List *schemaRels = NIL;
- schemaRels = GetSchemaPublicationRelations(schemaid, objectType,
- pub_partopt);
+ schemaRels = GetSchemaPublicationRelations(schemaid, pub_partopt);
result = list_concat(result, schemaRels);
}
return result;
}
-/*
- * Gets list of all relation published by FOR ALL SEQUENCES publication(s).
- */
-List *
-GetAllSequencesPublicationRelations(void)
-{
- Relation classRel;
- ScanKeyData key[1];
- TableScanDesc scan;
- HeapTuple tuple;
- List *result = NIL;
-
- classRel = table_open(RelationRelationId, AccessShareLock);
-
- ScanKeyInit(&key[0],
- Anum_pg_class_relkind,
- BTEqualStrategyNumber, F_CHAREQ,
- CharGetDatum(RELKIND_SEQUENCE));
-
- scan = table_beginscan_catalog(classRel, 1, key);
-
- while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
- {
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
- Oid relid = relForm->oid;
-
- if (is_publishable_class(relid, relForm))
- result = lappend_oid(result, relid);
- }
-
- table_endscan(scan);
-
- table_close(classRel, AccessShareLock);
- return result;
-}
-
/*
* Get publication using oid
*
pub->oid = pubid;
pub->name = pstrdup(NameStr(pubform->pubname));
pub->alltables = pubform->puballtables;
- pub->allsequences = pubform->puballsequences;
pub->pubactions.pubinsert = pubform->pubinsert;
pub->pubactions.pubupdate = pubform->pubupdate;
pub->pubactions.pubdelete = pubform->pubdelete;
pub->pubactions.pubtruncate = pubform->pubtruncate;
- pub->pubactions.pubsequence = pubform->pubsequence;
pub->pubviaroot = pubform->pubviaroot;
ReleaseSysCache(tup);
*schemarelids;
relids = GetPublicationRelations(publication->oid,
- PUB_OBJTYPE_TABLE,
publication->pubviaroot ?
PUBLICATION_PART_ROOT :
PUBLICATION_PART_LEAF);
schemarelids = GetAllSchemaPublicationRelations(publication->oid,
- PUB_OBJTYPE_TABLE,
publication->pubviaroot ?
PUBLICATION_PART_ROOT :
PUBLICATION_PART_LEAF);
SRF_RETURN_DONE(funcctx);
}
-
-/*
- * Returns Oids of sequences in a publication.
- */
-Datum
-pg_get_publication_sequences(PG_FUNCTION_ARGS)
-{
- FuncCallContext *funcctx;
- char *pubname = text_to_cstring(PG_GETARG_TEXT_PP(0));
- Publication *publication;
- List *sequences;
-
- /* stuff done only on the first call of the function */
- if (SRF_IS_FIRSTCALL())
- {
- MemoryContext oldcontext;
-
- /* create a function context for cross-call persistence */
- funcctx = SRF_FIRSTCALL_INIT();
-
- /* switch to memory context appropriate for multiple function calls */
- oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
- publication = GetPublicationByName(pubname, false);
-
- /*
- * Publications support partitioned tables, although all changes are
- * replicated using leaf partition identity and schema, so we only
- * need those.
- */
- if (publication->allsequences)
- sequences = GetAllSequencesPublicationRelations();
- else
- {
- List *relids,
- *schemarelids;
-
- relids = GetPublicationRelations(publication->oid,
- PUB_OBJTYPE_SEQUENCE,
- publication->pubviaroot ?
- PUBLICATION_PART_ROOT :
- PUBLICATION_PART_LEAF);
- schemarelids = GetAllSchemaPublicationRelations(publication->oid,
- PUB_OBJTYPE_SEQUENCE,
- publication->pubviaroot ?
- PUBLICATION_PART_ROOT :
- PUBLICATION_PART_LEAF);
- sequences = list_concat_unique_oid(relids, schemarelids);
- }
-
- funcctx->user_fctx = (void *) sequences;
-
- MemoryContextSwitchTo(oldcontext);
- }
-
- /* stuff done on every call of the function */
- funcctx = SRF_PERCALL_SETUP();
- sequences = (List *) funcctx->user_fctx;
-
- if (funcctx->call_cntr < list_length(sequences))
- {
- Oid relid = list_nth_oid(sequences, funcctx->call_cntr);
-
- SRF_RETURN_NEXT(funcctx, ObjectIdGetDatum(relid));
- }
-
- SRF_RETURN_DONE(funcctx);
-}
pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE C.oid = GPT.relid;
-CREATE VIEW pg_publication_sequences AS
- SELECT
- P.pubname AS pubname,
- N.nspname AS schemaname,
- C.relname AS sequencename
- FROM pg_publication P,
- LATERAL pg_get_publication_sequences(P.pubname) GPS,
- pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
- WHERE C.oid = GPS.relid;
-
CREATE VIEW pg_locks AS
SELECT * FROM pg_lock_status() AS L;
#include "access/genam.h"
#include "access/htup_details.h"
-#include "access/relation.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
} rf_context;
static List *OpenRelIdList(List *relids);
-static List *OpenRelationList(List *rels, char objectType);
-static void CloseRelationList(List *rels);
+static List *OpenTableList(List *tables);
+static void CloseTableList(List *rels);
static void LockSchemaList(List *schemalist);
-static void PublicationAddRelations(Oid pubid, List *rels, bool if_not_exists,
+static void PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
AlterPublicationStmt *stmt);
-static void PublicationDropRelations(Oid pubid, List *rels, bool missing_ok);
-static void PublicationAddSchemas(Oid pubid, List *schemas, char objectType,
- bool if_not_exists, AlterPublicationStmt *stmt);
-static void PublicationDropSchemas(Oid pubid, List *schemas, char objectType,
- bool missing_ok);
-
+static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
+static void PublicationAddSchemas(Oid pubid, List *schemas, bool if_not_exists,
+ AlterPublicationStmt *stmt);
+static void PublicationDropSchemas(Oid pubid, List *schemas, bool missing_ok);
static void
parse_publication_options(ParseState *pstate,
pubactions->pubupdate = true;
pubactions->pubdelete = true;
pubactions->pubtruncate = true;
- pubactions->pubsequence = true;
*publish_via_partition_root = false;
/* Parse options */
pubactions->pubupdate = false;
pubactions->pubdelete = false;
pubactions->pubtruncate = false;
- pubactions->pubsequence = false;
*publish_given = true;
publish = defGetString(defel);
pubactions->pubdelete = true;
else if (strcmp(publish_opt, "truncate") == 0)
pubactions->pubtruncate = true;
- else if (strcmp(publish_opt, "sequence") == 0)
- pubactions->pubsequence = true;
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
*/
static void
ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
- List **tables, List **sequences,
- List **tables_schemas, List **sequences_schemas)
+ List **rels, List **schemas)
{
ListCell *cell;
PublicationObjSpec *pubobj;
switch (pubobj->pubobjtype)
{
case PUBLICATIONOBJ_TABLE:
- *tables = lappend(*tables, pubobj->pubtable);
- break;
- case PUBLICATIONOBJ_SEQUENCE:
- *sequences = lappend(*sequences, pubobj->pubtable);
+ *rels = lappend(*rels, pubobj->pubtable);
break;
case PUBLICATIONOBJ_TABLES_IN_SCHEMA:
schemaid = get_namespace_oid(pubobj->name, false);
/* Filter out duplicates if user specifies "sch1, sch1" */
- *tables_schemas = list_append_unique_oid(*tables_schemas, schemaid);
- break;
- case PUBLICATIONOBJ_SEQUENCES_IN_SCHEMA:
- schemaid = get_namespace_oid(pubobj->name, false);
-
- /* Filter out duplicates if user specifies "sch1, sch1" */
- *sequences_schemas = list_append_unique_oid(*sequences_schemas, schemaid);
+ *schemas = list_append_unique_oid(*schemas, schemaid);
break;
case PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA:
search_path = fetch_search_path(false);
list_free(search_path);
/* Filter out duplicates if user specifies "sch1, sch1" */
- *tables_schemas = list_append_unique_oid(*tables_schemas, schemaid);
- break;
- case PUBLICATIONOBJ_SEQUENCES_IN_CUR_SCHEMA:
- search_path = fetch_search_path(false);
- if (search_path == NIL) /* nothing valid in search_path? */
- ereport(ERROR,
- errcode(ERRCODE_UNDEFINED_SCHEMA),
- errmsg("no schema has been selected for CURRENT_SCHEMA"));
-
- schemaid = linitial_oid(search_path);
- list_free(search_path);
-
- /* Filter out duplicates if user specifies "sch1, sch1" */
- *sequences_schemas = list_append_unique_oid(*sequences_schemas, schemaid);
+ *schemas = list_append_unique_oid(*schemas, schemaid);
break;
default:
/* shouldn't happen */
errdetail("Table \"%s\" in schema \"%s\" is already part of the publication, adding the same schema is not supported.",
RelationGetRelationName(rel),
get_namespace_name(relSchemaId)));
- else if (checkobjtype == PUBLICATIONOBJ_SEQUENCES_IN_SCHEMA)
- ereport(ERROR,
- errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("cannot add schema \"%s\" to publication",
- get_namespace_name(relSchemaId)),
- errdetail("Sequence \"%s\" in schema \"%s\" is already part of the publication, adding the same schema is not supported.",
- RelationGetRelationName(rel),
- get_namespace_name(relSchemaId)));
else if (checkobjtype == PUBLICATIONOBJ_TABLE)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
RelationGetRelationName(rel)),
errdetail("Table's schema \"%s\" is already part of the publication or part of the specified schema list.",
get_namespace_name(relSchemaId)));
- else if (checkobjtype == PUBLICATIONOBJ_SEQUENCE)
- ereport(ERROR,
- errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("cannot add relation \"%s.%s\" to publication",
- get_namespace_name(relSchemaId),
- RelationGetRelationName(rel)),
- errdetail("Sequence's schema \"%s\" is already part of the publication or part of the specified schema list.",
- get_namespace_name(relSchemaId)));
}
}
}
ObjectAddress
CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
{
- ListCell *lc;
Relation rel;
ObjectAddress myself;
Oid puboid;
bool publish_via_partition_root_given;
bool publish_via_partition_root;
AclResult aclresult;
- List *tables = NIL;
- List *sequences = NIL;
- List *tables_schemaidlist = NIL;
- List *sequences_schemaidlist = NIL;
-
- bool for_all_tables = false;
- bool for_all_sequences = false;
-
- /* Translate the list of object types (represented by strings) to bool flags. */
- foreach (lc, stmt->for_all_objects)
- {
- char *val = strVal(lfirst(lc));
- if (strcmp(val, "tables") == 0)
- for_all_tables = true;
- else if (strcmp(val, "sequences") == 0)
- for_all_sequences = true;
- }
+ List *relations = NIL;
+ List *schemaidlist = NIL;
/* must have CREATE privilege on database */
aclresult = pg_database_aclcheck(MyDatabaseId, GetUserId(), ACL_CREATE);
get_database_name(MyDatabaseId));
/* FOR ALL TABLES requires superuser */
- if (for_all_tables && !superuser())
+ if (stmt->for_all_tables && !superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to create FOR ALL TABLES publication")));
- /* FOR ALL SEQUENCES requires superuser */
- if (for_all_sequences && !superuser())
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to create FOR ALL SEQUENCES publication")));
-
rel = table_open(PublicationRelationId, RowExclusiveLock);
/* Check if name is used */
Anum_pg_publication_oid);
values[Anum_pg_publication_oid - 1] = ObjectIdGetDatum(puboid);
values[Anum_pg_publication_puballtables - 1] =
- BoolGetDatum(for_all_tables);
- values[Anum_pg_publication_puballsequences - 1] =
- BoolGetDatum(for_all_sequences);
+ BoolGetDatum(stmt->for_all_tables);
values[Anum_pg_publication_pubinsert - 1] =
BoolGetDatum(pubactions.pubinsert);
values[Anum_pg_publication_pubupdate - 1] =
BoolGetDatum(pubactions.pubdelete);
values[Anum_pg_publication_pubtruncate - 1] =
BoolGetDatum(pubactions.pubtruncate);
- values[Anum_pg_publication_pubsequence - 1] =
- BoolGetDatum(pubactions.pubsequence);
values[Anum_pg_publication_pubviaroot - 1] =
BoolGetDatum(publish_via_partition_root);
CommandCounterIncrement();
/* Associate objects with the publication. */
- if (for_all_tables || for_all_sequences)
+ if (stmt->for_all_tables)
{
/* Invalidate relcache so that publication info is rebuilt. */
CacheInvalidateRelcacheAll();
}
-
- /*
- * If the publication might have either tables or sequences (directly or
- * through a schema), process that.
- */
- if (!for_all_tables || !for_all_sequences)
+ else
{
- ObjectsInPublicationToOids(stmt->pubobjects, pstate,
- &tables, &sequences,
- &tables_schemaidlist,
- &sequences_schemaidlist);
+ ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
+ &schemaidlist);
/* FOR ALL TABLES IN SCHEMA requires superuser */
- if (list_length(tables_schemaidlist) > 0 && !superuser())
+ if (list_length(schemaidlist) > 0 && !superuser())
ereport(ERROR,
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to create FOR ALL TABLES IN SCHEMA publication"));
- /* FOR ALL SEQUENCES IN SCHEMA requires superuser */
- if (list_length(sequences_schemaidlist) > 0 && !superuser())
- ereport(ERROR,
- errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to create FOR ALL SEQUENCES IN SCHEMA publication"));
-
- /* tables added directly */
- if (list_length(tables) > 0)
+ if (list_length(relations) > 0)
{
List *rels;
- rels = OpenRelationList(tables, PUB_OBJTYPE_TABLE);
- CheckObjSchemaNotAlreadyInPublication(rels, tables_schemaidlist,
+ rels = OpenTableList(relations);
+ CheckObjSchemaNotAlreadyInPublication(rels, schemaidlist,
PUBLICATIONOBJ_TABLE);
TransformPubWhereClauses(rels, pstate->p_sourcetext,
CheckPubRelationColumnList(rels, pstate->p_sourcetext,
publish_via_partition_root);
- PublicationAddRelations(puboid, rels, true, NULL);
- CloseRelationList(rels);
+ PublicationAddTables(puboid, rels, true, NULL);
+ CloseTableList(rels);
}
- /* sequences added directly */
- if (list_length(sequences) > 0)
- {
- List *rels;
-
- rels = OpenRelationList(sequences, PUB_OBJTYPE_SEQUENCE);
- CheckObjSchemaNotAlreadyInPublication(rels, sequences_schemaidlist,
- PUBLICATIONOBJ_SEQUENCE);
- PublicationAddRelations(puboid, rels, true, NULL);
- CloseRelationList(rels);
- }
-
- /* tables added through a schema */
- if (list_length(tables_schemaidlist) > 0)
+ if (list_length(schemaidlist) > 0)
{
/*
* Schema lock is held until the publication is created to prevent
* concurrent schema deletion.
*/
- LockSchemaList(tables_schemaidlist);
- PublicationAddSchemas(puboid,
- tables_schemaidlist, PUB_OBJTYPE_TABLE,
- true, NULL);
- }
-
- /* sequences added through a schema */
- if (list_length(sequences_schemaidlist) > 0)
- {
- /*
- * Schema lock is held until the publication is created to prevent
- * concurrent schema deletion.
- */
- LockSchemaList(sequences_schemaidlist);
- PublicationAddSchemas(puboid,
- sequences_schemaidlist, PUB_OBJTYPE_SEQUENCE,
- true, NULL);
+ LockSchemaList(schemaidlist);
+ PublicationAddSchemas(puboid, schemaidlist, true, NULL);
}
}
AccessShareLock);
root_relids = GetPublicationRelations(pubform->oid,
- PUB_OBJTYPE_TABLE,
PUBLICATION_PART_ROOT);
foreach(lc, root_relids)
values[Anum_pg_publication_pubtruncate - 1] = BoolGetDatum(pubactions.pubtruncate);
replaces[Anum_pg_publication_pubtruncate - 1] = true;
-
- values[Anum_pg_publication_pubsequence - 1] = BoolGetDatum(pubactions.pubsequence);
- replaces[Anum_pg_publication_pubsequence - 1] = true;
}
if (publish_via_partition_root_given)
pubform = (Form_pg_publication) GETSTRUCT(tup);
/* Invalidate the relcache. */
- if (pubform->puballtables || pubform->puballsequences)
+ if (pubform->puballtables)
{
CacheInvalidateRelcacheAll();
}
*/
if (root_relids == NIL)
relids = GetPublicationRelations(pubform->oid,
- PUB_OBJTYPE_TABLE,
PUBLICATION_PART_ALL);
else
{
lfirst_oid(lc));
}
- /* tables */
- schemarelids = GetAllSchemaPublicationRelations(pubform->oid,
- PUB_OBJTYPE_TABLE,
- PUBLICATION_PART_ALL);
- relids = list_concat_unique_oid(relids, schemarelids);
-
- /* sequences */
- relids = list_concat_unique_oid(relids,
- GetPublicationRelations(pubform->oid,
- PUB_OBJTYPE_SEQUENCE,
- PUBLICATION_PART_ALL));
-
schemarelids = GetAllSchemaPublicationRelations(pubform->oid,
- PUB_OBJTYPE_SEQUENCE,
PUBLICATION_PART_ALL);
relids = list_concat_unique_oid(relids, schemarelids);
if (!tables && stmt->action != AP_SetObjects)
return;
- rels = OpenRelationList(tables, PUB_OBJTYPE_TABLE);
+ rels = OpenTableList(tables);
if (stmt->action == AP_AddObjects)
{
* Check if the relation is member of the existing schema in the
* publication or member of the schema list specified.
*/
- schemas = list_concat_copy(schemaidlist,
- GetPublicationSchemas(pubid,
- PUB_OBJTYPE_TABLE));
+ schemas = list_concat_copy(schemaidlist, GetPublicationSchemas(pubid));
CheckObjSchemaNotAlreadyInPublication(rels, schemas,
PUBLICATIONOBJ_TABLE);
CheckPubRelationColumnList(rels, queryString, pubform->pubviaroot);
- PublicationAddRelations(pubid, rels, false, stmt);
+ PublicationAddTables(pubid, rels, false, stmt);
}
else if (stmt->action == AP_DropObjects)
- PublicationDropRelations(pubid, rels, false);
+ PublicationDropTables(pubid, rels, false);
else /* AP_SetObjects */
{
List *oldrelids = GetPublicationRelations(pubid,
- PUB_OBJTYPE_TABLE,
PUBLICATION_PART_ROOT);
List *delrels = NIL;
ListCell *oldlc;
}
/* And drop them. */
- PublicationDropRelations(pubid, delrels, true);
+ PublicationDropTables(pubid, delrels, true);
/*
* Don't bother calculating the difference for adding, we'll catch and
* skip existing ones when doing catalog update.
*/
- PublicationAddRelations(pubid, rels, true, stmt);
+ PublicationAddTables(pubid, rels, true, stmt);
- CloseRelationList(delrels);
+ CloseTableList(delrels);
}
- CloseRelationList(rels);
+ CloseTableList(rels);
}
/*
*/
static void
AlterPublicationSchemas(AlterPublicationStmt *stmt,
- HeapTuple tup, List *schemaidlist,
- char objectType)
+ HeapTuple tup, List *schemaidlist)
{
Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
List *rels;
List *reloids;
- reloids = GetPublicationRelations(pubform->oid, objectType, PUBLICATION_PART_ROOT);
+ reloids = GetPublicationRelations(pubform->oid, PUBLICATION_PART_ROOT);
rels = OpenRelIdList(reloids);
CheckObjSchemaNotAlreadyInPublication(rels, schemaidlist,
PUBLICATIONOBJ_TABLES_IN_SCHEMA);
- CloseRelationList(rels);
- PublicationAddSchemas(pubform->oid, schemaidlist, objectType, false, stmt);
+ CloseTableList(rels);
+ PublicationAddSchemas(pubform->oid, schemaidlist, false, stmt);
}
else if (stmt->action == AP_DropObjects)
- PublicationDropSchemas(pubform->oid, schemaidlist, objectType, false);
+ PublicationDropSchemas(pubform->oid, schemaidlist, false);
else /* AP_SetObjects */
{
- List *oldschemaids = GetPublicationSchemas(pubform->oid, objectType);
+ List *oldschemaids = GetPublicationSchemas(pubform->oid);
List *delschemas = NIL;
/* Identify which schemas should be dropped */
LockSchemaList(delschemas);
/* And drop them */
- PublicationDropSchemas(pubform->oid, delschemas, objectType, true);
+ PublicationDropSchemas(pubform->oid, delschemas, true);
/*
* Don't bother calculating the difference for adding, we'll catch and
* skip existing ones when doing catalog update.
*/
- PublicationAddSchemas(pubform->oid, schemaidlist, objectType, true, stmt);
+ PublicationAddSchemas(pubform->oid, schemaidlist, true, stmt);
}
}
*/
static void
CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
- List *tables, List *tables_schemaidlist,
- List *sequences, List *sequences_schemaidlist)
+ List *tables, List *schemaidlist)
{
Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
if ((stmt->action == AP_AddObjects || stmt->action == AP_SetObjects) &&
- (tables_schemaidlist || sequences_schemaidlist) && !superuser())
+ schemaidlist && !superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to add or set schemas")));
* Check that user is allowed to manipulate the publication tables in
* schema
*/
- if (tables_schemaidlist && pubform->puballtables)
+ if (schemaidlist && pubform->puballtables)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
NameStr(pubform->pubname)),
errdetail("Tables from schema cannot be added to, dropped from, or set on FOR ALL TABLES publications.")));
- /*
- * Check that user is allowed to manipulate the publication sequences in
- * schema
- */
- if (sequences_schemaidlist && pubform->puballsequences)
- ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("publication \"%s\" is defined as FOR ALL SEQUENCES",
- NameStr(pubform->pubname)),
- errdetail("Sequences from schema cannot be added to, dropped from, or set on FOR ALL SEQUENCES publications.")));
-
/* Check that user is allowed to manipulate the publication tables. */
if (tables && pubform->puballtables)
ereport(ERROR,
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
NameStr(pubform->pubname)),
errdetail("Tables cannot be added to or dropped from FOR ALL TABLES publications.")));
-
- /* Check that user is allowed to manipulate the publication sequences. */
- if (sequences && pubform->puballsequences)
- ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("publication \"%s\" is defined as FOR ALL SEQUENCES",
- NameStr(pubform->pubname)),
- errdetail("Sequences cannot be added to or dropped from FOR ALL SEQUENCES publications.")));
-}
-
-/*
- * Add or remove sequence to/from publication.
- */
-static void
-AlterPublicationSequences(AlterPublicationStmt *stmt, HeapTuple tup,
- List *sequences, List *schemaidlist)
-{
- List *rels = NIL;
- Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
- Oid pubid = pubform->oid;
-
- /*
- * It is quite possible that for the SET case user has not specified any
- * tables in which case we need to remove all the existing tables.
- */
- if (!sequences && stmt->action != AP_SetObjects)
- return;
-
- rels = OpenRelationList(sequences, PUB_OBJTYPE_SEQUENCE);
-
- if (stmt->action == AP_AddObjects)
- {
- List *schemas = NIL;
-
- /*
- * Check if the relation is member of the existing schema in the
- * publication or member of the schema list specified.
- */
- schemas = list_concat_copy(schemaidlist,
- GetPublicationSchemas(pubid,
- PUB_OBJTYPE_SEQUENCE));
- CheckObjSchemaNotAlreadyInPublication(rels, schemas,
- PUBLICATIONOBJ_SEQUENCE);
- PublicationAddRelations(pubid, rels, false, stmt);
- }
- else if (stmt->action == AP_DropObjects)
- PublicationDropRelations(pubid, rels, false);
- else /* DEFELEM_SET */
- {
- List *oldrelids = GetPublicationRelations(pubid,
- PUB_OBJTYPE_SEQUENCE,
- PUBLICATION_PART_ROOT);
- List *delrels = NIL;
- ListCell *oldlc;
-
- CheckObjSchemaNotAlreadyInPublication(rels, schemaidlist,
- PUBLICATIONOBJ_SEQUENCE);
-
- /* Calculate which relations to drop. */
- foreach(oldlc, oldrelids)
- {
- Oid oldrelid = lfirst_oid(oldlc);
- ListCell *newlc;
- PublicationRelInfo *oldrel;
- bool found = false;
-
- foreach(newlc, rels)
- {
- PublicationRelInfo *newpubrel;
-
- newpubrel = (PublicationRelInfo *) lfirst(newlc);
- if (RelationGetRelid(newpubrel->relation) == oldrelid)
- {
- found = true;
- break;
- }
- }
- /* Not yet in the list, open it and add to the list */
- if (!found)
- {
- oldrel = palloc(sizeof(PublicationRelInfo));
- oldrel->whereClause = NULL;
- oldrel->columns = NULL;
- oldrel->relation = table_open(oldrelid,
- ShareUpdateExclusiveLock);
- delrels = lappend(delrels, oldrel);
- }
- }
-
- /* And drop them. */
- PublicationDropRelations(pubid, delrels, true);
-
- /*
- * Don't bother calculating the difference for adding, we'll catch and
- * skip existing ones when doing catalog update.
- */
- PublicationAddRelations(pubid, rels, true, stmt);
-
- CloseRelationList(delrels);
- }
-
- CloseRelationList(rels);
}
/*
AlterPublicationOptions(pstate, stmt, rel, tup);
else
{
- List *tables = NIL;
- List *sequences = NIL;
- List *tables_schemaidlist = NIL;
- List *sequences_schemaidlist = NIL;
+ List *relations = NIL;
+ List *schemaidlist = NIL;
Oid pubid = pubform->oid;
- ObjectsInPublicationToOids(stmt->pubobjects, pstate,
- &tables, &sequences,
- &tables_schemaidlist,
- &sequences_schemaidlist);
+ ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
+ &schemaidlist);
- CheckAlterPublication(stmt, tup,
- tables, tables_schemaidlist,
- sequences, sequences_schemaidlist);
+ CheckAlterPublication(stmt, tup, relations, schemaidlist);
heap_freetuple(tup);
errmsg("publication \"%s\" does not exist",
stmt->pubname));
- AlterPublicationTables(stmt, tup, tables, tables_schemaidlist,
+ AlterPublicationTables(stmt, tup, relations, schemaidlist,
pstate->p_sourcetext);
-
- AlterPublicationSequences(stmt, tup, sequences, sequences_schemaidlist);
-
- AlterPublicationSchemas(stmt, tup, tables_schemaidlist,
- PUB_OBJTYPE_TABLE);
-
- AlterPublicationSchemas(stmt, tup, sequences_schemaidlist,
- PUB_OBJTYPE_SEQUENCE);
+ AlterPublicationSchemas(stmt, tup, schemaidlist);
}
/* Cleanup. */
pubform = (Form_pg_publication) GETSTRUCT(tup);
/* Invalidate relcache so that publication info is rebuilt. */
- if (pubform->puballtables || pubform->puballsequences)
+ if (pubform->puballtables)
CacheInvalidateRelcacheAll();
CatalogTupleDelete(rel, &tup->t_self);
* partitions.
*/
schemaRels = GetSchemaPublicationRelations(pubsch->pnnspid,
- pubsch->pntype,
PUBLICATION_PART_ALL);
InvalidatePublicationRels(schemaRels);
* add them to a publication.
*/
static List *
-OpenRelationList(List *rels, char objectType)
+OpenTableList(List *tables)
{
List *relids = NIL;
- List *result = NIL;
+ List *rels = NIL;
ListCell *lc;
List *relids_with_rf = NIL;
List *relids_with_collist = NIL;
/*
* Open, share-lock, and check all the explicitly-specified relations
*/
- foreach(lc, rels)
+ foreach(lc, tables)
{
PublicationTable *t = lfirst_node(PublicationTable, lc);
bool recurse = t->relation->inh;
Relation rel;
Oid myrelid;
PublicationRelInfo *pub_rel;
- char myrelkind;
/* Allow query cancel in case this takes a long time */
CHECK_FOR_INTERRUPTS();
rel = table_openrv(t->relation, ShareUpdateExclusiveLock);
myrelid = RelationGetRelid(rel);
- myrelkind = get_rel_relkind(myrelid);
-
- /*
- * Make sure the relkind matches the expected object type. This may
- * happen e.g. when adding a sequence using ADD TABLE or a table
- * using ADD SEQUENCE).
- *
- * XXX We let through unsupported object types (views etc.). Those
- * will be caught later in check_publication_add_relation.
- */
- if (pub_get_object_type_for_relkind(myrelkind) != PUB_OBJTYPE_UNSUPPORTED &&
- pub_get_object_type_for_relkind(myrelkind) != objectType)
- ereport(ERROR,
- errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("object type does not match type expected by command"));
/*
* Filter out duplicates if user specifies "foo, foo".
pub_rel->relation = rel;
pub_rel->whereClause = t->whereClause;
pub_rel->columns = t->columns;
- result = lappend(result, pub_rel);
+ rels = lappend(rels, pub_rel);
relids = lappend_oid(relids, myrelid);
if (t->whereClause)
pub_rel->relation = rel;
/* child inherits WHERE clause from parent */
pub_rel->whereClause = t->whereClause;
+
/* child inherits column list from parent */
pub_rel->columns = t->columns;
- result = lappend(result, pub_rel);
+ rels = lappend(rels, pub_rel);
relids = lappend_oid(relids, childrelid);
if (t->whereClause)
list_free(relids);
list_free(relids_with_rf);
- return result;
+ return rels;
}
/*
* Close all relations in the list.
*/
static void
-CloseRelationList(List *rels)
+CloseTableList(List *rels)
{
ListCell *lc;
* Add listed tables to the publication.
*/
static void
-PublicationAddRelations(Oid pubid, List *rels, bool if_not_exists,
+PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
AlterPublicationStmt *stmt)
{
ListCell *lc;
- Assert(!stmt || !stmt->for_all_objects);
+ Assert(!stmt || !stmt->for_all_tables);
foreach(lc, rels)
{
* Remove listed tables from the publication.
*/
static void
-PublicationDropRelations(Oid pubid, List *rels, bool missing_ok)
+PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
{
ObjectAddress obj;
ListCell *lc;
* Add listed schemas to the publication.
*/
static void
-PublicationAddSchemas(Oid pubid, List *schemas, char objectType,
- bool if_not_exists, AlterPublicationStmt *stmt)
+PublicationAddSchemas(Oid pubid, List *schemas, bool if_not_exists,
+ AlterPublicationStmt *stmt)
{
ListCell *lc;
- Assert(!stmt || !stmt->for_all_objects);
+ Assert(!stmt || !stmt->for_all_tables);
foreach(lc, schemas)
{
Oid schemaid = lfirst_oid(lc);
ObjectAddress obj;
- obj = publication_add_schema(pubid, schemaid, objectType, if_not_exists);
+ obj = publication_add_schema(pubid, schemaid, if_not_exists);
if (stmt)
{
EventTriggerCollectSimpleCommand(obj, InvalidObjectAddress,
* Remove listed schemas from the publication.
*/
static void
-PublicationDropSchemas(Oid pubid, List *schemas, char objectType, bool missing_ok)
+PublicationDropSchemas(Oid pubid, List *schemas, bool missing_ok)
{
ObjectAddress obj;
ListCell *lc;
{
Oid schemaid = lfirst_oid(lc);
- psid = GetSysCacheOid3(PUBLICATIONNAMESPACEMAP,
+ psid = GetSysCacheOid2(PUBLICATIONNAMESPACEMAP,
Anum_pg_publication_namespace_oid,
ObjectIdGetDatum(schemaid),
- ObjectIdGetDatum(pubid),
- CharGetDatum(objectType));
+ ObjectIdGetDatum(pubid));
if (!OidIsValid(psid))
{
if (missing_ok)
NameStr(form->pubname)),
errhint("The owner of a FOR ALL TABLES publication must be a superuser.")));
- if (form->puballsequences && !superuser_arg(newOwnerId))
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to change owner of publication \"%s\"",
- NameStr(form->pubname)),
- errhint("The owner of a FOR ALL SEQUENCES publication must be a superuser.")));
-
if (!superuser_arg(newOwnerId) && is_schema_publication(form->oid))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
relation_close(seq_rel, NoLock);
}
-/*
- * Update the sequence state by modifying the existing sequence data row.
- *
- * This keeps the same relfilenode, so the behavior is non-transactional.
- */
-static void
-SetSequence_non_transactional(Oid seqrelid, int64 last_value, int64 log_cnt, bool is_called)
-{
- SeqTable elm;
- Relation seqrel;
- Buffer buf;
- HeapTupleData seqdatatuple;
- Form_pg_sequence_data seq;
-
- /* open and lock sequence */
- init_sequence(seqrelid, &elm, &seqrel);
-
- /* lock page' buffer and read tuple */
- seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
-
- /* check the comment above nextval_internal()'s equivalent call. */
- if (RelationNeedsWAL(seqrel))
- {
- GetTopTransactionId();
-
- if (XLogLogicalInfoActive())
- GetCurrentTransactionId();
- }
-
- /* ready to change the on-disk (or really, in-buffer) tuple */
- START_CRIT_SECTION();
-
- seq->last_value = last_value;
- seq->is_called = is_called;
- seq->log_cnt = log_cnt;
-
- MarkBufferDirty(buf);
-
- /* XLOG stuff */
- if (RelationNeedsWAL(seqrel))
- {
- xl_seq_rec xlrec;
- XLogRecPtr recptr;
- Page page = BufferGetPage(buf);
-
- XLogBeginInsert();
- XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
-
- xlrec.node = seqrel->rd_node;
- xlrec.created = false;
-
- XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
- XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
-
- recptr = XLogInsert(RM_SEQ_ID, XLOG_SEQ_LOG);
-
- PageSetLSN(page, recptr);
- }
-
- END_CRIT_SECTION();
-
- UnlockReleaseBuffer(buf);
-
- /* Clear local cache so that we don't think we have cached numbers */
- /* Note that we do not change the currval() state */
- elm->cached = elm->last;
-
- relation_close(seqrel, NoLock);
-}
-
-/*
- * Update the sequence state by creating a new relfilenode.
- *
- * This creates a new relfilenode, to allow transactional behavior.
- */
-static void
-SetSequence_transactional(Oid seq_relid, int64 last_value, int64 log_cnt, bool is_called)
-{
- SeqTable elm;
- Relation seqrel;
- Buffer buf;
- HeapTupleData seqdatatuple;
- Form_pg_sequence_data seq;
- HeapTuple tuple;
-
- /* open and lock sequence */
- init_sequence(seq_relid, &elm, &seqrel);
-
- /* lock page' buffer and read tuple */
- seq = read_seq_tuple(seqrel, &buf, &seqdatatuple);
-
- /* Copy the existing sequence tuple. */
- tuple = heap_copytuple(&seqdatatuple);
-
- /* Now we're done with the old page */
- UnlockReleaseBuffer(buf);
-
- /*
- * Modify the copied tuple to update the sequence state (similar to what
- * ResetSequence does).
- */
- seq = (Form_pg_sequence_data) GETSTRUCT(tuple);
- seq->last_value = last_value;
- seq->is_called = is_called;
- seq->log_cnt = log_cnt;
-
- /*
- * Create a new storage file for the sequence - this is needed for the
- * transactional behavior.
- */
- RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence);
-
- /*
- * Ensure sequence's relfrozenxid is at 0, since it won't contain any
- * unfrozen XIDs. Same with relminmxid, since a sequence will never
- * contain multixacts.
- */
- Assert(seqrel->rd_rel->relfrozenxid == InvalidTransactionId);
- Assert(seqrel->rd_rel->relminmxid == InvalidMultiXactId);
-
- /*
- * Insert the modified tuple into the new storage file. This does all the
- * necessary WAL-logging etc.
- */
- fill_seq_with_data(seqrel, tuple);
-
- /* Clear local cache so that we don't think we have cached numbers */
- /* Note that we do not change the currval() state */
- elm->cached = elm->last;
-
- relation_close(seqrel, NoLock);
-}
-
-/*
- * Set a sequence to a specified internal state.
- *
- * The change is made transactionally, so that on failure of the current
- * transaction, the sequence will be restored to its previous state.
- * We do that by creating a whole new relfilenode for the sequence; so this
- * works much like the rewriting forms of ALTER TABLE.
- *
- * Caller is assumed to have acquired AccessExclusiveLock on the sequence,
- * which must not be released until end of transaction. Caller is also
- * responsible for permissions checking.
- */
-void
-SetSequence(Oid seq_relid, bool transactional, int64 last_value, int64 log_cnt, bool is_called)
-{
- if (transactional)
- SetSequence_transactional(seq_relid, last_value, log_cnt, is_called);
- else
- SetSequence_non_transactional(seq_relid, last_value, log_cnt, is_called);
-}
-
/*
* Initialize a sequence's relation with the specified tuple as content
*
/* check the comment above nextval_internal()'s equivalent call. */
if (RelationNeedsWAL(rel))
- {
GetTopTransactionId();
- if (XLogLogicalInfoActive())
- GetCurrentTransactionId();
- }
-
START_CRIT_SECTION();
MarkBufferDirty(buf);
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
xlrec.node = rel->rd_node;
- xlrec.created = true;
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
XLogRegisterData((char *) tuple->t_data, tuple->t_len);
* It's sufficient to ensure the toplevel transaction has an xid, no need
* to assign xids subxacts, that'll already trigger an appropriate wait.
* (Have to do that here, so we're outside the critical section)
- *
- * We have to ensure we have a proper XID, which will be included in
- * the XLOG record by XLogRecordAssemble. Otherwise the first nextval()
- * in a subxact (without any preceding changes) would get XID 0, and it
- * would then be impossible to decide which top xact it belongs to.
- * It'd also trigger assert in DecodeSequence. We only do that with
- * wal_level=logical, though.
- *
- * XXX This might seem unnecessary, because if there's no XID the xact
- * couldn't have done anything important yet, e.g. it could not have
- * created a sequence. But that's incorrect, because of subxacts. The
- * current subtransaction might not have done anything yet (thus no XID),
- * but an earlier one might have created the sequence.
*/
if (logit && RelationNeedsWAL(seqrel))
- {
GetTopTransactionId();
- if (XLogLogicalInfoActive())
- GetCurrentTransactionId();
- }
-
/* ready to change the on-disk (or really, in-buffer) tuple */
START_CRIT_SECTION();
seq->log_cnt = 0;
xlrec.node = seqrel->rd_node;
- xlrec.created = false;
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
/* check the comment above nextval_internal()'s equivalent call. */
if (RelationNeedsWAL(seqrel))
- {
GetTopTransactionId();
- if (XLogLogicalInfoActive())
- GetCurrentTransactionId();
- }
-
/* ready to change the on-disk (or really, in-buffer) tuple */
START_CRIT_SECTION();
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
xlrec.node = seqrel->rd_node;
- xlrec.created = false;
-
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
} SubOpts;
static List *fetch_table_list(WalReceiverConn *wrconn, List *publications);
-static List *fetch_sequence_list(WalReceiverConn *wrconn, List *publications);
static void check_duplicates_in_publist(List *publist, Datum *datums);
static List *merge_publications(List *oldpublist, List *newpublist, bool addpub, const char *subname);
static void ReportSlotConnectionError(List *rstates, Oid subid, char *slotname, char *err);
{
char *err;
WalReceiverConn *wrconn;
- List *relations;
+ List *tables;
ListCell *lc;
- char sync_state;
+ char table_state;
/* Try to connect to the publisher. */
wrconn = walrcv_connect(conninfo, true, stmt->subname, &err);
* Set sync state based on if we were asked to do data copy or
* not.
*/
- sync_state = opts.copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY;
+ table_state = opts.copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY;
/*
- * Get the table and sequence list from publisher and build
- * local relation sync status info.
+ * Get the table list from publisher and build local table status
+ * info.
*/
- relations = fetch_table_list(wrconn, publications);
- relations = list_concat(relations,
- fetch_sequence_list(wrconn, publications));
-
- foreach(lc, relations)
+ tables = fetch_table_list(wrconn, publications);
+ foreach(lc, tables)
{
RangeVar *rv = (RangeVar *) lfirst(lc);
Oid relid;
CheckSubscriptionRelkind(get_rel_relkind(relid),
rv->schemaname, rv->relname);
- AddSubscriptionRelState(subid, relid, sync_state,
+ AddSubscriptionRelState(subid, relid, table_state,
InvalidXLogRecPtr);
}
*
* Note that if tables were specified but copy_data is false
* then it is safe to enable two_phase up-front because those
- * relations are already initially in READY state. When the
- * subscription has no relations, we leave the twophase state
- * as PENDING, to allow ALTER SUBSCRIPTION ... REFRESH
+ * tables are already initially in READY state. When the
+ * subscription has no tables, we leave the twophase state as
+ * PENDING, to allow ALTER SUBSCRIPTION ... REFRESH
* PUBLICATION to work.
*/
- if (opts.twophase && !opts.copy_data && relations != NIL)
+ if (opts.twophase && !opts.copy_data && tables != NIL)
twophase_enabled = true;
walrcv_create_slot(wrconn, opts.slot_name, false, twophase_enabled,
if (validate_publications)
check_publications(wrconn, validate_publications);
- /* Get the list of relations from publisher. */
+ /* Get the table list from publisher. */
pubrel_names = fetch_table_list(wrconn, sub->publications);
- pubrel_names = list_concat(pubrel_names,
- fetch_sequence_list(wrconn, sub->publications));
/* Get local table list. */
subrel_states = GetSubscriptionRelations(sub->oid);
return tablelist;
}
-/*
- * Get the list of sequences which belong to specified publications on the
- * publisher connection.
- */
-static List *
-fetch_sequence_list(WalReceiverConn *wrconn, List *publications)
-{
- WalRcvExecResult *res;
- StringInfoData cmd;
- TupleTableSlot *slot;
- Oid tableRow[2] = {TEXTOID, TEXTOID};
- ListCell *lc;
- bool first;
- List *tablelist = NIL;
-
- Assert(list_length(publications) > 0);
-
- initStringInfo(&cmd);
- appendStringInfoString(&cmd, "SELECT DISTINCT s.schemaname, s.sequencename\n"
- " FROM pg_catalog.pg_publication_sequences s\n"
- " WHERE s.pubname IN (");
- first = true;
- foreach(lc, publications)
- {
- char *pubname = strVal(lfirst(lc));
-
- if (first)
- first = false;
- else
- appendStringInfoString(&cmd, ", ");
-
- appendStringInfoString(&cmd, quote_literal_cstr(pubname));
- }
- appendStringInfoChar(&cmd, ')');
-
- res = walrcv_exec(wrconn, cmd.data, 2, tableRow);
- pfree(cmd.data);
-
- if (res->status != WALRCV_OK_TUPLES)
- ereport(ERROR,
- (errmsg("could not receive list of replicated sequences from the publisher: %s",
- res->err)));
-
- /* Process sequences. */
- slot = MakeSingleTupleTableSlot(res->tupledesc, &TTSOpsMinimalTuple);
- while (tuplestore_gettupleslot(res->tuplestore, true, false, slot))
- {
- char *nspname;
- char *relname;
- bool isnull;
- RangeVar *rv;
-
- nspname = TextDatumGetCString(slot_getattr(slot, 1, &isnull));
- Assert(!isnull);
- relname = TextDatumGetCString(slot_getattr(slot, 2, &isnull));
- Assert(!isnull);
-
- rv = makeRangeVar(nspname, relname, -1);
- tablelist = lappend(tablelist, rv);
-
- ExecClearTuple(slot);
- }
- ExecDropSingleTupleTableSlot(slot);
-
- walrcv_clear_result(res);
-
- return tablelist;
-}
-
/*
* This is to report the connection failure while dropping replication slots.
* Here, we report the WARNING for all tablesync slots so that user can drop
#include "catalog/pg_inherits.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
-#include "catalog/pg_publication_namespace.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
* Check that setting the relation to a different schema won't result in a
* publication having both a schema and the same schema's table, as this
* is not supported.
- *
- * XXX We do this for tables and sequences, but it's better to keep the two
- * blocks separate, to make the strings easier to translate.
*/
if (stmt->objectType == OBJECT_TABLE)
{
ListCell *lc;
- List *schemaPubids = GetSchemaPublications(nspOid, PUB_OBJTYPE_TABLE);
+ List *schemaPubids = GetSchemaPublications(nspOid);
List *relPubids = GetRelationPublications(RelationGetRelid(rel));
foreach(lc, relPubids)
get_publication_name(pubid, false)));
}
}
- else if (stmt->objectType == OBJECT_SEQUENCE)
- {
- ListCell *lc;
- List *schemaPubids = GetSchemaPublications(nspOid, PUB_OBJTYPE_SEQUENCE);
- List *relPubids = GetRelationPublications(RelationGetRelid(rel));
-
- foreach(lc, relPubids)
- {
- Oid pubid = lfirst_oid(lc);
-
- if (list_member_oid(schemaPubids, pubid))
- ereport(ERROR,
- errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot move sequence \"%s\" to schema \"%s\"",
- RelationGetRelationName(rel), stmt->newschema),
- errdetail("The schema \"%s\" and same schema's sequence \"%s\" cannot be part of the same publication \"%s\".",
- stmt->newschema,
- RelationGetRelationName(rel),
- get_publication_name(pubid, false)));
- }
- }
/* common checks on switching namespaces */
CheckSetNamespace(oldNspOid, nspOid);
CheckSubscriptionRelkind(char relkind, const char *nspname,
const char *relname)
{
- if (relkind != RELKIND_RELATION &&
- relkind != RELKIND_PARTITIONED_TABLE &&
- relkind != RELKIND_SEQUENCE)
+ if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot use relation \"%s.%s\" as logical replication target",
COPY_STRING_FIELD(pubname);
COPY_NODE_FIELD(options);
COPY_NODE_FIELD(pubobjects);
- COPY_NODE_FIELD(for_all_objects);
+ COPY_SCALAR_FIELD(for_all_tables);
return newnode;
}
COPY_STRING_FIELD(pubname);
COPY_NODE_FIELD(options);
COPY_NODE_FIELD(pubobjects);
- COPY_NODE_FIELD(for_all_objects);
+ COPY_SCALAR_FIELD(for_all_tables);
COPY_SCALAR_FIELD(action);
return newnode;
COMPARE_STRING_FIELD(pubname);
COMPARE_NODE_FIELD(options);
COMPARE_NODE_FIELD(pubobjects);
- COMPARE_NODE_FIELD(for_all_objects);
+ COMPARE_SCALAR_FIELD(for_all_tables);
return true;
}
COMPARE_STRING_FIELD(pubname);
COMPARE_NODE_FIELD(options);
COMPARE_NODE_FIELD(pubobjects);
- COMPARE_NODE_FIELD(for_all_objects);
+ COMPARE_SCALAR_FIELD(for_all_tables);
COMPARE_SCALAR_FIELD(action);
return true;
transform_element_list transform_type_list
TriggerTransitions TriggerReferencing
vacuum_relation_list opt_vacuum_relation_list
- drop_option_list pub_obj_list pub_obj_type_list
+ drop_option_list pub_obj_list
%type <node> opt_routine_body
%type <groupclause> group_clause