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].
stephan [Wed, 14 Dec 2022 18:06:01 +0000 (18:06 +0000)]
Rename the new peek/pokeF32() and peek/pokeF64() to peek/poke32f() and peek/poke64f() for consistency with related APIs and because they're easier on both the eyes and the fingers.
drh [Wed, 14 Dec 2022 17:46:35 +0000 (17:46 +0000)]
Rework the code that computes the datatypes and affinities for subqueries
and views. If the subquery/view is constructed from a compound SELECT where
the affinity varies across arms of the compound, set the affinity for the
corresponding column in the constructed view to be BLOB so that it is allowed
to take on any data type.
drh [Wed, 14 Dec 2022 14:41:35 +0000 (14:41 +0000)]
If the SELECT that implements a subquery or a VIEW or a CREATE TABLE AS is
a compound with different result datatypes on two or more arms of the compound,
then the overall column type becomes BLOB (ANY).
stephan [Wed, 14 Dec 2022 14:28:54 +0000 (14:28 +0000)]
Add convenience variants of sqlite3.wasm.peek/poke() for each numeric type to help reduce errors related to typos in the final argument (type-name strings). If wasm.xWrap.FuncPtrAdapter is called as a function, instead of a constructor, it now behaves as if it were called as a constructor (previously it threw an exception).
drh [Wed, 14 Dec 2022 09:06:45 +0000 (09:06 +0000)]
Back out the part of the change in [88a05141c28e5ff1] that adds affinity to
the materialization of a view, as the affinity can be undefined for a compound
query. This passes all TCL tests, but shows failures in the TH3 tests derived
from [forum:/forumpost/6f842bc5b2dadcb2|forum post 6f842bc5b2dadcb2], presumably
because the WHERE clause of the query uses constraints of the form
"source_crs_code='8675'" instead of "source_crs_code=8675". Perhaps further
changes on this branch should reimplement affinity on joins in cases where
the affinity is unambiguous.
stephan [Wed, 14 Dec 2022 08:01:34 +0000 (08:01 +0000)]
A micro-optimization in sqlite3.oo1.DB.exec(). Changed the rowMode option of that method to only accept $X instead of $X, @X, and :X, as the extra options are entirely superfluous and may lead to confusion.
dan [Tue, 13 Dec 2022 19:40:56 +0000 (19:40 +0000)]
Prevent the sessions rebaser from generating changesets containing UPDATE records for which non-PK fields are present in the old.* but not the new.* record. Also update the changeset iterator to work around such changesets.
stephan [Tue, 13 Dec 2022 08:25:28 +0000 (08:25 +0000)]
Extend the sqlite3.wasm function pointer argument converter to be able to handle the "two-layered context" of sqlite3_create_collation() and friends and make use of FuncPtrAdapter to perform JS-to-WASM function conversion for them.
drh [Mon, 12 Dec 2022 21:22:23 +0000 (21:22 +0000)]
Further fix for ticket [57c47526c34f01e8]. If a subquery has a result set
column of the form "CAST(expr AS NUMERIC)" do not give that column NUMERIC
affinity. NUMERIC affinity always goes to an integer if able, but a CAST
to numeric is a no-op if the input is a number. So the two are not equivalent.
drh [Mon, 12 Dec 2022 18:58:53 +0000 (18:58 +0000)]
If a subquery has a result column of the form "CAST(... AS NUMERIC)" then
give that column no affinity rather than NUMERIC affinity. This is because
casting to numeric preserves real values that could be integers but numeric
affinity does not. By using no affinity on the column, we make the behavior
consistent if the subquery is implemented as a co-routine or is materialized.
stephan [Mon, 12 Dec 2022 18:42:39 +0000 (18:42 +0000)]
Revert part of [9386d6f63468] because the new automatic function pointer binding cannot properly track per-context function mappings when the context is more complex than a single context-type pointer. e.g. it is fine for sqlite3_trace_v2() but it breaks down with sqlite3_create_collation() because that one needs to use the collation name as part of the context key and we cannot sensibly do so with the current code.
stephan [Mon, 12 Dec 2022 14:31:38 +0000 (14:31 +0000)]
Move JS-to-C binding signatures from sqlite3-api-prologue.js to sqlite3-api-glue.js to allow for use of the new/experimental sqlite3.wasm.xWrap() feature which automatically binds JS functions to WASM/C as needed, which simplifies creation of bindings which take C function pointers. Reimplement sqlite3_exec(), sqlite3_create_collation(), sqlite3_progress_handler() to use this new feature.
stephan [Mon, 12 Dec 2022 08:16:47 +0000 (08:16 +0000)]
Rework the internals of how argument/result types are converted to/from wasm in prep for attempting to support automated conversions of function pointer argument types.
dan [Sat, 10 Dec 2022 19:22:39 +0000 (19:22 +0000)]
Ensure that the types and collation sequences of a view are taken from the leftmost component of compound SELECTs, even when column names are explicitly provided for the view.
dan [Sat, 10 Dec 2022 17:54:55 +0000 (17:54 +0000)]
Ensure that the types and collation sequences of a view are taken from the leftmost component of compound SELECTs, even when column names are explicitly provided for the view. Possible fix for [679ed6a2].