| 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 TABLE mytable (key int PRIMARY KEY, value text); |
| 11 |
CREATE TRIGGER tcntrig AFTER INSERT OR UPDATE OR DELETE ON mytable |
| 12 |
FOR EACH ROW EXECUTE FUNCTION triggered_change_notification(mychannel); |
| 13 |
} |
| 14 |
|
| 15 |
teardown |
| 16 |
{ |
| 17 |
DROP TABLE mytable; |
| 18 |
} |
| 19 |
|
| 20 |
session s1 |
| 21 |
step listen { LISTEN mychannel; } |
| 22 |
step insert { INSERT INTO mytable VALUES(1, 'one'); } |
| 23 |
step insert2 { INSERT INTO mytable VALUES(2, 'two'); } |
| 24 |
step update { UPDATE mytable SET value = 'foo' WHERE key = 2; } |
| 25 |
step delete { DELETE FROM mytable; } |
| 26 |
|
| 27 |
|
| 28 |
permutation listen insert insert2 update delete |