theory/pgtap — Issue #17: Ignore Internal Triggers
Author: theory
Created: 2012-02-07 17:12:02+00:00
State: open

Looks as though `triggers_are()` needs to ignore internal triggers. [The docs](http://www.postgresql.org/docs/current/static/catalog-pg-trigger.html) say something about how internal triggers are "usually, to enforce the constraint identified by tgconstraint". Not sure what that means exactly, so worth looking into to write a test to replicate such triggers, and then probably apply this patch to ignore them.

--- a/sql/pgtap.sql.in
+++ b/sql/pgtap.sql.in
@@ -7086,6 +7086,7 @@ RETURNS TEXT AS $$
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = $1
AND c.relname = $2
+ AND NOT t.tgisinternal
EXCEPT
SELECT $3[i]
FROM generate_series(1, array_upper($3, 1)) s(i)
@@ -7100,6 +7101,7 @@ RETURNS TEXT AS $$
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = $1
AND c.relname = $2
+ AND NOT t.tgisinternal
),
$4
);
@@ -7123,6 +7125,7 @@ RETURNS TEXT AS $$
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = $1
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
+ AND NOT t.tgisinternal
EXCEPT
SELECT $2[i]
FROM generate_series(1, array_upper($2, 1)) s(i)
@@ -7136,6 +7139,7 @@ RETURNS TEXT AS $$
JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
+ AND NOT t.tgisinternal
),
$3
);