Commit 8363e137 authored by Peter Mount's avatar Peter Mount

Jens Glaser found that getPrimaryKeys() had a table called test hardwired

into it.
parent cd68ecfe
...@@ -2152,19 +2152,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2152,19 +2152,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
{ {
return connection.createStatement().executeQuery("SELECT " + return connection.createStatement().executeQuery("SELECT " +
" '' as TABLE_CAT," + "'' as TABLE_CAT," +
" '' AS TABLE_SCHEM," + "'' AS TABLE_SCHEM," +
" bc.relname AS TABLE_NAME," + "bc.relname AS TABLE_NAME," +
" a.attname AS COLUMN_NAME," + "a.attname AS COLUMN_NAME," +
" a.attnum as KEY_SEQ," + "a.attnum as KEY_SEQ,"+
" ic.relname as PK_NAME" + "ic.relname as PK_NAME " +
" from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" + " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
" where bc.relkind = 'r'"+ " WHERE bc.relkind = 'r' " + // -- not indices
" and upper(bc.relname) = upper('test')" + " and upper(bc.relname) = upper('"+table+"')" +
" and i.indrelid = bc.oid" + " and i.indrelid = bc.oid" +
" and i.indexrelid = ic.oid and a.attrelid = ic.oid"+ " and i.indexrelid = ic.oid" +
" and i.indisprimary='t'"+ " and ic.oid = a.attrelid" +
" order by table_name, pk_name,key_seq;" " and i.indisprimary='t' " +
" ORDER BY table_name, pk_name, key_seq"
); );
} }
......
...@@ -2152,19 +2152,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2152,19 +2152,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
{ {
return connection.createStatement().executeQuery("SELECT " + return connection.createStatement().executeQuery("SELECT " +
" '' as TABLE_CAT," + "'' as TABLE_CAT," +
" '' AS TABLE_SCHEM," + "'' AS TABLE_SCHEM," +
" bc.relname AS TABLE_NAME," + "bc.relname AS TABLE_NAME," +
" a.attname AS COLUMN_NAME," + "a.attname AS COLUMN_NAME," +
" a.attnum as KEY_SEQ," + "a.attnum as KEY_SEQ,"+
" ic.relname as PK_NAME" + "ic.relname as PK_NAME " +
" from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" + " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
" where bc.relkind = 'r'"+ " WHERE bc.relkind = 'r' " + // -- not indices
" and upper(bc.relname) = upper('test')" + " and upper(bc.relname) = upper('"+table+"')" +
" and i.indrelid = bc.oid" + " and i.indrelid = bc.oid" +
" and i.indexrelid = ic.oid and a.attrelid = ic.oid"+ " and i.indexrelid = ic.oid" +
" and i.indisprimary='t'"+ " and ic.oid = a.attrelid" +
" order by table_name, pk_name,key_seq;" " and i.indisprimary='t' " +
" ORDER BY table_name, pk_name, key_seq"
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment