Skip to content

Raise DB-API exceptions from Rust (phase 2) - #8

Merged
dominikpeter merged 3 commits into
mainfrom
rust/phase2-errors
Nov 1, 2026
Merged

dominikpeter merged 3 commits into
mainfrom
rust/phase2-errors

Conversation

@dominikpeter

Copy link
Copy Markdown
Member

Moves exception construction into Rust (src/errors.rs).

  • SQLSTATE to class table, the 1222 / 2628 / 8114 promotions and the driver_error / ddbc_error / sqlstate / native_error attributes are built in Rust; classes are imported once from arrowsql.exceptions. The "Raising exception" / "Unknown SQLSTATE" / "Connection error" log lines still go through the Python logger.
  • New DDBCRaiseFor(handle_type, handle, ret) replaces the DDBCSQLCheckError + regex round trip. helpers.check_error calls it, and falls back to the Python path when a test replaced DDBCSQLCheckError / DDBCSQLGetAllDiagRecords.
  • Native Connection and getinfo raise typed exceptions. _raise_connection_error stays as a shim for mocks that raise RuntimeError("SQLSTATE:..."). Connection close/rollback sites catch (RuntimeError, Error).
  • Native close() with an open transaction (25000) stays a RuntimeError: upstream's test_failed_native_disconnect_preserves_child_statement matches on it.
  • exceptions.sqlstate_to_exception / raise_exception are thin shims; the 140-line Python table is gone.
  • async hub uses the same builder.

Error path (SELECT * FROM no_such_table, release build): median 184.5us before, 176.5us after; 10k failing executes 1.90s vs 2.02s best of 3. Within noise, the round trip dominates.

Tests: common_issues/port/mock pass; upstream baseline 0 missing before the merge of main.

🤖 Generated with Claude Code

SQLSTATE table, class promotions and typed native Connection errors now live in src/errors.rs; check_error, raise_exception, sqlstate_to_exception and _raise_connection_error are thin shims.

Co-Authored-By: Claude <noreply@anthropic.com>
@dominikpeter
dominikpeter merged commit ddd4c17 into main Nov 1, 2026
22 checks passed
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