File: basic.out

package info (click to toggle)
pglogical 2.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,236 kB
  • sloc: ansic: 39,239; sql: 4,466; perl: 693; makefile: 210; sh: 77
file content (198 lines) | stat: -rw-r--r-- 5,581 bytes parent folder | download | duplicates (5)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
-- basic builtin datatypes
SELECT * FROM pglogical_regress_variables()
\gset
\c :provider_dsn
SELECT pglogical.replicate_ddl_command($$
	CREATE TABLE public.basic_dml (
		id serial primary key,
		other integer,
		data text,
		something interval
	);
$$);
 replicate_ddl_command 
-----------------------
 t
(1 row)

SELECT * FROM pglogical.replication_set_add_table('default', 'basic_dml');
 replication_set_add_table 
---------------------------
 t
(1 row)

SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
ALTER TABLE public.basic_dml ADD COLUMN subonly integer;
ALTER TABLE public.basic_dml ADD COLUMN subonly_def integer DEFAULT 99;
\c :provider_dsn
-- check basic insert replication
INSERT INTO basic_dml(other, data, something)
VALUES (5, 'foo', '1 minute'::interval),
       (4, 'bar', '12 weeks'::interval),
       (3, 'baz', '2 years 1 hour'::interval),
       (2, 'qux', '8 months 2 days'::interval),
       (1, NULL, NULL);
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something, subonly, subonly_def FROM basic_dml ORDER BY id;
 id | other | data |    something     | subonly | subonly_def 
----+-------+------+------------------+---------+-------------
  1 |     5 | foo  | @ 1 min          |         |          99
  2 |     4 | bar  | @ 84 days        |         |          99
  3 |     3 | baz  | @ 2 years 1 hour |         |          99
  4 |     2 | qux  | @ 8 mons 2 days  |         |          99
  5 |     1 |      |                  |         |          99
(5 rows)

-- update one row
\c :provider_dsn
UPDATE basic_dml SET other = '4', data = NULL, something = '3 days'::interval WHERE id = 4;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
 id | other | data |    something     
----+-------+------+------------------
  1 |     5 | foo  | @ 1 min
  2 |     4 | bar  | @ 84 days
  3 |     3 | baz  | @ 2 years 1 hour
  4 |     4 |      | @ 3 days
  5 |     1 |      | 
(5 rows)

-- update multiple rows
\c :provider_dsn
UPDATE basic_dml SET other = id, data = data || id::text;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
 id | other | data |    something     
----+-------+------+------------------
  1 |     1 | foo1 | @ 1 min
  2 |     2 | bar2 | @ 84 days
  3 |     3 | baz3 | @ 2 years 1 hour
  4 |     4 |      | @ 3 days
  5 |     5 |      | 
(5 rows)

\c :provider_dsn
UPDATE basic_dml SET other = id, something = something - '10 seconds'::interval WHERE id < 3;
UPDATE basic_dml SET other = id, something = something + '10 seconds'::interval WHERE id > 3;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something, subonly, subonly_def FROM basic_dml ORDER BY id;
 id | other | data |     something      | subonly | subonly_def 
----+-------+------+--------------------+---------+-------------
  1 |     1 | foo1 | @ 50 secs          |         |          99
  2 |     2 | bar2 | @ 84 days -10 secs |         |          99
  3 |     3 | baz3 | @ 2 years 1 hour   |         |          99
  4 |     4 |      | @ 3 days 10 secs   |         |          99
  5 |     5 |      |                    |         |          99
(5 rows)

-- delete one row
\c :provider_dsn
DELETE FROM basic_dml WHERE id = 2;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
 id | other | data |    something     
----+-------+------+------------------
  1 |     1 | foo1 | @ 50 secs
  3 |     3 | baz3 | @ 2 years 1 hour
  4 |     4 |      | @ 3 days 10 secs
  5 |     5 |      | 
(4 rows)

-- delete multiple rows
\c :provider_dsn
DELETE FROM basic_dml WHERE id < 4;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
 id | other | data |    something     
----+-------+------+------------------
  4 |     4 |      | @ 3 days 10 secs
  5 |     5 |      | 
(2 rows)

-- truncate
\c :provider_dsn
TRUNCATE basic_dml;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
 id | other | data | something 
----+-------+------+-----------
(0 rows)

-- copy
\c :provider_dsn
\COPY basic_dml FROM STDIN WITH CSV
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT id, other, data, something FROM basic_dml ORDER BY id;
  id  | other | data | something 
------+-------+------+-----------
 9000 |     1 | aaa  | @ 1 hour
 9001 |     2 | bbb  | @ 2 years
 9002 |     3 | ccc  | @ 3 mins
 9003 |     4 | ddd  | @ 4 days
(4 rows)

\c :provider_dsn
\set VERBOSITY terse
SELECT pglogical.replicate_ddl_command($$
	DROP TABLE public.basic_dml CASCADE;
$$);
NOTICE:  drop cascades to table public.basic_dml membership in replication set default
 replicate_ddl_command 
-----------------------
 t
(1 row)