go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

SQLiteConn: Add 'Raw' method to give access to underlying sqlite3 context structure

Open gwd opened this issue 2 months ago • 1 comments

This is necessary, for instance, to allow users of the package to make their own CGo callbacks, and have the underlying sqlite3 library call those C functions directly.

Note that the intention from the sqlite3 library seems to be that there should be a measure of binary compatibility between versions: even extensions compiled against an older different version of sqlite3 should be able to call sqlite3_create_function with no problems. So this should work even if users of the package have a slightly different version of the sqlite3.h header.

Note that the code itself was written by @rittneje. I tested it and wrote the comments.

Signed-off-by: George Dunlap [email protected]

v2: Just copy @rittneje's code exactly:

  • Grab the lock while the function is running
  • Replace the error code with our own if it's of type ErrNo

gwd avatar Oct 21 '25 16:10 gwd