Skip to content

IGNITE-12381 SQL: Propagate H2 error codes to IgniteSQLException - #13719

Open
XianReallyHot-ZZH wants to merge 2 commits into
apache:masterfrom
XianReallyHot-ZZH:IGNITE-12381-h2-error-codes
Open

XianReallyHot-ZZH wants to merge 2 commits into
apache:masterfrom
XianReallyHot-ZZH:IGNITE-12381-h2-error-codes

Conversation

@XianReallyHot-ZZH

Copy link
Copy Markdown

Ticket: IGNITE-12381

What changes

H2Connection.prepareStatement() / prepareStatementNoCache() and the SQLException catch in QueryParser#parseH2 wrapped every H2 error into IgniteSQLException with the generic IgniteQueryErrorCode.PARSING code, 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:

H2 code Ignite code
TABLE_OR_VIEW_NOT_FOUND_1 (42102) TABLE_NOT_FOUND
TABLE_OR_VIEW_ALREADY_EXISTS_1 (42101) TABLE_ALREADY_EXISTS
COLUMN_NOT_FOUND_1 (42122) COLUMN_NOT_FOUND
DUPLICATE_COLUMN_NAME_1 (42121) COLUMN_ALREADY_EXISTS
INDEX_ALREADY_EXISTS_1 (42111) INDEX_ALREADY_EXISTS
INDEX_NOT_FOUND_1 (42112) INDEX_NOT_FOUND
SCHEMA_NOT_FOUND_1 (90079) SCHEMA_NOT_FOUND

All other codes keep the default PARSING. Error messages are unchanged, and so are SQL states — every mapped code already resolves to SqlStateCode.PARSING_EXCEPTION in IgniteQueryErrorCode#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 testParseErrorCodes in IgniteCacheSqlQueryErrorSelfTest (modules/indexing) asserts IgniteSQLException.statusCode() for selects and DML against missing tables, a missing column, a missing schema, and that a pure syntax error still yields PARSING. All existing message assertions in that class pass unchanged, as do JdbcErrorsSelfTest and JdbcThinErrorsSelfTest (modules/clients, 75 tests).

@XianReallyHot-ZZH

Copy link
Copy Markdown
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant