-
Notifications
You must be signed in to change notification settings - Fork 156
/
pglogical--1.2.2--2.0.0.sql
97 lines (84 loc) · 4.3 KB
/
pglogical--1.2.2--2.0.0.sql
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
ALTER TABLE pglogical.subscription ADD COLUMN sub_apply_delay interval NOT NULL DEFAULT '0';
CREATE TABLE pglogical.replication_set_seq (
set_id oid NOT NULL,
set_seqoid regclass NOT NULL,
PRIMARY KEY(set_id, set_seqoid)
) WITH (user_catalog_table=true);
WITH seqs AS (
SELECT r.set_id, r.set_reloid
FROM pg_class c
JOIN replication_set_relation r ON (r.set_reloid = c.oid)
WHERE c.relkind = 'S'
), inserted AS (
INSERT INTO replication_set_seq SELECT set_id, set_reloid FROM seqs
)
DELETE FROM replication_set_relation r USING seqs s WHERE r.set_reloid = s.set_reloid;
ALTER TABLE pglogical.replication_set_relation RENAME TO replication_set_table;
ALTER TABLE pglogical.replication_set_table
ADD COLUMN set_att_list text[],
ADD COLUMN set_row_filter pg_node_tree;
DROP FUNCTION pglogical.replication_set_add_table(set_name name, relation regclass, synchronize_data boolean);
CREATE FUNCTION pglogical.replication_set_add_table(set_name name, relation regclass, synchronize_data boolean DEFAULT false, columns text[] DEFAULT NULL, row_filter text DEFAULT NULL)
RETURNS boolean CALLED ON NULL INPUT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_replication_set_add_table';
DROP FUNCTION pglogical.alter_subscription_resynchronize_table(subscription_name name, relation regclass);
CREATE FUNCTION pglogical.alter_subscription_resynchronize_table(subscription_name name, relation regclass,
truncate boolean DEFAULT true)
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_alter_subscription_resynchronize_table';
DROP FUNCTION pglogical.create_subscription(subscription_name name, provider_dsn text,
replication_sets text[], synchronize_structure boolean,
synchronize_data boolean, forward_origins text[]);
CREATE FUNCTION pglogical.create_subscription(subscription_name name, provider_dsn text,
replication_sets text[] = '{default,default_insert_only,ddl_sql}', synchronize_structure boolean = false,
synchronize_data boolean = true, forward_origins text[] = '{all}', apply_delay interval DEFAULT '0')
RETURNS oid STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_create_subscription';
DROP VIEW pglogical.TABLES;
CREATE VIEW pglogical.TABLES AS
WITH set_relations AS (
SELECT s.set_name, r.set_reloid
FROM pglogical.replication_set_table r,
pglogical.replication_set s,
pglogical.local_node n
WHERE s.set_nodeid = n.node_id
AND s.set_id = r.set_id
),
user_tables AS (
SELECT r.oid, n.nspname, r.relname, r.relreplident
FROM pg_catalog.pg_class r,
pg_catalog.pg_namespace n
WHERE r.relkind = 'r'
AND r.relpersistence = 'p'
AND n.oid = r.relnamespace
AND n.nspname !~ '^pg_'
AND n.nspname != 'information_schema'
AND n.nspname != 'pglogical'
)
SELECT r.oid AS relid, n.nspname, r.relname, s.set_name
FROM pg_catalog.pg_namespace n,
pg_catalog.pg_class r,
set_relations s
WHERE r.relkind = 'r'
AND n.oid = r.relnamespace
AND r.oid = s.set_reloid
UNION
SELECT t.oid AS relid, t.nspname, t.relname, NULL
FROM user_tables t
WHERE t.oid NOT IN (SELECT set_reloid FROM set_relations);
CREATE FUNCTION pglogical.show_repset_table_info(relation regclass, repsets text[], OUT relid oid, OUT nspname text,
OUT relname text, OUT att_list text[], OUT has_row_filter boolean)
RETURNS record STRICT STABLE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_show_repset_table_info';
CREATE FUNCTION pglogical.table_data_filtered(reltyp anyelement, relation regclass, repsets text[])
RETURNS SETOF anyelement CALLED ON NULL INPUT STABLE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_table_data_filtered';
CREATE TABLE pglogical.depend (
classid oid NOT NULL,
objid oid NOT NULL,
objsubid integer NOT NULL,
refclassid oid NOT NULL,
refobjid oid NOT NULL,
refobjsubid integer NOT NULL,
deptype "char" NOT NULL
) WITH (user_catalog_table=true);
DROP EVENT TRIGGER IF EXISTS pglogical_truncate_trigger_add;
DROP EVENT TRIGGER IF EXISTS pglogical_dependency_check_trigger;
DROP FUNCTION IF EXISTS pglogical.truncate_trigger_add();
DROP FUNCTION IF EXISTS pglogical.dependency_check_trigger();
DROP FUNCTION IF EXISTS pglogical_hooks_setup(internal);