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

[BUG] regression introduced in 7.4.1. DatbaseMetadata.getColumns fails to return metadata when values escaped #1139

Closed
dqmdev opened this issue Sep 4, 2019 · 2 comments
Labels
Bug A bug in the driver. A high priority item that one can expect to be addressed quickly.

Comments

@dqmdev
Copy link

dqmdev commented Sep 4, 2019

Driver version

7.4.1

SQL Server version

14.00.3612

Client Operating System

any

JAVA/JVM version

IBM Java 8 S5 FP35

Table schema

Problem description

The 7.4.1 driver fails to return a result set from DatabaseMetadata.getColumns when the table name parameter has escaped the underscore in the table name.

This is an introduced issue in 7.4.1.

Did not happen in prior releases such as 7.2.1 or earlier

Scenario#1 - getTables

ResultSet rs = dbMeta.getTables( "dbcert", "dbo", "TPATT\_1\_1", null );

DatabaseMetadata Interface: [getDatabaseProductName(Microsoft SQL Server) getDatabaseMajorVersion(14) getDatabaseMinorVersion(0) getDatabaseProductVersion(14.00.3162)]
DatabaseMetadata Interface getJDBCMajor(4) getJDBCMinor(2)
DatabaseMetadata Interface: [getDriverName(Microsoft JDBC Driver 7.2 for SQL Server) getDriverVersion(7.2.1.0)]

Database says search escape is \

Get Tables

Column Name:TABLE_CAT, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_SCHEM, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_TYPE, display size:32, type name:varchar, type id:12, precision:32, scale:0 () () ()
Column Name:REMARKS, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
[DBCERT],[dbo],[TPATT_1_1],[TABLE],[null]
Rows printed 1

Scenario#2 - getColumns

ResultSet rs = dbMeta.getColumns( "dbcert", "dbo", "TPATT\_1\_1", "%");

DatabaseMetadata Interface: [getDatabaseProductName(Microsoft SQL Server) getDatabaseMajorVersion(14) getDatabaseMinorVersion(0) getDatabaseProductVersion(14.00.3162)]
DatabaseMetadata Interface getJDBCMajor(4) getJDBCMinor(2)
DatabaseMetadata Interface: [getDriverName(Microsoft JDBC Driver 7.2 for SQL Server) getDriverVersion(7.2.1.0)]
Database says default isolation level is 2
Database says search escape is
Database says subquery quantified is true
Get Tables

Column Name:TABLE_CAT, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_SCHEM, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_TYPE, display size:32, type name:varchar, type id:12, precision:32, scale:0 () () ()
Column Name:REMARKS, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
[DBCERT],[dbo],[TPATT_1_1],[TABLE],[null]
Rows printed 1
Get Table Columns
Columns 292

Column Name:TABLE_CAT, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_SCHEM, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:COLUMN_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:DATA_TYPE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:TYPE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:COLUMN_SIZE, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:BUFFER_LENGTH, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:DECIMAL_DIGITS, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:NUM_PREC_RADIX, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:NULLABLE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:REMARKS, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
Column Name:COLUMN_DEF, display size:4000, type name:nvarchar, type id:-9, precision:4000, scale:0 () () ()
Column Name:SQL_DATA_TYPE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SQL_DATETIME_SUB, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:CHAR_OCTET_LENGTH, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:ORDINAL_POSITION, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:IS_NULLABLE, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
Column Name:SS_IS_SPARSE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SS_IS_COLUMN_SET, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:IS_GENERATEDCOLUMN, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:IS_AUTOINCREMENT, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SS_UDT_CATALOG_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_UDT_SCHEMA_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_UDT_ASSEMBLY_TYPE_NAME, display size:4000, type name:nvarchar, type id:-9, precision:4000, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_CATALOG_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_SCHEMA_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_DATA_TYPE, display size:3, type name:tinyint, type id:-6, precision:3, scale:0 () () ()
[DBCERT],[dbo],[TPATT_1_1],[RNUM],[4],[int],[10],[4],[0],[10],[0],[null],[null],[4],[null],[null],[1],[NO],[0],[0],[0],[NO],[null],[null],[null],[null],[null],[null],[56]
[DBCERT],[dbo],[TPATT_1_1],[C_1],[4],[int],[10],[4],[0],[10],[1],[null],[null],[4],[null],[null],[2],[YES],[0],[0],[0],[NO],[null],[null],[null],[null],[null],[null],[38]
[DBCERT],[dbo],[TPATT_1_1],[C11],[4],[int],[10],[4],[0],[10],[1],[null],[null],[4],[null],[null],[3],[YES],[0],[0],[0],[NO],[null],[null],[null],[null],[null],[null],[38]
[DBCERT],[dbo],[TPATT_1_1],[C%1],[4],[int],[10],[4],[0],[10],[1],[null],[null],[4],[null],[null],[4],[YES],[0],[0],[0],[NO],[null],[null],[null],[null],[null],[null],[38]
[DBCERT],[dbo],[TPATT_1_1],[C\1\1],[4],[int],[10],[4],[0],[10],[1],[null],[null],[4],[null],[null],[5],[YES],[0],[0],[0],[NO],[null],[null],[null],[null],[null],[null],[38]
Rows printed 5

DatabaseMetadata Interface: [getDatabaseProductName(Microsoft SQL Server) getDatabaseMajorVersion(14) getDatabaseMinorVersion(0) getDatabaseProductVersion(14.00.3162)]
DatabaseMetadata Interface getJDBCMajor(4) getJDBCMinor(2)
DatabaseMetadata Interface: [getDriverName(Microsoft JDBC Driver 7.4 for SQL Server) getDriverVersion(7.4.1.0)]

Database says search escape is \

Column Name:TABLE_CAT, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_SCHEM, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_TYPE, display size:32, type name:varchar, type id:12, precision:32, scale:0 () () ()
Column Name:REMARKS, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
[DBCERT],[dbo],[TPATT_1_1],[TABLE],[null]
Rows printed 1
Get Table Columns
Columns 463

Column Name:TABLE_CAT, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_SCHEM, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:TABLE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:COLUMN_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:DATA_TYPE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:TYPE_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:COLUMN_SIZE, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:BUFFER_LENGTH, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:DECIMAL_DIGITS, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:NUM_PREC_RADIX, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:NULLABLE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:REMARKS, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
Column Name:COLUMN_DEF, display size:4000, type name:nvarchar, type id:-9, precision:4000, scale:0 () () ()
Column Name:SQL_DATA_TYPE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SQL_DATETIME_SUB, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:CHAR_OCTET_LENGTH, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:ORDINAL_POSITION, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:IS_NULLABLE, display size:254, type name:varchar, type id:12, precision:254, scale:0 () () ()
Column Name:SCOPE_CATALOG, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:SCOPE_SCHEMA, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:SCOPE_TABLE, display size:11, type name:int, type id:4, precision:10, scale:0 () () ()
Column Name:SOURCE_DATA_TYPE, display size:3, type name:tinyint, type id:-6, precision:3, scale:0 () () ()
Column Name:IS_AUTOINCREMENT, display size:3, type name:varchar, type id:12, precision:3, scale:0 () () ()
Column Name:IS_GENERATEDCOLUMN, display size:3, type name:varchar, type id:12, precision:3, scale:0 () () ()
Column Name:SS_IS_SPARSE, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SS_IS_COLUMN_SET, display size:6, type name:smallint, type id:5, precision:5, scale:0 () () ()
Column Name:SS_UDT_CATALOG_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_UDT_SCHEMA_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_UDT_ASSEMBLY_TYPE_NAME, display size:1073741823, type name:nvarchar, type id:-9, precision:1073741823, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_CATALOG_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_SCHEMA_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Column Name:SS_XML_SCHEMACOLLECTION_NAME, display size:128, type name:nvarchar, type id:-9, precision:128, scale:0 () () ()
Rows printed 0

@dqmdev dqmdev added the Bug A bug in the driver. A high priority item that one can expect to be addressed quickly. label Sep 4, 2019
@dqmdev
Copy link
Author

dqmdev commented Sep 4, 2019

Example DDL

create table "TPATT_1_1" ("RNUM" integer not null , C_1 integer, C11 integer, "C%1" integer, "C\1\1" integer );

create table "TPATT1111" ("RNUM" integer not null , C_1 integer, C11 integer, "C%1" integer, "C\1_1" integer );

create table "TPATT\1_1" ("RNUM" integer not null , C21 integer, C11 integer, "C%1" integer, "C\1\11" integer );

@dqmdev dqmdev changed the title [BUG] DatbaseMetadata.getColumns fails to return metadata when values escaped [BUG] regression introduced in 7.4.1. DatbaseMetadata.getColumns fails to return metadata when values escaped Sep 4, 2019
@peterbae
Copy link
Contributor

peterbae commented Sep 4, 2019

Hi @dqmdev, thanks for contacting us. We are aware of the issue, and an identical issue was created here: #1136. I've attached a driver jar with the fix included in the comments, so please give that a try. In the meantime, I'll close this issue as duplicate.

@peterbae peterbae closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the driver. A high priority item that one can expect to be addressed quickly.
Projects
None yet
Development

No branches or pull requests

2 participants