[DBD::Pg 3/4] In tests, make sure we drop the fully-qualified versions of the operators we created

dbdpg-commits-gENoVmVU/[email protected] Tue, 6 Jan 2015 16:56:21 +0000
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Committed by Greg Sabino Mullane <greg-O9fzpki4YnJWk0Htik3J/[email protected]>

Subject: [DBD::Pg 3/4] In tests, make sure we drop the fully-qualified
versions of the operators we created

---
 t/dbdpg_test_setup.pl | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/t/dbdpg_test_setup.pl b/t/dbdpg_test_setup.pl
index 2846dc0..6277df0 100644
--- a/t/dbdpg_test_setup.pl
+++ b/t/dbdpg_test_setup.pl
@@ -821,10 +821,12 @@ sub operator_exists {
 
 	my ($dbh,$opname,$leftarg,$rightarg) = @_;
 
-	my $SQL = 'SELECT 1 FROM pg_catalog.pg_operator '.
-		'WHERE oprname=? AND oprleft::regtype::text = ? AND oprright::regtype::text = ?';
+	my $schema = 'dbd_pg_testschema';
+	my $SQL = 'SELECT 1 FROM pg_operator o, pg_namespace n '.
+		'WHERE oprname=? AND oprleft::regtype::text = ? AND oprright::regtype::text = ?'.
+			' AND o.oprnamespace = n.oid AND n.nspname = ?';
 	my $sth = $dbh->prepare_cached($SQL);
-	my $count = $sth->execute($opname,$leftarg,$rightarg);
+	my $count = $sth->execute($opname,$leftarg,$rightarg,$schema);
 	$sth->finish();
 	return $count < 1 ? 0 : 1;
 
@@ -853,7 +855,7 @@ sub cleanup_database {
 	for my $name (@operators) {
 		my ($opname,$leftarg,$rightarg) = split /\./ => $name;
 		next if ! operator_exists($dbh,$opname,$leftarg,$rightarg);
-		$dbh->do("DROP OPERATOR $opname($leftarg,$rightarg)");
+		$dbh->do("DROP OPERATOR dbd_pg_testschema.$opname($leftarg,$rightarg)");
 	}
 
 	for my $name (@tables) {
-- 
1.8.4