[libpostgresql-jdbc-java] 61/128: Added another test case for searching objects using search_path

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit a7d80750d712e776d9aac6479215bf81816aef27
Author: Valentine Gogichashvili <valgog at gmail.com>
Date:   Mon Apr 15 11:16:23 2013 +0200

    Added another test case for searching objects using search_path
---
 .../test/jdbc2/SearchPathLookupTest.java           | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/org/postgresql/test/jdbc2/SearchPathLookupTest.java b/org/postgresql/test/jdbc2/SearchPathLookupTest.java
index 2de7acb..56f8d65 100644
--- a/org/postgresql/test/jdbc2/SearchPathLookupTest.java
+++ b/org/postgresql/test/jdbc2/SearchPathLookupTest.java
@@ -33,6 +33,10 @@ public class SearchPathLookupTest extends TestCase
 
     // TODO: make @getMetaData() consider search_path as well
 
+    /**
+     * This usecase is most common, here the object we are searching for is 
+     * in the current_schema (the first schema in the search_path)
+     */
     public void testSearchPathNormalLookup() throws Exception
     {
         con = (BaseConnection) TestUtil.openDB();
@@ -63,6 +67,41 @@ public class SearchPathLookupTest extends TestCase
         }
     }
     
+    /**
+     * This usecase is for the situations, when an object is located in a schema,
+     * that is in the search_path, but not in the current_schema, for example
+     * a public schema or some kind of schema, that is used for keeping utility objects.
+     */
+    public void testSearchPathHiddenLookup() throws Exception
+    {
+        con = (BaseConnection) TestUtil.openDB();
+        Statement stmt = con.createStatement();
+        try {
+            TestUtil.createSchema( con, "first_schema" );
+            TestUtil.createTable( con, "first_schema.x", "first_schema_field_n int4");
+            TestUtil.createSchema( con, "second_schema" );
+            TestUtil.createTable( con, "second_schema.y", "second_schema_field_n text");
+            TestUtil.createSchema( con, "third_schema" );
+            TestUtil.createTable( con, "third_schema.x", "third_schema_field_n float");
+            TestUtil.createSchema( con, "last_schema" );
+            TestUtil.createTable( con, "last_schema.y", "last_schema_field_n text");
+            stmt.execute("SET search_path TO first_schema, second_schema, last_schema, public;");
+            TypeInfo typeInfo = con.getTypeInfo();
+            int OID = typeInfo.getPGType("y");
+            ResultSet rs = stmt.executeQuery("SELECT 'second_schema.y'::regtype::oid");
+            assertTrue(rs.next());
+            assertEquals(OID, rs.getInt(1));
+            assertTrue(!rs.next());
+            TestUtil.dropSchema( con, "first_schema" );
+            TestUtil.dropSchema( con, "second_schema" );
+            TestUtil.dropSchema( con, "third_schema" );
+            TestUtil.dropSchema( con, "last_schema" );
+        } finally {
+            if ( stmt != null ) stmt.close();
+            TestUtil.closeDB( con );
+        }
+    }
+    
     public void testSearchPathBackwardsCompatibleLookup() throws Exception
     {
         con = (BaseConnection) TestUtil.openDB();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list