Skip to content

Commit

Permalink
Attribute and row filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PJMODOS committed Oct 8, 2016
1 parent 49ba221 commit af77ddc
Show file tree
Hide file tree
Showing 5 changed files with 626 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ SCRIPTS_built = pglogical_create_subscriber

REGRESS = preseed infofuncs init_fail init preseed_check basic extended \
toasted replication_set add_table matview bidirectional primary_key \
interfaces foreign_key functions copy triggers parallel drop
interfaces foreign_key functions copy triggers parallel row_filter \
att_filter drop

EXTRA_CLEAN += pglogical.control compat94/pglogical_compat.o \
compat95/pglogical_compat.o pglogical_create_subscriber.o
Expand Down
196 changes: 196 additions & 0 deletions expected/att_filter.out
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)

Loading

0 comments on commit af77ddc

Please sign in to comment.