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

Fix escaping wildcards in column lookup and make escaping optional #142

Closed
ckunki opened this issue Mar 14, 2023 · 2 comments · Fixed by #143
Closed

Fix escaping wildcards in column lookup and make escaping optional #142

ckunki opened this issue Mar 14, 2023 · 2 comments · Fixed by #143
Assignees
Labels
bug Unwanted / harmful behavior

Comments

@ckunki
Copy link
Collaborator

ckunki commented Mar 14, 2023

Based on issue #136 VSCJDBC release 10.4.0 introduced escaped wildcards when looking up column metadata which was implemented in BaseColumnMetadataReader.getColumnMetadata().

This seems to work fine for exasol-virtual-schema as demonstrated by a related test.

Unfortunately the Oracle JDBC driver seems to deviate from JDBC standard in the way that escaped wildcards in the name of a database schema or a table lead to no matching columns found. So the change introduced with #136 needs to be rolled back for ORAVS and maybe other virtual schemas as well.

See

The current ticket therefore proposes to make the wildcard escaping optional by providing a method that SQL dialects inheriting from VSCJDBC can override in order to escape wildcards.

Later on

@ckunki ckunki added the bug Unwanted / harmful behavior label Mar 14, 2023
@ckunki
Copy link
Collaborator Author

ckunki commented Mar 14, 2023

Proposal: VSCJDBC, class BaseColumnMetadataReader:

  protected ResultSet getColumnMetadata(final String catalogName, final String schemaNamePattern,
            final String tableNamePattern) throws SQLException {
        return this.connection.getMetaData().getColumns(catalogName, 
              schemaNamePattern, tableNamePattern, ANY_COLUMN);
    }

Proposal: VSEXA class ExasolColumnMetadataReader extends BaseColumnMetadataReader:

    @Override
    protected ResultSet getColumnMetadata(final String catalogName, final String schemaNamePattern,
            final String tableNamePattern) throws SQLException {
        return this.connection.getMetaData().getColumns(catalogName, 
                Wildcards.escape(schemaNamePattern),
                Wildcards.escape(tableNamePattern), ANY_COLUMN);
    }

@ckunki ckunki self-assigned this Mar 14, 2023
@ckunki ckunki changed the title Make Wildcard escaping optional Use DatabaseMetaData.getSearchStringEscape() and Make Wildcard escaping optional Mar 15, 2023
@ckunki
Copy link
Collaborator Author

ckunki commented Mar 15, 2023

Additional fixes

Problem Fix
VSCJDBC also escaped wild cards in the name of the database catalog, conflicting with the parameter's documentation as literal string. Do not escape potential wild cards in the name of the database catalog.
VSCJDBC always used the backslash as escape string, while there are SQL dialects with different escape string, e.g. VSORA using a forward slash /. Use java.sql.DatabaseMetaData.getSearchStringEscape() to inquire the escape string for the specific SQL dialect.

@ckunki ckunki changed the title Use DatabaseMetaData.getSearchStringEscape() and Make Wildcard escaping optional Fix escaping wildcards in column lookup and make escaping optional Mar 15, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unwanted / harmful behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant