SQLiteConn: Add 'Raw' method to give access to underlying sqlite3 context structure#1360
Open
gwd wants to merge 2 commits intomattn:masterfrom
Open
SQLiteConn: Add 'Raw' method to give access to underlying sqlite3 context structure#1360gwd wants to merge 2 commits intomattn:masterfrom
gwd wants to merge 2 commits intomattn:masterfrom
Conversation
…text structure 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
Note that you can't call cgo from within a test file; so in order to test the functionality, create new package, .../internal/sqlite3test, to define the callback. Then in the main sqlite3 package, add a test file which includes this package and calls the callback. As with the previous commit, the idea and the basic code was written by @rittneje; I massaged it so that it compiled and passed with Go 1.9, and wrote this commit message and the comments. NB that Golang 1.9 doesn't have sql.OpenDB, so we have to register a new database driver. Signed-off-by: George Dunlap <[email protected]> v4: - Refactor to get rid of sql.OpenDB call, which only appeared in Go 1.10 v3: - New
Author
|
This is a rebased / re-opened version of #784, which got closed when I accidentally deleted the backing branch from github. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: