]> granicus.if.org Git - postgresql/commitdiff
Jens Glaser found that getPrimaryKeys() had a table called test hardwired
authorPeter Mount <peter@retep.org.uk>
Wed, 15 Sep 1999 21:12:34 +0000 (21:12 +0000)
committerPeter Mount <peter@retep.org.uk>
Wed, 15 Sep 1999 21:12:34 +0000 (21:12 +0000)
into it.

src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java
src/interfaces/jdbc/postgresql/jdbc2/DatabaseMetaData.java

index 84130f2cb46a14d0876f362fa3e03c5699a8f476..eae5ac6b5146ea74f930bfb547feb0ba3e6d78d9 100644 (file)
@@ -2152,20 +2152,21 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
   public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
   {
     return connection.createStatement().executeQuery("SELECT " +
-                                                    " '' as TABLE_CAT," +
-                                                    " '' AS TABLE_SCHEM," +
-                                                    " bc.relname AS TABLE_NAME," +
-                                                    " a.attname AS COLUMN_NAME," +
-                                                    " a.attnum as KEY_SEQ," +
-                                                    " ic.relname as PK_NAME" +
-                                                    " from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" +
-                                                    " where bc.relkind = 'r'"+
-                                                    " and upper(bc.relname) = upper('test')" +
-                                                    " and i.indrelid = bc.oid" +
-                                                    " and i.indexrelid = ic.oid  and a.attrelid = ic.oid"+
-                                                    " and i.indisprimary='t'"+
-                                                    " order by table_name, pk_name,key_seq;"
-                                                    );
+                                                     "'' as TABLE_CAT," +
+                                                     "'' AS TABLE_SCHEM," +
+                                                     "bc.relname AS TABLE_NAME," +
+                                                     "a.attname AS COLUMN_NAME," +
+                                                     "a.attnum as KEY_SEQ,"+
+                                                     "ic.relname as PK_NAME " +
+                                                     " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
+                                                     " WHERE bc.relkind = 'r' " + //    -- not indices
+                                                     "  and upper(bc.relname) = upper('"+table+"')" +
+                                                     "  and i.indrelid = bc.oid" +
+                                                     "  and i.indexrelid = ic.oid" +
+                                                     "  and ic.oid = a.attrelid" +
+                                                     "  and i.indisprimary='t' " +
+                                                     " ORDER BY table_name, pk_name, key_seq"
+                                                     );
   }
   
   /**
index b6550654efda6418dbee9f029f895af444e2e730..9a16640d59aae809fb78df936f208a1f106af179 100644 (file)
@@ -2152,20 +2152,21 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
   public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
   {
     return connection.createStatement().executeQuery("SELECT " +
-                                                    " '' as TABLE_CAT," +
-                                                    " '' AS TABLE_SCHEM," +
-                                                    " bc.relname AS TABLE_NAME," +
-                                                    " a.attname AS COLUMN_NAME," +
-                                                    " a.attnum as KEY_SEQ," +
-                                                    " ic.relname as PK_NAME" +
-                                                    " from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" +
-                                                    " where bc.relkind = 'r'"+
-                                                    " and upper(bc.relname) = upper('test')" +
-                                                    " and i.indrelid = bc.oid" +
-                                                    " and i.indexrelid = ic.oid  and a.attrelid = ic.oid"+
-                                                    " and i.indisprimary='t'"+
-                                                    " order by table_name, pk_name,key_seq;"
-                                                    );
+                                                     "'' as TABLE_CAT," +
+                                                     "'' AS TABLE_SCHEM," +
+                                                     "bc.relname AS TABLE_NAME," +
+                                                     "a.attname AS COLUMN_NAME," +
+                                                     "a.attnum as KEY_SEQ,"+
+                                                     "ic.relname as PK_NAME " +
+                                                     " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
+                                                     " WHERE bc.relkind = 'r' " + //    -- not indices
+                                                     "  and upper(bc.relname) = upper('"+table+"')" +
+                                                     "  and i.indrelid = bc.oid" +
+                                                     "  and i.indexrelid = ic.oid" +
+                                                     "  and ic.oid = a.attrelid" +
+                                                     "  and i.indisprimary='t' " +
+                                                     " ORDER BY table_name, pk_name, key_seq"
+                                                     );
   }
   
   /**