Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8363e13

Browse files
author
Peter Mount
committed
Jens Glaser found that getPrimaryKeys() had a table called test hardwired
into it.
1 parentcd68ecf commit8363e13

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
publicjava.sql.ResultSetgetPrimaryKeys(Stringcatalog,Stringschema,Stringtable)throwsSQLException
21532153
{
21542154
returnconnection.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
publicjava.sql.ResultSetgetPrimaryKeys(Stringcatalog,Stringschema,Stringtable)throwsSQLException
21532153
{
21542154
returnconnection.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)

[8]ページ先頭

©2009-2025 Movatter.jp