[libpostgresql-jdbc-java] 59/128: Test is checking search_path usage dirctly on TypeInfo methods

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 3beba29b205f5732e9ecae2765ce01a5ce153dda
Author: Valentine Gogichashvili <valgog at gmail.com>
Date:   Fri Apr 12 03:31:40 2013 +0200

    Test is checking search_path usage dirctly on TypeInfo methods
---
 .../test/jdbc2/SearchPathLookupTest.java           | 39 ++++++++++++----------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/org/postgresql/test/jdbc2/SearchPathLookupTest.java b/org/postgresql/test/jdbc2/SearchPathLookupTest.java
index e440c19..2de7acb 100644
--- a/org/postgresql/test/jdbc2/SearchPathLookupTest.java
+++ b/org/postgresql/test/jdbc2/SearchPathLookupTest.java
@@ -7,6 +7,9 @@
 */
 package org.postgresql.test.jdbc2;
 
+import org.postgresql.PGConnection;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.TypeInfo;
 import org.postgresql.test.TestUtil;
 import junit.framework.TestCase;
 import java.sql.*;
@@ -19,7 +22,7 @@ import java.sql.*;
 public class SearchPathLookupTest extends TestCase
 {
 
-    private Connection con;
+    private BaseConnection con;
     /*
      * Constructor
      */
@@ -28,9 +31,11 @@ public class SearchPathLookupTest extends TestCase
         super(name);
     }
 
+    // TODO: make @getMetaData() consider search_path as well
+
     public void testSearchPathNormalLookup() throws Exception
     {
-        con = TestUtil.openDB();
+        con = (BaseConnection) TestUtil.openDB();
         Statement stmt = con.createStatement();
         try {
             TestUtil.createSchema( con, "first_schema" );
@@ -42,10 +47,11 @@ public class SearchPathLookupTest extends TestCase
             TestUtil.createSchema( con, "last_schema" );
             TestUtil.createTable( con, "last_schema.x", "last_schema_field_n text");
             stmt.execute("SET search_path TO third_schema;");
-            DatabaseMetaData dbmd = con.getMetaData();
-            ResultSet rs = dbmd.getColumns("", "", "x", "");
+            TypeInfo typeInfo = con.getTypeInfo();
+            int OID = typeInfo.getPGType("x");
+            ResultSet rs = stmt.executeQuery("SELECT 'third_schema.x'::regtype::oid");
             assertTrue(rs.next());
-            assertEquals("third_schema_field_n", rs.getString("COLUMN_NAME"));
+            assertEquals(OID, rs.getInt(1));
             assertTrue(!rs.next());
             TestUtil.dropSchema( con, "first_schema" );
             TestUtil.dropSchema( con, "second_schema" );
@@ -57,28 +63,25 @@ public class SearchPathLookupTest extends TestCase
         }
     }
     
-    /* -- TODO: make this test work 
     public void testSearchPathBackwardsCompatibleLookup() throws Exception
     {
-        con = TestUtil.openDB();
+        con = (BaseConnection) TestUtil.openDB();
+        Statement stmt = con.createStatement();
         try {
             TestUtil.createSchema( con, "first_schema" );
             TestUtil.createTable( con, "first_schema.x", "first_schema_field int4");
             TestUtil.createSchema( con, "second_schema" );
             TestUtil.createTable( con, "second_schema.x", "second_schema_field text");
-            try {
-                DatabaseMetaData dbmd = con.getMetaData();
-                ResultSet rs = dbmd.getColumns("", "", "x", "");
-                assertTrue(rs.next());
-                assertEquals("second_schema_field", rs.getString("COLUMN_NAME"));
-                assertTrue(!rs.next());
-            } finally {
-                TestUtil.dropSchema( con, "first_schema" );
-                TestUtil.dropSchema( con, "second_schema" );
-            }
+            TypeInfo typeInfo = con.getTypeInfo();
+            int OID = typeInfo.getPGType("x");
+            ResultSet rs = stmt.executeQuery("SELECT oid FROM pg_type WHERE typname = 'x' ORDER BY oid DESC LIMIT 1");
+            assertTrue(rs.next());
+            assertEquals(OID, rs.getInt(1));
+            assertTrue(!rs.next());
+            TestUtil.dropSchema( con, "first_schema" );
+            TestUtil.dropSchema( con, "second_schema" );
         } finally {
             TestUtil.closeDB( con );
         }
     }
-    */
 }

-- 
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