Skip to content

Commit 6866b48

Browse files
oliricedarora
authored andcommitted
add wal2json tests
1 parent 5bab9d8 commit 6866b48

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

nix/tests/expected/wal2json.out

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
create schema v;
2+
create table v.foo(
3+
id int primary key
4+
);
5+
select
6+
1
7+
from
8+
pg_create_logical_replication_slot('reg_test', 'wal2json', false);
9+
?column?
10+
----------
11+
1
12+
(1 row)
13+
14+
insert into v.foo(id) values (1);
15+
select
16+
data
17+
from
18+
pg_logical_slot_get_changes(
19+
'reg_test',
20+
null,
21+
null,
22+
'include-pk', '1',
23+
'include-transaction', 'false',
24+
'include-timestamp', 'false',
25+
'include-type-oids', 'false',
26+
'format-version', '2',
27+
'actions', 'insert,update,delete'
28+
) x;
29+
data
30+
--------------------------------------------------------------------------------------------------------------------------------------
31+
{"action":"I","schema":"v","table":"foo","columns":[{"name":"id","type":"integer","value":1}],"pk":[{"name":"id","type":"integer"}]}
32+
(1 row)
33+
34+
select
35+
pg_drop_replication_slot('reg_test');
36+
pg_drop_replication_slot
37+
--------------------------
38+
39+
(1 row)
40+
41+
drop schema v cascade;
42+
NOTICE: drop cascades to table v.foo

nix/tests/sql/wal2json.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
create schema v;
2+
3+
create table v.foo(
4+
id int primary key
5+
);
6+
7+
select
8+
1
9+
from
10+
pg_create_logical_replication_slot('reg_test', 'wal2json', false);
11+
12+
insert into v.foo(id) values (1);
13+
14+
select
15+
data
16+
from
17+
pg_logical_slot_get_changes(
18+
'reg_test',
19+
null,
20+
null,
21+
'include-pk', '1',
22+
'include-transaction', 'false',
23+
'include-timestamp', 'false',
24+
'include-type-oids', 'false',
25+
'format-version', '2',
26+
'actions', 'insert,update,delete'
27+
) x;
28+
29+
select
30+
pg_drop_replication_slot('reg_test');
31+
32+
drop schema v cascade;

0 commit comments

Comments
 (0)