Permalink
Browse files

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

  • Loading branch information...
1 parent afbb24a commit a76bf092b13d366a07714ee3f5b42964af29a8f2 @theory committed Jan 24, 2013
Showing with 14 additions and 0 deletions.
  1. +2 −0 Changes
  2. +11 −0 sql/pgtap--0.92.0--0.93.0.sql
  3. +1 −0 sql/pgtap.sql.in
View
@@ -7,6 +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.
0.92.0 2013-01-16T00:41:07Z
---------------------------
@@ -106,3 +106,14 @@ BEGIN
);
END;
$$ LANGUAGE plpgsql;
+
+-- _keys( table, constraint_type )
+CREATE OR REPLACE FUNCTION _keys ( NAME, CHAR )
+RETURNS SETOF NAME[] AS $$
+ SELECT _pg_sv_column_array(x.conrelid,x.conkey)
+ FROM pg_catalog.pg_class c
+ JOIN pg_catalog.pg_constraint x ON c.oid = x.conrelid
+ AND c.relname = $1
+ AND x.contype = $2
+ WHERE pg_catalog.pg_table_is_visible(c.oid)
+$$ LANGUAGE sql;
View
@@ -1790,6 +1790,7 @@ RETURNS SETOF NAME[] AS $$
JOIN pg_catalog.pg_constraint x ON c.oid = x.conrelid
AND c.relname = $1
AND x.contype = $2
+ WHERE pg_catalog.pg_table_is_visible(c.oid)
$$ LANGUAGE sql;
-- _ckeys( schema, table, constraint_type )

0 comments on commit a76bf09

Please sign in to comment.