This commit introduces a new type 'ErrNo', implementing the error
interface. Constants for all sqlite3 error codes are provided
in the new source file "error.go".
By loading extensions this way, it's not possible to later load
extensions using db.Exec, which improves security, and makes it much
easier to load extensions correctly. The zero value for the slice
(the empty slice) loads no extensions by default.
The extension example has been updated to use this much simpler system.
The ConnectHook field is still in SQLiteDriver in case it's needed for
other driver-wide initialization.
Updates #71 of mattn/go-sqlite3.
The ConnectHook field of an SQLiteDriver should return an error in
case something bad happened during the hook.
The extension example needs to load the extension in a ConnectHook,
otherwise the extension is only loaded in a single connection in the pool.
By putting the extension loading in the ConnectHook, its called for every
connection that is opened by the sql.DB.
This commit introduces a new type 'ErrNo', implementing the error
interface. Constants for all sqlite3 error codes are provided
in the new source file "error.go".
sqlite3 documentation states sqlite3_column_blob could modify the
the content and recommends the "safest and easiest" policy is to
invoke sqlite3_column_blob() followed by sqlite3_column_bytes()
from: http://www.sqlite.org/c3ref/column_blob.html
SQLite3 stores timestamps very naively -- they're completely untyped,
and can contain any value. The previous implementation always inserts
values in the 'datetime' format, and returns an error when attempting to
extract a field with a different format.
Some legacy databases, unfortunately, were generated using the 'date'
SQLite3 function, which produces rows in the '2006-01-02' format. This
patch adds a special case so that these rows can be extracted without
error.
Original:
--- FAIL: TestInsert (0.00 seconds)
sqlite3_test.go:42: Failed to create table:%!(EXTRA *errors.errorString=unable to open database file)
With corrections:
--- FAIL: TestInsert (0.00 seconds)
sqlite3_test.go:42: Failed to create table: unable to open database file
SQLite stores boolean values as an integer, serializing true as 1 and
false as 0 [1], but it does not actually enforce this range. To match
the documentation (and fix the broken test case), this patch makes a Go
boolean true serialize properly to 1.
[1] http://www.sqlite.org/datatype3.html