[libpostgresql-jdbc-java] 05/11: In DatabaseMetaData.getSchemas, return the user's own temp schemas, but no others. Previously it wasn't returning the users own temp schema, but was showing all toast temp schemas.

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


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

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

commit 43a4da7772063cb05b6184f412170e68bbec9e84
Author: Kris Jurka <books at ejurka.com>
Date:   Wed Dec 22 16:53:56 2010 +0000

    In DatabaseMetaData.getSchemas, return the user's own temp schemas,
    but no others.  Previously it wasn't returning the users own temp
    schema, but was showing all toast temp schemas.
    
    Per report from Thomas Kellerer.
---
 org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java | 6 ++++--
 org/postgresql/test/jdbc2/DatabaseMetaDataTest.java     | 5 +----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
index e3e3572..7046393 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2008, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.57.2.1 2010/10/16 00:38:39 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.57.2.2 2010/10/23 07:30:53 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -2145,9 +2145,11 @@ public abstract class AbstractJdbc2DatabaseMetaData
     public java.sql.ResultSet getSchemas() throws SQLException
     {
         String sql;
+        // Show only the users temp schemas, but not other peoples
+        // because they can't access any objects in them.
         if (connection.haveMinimumServerVersion("7.3"))
         {
-            sql = "SELECT nspname AS TABLE_SCHEM FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND nspname !~ '^pg_temp_' ORDER BY TABLE_SCHEM";
+            sql = "SELECT nspname AS TABLE_SCHEM FROM pg_catalog.pg_namespace WHERE nspname <> 'pg_toast' AND (nspname !~ '^pg_temp_' OR nspname = (pg_catalog.current_schemas(true))[1]) AND (nspname !~ '^pg_toast_temp_' OR nspname = replace((pg_catalog.current_schemas(true))[1], 'pg_temp_', 'pg_toast_temp_')) ORDER BY TABLE_SCHEM";
         }
         else
         {
diff --git a/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java b/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
index f529ac5..ddd9308 100644
--- a/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+++ b/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2008, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.47.2.1 2010/10/16 00:38:39 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.47.2.2 2010/10/23 07:30:53 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -714,9 +714,6 @@ public class DatabaseMetaDataTest extends TestCase
 
     public void testSchemas() throws Exception
     {
-        if (!TestUtil.haveMinimumServerVersion(con, "7.3"))
-            return ;
-
         DatabaseMetaData dbmd = con.getMetaData();
         assertNotNull(dbmd);
 

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