Skip to content

Implement ODBC catalog metadata - #671

Merged
Shfdis merged 5 commits into
ydb-platform:odbc-driver-featurefrom
Shfdis:odbc-catalog-metadata
Sep 30, 2026
Merged

Shfdis merged 5 commits into
ydb-platform:odbc-driver-featurefrom
Shfdis:odbc-catalog-metadata

Conversation

@Shfdis

@Shfdis Shfdis commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • implement SQLTables special enumeration and metadata-ID semantics
  • resolve SQLColumns, SQLPrimaryKeys, and SQLStatistics relative to the current catalog
  • report complete column descriptors, composite primary keys, and index statistics
  • preserve null versus empty metadata arguments and escaped SQL LIKE matching
  • add native regression coverage for catalog paths, descriptors, validation, and statistics

@Shfdis

Shfdis commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Shfdis Shfdis changed the title YDBAPPTEAM-1843 Implement ODBC catalog metadata Implement ODBC catalog metadata Sep 29, 2026

@robot-vibe-db robot-vibe-db Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

Verdict: ✅ No critical issues found

Critical issues

No critical issues found.

Other findings

  • Major | High: catalog metadata traversal no longer prunes to the pattern's literal prefix — every SQLTables/SQLColumns/SQLPrimaryKeys/SQLStatistics call recursively lists the entire database tree, even for exact-name lookups — odbc/src/statement_metadata.cpp:659
  • Minor | Medium: SQLTables special-value handling (SQL_ALL_CATALOGS / SQL_ALL_SCHEMAS / SQL_ALL_TABLE_TYPES) runs even when SQL_ATTR_METADATA_ID = SQL_TRUE, where those values are supposed to be treated as literal identifiers — odbc/src/statement_metadata.cpp:388
  • Minor | Medium: with SQL_ATTR_METADATA_ID = SQL_FALSE, catalog arguments no longer support pattern matching in SQLColumns/SQLTables (e.g. catalog "%" now yields an empty result set instead of the current catalog); only the fully-empty SQLTables combination handles SQL_ALL_CATALOGS — odbc/src/statement_metadata.cpp:333
  • Minor | Medium: table name patterns are matched against the absolute path, so patterns like "prefix%" or "%" miss tables located in subdirectories ("%" matches only the top level while a null argument enumerates everything) — odbc/src/statement_metadata.cpp:663
  • Minor | Low: CARDINALITY is silently reported as NULL for tables with more rows than INT32_MAX (Int32OrNull), losing the statistic instead of reporting a value — odbc/src/statement_metadata.cpp:480
  • Minor | Low: no test covers SQLStatistics with SQL_INDEX_ALL when both unique and non-unique indexes exist (ordering by NON_UNIQUE then INDEX_NAME), since the unique-index coverage only queries SQL_INDEX_UNIQUE — odbc/tests/integration/metadata_api_it.cpp:666
  • Nit | Low: the SQLTables result-set sort comparator allocates temporary strings (GetTableType/GetMetadataTableName) on every comparison — odbc/src/statement_metadata.cpp:426
  • Nit | Low: a trailing lone backslash in a LIKE pattern is treated as a literal backslash rather than an invalid/malformed escape — odbc/src/utils/sql_like.h:30

This review was generated automatically. Critical issues require attention; other findings are advisory.
If this comment was useful, please give it a 👍 — it helps us improve the review bot.

Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp Outdated
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/tests/integration/metadata_api_it.cpp
Comment thread odbc/src/statement_metadata.cpp Outdated
Comment thread odbc/src/utils/sql_like.h
@robot-vibe-db

robot-vibe-db Bot commented Sep 29, 2026

Copy link
Copy Markdown

Full analysis log

Analysis performed by claude, z-ai/glm-5.3-flash.

@robot-vibe-db robot-vibe-db Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

Verdict: ✅ No critical issues found

Critical issues

No critical issues found.

Other findings

  • Major | High: SQLColumns passes catalogPatternsAllowed=false, so catalog search patterns (e.g. "%" or "loca%") are compared literally against the single catalog and return an empty result set instead of matching it — per ODBC, CatalogName is a pattern argument when SQL_ATTR_METADATA_ID=SQL_FALSE — odbc/src/statement_metadata.cpp:352
  • Minor | Medium: SQLStatistics rejects SQL_INDEX_HASH with HY100; ODBC defines SQL_INDEX_HASH as a valid Unique value, and a driver without hash-index support should return an empty result set rather than an error — odbc/src/statement_metadata.cpp:468
  • Minor | Medium: SQLSpecialColumns was not migrated to the new null/empty metadata-argument semantics: null pointers are silently converted to empty strings, so with SQL_ATTR_METADATA_ID=SQL_TRUE a null catalog/schema/table is not rejected with HY009 like the other catalog APIs, and an empty TableName now yields an empty result set instead of a list of candidates — odbc/src/statement_metadata.cpp:535
  • Minor | Medium: the SQL_ALL_TABLE_TYPES special enumeration is not gated on patternsAllowed; with SQL_ATTR_METADATA_ID=SQL_TRUE (where "%" is documented as a literal identifier and the new HY009 rules apply) passing TableType="%" still returns the type list, inconsistent with the strict semantics introduced in this PR — odbc/src/statement_metadata.cpp:420
  • Minor | Medium: no integration coverage for catalog arguments in SQLColumns (e.g. catalog "%" with MetadataId=SQL_FALSE); such a test would have caught the catalog-pattern regression — odbc/tests/integration/metadata_api_it.cpp:568
  • Minor | Low: GetBufferLength falls back to GetColumnSize for character types, reporting the character count instead of the byte length (spec: BUFFER_LENGTH is the size in bytes, including the terminator, needed to transfer the column) — odbc/src/statement_metadata.cpp:233
  • Minor | Low: null and empty-string TableType are both treated as "match all types" (MatchesTableTypeFilter with an empty filter returns true); per ODBC an empty list of table types is distinct from a null pointer — odbc/src/statement_metadata.cpp:443
  • Nit | High: directory pruning builds a temporary fullPath + "/" string for every visited node; comparing prefix bounds directly (e.g. via std::string_view::starts_with on the parent path plus the separator length) avoids the allocation on large catalogs — odbc/src/statement_metadata.cpp:682

This review was generated automatically. Critical issues require attention; other findings are advisory.
If this comment was useful, please give it a 👍 — it helps us improve the review bot.

Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp Outdated
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp
Comment thread odbc/src/statement_metadata.cpp Outdated
Comment thread odbc/tests/integration/metadata_api_it.cpp
@robot-vibe-db

robot-vibe-db Bot commented Sep 29, 2026

Copy link
Copy Markdown

Full analysis log

Analysis performed by claude, z-ai/glm-5.3-flash.

@Shfdis
Shfdis merged commit 6a74cc6 into ydb-platform:odbc-driver-feature Sep 30, 2026
33 checks passed
@Shfdis
Shfdis deleted the odbc-catalog-metadata branch September 30, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant