1
1
CREATE TABLE pglogical .node (
2
- node_id oid NOT NULL PRIMARY KEY ,
3
- node_name name NOT NULL UNIQUE
2
+ node_id oid NOT NULL PRIMARY KEY ,
3
+ node_name name NOT NULL UNIQUE
4
4
) WITH (user_catalog_table= true);
5
5
6
6
CREATE TABLE pglogical .node_interface (
7
- if_id oid NOT NULL PRIMARY KEY ,
8
- if_name name NOT NULL , -- default same as node name
9
- if_nodeid oid REFERENCES node(node_id),
10
- if_dsn text NOT NULL ,
11
- UNIQUE (if_nodeid, if_name)
7
+ if_id oid NOT NULL PRIMARY KEY ,
8
+ if_name name NOT NULL , -- default same as node name
9
+ if_nodeid oid REFERENCES node(node_id),
10
+ if_dsn text NOT NULL ,
11
+ UNIQUE (if_nodeid, if_name)
12
12
);
13
13
14
14
CREATE TABLE pglogical .local_node (
15
- node_id oid PRIMARY KEY REFERENCES node(node_id),
16
- node_local_interface oid NOT NULL REFERENCES node_interface(if_id)
15
+ node_id oid PRIMARY KEY REFERENCES node(node_id),
16
+ node_local_interface oid NOT NULL REFERENCES node_interface(if_id)
17
17
);
18
18
19
19
-- Currently we allow only one node record per database
20
20
CREATE UNIQUE INDEX local_node_onlyone ON pglogical .local_node ((true));
21
21
22
22
CREATE TABLE pglogical .subscription (
23
- sub_id oid NOT NULL PRIMARY KEY ,
24
- sub_name name NOT NULL UNIQUE,
25
- sub_origin oid NOT NULL REFERENCES node(node_id),
26
- sub_target oid NOT NULL REFERENCES node(node_id),
23
+ sub_id oid NOT NULL PRIMARY KEY ,
24
+ sub_name name NOT NULL UNIQUE,
25
+ sub_origin oid NOT NULL REFERENCES node(node_id),
26
+ sub_target oid NOT NULL REFERENCES node(node_id),
27
27
sub_origin_if oid NOT NULL REFERENCES node_interface(if_id),
28
- sub_target_if oid NOT NULL REFERENCES node_interface(if_id),
29
- sub_enabled boolean NOT NULL DEFAULT true,
30
- sub_slot_name name NOT NULL ,
31
- sub_replication_sets text [],
32
- sub_forward_origins text [],
33
- UNIQUE (sub_origin, sub_target)
28
+ sub_target_if oid NOT NULL REFERENCES node_interface(if_id),
29
+ sub_enabled boolean NOT NULL DEFAULT true,
30
+ sub_slot_name name NOT NULL ,
31
+ sub_replication_sets text [],
32
+ sub_forward_origins text [],
33
+ UNIQUE (sub_origin, sub_target)
34
34
);
35
35
36
36
CREATE TABLE pglogical .local_sync_status (
37
- sync_kind " char" NOT NULL CHECK (sync_kind IN (' i' , ' s' , ' d' , ' f' )),
38
- sync_subid oid NOT NULL REFERENCES pglogical .subscription (sub_id),
39
- sync_nspname name,
40
- sync_relname name,
41
- sync_status " char" NOT NULL ,
42
- UNIQUE (sync_subid, sync_nspname, sync_relname)
37
+ sync_kind " char" NOT NULL CHECK (sync_kind IN (' i' , ' s' , ' d' , ' f' )),
38
+ sync_subid oid NOT NULL REFERENCES pglogical .subscription (sub_id),
39
+ sync_nspname name,
40
+ sync_relname name,
41
+ sync_status " char" NOT NULL ,
42
+ UNIQUE (sync_subid, sync_nspname, sync_relname)
43
43
);
44
44
45
45
@@ -49,8 +49,8 @@ CREATE FUNCTION pglogical.drop_node(node_name name, ifexists boolean DEFAULT fal
49
49
RETURNS boolean STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_drop_node' ;
50
50
51
51
CREATE FUNCTION pglogical .create_subscription(subscription_name name, provider_dsn text ,
52
- replication_sets text [] = ' {default,default_insert_only}' , synchronize_structure boolean = true,
53
- synchronize_data boolean = true, forward_origins text [] = ' {all}' )
52
+ replication_sets text [] = ' {default,default_insert_only}' , synchronize_structure boolean = true,
53
+ synchronize_data boolean = true, forward_origins text [] = ' {all}' )
54
54
RETURNS oid STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_create_subscription' ;
55
55
CREATE FUNCTION pglogical .drop_subscription(subscription_name name, ifexists boolean DEFAULT false)
56
56
RETURNS oid STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_drop_subscription' ;
@@ -66,67 +66,67 @@ CREATE FUNCTION pglogical.alter_subscription_remove_replication_set(subscription
66
66
RETURNS boolean STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_alter_subscription_remove_replication_set' ;
67
67
68
68
CREATE FUNCTION pglogical .show_subscription_status(subscription_name name DEFAULT NULL ,
69
- OUT subscription_name text , OUT status text , OUT provider_node text ,
70
- OUT provider_dsn text , OUT slot_name text , OUT replication_sets text [],
71
- OUT forward_origins text [])
69
+ OUT subscription_name text , OUT status text , OUT provider_node text ,
70
+ OUT provider_dsn text , OUT slot_name text , OUT replication_sets text [],
71
+ OUT forward_origins text [])
72
72
RETURNS SETOF record STABLE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_show_subscription_status' ;
73
73
74
74
CREATE TABLE pglogical .replication_set (
75
- set_id oid NOT NULL PRIMARY KEY ,
76
- set_nodeid oid NOT NULL ,
75
+ set_id oid NOT NULL PRIMARY KEY ,
76
+ set_nodeid oid NOT NULL ,
77
77
set_name name NOT NULL ,
78
78
replicate_insert boolean NOT NULL DEFAULT true,
79
79
replicate_update boolean NOT NULL DEFAULT true,
80
80
replicate_delete boolean NOT NULL DEFAULT true,
81
81
replicate_truncate boolean NOT NULL DEFAULT true,
82
- UNIQUE (set_nodeid, set_name)
82
+ UNIQUE (set_nodeid, set_name)
83
83
) WITH (user_catalog_table= true);
84
84
85
85
CREATE TABLE pglogical .replication_set_table (
86
86
set_id integer NOT NULL ,
87
- set_reloid regclass NOT NULL ,
88
- PRIMARY KEY (set_id, set_reloid)
87
+ set_reloid regclass NOT NULL ,
88
+ PRIMARY KEY (set_id, set_reloid)
89
89
) WITH (user_catalog_table= true);
90
90
91
91
CREATE VIEW pglogical .TABLES AS
92
- WITH set_tables AS (
93
- SELECT s .set_name , t .set_reloid
94
- FROM pglogical .replication_set_table t,
95
- pglogical .replication_set s,
92
+ WITH set_tables AS (
93
+ SELECT s .set_name , t .set_reloid
94
+ FROM pglogical .replication_set_table t,
95
+ pglogical .replication_set s,
96
96
pglogical .local_node n
97
- WHERE s .set_nodeid = n .node_id
98
- AND s .set_id = t .set_id
97
+ WHERE s .set_nodeid = n .node_id
98
+ AND s .set_id = t .set_id
99
99
),
100
- user_tables AS (
101
- SELECT r .oid , n .nspname , r .relname , r .relreplident
102
- FROM pg_catalog .pg_class r,
103
- pg_catalog .pg_namespace n
104
- WHERE r .relkind = ' r'
100
+ user_tables AS (
101
+ SELECT r .oid , n .nspname , r .relname , r .relreplident
102
+ FROM pg_catalog .pg_class r,
103
+ pg_catalog .pg_namespace n
104
+ WHERE r .relkind = ' r'
105
105
AND r .relpersistence = ' p'
106
- AND n .oid = r .relnamespace
107
- AND n .nspname !~ ' ^pg_'
108
- AND n .nspname != ' information_schema'
109
- AND n .nspname != ' pglogical'
110
- )
106
+ AND n .oid = r .relnamespace
107
+ AND n .nspname !~ ' ^pg_'
108
+ AND n .nspname != ' information_schema'
109
+ AND n .nspname != ' pglogical'
110
+ )
111
111
SELECT n .nspname , r .relname , s .set_name
112
- FROM pg_catalog .pg_namespace n,
113
- pg_catalog .pg_class r,
114
- set_tables s
112
+ FROM pg_catalog .pg_namespace n,
113
+ pg_catalog .pg_class r,
114
+ set_tables s
115
115
WHERE r .relkind = ' r'
116
- AND n .oid = r .relnamespace
117
- AND r .oid = s .set_reloid
118
- UNION
116
+ AND n .oid = r .relnamespace
117
+ AND r .oid = s .set_reloid
118
+ UNION
119
119
SELECT t .nspname , t .relname , NULL
120
- FROM user_tables t
120
+ FROM user_tables t
121
121
WHERE t .oid NOT IN (SELECT set_reloid FROM set_tables);
122
122
123
123
CREATE FUNCTION pglogical .create_replication_set(set_name name,
124
- replicate_insert boolean = true, replicate_update boolean = true,
125
- replicate_delete boolean = true, replicate_truncate boolean = true)
124
+ replicate_insert boolean = true, replicate_update boolean = true,
125
+ replicate_delete boolean = true, replicate_truncate boolean = true)
126
126
RETURNS oid STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_create_replication_set' ;
127
127
CREATE FUNCTION pglogical .alter_replication_set(set_name name,
128
- replicate_insert boolean DEFAULT NULL , replicate_update boolean DEFAULT NULL ,
129
- replicate_delete boolean DEFAULT NULL , replicate_truncate boolean DEFAULT NULL )
128
+ replicate_insert boolean DEFAULT NULL , replicate_update boolean DEFAULT NULL ,
129
+ replicate_delete boolean DEFAULT NULL , replicate_truncate boolean DEFAULT NULL )
130
130
RETURNS oid CALLED ON NULL INPUT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_alter_replication_set' ;
131
131
CREATE FUNCTION pglogical .drop_replication_set(set_name name, ifexists boolean DEFAULT false)
132
132
RETURNS boolean STRICT VOLATILE LANGUAGE c AS ' MODULE_PATHNAME' , ' pglogical_drop_replication_set' ;
0 commit comments