File: selecttable.sql

package info (click to toggle)
wal2json 2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,672 kB
  • sloc: ansic: 2,524; sql: 1,136; makefile: 27; sh: 6
file content (38 lines) | stat: -rw-r--r-- 2,186 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
\set VERBOSITY terse

-- predictability
SET synchronous_commit = on;

DROP TABLE IF EXISTS select_table_1;
DROP TABLE IF EXISTS select_table_2;
DROP TABLE IF EXISTS select_table_3;
DROP SCHEMA IF EXISTS select_schema_1 CASCADE;
DROP SCHEMA IF EXISTS select_schema_2 CASCADE;

CREATE SCHEMA select_schema_1;
CREATE SCHEMA select_schema_2;

CREATE TABLE select_table_1 (a integer, b text, primary key(a));
CREATE TABLE select_schema_1.select_table_1 (a integer, b text, primary key(a));
CREATE TABLE select_schema_1.select_table_2 (a integer, b text, primary key(a));
CREATE TABLE select_schema_2.select_table_1 (a integer, b text, primary key(a));
CREATE TABLE select_schema_2.select_table_2 (a integer, b text, primary key(a));
CREATE TABLE select_schema_2.select_table_3 (a integer, b text, primary key(a));
CREATE TABLE select_table_2 (a integer, b text, primary key(a));
CREATE TABLE select_table_3 (a integer, b text, primary key(a));

SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');

INSERT INTO select_table_1 (a, b) VALUES(1, 'public.select_table_1');
INSERT INTO select_schema_1.select_table_1 (a, b) VALUES(1, 'select_schema_1.select_table_1');
INSERT INTO select_schema_1.select_table_2 (a, b) VALUES(1, 'select_schema_1.select_table_2');
INSERT INTO select_schema_2.select_table_1 (a, b) VALUES(1, 'select_schema_2.select_table_1');
INSERT INTO select_schema_2.select_table_2 (a, b) VALUES(1, 'select_schema_2.select_table_2');
INSERT INTO select_schema_2.select_table_3 (a, b) VALUES(1, 'select_schema_2.select_table_3');
INSERT INTO select_table_2 (a, b) VALUES(1, 'public.select_table_2');
INSERT INTO select_table_3 (a, b) VALUES(1, 'public.select_table_3');

SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'add-tables', '   foo.bar,*.select_table_1  ,select_schema_2.* , public.select_table_3  ');
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'add-tables', '   foo.bar,*.select_table_1  ,select_schema_2.* , public.select_table_3  ');
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');