Permalink
Browse files

Non-schema-qualified tables must be visible when testing triggers.

  • Loading branch information...
theory committed Jan 24, 2013
1 parent a76bf09 commit 870d1ba8755e6bccb54ca644ee29fb7aae8e5782
Showing with 15 additions and 2 deletions.
  1. +2 −2 Changes
  2. +12 −0 sql/pgtap--0.92.0--0.93.0.sql
  3. +1 −0 sql/pgtap.sql.in
View
@@ -7,8 +7,8 @@ Revision history for pgTAP
* Fixed misselling of "constraint" in constraint test diagnostic output.
* Fixed `fk_ok()` so that the table must be visible in the search path when
the schema name is not specified.
-* Fixed constraint-checking functions so that they only look at tables visible
- in the search path unles the schema is specified.
+* Fixed constraint- and trigger-checking functions so that they only look at
+ tables visible in the search path unles the schema is specified.
0.92.0 2013-01-16T00:41:07Z
---------------------------
@@ -117,3 +117,15 @@ RETURNS SETOF NAME[] AS $$
AND x.contype = $2
WHERE pg_catalog.pg_table_is_visible(c.oid)
$$ LANGUAGE sql;
+
+CREATE OR REPLACE FUNCTION _trig ( NAME, NAME )
+RETURNS BOOLEAN AS $$
+ SELECT EXISTS(
+ SELECT true
+ FROM pg_catalog.pg_trigger t
+ JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid
+ WHERE c.relname = $1
+ AND t.tgname = $2
+ AND pg_catalog.pg_table_is_visible(c.oid)
+ );
+$$ LANGUAGE SQL;
View
@@ -3073,6 +3073,7 @@ RETURNS BOOLEAN AS $$
JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid
WHERE c.relname = $1
AND t.tgname = $2
+ AND pg_catalog.pg_table_is_visible(c.oid)
);
$$ LANGUAGE SQL;

0 comments on commit 870d1ba

Please sign in to comment.