XianReallyHot-ZZH opened a new pull request, #13719:
URL: https://github.com/apache/ignite/pull/13719

   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).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to