Skip to content

sqlite3_set_errmsg#1752

Merged
gwenn merged 9 commits into
rusqlite:masterfrom
gwenn:sqlite3_set_errmsg
Apr 25, 2026
Merged

sqlite3_set_errmsg#1752
gwenn merged 9 commits into
rusqlite:masterfrom
gwenn:sqlite3_set_errmsg

Conversation

@gwenn

@gwenn gwenn commented Nov 8, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/collation.rs Outdated
Comment thread src/error.rs
pub unsafe fn set_errmsg(
db: *mut ffi::sqlite3,
code: c_int,
msg: Option<&std::ffi::CStr>,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CStr vs str

@codecov

codecov Bot commented Mar 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.64%. Comparing base (d76b42f) to head (711df8f).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1752      +/-   ##
==========================================
+ Coverage   87.57%   87.64%   +0.06%     
==========================================
  Files          58       58              
  Lines       10825    10878      +53     
==========================================
+ Hits         9480     9534      +54     
+ Misses       1345     1344       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gwenn gwenn force-pushed the sqlite3_set_errmsg branch from b2454fc to 14ee3f1 Compare April 25, 2026 09:17
@gwenn gwenn marked this pull request as ready for review April 25, 2026 09:24
@gwenn gwenn requested a review from Copilot April 25, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for SQLite’s sqlite3_set_errmsg() API and improves error introspection/propagation so wrapper/extension callbacks can surface richer SQLite error information.

Changes:

  • Add Error::sqlite_extended_error_code() accessor and test coverage for extended error codes.
  • Expose Connection::set_errmsg() (behind modern_sqlite) and implement the underlying error::set_errmsg() wrapper.
  • Update collation-needed callback handling to propagate Rust callback errors to SQLite via sqlite3_set_errmsg() when available.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/statement.rs Extends an existing test to assert extended SQLite error code.
src/lib.rs Adds a Connection::set_errmsg() API (feature-gated).
src/error.rs Adds sqlite_extended_error_code() and an sqlite3_set_errmsg() wrapper.
src/collation.rs Sets SQLite error code/message when collation-needed callback fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib.rs
Comment thread src/collation.rs
Comment thread src/error.rs
Comment on lines +524 to +532
/// Set error code and message
/// # Safety
/// This function is unsafe because it uses raw pointer
#[cfg(feature = "modern_sqlite")] // 3.51.0
pub unsafe fn set_errmsg(
db: *mut ffi::sqlite3,
code: c_int,
msg: Option<&std::ffi::CStr>,
) -> Result<()> {

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The # Safety docs for error::set_errmsg are currently too vague for an unsafe fn (it’s not just “uses raw pointer”). Please document the concrete safety preconditions (e.g., db must be a valid, open sqlite3* for the duration of the call; any threading/ownership expectations if applicable).

Copilot uses AI. Check for mistakes.
@gwenn gwenn force-pushed the sqlite3_set_errmsg branch from 2111f38 to 711df8f Compare April 25, 2026 11:16
@gwenn gwenn merged commit 4f7bd63 into rusqlite:master Apr 25, 2026
17 checks passed
@gwenn gwenn deleted the sqlite3_set_errmsg branch April 25, 2026 11:46
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.

2 participants