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 <dunlapg@umich.edu>
v4:
- Refactor to get rid of sql.OpenDB call, which only appeared in Go
1.10
v3:
- New
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 <dunlapg@umich.edu>
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
* Add build tags to support both x86 and ARM compilation on macOS
* Documentation fix: command line for build under macOS
* Global replace 'macOS X' -> 'macOS'. Fix typo in -tags cmd line param
* `README.md`: fix all `--tags` -> `-tags`
---------
Co-authored-by: Denis Dmitriev <dmitriev@itspartner.net>
As it was, the vtable example will give an error when adding any kind of SQL constraint in the SQL statement. Updating the BestIndex method will ensure that adding SQL constraints will not result in errors
Signed-off-by: David Vassallo <davevassallo@gmail.com>
Signed-off-by: David Vassallo <davevassallo@gmail.com>
# Enhancement
Update `README.md` with new instructions for Mac OS cross compiling.
# Why?
The current suggested solution `xgo` is no longer maintained (GitHub archived repository).
# Credits
Credits go to Pieter Claerhout (@pieterclaerhout) and his blog post: https://www.yellowduck.be/posts/cross-compile-a-go-package-which-uses-sqlite3
Add support for SQLITE_ENABLE_MATH_FUNCTIONS compile-time option via the sqlite_math_functions build tag.
Co-authored-by: Dominik Kraus <dominik.kraus@nktek.de>
This commit adds the `sqlite_os_trace` build tag which sets the
`SQLITE_FORCE_OS_TRACE` and `SQLITE_DEBUG_OS_TRACE` compilation
flags. This produces verbose debugging output of every operating
system call made by SQLite.
This commit adds the SQLiteConn.FileControlInt() method which calls the
underlying sqlite3_file_control() function with an int argument. This can
be used for low-level operations on SQLite databases such as persisting
the WAL file after database close.