Skip to content

fix(capi): preserve error message on unsuccessful QueryResult (#754) - #762

Open
adsharma wants to merge 1 commit into
mainfrom
fix/754-capi-last-error-message
Open

fix(capi): preserve error message on unsuccessful QueryResult (#754)#762
adsharma wants to merge 1 commit into
mainfrom
fix/754-capi-last-error-message

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Fixes #754

Several C API entry points returned LbugError while leaving the last-error message empty, so bindings (notably the JVM) could only report a generic string. The fix is to populate the last-error message on every error path, matching the convention already used by lbug_connection_get_pushed_sql.

Changes (5 sites, all in src/c_api/):

  • connection.cpp setQueryResult — set last error before return LbugError; on the unsuccessful-result path
  • connection.cpp lbug_connection_query — same
  • connection.cpp lbug_connection_execute — same
  • query_result.cpp lbug_query_result_get_arrow_schema — call setLastCAPIErrorMessage(e.what()) in the catch block
  • query_result.cpp lbug_query_result_get_next_arrow_chunk — same

Tests added (3, all pass):

  • CApiConnectionTest.GetLastErrorQueryFailureMATCH (a:NoSuchTable) RETURN a returns LbugError and lbug_get_last_error() carries the binder exception text
  • CApiConnectionTest.GetLastErrorExecuteFailure — same for lbug_connection_execute
  • CApiQueryResultTest.GetLastErrorArrowSchemaFailurelbug_query_result_get_arrow_schema on a JSON column reports the underlying exception through lbug_get_last_error()

All 145 existing C API tests continue to pass. The bindings will now surface real diagnostic messages instead of the generic fallback.

Set the last-error message on five error paths that previously returned
LbugError without populating the error string:

- setQueryResult (connection.cpp)
- lbug_connection_query (connection.cpp)
- lbug_connection_execute (connection.cpp)
- lbug_query_result_get_arrow_schema (query_result.cpp)
- lbug_query_result_get_next_arrow_chunk (query_result.cpp)

Add three tests:
- GetLastErrorQueryFailure: query against nonexistent table
- GetLastErrorExecuteFailure: execute prepared statement failing at runtime
- GetLastErrorArrowSchemaFailure: get Arrow schema from JSON column

All 145 existing C API tests continue to pass.
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.

Bug: Preserve the error message when a C API call fails with an unsuccessful QueryResult

1 participant