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].
stephan [Fri, 9 Dec 2022 15:12:07 +0000 (15:12 +0000)]
Expose sqlite3_value_frombind/nochange/numeric_type() to WASM. Add a flag to sqlite3_value_to_js() to cause it to return undefined, instead of throwing, if no conversion can be found.
stephan [Fri, 9 Dec 2022 14:46:24 +0000 (14:46 +0000)]
Refactor the sqlite3_value-to-JS conversion from an internal detail to sqlite3.capi.sqlite3_value_to_js() for use with routines like sqlite3_module::xFilter().
stephan [Fri, 9 Dec 2022 12:12:49 +0000 (12:12 +0000)]
Remove some unused sqlite3_status() codes from the JS API. Add custom JS wrappers for sqlite3_create_collation/_v2() which accept JS functions (plus tests). Expand the argument options for sqlite3_wasm_db_error() to enable it to translate exception objects to C-level errors.
stephan [Fri, 9 Dec 2022 09:23:27 +0000 (09:23 +0000)]
Rename the oft-used, verbose sqlite3.wasm.get/setMemValue() and get/setPtrValue() to peek/poke() and peek/pokePtr(). The old names are retained as aliases just in case any client code actually uses them, but they are now deprecated.
stephan [Fri, 9 Dec 2022 05:47:42 +0000 (05:47 +0000)]
Export sqlite3_status() and sqlite3_stmt_status() to wasm. Expand the arg/return semantics of wasm.get/setPtrValue() and get/setMemValue() to simplify handling of multiple pointers.
stephan [Fri, 9 Dec 2022 01:49:17 +0000 (01:49 +0000)]
Expose sqlite3_db_status() and sqlite3_db_config() to wasm, noting that the latter requires several internal wrappers to account for the various varidic forms (C varargs cannot be bound to wasm).