Skip to content

Commit 418ec32

Browse files
committed
Add a regression test for contrib/tcn.
Just whittling down the list of contrib modules with zero coverage. Discussion: https://postgr.es/m/909667.1659222591@sss.pgh.pa.us
1 parent b592422 commit 418ec32

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

contrib/tcn/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated subdirectories
2+
/log/
3+
/results/
4+
/output_iso/
5+
/tmp_check/
6+
/tmp_check_iso/

contrib/tcn/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ EXTENSION = tcn
66
DATA = tcn--1.0.sql
77
PGFILEDESC = "tcn - trigger function notifying listeners"
88

9+
ISOLATION = tcn
10+
911
ifdef USE_PGXS
1012
PG_CONFIG = pg_config
1113
PGXS := $(shell $(PG_CONFIG) --pgxs)

contrib/tcn/expected/tcn.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Parsed test spec with 1 sessions
2+
3+
starting permutation: listen insert insert2 update delete
4+
step listen: LISTEN mychannel;
5+
step insert: INSERT INTO mytable VALUES(1, 'one');
6+
s1: NOTIFY "mychannel" with payload ""mytable",I,"key"='1'" from s1
7+
step insert2: INSERT INTO mytable VALUES(2, 'two');
8+
s1: NOTIFY "mychannel" with payload ""mytable",I,"key"='2'" from s1
9+
step update: UPDATE mytable SET value = 'foo' WHERE key = 2;
10+
s1: NOTIFY "mychannel" with payload ""mytable",U,"key"='2'" from s1
11+
step delete: DELETE FROM mytable;
12+
s1: NOTIFY "mychannel" with payload ""mytable",D,"key"='1'" from s1
13+
s1: NOTIFY "mychannel" with payload ""mytable",D,"key"='2'" from s1

contrib/tcn/specs/tcn.spec

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Tests for contrib/tcn
2+
3+
# These tests use only self-notifies within a single session,
4+
# which are convenient because they minimize timing concerns.
5+
# Whether the NOTIFY mechanism works across sessions is not
6+
# really tcn's problem.
7+
8+
setup
9+
{
10+
CREATE EXTENSION tcn;
11+
CREATE TABLE mytable (key int PRIMARY KEY, value text);
12+
CREATE TRIGGER tcntrig AFTER INSERT OR UPDATE OR DELETE ON mytable
13+
FOR EACH ROW EXECUTE FUNCTION triggered_change_notification(mychannel);
14+
}
15+
16+
teardown
17+
{
18+
DROP TABLE mytable;
19+
}
20+
21+
session s1
22+
step listen { LISTEN mychannel; }
23+
step insert { INSERT INTO mytable VALUES(1, 'one'); }
24+
step insert2 { INSERT INTO mytable VALUES(2, 'two'); }
25+
step update { UPDATE mytable SET value = 'foo' WHERE key = 2; }
26+
step delete { DELETE FROM mytable; }
27+
28+
29+
permutation listen insert insert2 update delete

0 commit comments

Comments
 (0)