Repository navigation
IGNITE-12381 SQL: Propagate H2 error codes to IgniteSQLException - #13719
Conversation
|
The branch is rebased onto the latest master, which includes the fix for the ducktape GitHub checks failing on Ubuntu 26.04 runners (#13728). Could a committer please approve the workflow run so the checks can be re-verified on the new runner configuration? Many thanks! |
|
Thanks, I run a TC [1] lets wait for results [1] https://ci2.ignite.apache.org/buildConfiguration/IgniteTests24Java8_RunAll/9446231 |
|
Unfortunately it need to be fixed on c++ tests too, check TestSyntaxError, TestSqlStateOnErrors |
|
Thanks for running the TeamCity builds! The C++ tests have been updated to match the propagated H2 error codes (commit edac422):
Also added an Verified at the H2 level (1.4.197 patched): INSERT with unknown column → 42122, unknown schema → 90079, unknown table → 42102, the new syntax-error statement → 42001. The full |
|
@XianReallyHot-ZZH sorry but tests still failed: |
…egistered H2 resolves the table name during statement preparation before reporting syntax or column errors. TestType is registered in the "cache" schema, so the previous PUBLIC-schema connections made both INSERT statements fail with TABLE_NOT_FOUND (42S02) instead of the intended errors. - TestSyntaxError / TestColumnNotFound: connect with SCHEMA=cache so the statements exercise the syntax error (42000) and the column-not-found error (42S22) respectively. - TestErrorMessage: the missing table now surfaces its own SQLSTATE, so the expected message prefix is 42S02 instead of 42000.
|
Found the root cause — it was in my previous fix, not in the propagation itself. H2 resolves the table name during statement preparation before reporting syntax or column errors, and both new ODBC tests connected with Verified against a local node started with the same caches as the ODBC test configuration (
Fix (commit af81887):
Could you please re-run the ODBC TeamCity suites once more? Thanks! |
Propagating H2 error codes makes a query against a missing schema reach the ODBC driver as SCHEMA_NOT_FOUND (3015), which had no case in ResponseStatusToSqlState and fell through to the generic HY000 state (the code was reported as 42000 before this change). Map it to the standard invalid-schema-name state 3F000, add a TestSchemaNotFound case to the ODBC error suite, and pin the COLUMN_ALREADY_EXISTS mapping (duplicate column list entry in an INSERT) with a Java-side assertion. Also drop a dead boost/regex include, fix a stale comment and pass SQL_NTS instead of sizeof() in TestErrorMessage.
|
While re-checking the branch I found one more gap in the ODBC path: with the propagated codes, a query against a missing schema (e.g. Two small test cleanups ride along: a stale comment + The branch now carries two commits since your last run (af81887 + 5d049d1) — same re-run request stands. Thanks! |
Ticket: IGNITE-12381
What changes
H2Connection.prepareStatement()/prepareStatementNoCache()and theSQLExceptioncatch inQueryParser#parseH2wrapped every H2 error intoIgniteSQLExceptionwith the genericIgniteQueryErrorCode.PARSINGcode, so a client could not distinguish, say, a missing table from a plain syntax error without parsing the message text.This adds
H2Utils.h2ErrorCode(int)mapping the H2 error codes that have a direct Ignite counterpart, and uses it at all three wrap sites:TABLE_OR_VIEW_NOT_FOUND_1(42102)TABLE_NOT_FOUNDTABLE_OR_VIEW_ALREADY_EXISTS_1(42101)TABLE_ALREADY_EXISTSCOLUMN_NOT_FOUND_1(42122)COLUMN_NOT_FOUNDDUPLICATE_COLUMN_NAME_1(42121)COLUMN_ALREADY_EXISTSINDEX_ALREADY_EXISTS_1(42111)INDEX_ALREADY_EXISTSINDEX_NOT_FOUND_1(42112)INDEX_NOT_FOUNDSCHEMA_NOT_FOUND_1(90079)SCHEMA_NOT_FOUNDAll other codes keep the default
PARSING. Error messages are unchanged, and so are SQL states — every mapped code already resolves toSqlStateCode.PARSING_EXCEPTIONinIgniteQueryErrorCode#codeToSqlState, so only the integer error code visible through JDBC/ODBC becomes more specific. The change affects the H2 engine path (ignite-indexing) only; the default Calcite engine is untouched.Testing
New
testParseErrorCodesinIgniteCacheSqlQueryErrorSelfTest(modules/indexing) assertsIgniteSQLException.statusCode()for selects and DML against missing tables, a missing column, a missing schema, and that a pure syntax error still yieldsPARSING. All existing message assertions in that class pass unchanged, as doJdbcErrorsSelfTestandJdbcThinErrorsSelfTest(modules/clients, 75 tests).