Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure DatabaseMetaData includes all required columns [JDBC193] #241

Closed
firebird-automations opened this issue Oct 27, 2011 · 19 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

Relate to JDBC228
Is related to JDBC230

A number of methods of DatabaseMetaData need to be updated to include additional columns for JDBC 4.x compatibility.
Methods identified so far:
* getProcedures (1 extra column)
* getProcedureColumns (7 extra columns)
* getTables (5 extra columns)
* getColumns (6 extra columns)
* getUDTs (1 extra column)

Commits: 8de49a0 d30e4d7 6f4a06c 886fd32 a56e494 7e5cc9e dece951 6f729f9 d09e2bc 5499ee7 3e42bf7 8f9a191 5b30a6f 87f7fee c75d0c0 0c85a68 85a32b5 289f929 5702e18 2e75954

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.2 [ 10053 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Added columns to metadata. The getProcedureColumns needs some ODS specific retrieval of information. Also need to investigate the intention of some of the columns (eg ORDINAL_POSITION of getProcedureColumns has a vague description).

The index of OWNER_NAME in getTables() has changed as this column is Jaybird specific and not defined in JDBC.

Also need to check other methods for missing columns.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Extra tests for metadata are required as well: I forgot to increase some array sizes.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Added test for getColumns()

During writing the tests I also made the following changes:
* Added BIGINT support to COLUMN_SIZE, NUM_PREC_RADIX and DECIMAL_DIGITS (as it was missing)
* Column SCOPE_CATLOG if JDBC 4.0 or earlier, SCOPE_CATALOG in JDBC 4.1 and higher (gotta love standards fixing 'typos')
* Column BUFFER_LENGTH is now actual NULL instead of actual 0
* Column DECIMAL_DIGITS is actual NULL for all types except NUMERIC, DECIMAL (value equals scale), and BIGINT, INTEGER and SMALLINT (value is actual 0) as defined in SQL 2003 Schemata definition (this includes DOUBLE PRECISION and FLOAT having it NULL!)
* Column NUM_PREC_RADIX is 10 only for integral, fixed point and floating point types, actual NULL for all others
* Column CHAR_OCTET_LENGTH is only set for CHAR and VARCHAR and is actual NULL for all other datatypes
* Column IS_AUTOINCREMENT also returns "" (unknown) for NUMERIC and DECIMAL with scale 0, explicit "NO" for scale != 0
* Determining java.sql.Types value for DATA_TYPE and name for TYPE_NAME for NUMERIC and DECIMAL no longer looks at scale, only at actual subtype
* Added NUMERIC/DECIMAL determination of TYPE_NAME for Firebird type smallint (type 7) as it was missing (was present for DATA_TYPE)

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Added support for IS_GENERATEDCOLUMN (which identifies COMPUTED BY / GENERATED ALWAYS AS columns), rewrote getColumns() metadata tests to reduce duplication and potential for typing errors.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Update getColumns() metadata + refactored some things for other (future0 metadata tests
Added tests for getTables() : work in progress

I need to research the exact treatment of quoted vs unquoted identifiers in JDBC, as the standard is opaque about the following:
* Should TABLE_NAME (and COLUMN_NAME for that matter) returning the table cq column name quoted or unquoted (current implementation returns unquoted as they are stored unquoted)
* Should the tableNamePattern and columnNamePattern be quoted or unquoted when searching for quoted identifiers (current implementation requires quoted, but the JDBC spec says "tableNamePattern - a table name pattern; must match the table name as it is stored in the database" and as it is, they are stored unquoted in their original case.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue relate to JDBC228 [ JDBC228 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

* Added test for getUDTs()
* fixed getUDTs() DATA_TYPE column type (from VARCHAR to INTEGER), apparently the JDBC 2.0 specified the wrong column type (was String, changed to int in JDBC 3.0)
* Fixed column index mistake I made when adding the BASE_TYPE column to getUDTs()

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

* Added tests for getProcedures()
* Fixed case where empty string is passed as procedureNamePattern to bring it in line with behaviour of getColumns() and getTables()

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

* Made some changes to getProcedureColumns to comply with expectations defined in JDBC spec and javadoc
** Include value for CHARACTER_OCTET_LENGTH (if CHAR and VARCHAR)
** Include value for ORDINAL_POSITION
** Changed setting PRECISION, SCALE and RADIX to be in line with JDBC spec (and behavior in getColumns())
* Added some TODOs for things that require further research (value of COLUMN_TYPE see JDBC229 + some other things)
* Added basic tests for getProcedureColumns

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue is related to JDBC230 [ JDBC230 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Procedures listed in this ticket have been updated. Created JDBC230 to add tests for other resultset-producing metadata methods in the future.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Some of the changes I made use CASE WHEN, this was introduced with Firebird 1.5; rewrite so that Jaybird continues working with Firebird 1.0

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Reopened [ 4 ]

resolution: Fixed [ 1 ] =>

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Removed CASE constructs from metadata queries

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Reopened [ 4 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants