Skip to content

Commit 8363e13

Browse files
author
Peter Mount
committed
Jens Glaser found that getPrimaryKeys() had a table called test hardwired
into it.
1 parent cd68ecf commit 8363e13

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,20 +2152,21 @@ public java.sql.ResultSet getVersionColumns(String catalog, String schema, Strin
21522152
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
21532153
{
21542154
return connection.createStatement().executeQuery("SELECT " +
2155-
" '' as TABLE_CAT," +
2156-
" '' AS TABLE_SCHEM," +
2157-
" bc.relname AS TABLE_NAME," +
2158-
" a.attname AS COLUMN_NAME," +
2159-
" a.attnum as KEY_SEQ," +
2160-
" ic.relname as PK_NAME" +
2161-
" from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" +
2162-
" where bc.relkind = 'r'"+
2163-
" and upper(bc.relname) = upper('test')" +
2164-
" and i.indrelid = bc.oid" +
2165-
" and i.indexrelid = ic.oid and a.attrelid = ic.oid"+
2166-
" and i.indisprimary='t'"+
2167-
" order by table_name, pk_name,key_seq;"
2168-
);
2155+
"'' as TABLE_CAT," +
2156+
"'' AS TABLE_SCHEM," +
2157+
"bc.relname AS TABLE_NAME," +
2158+
"a.attname AS COLUMN_NAME," +
2159+
"a.attnum as KEY_SEQ,"+
2160+
"ic.relname as PK_NAME " +
2161+
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
2162+
" WHERE bc.relkind = 'r' " + // -- not indices
2163+
" and upper(bc.relname) = upper('"+table+"')" +
2164+
" and i.indrelid = bc.oid" +
2165+
" and i.indexrelid = ic.oid" +
2166+
" and ic.oid = a.attrelid" +
2167+
" and i.indisprimary='t' " +
2168+
" ORDER BY table_name, pk_name, key_seq"
2169+
);
21692170
}
21702171

21712172
/**

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,20 +2152,21 @@ public java.sql.ResultSet getVersionColumns(String catalog, String schema, Strin
21522152
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
21532153
{
21542154
return connection.createStatement().executeQuery("SELECT " +
2155-
" '' as TABLE_CAT," +
2156-
" '' AS TABLE_SCHEM," +
2157-
" bc.relname AS TABLE_NAME," +
2158-
" a.attname AS COLUMN_NAME," +
2159-
" a.attnum as KEY_SEQ," +
2160-
" ic.relname as PK_NAME" +
2161-
" from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" +
2162-
" where bc.relkind = 'r'"+
2163-
" and upper(bc.relname) = upper('test')" +
2164-
" and i.indrelid = bc.oid" +
2165-
" and i.indexrelid = ic.oid and a.attrelid = ic.oid"+
2166-
" and i.indisprimary='t'"+
2167-
" order by table_name, pk_name,key_seq;"
2168-
);
2155+
"'' as TABLE_CAT," +
2156+
"'' AS TABLE_SCHEM," +
2157+
"bc.relname AS TABLE_NAME," +
2158+
"a.attname AS COLUMN_NAME," +
2159+
"a.attnum as KEY_SEQ,"+
2160+
"ic.relname as PK_NAME " +
2161+
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
2162+
" WHERE bc.relkind = 'r' " + // -- not indices
2163+
" and upper(bc.relname) = upper('"+table+"')" +
2164+
" and i.indrelid = bc.oid" +
2165+
" and i.indexrelid = ic.oid" +
2166+
" and ic.oid = a.attrelid" +
2167+
" and i.indisprimary='t' " +
2168+
" ORDER BY table_name, pk_name, key_seq"
2169+
);
21692170
}
21702171

21712172
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy