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.
drh [Wed, 21 Dec 2022 19:11:56 +0000 (19:11 +0000)]
More efficient implementation of large precisions on the "%c" format for
the built-in printf(). This is an effort to avoid a reported
timeout on a (ridiculous) query generated by OSSFuzz.
drh [Wed, 21 Dec 2022 14:13:49 +0000 (14:13 +0000)]
Ensure that the expression of a virtual column really is an expression and
not just a reference to another column, as a real expression is necessary for
the indexed expression coverage optimization to work properly.
[forum:/forumpost/07b36e3899a9ae21|Forum thread 07b36e3899a9ae21].
drh [Wed, 21 Dec 2022 12:18:06 +0000 (12:18 +0000)]
New WHERETRACE entries for adding and removing objects from the
Parse.pIdxEpr list as part of indexed expression coverage. Debug and
testing changes only - no affect on production builds.
drh [Tue, 20 Dec 2022 01:48:43 +0000 (01:48 +0000)]
Do not use indexed expressions to replace the expression being indexed on a
RIGHT JOIN as that leads to problems, as shown by
dbsqlfuzz a644e70d7683a7ca59c71861a153c1dccf8850b9.
stephan [Sat, 17 Dec 2022 11:14:35 +0000 (11:14 +0000)]
Update wasmfs.make to get WASMFS building again, but changes made to OPFS-over-WASMFS since we last tested it have made it incompatible with how we used it. It can now only be used from worker threads, eliminating the one benefit it had over the sqlite3_vfs OPFS implementation. Remove/amend references to WASMFS in the docs and remove all WASMFS-specific test app links from index.html.
drh [Fri, 16 Dec 2022 18:32:07 +0000 (18:32 +0000)]
Disallow some of the query invariant tests on SQL statements that contain
a GROUP BY since output terms that are no covered by the GROUP BY are
indeterminant.
stephan [Fri, 16 Dec 2022 13:04:21 +0000 (13:04 +0000)]
Expose a JS-friendly subset of sqlite3_config() to JS, with the notable caveats that (1) setting up the JS bindings requires starting the library, making sqlite3_config() illegal to call and (2) calling sqlite3_shutdown() in order to make it legal to call sqlite3_config() may undo certain JS-side library initialization. Move sqlite3_(de)serialize() into the int64-mode-only bindings because of their int64 args.
drh [Thu, 15 Dec 2022 20:03:08 +0000 (20:03 +0000)]
Create a new affinity called FLEXNUM that works like NUMERIC except that it
never tries to convert integer to real or real to integer. The affinity is
only used internally - it is not possible to create a table column with this
affinity. This affinity is used on subqueries and views that are built off
of a compound SELECT and where the datatype is controlled by a CAST expression.
dbsqlfuzz c9ee6f9a0a8b8fefb02cf69de2a8b67ca39525c8
drh [Wed, 14 Dec 2022 18:34:05 +0000 (18:34 +0000)]
Adjust the query planner to be more aggressive about using co-routines rather
than materializing subqueries and views. Implementation of enhancement
request [73ebbb3a3d1a7bd3].