[CONJ-41] connection.getMetaData().getPrimaryKeys() returns wrong ordinal_colum when primary key is not in the first colum. Created: 2013-05-23 Updated: 2013-09-20 Resolved: 2013-06-11 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | None |
| Affects Version/s: | 1.1.1 |
| Fix Version/s: | 1.1.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Frank S | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Try the following
When you use the query like it is coded in MySQLDatabaseMetaData to query the primary keys with getPrimaryKeys() Consider the follwing testcase:
As KEY_SEQ which is the ordinal position of the primary key should be returned 1 and not the column of the primary key. The Sun jdbc implementation uses a own resultset which is build against "show keys from table"
As Seq_in_index which is mapped as KEY_SEQ is returned 1, the right value.
|
| Comments |
| Comment by Frank S [ 2013-05-23 ] |
|
Sorry for the bad formatting, I'm not able to edit the task after I have created it. |
| Comment by Frank S [ 2013-05-23 ] |
|
FIX: public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { String sql = "SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, " + "ORDINAL_POSITION KEY_SEQ, NULL PK_NAME " + "FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE " + "WHERE " + catalogCond("TABLE_SCHEMA", catalog) + "AND " + patternCond("TABLE_NAME", table) + " ORDER BY column_name;"; return executeQuery(sql); } |