Skip to content

ResultSetMetaData.getSchemaName() returns empty string for aliased columns #3186

@LeviticusMB

Description

@LeviticusMB

I'm sometimes using the ResultSetMetaData to query the INFORMATION_SCHEMA.COLUMNS table based on table catalog, table schema, table name and column name.

However, when AS is used to change the label in the result set, the schema name becomes the empty string and thus the lookup from COLUMNS fails.

Example:

CREATE TABLE test(col1 int, col2 varchar);
INSERT INTO test VALUES(10, 't1');
SELECT col1, col2 AS second FROM test;

Here is the ResultSetMetaData according to DBeaver:

Name Label # Type Catalog Name Schema Name Table Name Max Length Precision Scale JDBC Type Not Null Auto
COL1 COL1 0 INTEGER _DIVINE_URI_TEST_ PUBLIC TEST 11 10 0 INTEGER false false
COL2 SECOND 1 VARCHAR _DIVINE_URI_TEST_ TEST 2147483647 2147483647 0 VARCHAR false false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions