This PR adds handling for user defined functions. Initially only the
xFunc parameter will be set, the others will come in subsequent PRs.
A test for a 'regexp' udf was added to check that the query
"SELECT 'seafood' REGEXP 'foo.*'"
works as expected.
Building on the _pragma query param support added in 508747c9, support
a new _time_format query param.
If _time_format is set to "sqlite", written times use the time package
format "2006-01-02 15:04:05.999999999-07:00". This is the format
mattn/go-sqlite3 uses and is format 4 at
https://sqlite.org/lang_datefunc.html#time_values.
By default, times are formatted with time.Time.String. This maintains
compatibility with existing users of the driver.
Fixes#47
In conn.step, use conn.errstr which gets the error from sqlite instead
of looking up the result code in the ErrorCodeString map.
This changes the code 5 (SQLITE_BUSY) message slightly, including
"database is locked" as returned my errstr. "SQLITE_BUSY" is still
added to the message.
Fixes#73
modernc.org/libc.Start does this when wrapping funcs main to seed data
for libc.Xgetenv and friends.
However, sqlite doesn't use libc.Start. It sets libc bits up in an
init func. This leaves the libc view of the enivorment empty/null.
When the sqlite "localtime" modifier used with datetime/strftime/etc,
sqlite eventually calls libc.Xlocaltime which wants to read TZ from
the environment. With an empty/null libc enivornment, this segfaults.
To fix that, call libc.SetEnviron in func init like libc.Start
does.
Fixes https://gitlab.com/cznic/sqlite/-/issues/49
Fix a bug around ensuring each index matches a corresponding
argument.
Support ?NNN parameters by checking for a match between NNN and
Ordinal. Do the same for $NNN even though $NNN should technically
require sql.Named.
Updates https://gitlab.com/cznic/sqlite/-/issues/42.