-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
626 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
-- basic builtin datatypes | ||
SELECT * FROM pglogical_regress_variables() | ||
\gset | ||
\c :provider_dsn | ||
CREATE TABLE public.basic_dml ( | ||
id serial primary key, | ||
other integer, | ||
data text, | ||
something interval | ||
); | ||
SELECT * FROM pglogical.replication_set_add_table('default', 'basic_dml', att_filter := '{id, data, something}'); | ||
replication_set_add_table | ||
--------------------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
CREATE TABLE public.basic_dml ( | ||
id serial primary key, | ||
data text, | ||
something interval, | ||
subonly integer, | ||
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 pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+------------------ | ||
1 | foo | @ 1 min | ||
2 | bar | @ 84 days | ||
3 | baz | @ 2 years 1 hour | ||
4 | qux | @ 8 mons 2 days | ||
5 | | | ||
(5 rows) | ||
|
||
-- update one row | ||
\c :provider_dsn | ||
UPDATE basic_dml SET other = '4', data = NULL, something = '3 days'::interval WHERE id = 4; | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+------------------ | ||
1 | foo | @ 1 min | ||
2 | bar | @ 84 days | ||
3 | baz | @ 2 years 1 hour | ||
4 | | @ 3 days | ||
5 | | | ||
(5 rows) | ||
|
||
-- update multiple rows | ||
\c :provider_dsn | ||
UPDATE basic_dml SET other = id, data = data || id::text; | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+------------------ | ||
1 | foo1 | @ 1 min | ||
2 | bar2 | @ 84 days | ||
3 | baz3 | @ 2 years 1 hour | ||
4 | | @ 3 days | ||
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 pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something, subonly, subonly_def FROM basic_dml ORDER BY id; | ||
id | data | something | subonly | subonly_def | ||
----+------+--------------------+---------+------------- | ||
1 | foo1 | @ 50 secs | | 99 | ||
2 | bar2 | @ 84 days -10 secs | | 99 | ||
3 | baz3 | @ 2 years 1 hour | | 99 | ||
4 | | @ 3 days 10 secs | | 99 | ||
5 | | | | 99 | ||
(5 rows) | ||
|
||
-- delete one row | ||
\c :provider_dsn | ||
DELETE FROM basic_dml WHERE id = 2; | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+------------------ | ||
1 | foo1 | @ 50 secs | ||
3 | baz3 | @ 2 years 1 hour | ||
4 | | @ 3 days 10 secs | ||
5 | | | ||
(4 rows) | ||
|
||
-- delete multiple rows | ||
\c :provider_dsn | ||
DELETE FROM basic_dml WHERE id < 4; | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+------------------ | ||
4 | | @ 3 days 10 secs | ||
5 | | | ||
(2 rows) | ||
|
||
-- truncate | ||
\c :provider_dsn | ||
TRUNCATE basic_dml; | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
----+------+----------- | ||
(0 rows) | ||
|
||
-- copy | ||
\c :provider_dsn | ||
\COPY basic_dml FROM STDIN WITH CSV | ||
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0); | ||
pg_xlog_wait_remote_apply | ||
--------------------------- | ||
|
||
(1 row) | ||
|
||
\c :subscriber_dsn | ||
SELECT id, data, something FROM basic_dml ORDER BY id; | ||
id | data | something | ||
------+------+----------- | ||
9000 | aaa | @ 1 hour | ||
9001 | bbb | @ 2 years | ||
9002 | ccc | @ 3 mins | ||
9003 | 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 1 other object | ||
replicate_ddl_command | ||
----------------------- | ||
t | ||
(1 row) | ||
|
Oops, something went wrong.