[libpostgresql-jdbc-java] 02/14: DatabaseMetaData.getTables should return all table type if passed null as for the types array. It was previously returning only those tables that psql's \d command would for a null type filter.

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


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

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

commit 9604d6d4b0cdcadaa8923bed10b00ee5d9b4e0c1
Author: Kris Jurka <books at ejurka.com>
Date:   Tue Nov 29 06:02:16 2005 +0000

    DatabaseMetaData.getTables should return all table type if passed
    null as for the types array.  It was previously returning only those
    tables that psql's \d command would for a null type filter.
    
    Reported by Thomas Kellerer.
---
 .../jdbc2/AbstractJdbc2DatabaseMetaData.java       | 33 ++++++++--------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
index 8181573..97e95b5 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.23 2005/07/04 18:50:29 davec Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.24 2005/09/14 19:08:50 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -2165,27 +2165,24 @@ public abstract class AbstractJdbc2DatabaseMetaData
             }
         }
 
-        if (types == null)
-        {
-            types = defaultTableTypes;
-        }
         if (tableNamePattern != null)
         {
             select += " AND c.relname LIKE '" + escapeQuotes(tableNamePattern) + "' ";
         }
-        String sql = select;
-        sql += " AND (false ";
-        for (int i = 0; i < types.length; i++)
-        {
-            Hashtable clauses = (Hashtable)tableTypeClauses.get(types[i]);
-            if (clauses != null)
+        if (types != null) {
+            select += " AND (false ";
+            for (int i = 0; i < types.length; i++)
             {
-                String clause = (String)clauses.get(useSchemas);
-                sql += " OR ( " + clause + " ) ";
+                Hashtable clauses = (Hashtable)tableTypeClauses.get(types[i]);
+                if (clauses != null)
+                {
+                    String clause = (String)clauses.get(useSchemas);
+                    select += " OR ( " + clause + " ) ";
+                }
             }
+            select += ") ";
         }
-        sql += ") ";
-        sql += orderby;
+        String sql = select + orderby;
 
         return createMetaDataStatement().executeQuery(sql);
     }
@@ -2239,12 +2236,6 @@ public abstract class AbstractJdbc2DatabaseMetaData
         ht.put("NOSCHEMAS", "c.relkind = 'i' AND c.relname LIKE 'pg\\\\_temp\\\\_%' ");
     }
 
-    // These are the default tables, used when NULL is passed to getTables
-    // The choice of these provide the same behaviour as psql's \d
-    private static final String defaultTableTypes[] = {
-                "TABLE", "VIEW", "INDEX", "SEQUENCE", "TEMPORARY TABLE"
-            };
-
     /*
      * Get the schema names available in this database.  The results
      * are ordered by schema name.

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