[libpostgresql-jdbc-java] 03/11: 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:19 UTC 2017


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

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

commit b43ccba3c4f2cf8c69d5b8bda1faa98a1f57173d
Author: Kris Jurka <books at ejurka.com>
Date:   Tue Nov 29 06:02:33 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 c737e19..00c2c7c 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.17 2004/12/14 06:23:40 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.18 2005/01/11 08:25:45 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -2156,27 +2156,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);
     }
@@ -2230,12 +2227,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