Skip to content

Column index mismatch between ResultSet an ResultSetMetadata #2498

@rafaelsarro

Description

@rafaelsarro

Description

This pertains to jdbc-v2.
The application is using clickhouse jdbc v0.8.6 (shaded-all jar as suggested in documentation). Additionally we are using the same code that runs on top of MariaDB or Oracle. We are testing using on top of Clickhouse.

It seems that there is a mismatch between the response from the findColumn method in ResultSetImpl class and the input expected by the method getColumn in ResultSetMetadataImpl class.
The first one returns index 0 for a column, and if that is reused as input in the metadata, then we get an out of bound error.

Steps to reproduce

  1. After running a SQL via JDBC, introspect the ResultSet via the findColumn method
  2. Use the index returned to consult the ResultSetMetadata and get information about this column.

Error Log or Exception StackTrace

Sample stack trace. (Edited for clarity)

Caused by: com.nokia.oss.qengine.DBException: Unexpected SQL exception: Column index out of range: 0
SqlState: HY000
Sql:select some_column from some_table where some_condition
	at deployment.deployment.war//com.nokia.packageName.executeAndProcessResults(BasicMemberRetriver.java:179)
	at deployment.deployment.war//com.nokia.packageName.getMemberList(BasicMemberRetriver.java:74)
	at deployment.deployment.war//com.nokia.packageName.getMembersAsList(MembersHelper.java:234)
	... 82 more
Caused by: java.sql.SQLException: Column index out of range: 0
	at deployment.deployment.war//com.clickhouse.jdbc.metadata.ResultSetMetaDataImpl.getColumn(ResultSetMetaDataImpl.java:38)
	at deployment.deployment.war//com.clickhouse.jdbc.metadata.ResultSetMetaDataImpl.getColumnType(ResultSetMetaDataImpl.java:149)

Expected Behaviour

Code Example

Configuration

Client Configuration

Environment

  • Cloud
  • Client version:
  • Language version:
  • OS:

ClickHouse Server

  • ClickHouse Server version:
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jdbc-metadataissue handling metadata things like getting type of columnbugjdbc-v2jdbc-v2 issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions