drh [Thu, 12 Jan 2023 19:51:49 +0000 (19:51 +0000)]
Fix sqlite3_prepare() so that it only invokes the progress handler on every
N-th call to sqlite3ProgressCheck(), where N is the progress handler step
count. Also fix faulty asserts exposed by the ability to interrupt in the
middle of sqlite3_prepare().
drh [Thu, 12 Jan 2023 13:25:48 +0000 (13:25 +0000)]
Attempt to provide a mechanism to do early termination of long-running
statement preparation by invoking the progress handler at strategic points
during sqlite3_parpare(). This experiment shows that sqlite3_prepare() might
leave the resulting prepared statement uninitialized following an interrupt.
drh [Wed, 11 Jan 2023 17:50:24 +0000 (17:50 +0000)]
If OP_Rewind has P2 of zero, that is an assertion that the table is never
empty. This fixes a false-positive in the out-of-subroutine jump detection
logic added in version 3.39.0, and which was causing the assertion on the
previous check-in.
drh [Wed, 11 Jan 2023 16:44:57 +0000 (16:44 +0000)]
Add an assert() to the byte-code engine that goes off if the OP_Halt opcode
is invoked with SQLITE_INTERNAL. This causes the RIGHT JOIN error
"Opcode jumps to ... which is outside the subroutine ..." to fail immediately,
causing it to come more readily to tester's attention. There is at least
one testcase in test/fuzzdata8.db that asserts due to this change.
drh [Wed, 11 Jan 2023 00:27:06 +0000 (00:27 +0000)]
Add a new sqlite3_is_interrupted() interface that can be used by long-running
app-defined functions and similar to see if they need to exit early due to
an sqlite3_interrupt() call.
drh [Tue, 10 Jan 2023 19:57:26 +0000 (19:57 +0000)]
When computing the datatypes for columns in a view, use the same datatype name
as the underlying table if such is available and is consistent with
the computed affinity of the column.
[forum:/forumpost/7fb1fe9dcf310ef5|Forum thread 7fb1fe9dcf310ef5].
drh [Thu, 5 Jan 2023 01:26:58 +0000 (01:26 +0000)]
In the zipvfile extension (which is not part of the SQLite amalgamation, but
which is included in the CLI by default) ensure that fopen() is not invoked
using a NULL filename. Fix for the issue reported by
[forum:/forumpost/d1c96a9032e564f8|forum post d1c96a9032e564f8].
dan [Wed, 4 Jan 2023 17:46:29 +0000 (17:46 +0000)]
Ensure that LIMIT clauses may be passed through to virtual table implementations even if the WHERE clause uses operators that may only be optimized by virtual, not built-in, tables (!=, functions, MATCH etc.).
drh [Wed, 4 Jan 2023 15:18:52 +0000 (15:18 +0000)]
Enhance PRAGMA integrity_check so that it verifies that the string values
stored in indexes are byte-for-byte identical to the values in the table, and
not just equivalent according to the collating sequence.
dbsqlfuzz 686e2e205e0c0594d3fb524bea0c25e621d1a870.
stephan [Wed, 4 Jan 2023 03:14:06 +0000 (03:14 +0000)]
Remove the JS-side SQLITE_WASM_DEALLOC sanity check which triggers the problem mentioned in [688c5c13d156] and [ae0196d86ee8], for reasons covered in the code comments, per discussion in [forum:e5b20e1feb|forum post e5b20e1feb].
stephan [Mon, 2 Jan 2023 20:07:30 +0000 (20:07 +0000)]
Another reformulation of SQLITE_WASM_DEALLOC to attempt to work around a Safari-specific quirk reported in [forum:5489305f601b8c3f|forum post 5489305f601b8c3f].
stephan [Sun, 1 Jan 2023 12:22:16 +0000 (12:22 +0000)]
An alternative solution to mapping SQLITE_WASM_DEALLOC to the proper function pointer in JS, to account for a Safari-specific quirk reported in [forum:e5b20e1feb|forum post e5b20e1feb].
drh [Mon, 26 Dec 2022 15:14:24 +0000 (15:14 +0000)]
Fix an infinite loop in the MEMSYS5 auxiliary memory allocator that occurs
for memory allocations between 1GiB and 2GiB in size. Error introduced
by check-in [949133231f8f751a]. The problem only affects builds that
include the SQLITE_ENABLE_MEMSYS5 compile-time option.
stephan [Mon, 26 Dec 2022 13:00:58 +0000 (13:00 +0000)]
Add JS infrastructure which enables sqlite3.capi.sqlite3_close_v2() to clean up stale JS-to-WASM collation function conversions installed on behalf of a given db handle. The same for UDF mappings is TODO.
stephan [Mon, 26 Dec 2022 11:13:09 +0000 (11:13 +0000)]
Reimplement sqlite3.capi.sqlite3_close_v2() and sqlite3session_delete() as a hand-written bindings so that they can attempt to clean up certain (potentially) FuncPtrAdapter-installed functions before closing. Correct the create-function family of JS-to-function-pointer automated conversions to include the UDF's arity as part of the mapping's key so that (un)binding a UDF to different functions for different arities works (and add tests confirming it). Correct a broken doc link in module-symbols.html.
stephan [Sun, 25 Dec 2022 22:44:13 +0000 (22:44 +0000)]
Add sqlite3.oo1.DB.selectValues(). Correct a logic error which could cause DB.selectValue(), DB.selectArray(), and DB.selectObject() to fail to finalize a statement if a call to bind() failed. Add more session API tests.
stephan [Sun, 25 Dec 2022 17:09:34 +0000 (17:09 +0000)]
Replace the "manual" implementation of sqlite3.capi.sqlite3_exec() with a briefer "automated" one via the [7f9ace1b11a67] feature addition. Minor code-adjacent internal cleanups.
stephan [Sun, 25 Dec 2022 14:04:06 +0000 (14:04 +0000)]
Add missing sqlite3_context_db_handle() JS binding. Reimplement sqlite3_set_authorizer() and sqlite3_set_auxdata() JS bindings to take advantage of [7f9ace1b11a67]. Teach FuncPtrAdapter to emit a console.warn() message if it is invoked after the library is bootstrapped, the goal being to inform users that it's an internal API and should not be invoked from client-side code.
stephan [Sun, 25 Dec 2022 12:51:53 +0000 (12:51 +0000)]
Enhance sqlite3.wasm.xWrap.FuncPtrAdapter to be able to handle sqlite3_create_function() and friends and reimplement those bindings to use this feature (this will also simplify certain session API bindings). Interal API changes only with no client-side breakage.
stephan [Sun, 25 Dec 2022 10:22:27 +0000 (10:22 +0000)]
Simplify the signature for JS functions, as opposed to function pointers, passed to sqlite3_exec(), eliminating the superfluous initial two arguments. Update related tests to demonstrate both function-passing approaches.
stephan [Sat, 24 Dec 2022 15:28:45 +0000 (15:28 +0000)]
Replace JS-side use of SQLITE_TRANSIENT with the new SQLITE_WASM_DEALLOC, reducing the amount allocation/copying required by sqlite3_bind_blob/text() and sqlite3_result_blob/text(). Remove the 'experimental' log message from the virtual table tests.
stephan [Sat, 24 Dec 2022 01:59:42 +0000 (01:59 +0000)]
If sqlite3.oo1.DB.exec()'s callback returns a literal false, stop step()ing over results as if the end of the result set had been reached. Unrelated minor code-adjacent cleanups.
stephan [Fri, 23 Dec 2022 23:46:33 +0000 (23:46 +0000)]
Reimplement JS's sqlite3_bind_text/blob() with hand-written bindings to permit more flexible inputs. Add automated JS-to-C function conversion to sqlite3_busy_handler(). sqlite3.wasm.xWrap()'s '*' argument conversion no longer treats JS strings as C-strings: those conversions require explicit opt-in via the 'string' converter (or equivalent).
stephan [Fri, 23 Dec 2022 19:16:45 +0000 (19:16 +0000)]
Consolidate/unify how the JS bindings of the create_function/collation family of functions react to a non-UTF8 encoding: they now treat a falsy value as SQLITE_UTF8 and fail with SQLITE_FORMAT for an invalid encoding.
stephan [Fri, 23 Dec 2022 14:11:54 +0000 (14:11 +0000)]
Add sqlite3.capi JS bindings for the sqlite3session_...(), sqlite3changeset_...() and sqlite3changegroup_...() APIs, noting that they are completely untested. Aside from missing tests, these bindings reveal a slight string-argument-type shortcoming in the callback function pointer "reverse binding" which should ideally be resolved before publishing them.