stephan [Thu, 1 Dec 2022 15:22:03 +0000 (15:22 +0000)]
sqlite3_js_create_file() now accepts an ArrayBuffer data source. Add test for OPFS-based export/re-import. The (sqlite3*) argument converter now optionally accepts sqlite3.oo1.DB instances.
stephan [Thu, 1 Dec 2022 03:55:28 +0000 (03:55 +0000)]
Expand "sqlite3_vfs*" JS-to-WASM function argument conversions to accept VFS names (JS strings) and capi.sqlite3_vfs instances. Implement sqlite3_js_vfs_create_file() to facilitate creation of file-upload features which store the file in VFS-specific storage (where possible, e.g. "unix" and "opfs" VFSes). Correct an argument type check in the SQLite3Error and WasmAllocError constructors.
stephan [Wed, 30 Nov 2022 18:21:01 +0000 (18:21 +0000)]
Rename some JS files from X.js to X.c-pp.js to keep the maintainer, and downstream build customizers, aware that those files contain constructs specific to the c-pp preprocessor and will not run as-is in JS.
stephan [Wed, 30 Nov 2022 11:50:16 +0000 (11:50 +0000)]
Install sqlite3_malloc/sqlite3_free() as the JS-side WASM allocator (as opposed to replacing C-level's malloc()/free() with them). All tests work and this eliminates the potential for allocator discrepancies when using the (de)serialize APIs.
stephan [Wed, 30 Nov 2022 08:37:17 +0000 (08:37 +0000)]
Simplify how the OPFS VFS async proxy copies initial state sent to it from the synchronous side of the connection. Make the lock-wait time a multiple of the wait-loop timeout interval.
stephan [Wed, 30 Nov 2022 07:17:29 +0000 (07:17 +0000)]
Rename some OPFS JS files. Prevent JS bindings of sqlite3_uri_...() from performing JS-to-C-string argument conversion on their first argument, as doing so is specifically illegal.
stephan [Wed, 30 Nov 2022 05:27:36 +0000 (05:27 +0000)]
Refactor a significant chunk of the OPFS sqlite3_vfs init code into sqlite3.VfsHelper, and internal-use-only API encapsulating code relevant to creating new VFSes in JS. Intended to assist in pending experimentation with an alternative OPFS VFS.
stephan [Tue, 29 Nov 2022 18:28:40 +0000 (18:28 +0000)]
sqlite3.oo1.OpfsDb: default to journal_mode=persist, as current tests show it to be marginally faster than truncate/delete in Chrome v109. Also increase default busy_timeout from 2 seconds to 3, admittedly on a whim.
drh [Tue, 29 Nov 2022 17:52:04 +0000 (17:52 +0000)]
Change the handling of hwtime.h to make it easier to compile performance
measurement builds that make use of hwtime.h. This should not affect
productions builds.
stephan [Tue, 29 Nov 2022 05:25:08 +0000 (05:25 +0000)]
Internal restructuring of the OPFS sqlite3_vfs in order to facilitate certain experimentation and improve error reporting/hints if it cannot be activated. Deprecate the name sqlite3.opfs.OpfsDb, preferring sqlite3.oo1.OpfsDb for consistency with JsStorageDb and any future DB subclasses.
stephan [Tue, 29 Nov 2022 02:23:12 +0000 (02:23 +0000)]
Add an explicit warning about the current API-instability of the sqlite3.opfs namespace, which may need to be eliminated based on re-thinking of how the OPFS sqlite3_vfs is registered. Comment changes only - no code.
drh [Mon, 28 Nov 2022 19:42:48 +0000 (19:42 +0000)]
Implementation of enhancement request [695a1a53dea6b240]: The query planner
has improved awareness of when indexes on expressions are covering and adjusts
their costs accordingly.
drh [Mon, 28 Nov 2022 15:23:53 +0000 (15:23 +0000)]
Rework the covering index checking routine, whereIsCoveringIndex(), so that
it can return a "maybe" result for aggregate queries where we are not exactly
sure. The index is scored as if it is covering, but the main table is
still opened.
stephan [Sun, 27 Nov 2022 00:57:56 +0000 (00:57 +0000)]
Document an OPFS API change in Chrome v108 which does not break our code but does change several formerly async methods to synchronous. No code changes.
stephan [Sat, 26 Nov 2022 15:24:58 +0000 (15:24 +0000)]
OPFS VFS: add the opfs-unlock-asap=1 URI flag which tells the VFS to release implicit locks ASAP instead of during VFS idle time. This improves concurrency notably in the test app but brings a significant performance penalty in speedtest1 (roughly 4x slowdown). This is not the final word in OPFS concurrency, but gets us a step further.
drh [Fri, 25 Nov 2022 17:05:55 +0000 (17:05 +0000)]
Relax restriction (8) on the push-down optimization so that it only applies
if one or more columns uses a collating sequence other than BINARY.
See [forum:/forumpost/3824ced748baa808|forum post 3824ced748baa808] and
check-in [346a3b12b861ce7b].
drh [Fri, 25 Nov 2022 16:32:59 +0000 (16:32 +0000)]
Fix #ifdefs so that restrictions (8) and (9) of the push-down optimization
are still enforced even if compiled with SQLITE_OMIT_WINDOWFUNC. This
fixes a bug introduced by check-in [346a3b12b861ce7b].
drh [Fri, 25 Nov 2022 16:10:48 +0000 (16:10 +0000)]
Immprove the query planner such that it is able to make use of indexed
expressions within an aggregate query with GROUP BY. This implements
enhancement request [99378177930f87bd].
drh [Fri, 25 Nov 2022 15:52:00 +0000 (15:52 +0000)]
Add restriction (9) to the push-down optimization: If the subquery is
a compound then all arms of the compound must have the same affinity.
dbsqlfuzz 3a548de406a50e896c1bf7142692d35d339d697f.
drh [Thu, 24 Nov 2022 19:02:40 +0000 (19:02 +0000)]
Take care not to try to add comments to a TK_AGG_COLUMN opcode that does
not have an associated Table object because it is a reference to an indexed
expression.
dan [Thu, 24 Nov 2022 15:32:00 +0000 (15:32 +0000)]
Update multiplex3.test to account for the fact that the multiplexor xDelete method may return an error even if it manages to delete the first chunk of a file.
stephan [Wed, 23 Nov 2022 19:03:22 +0000 (19:03 +0000)]
Add an experimental OPFS VFS-specific URI flag, opfs-unlock-asap, which tells the VFS to release implicit locks ASAP. This permits higher concurrency but hurts performance considerably. This may or may not be obsoleted by other concurrency-related experimentation.
drh [Wed, 23 Nov 2022 18:51:04 +0000 (18:51 +0000)]
Aggregates with GROUP BY now make use of expressions on indexes. This code
works and gets the correct answer for the test case in the ticket. Lots more
testing and documentation is needed, however.
stephan [Wed, 23 Nov 2022 16:39:07 +0000 (16:39 +0000)]
Initial infrastructure for adding a mode to the OPFS VFS which causes implicit locks to be released ASAP, which increases concurrency at the cost of performance.
dan [Wed, 23 Nov 2022 16:08:49 +0000 (16:08 +0000)]
Update Makefile.in to include new target "sqlite3r.c". For generating "sqlite3r.c" and "sqlite3r.h", versions of the amalgamation that include the recover extension. To build the shell tool against these files, add -DSQLITE_HAVE_SQLITE3R.
drh [Tue, 22 Nov 2022 19:49:16 +0000 (19:49 +0000)]
Rename the SELECTTRACE macro to TREETRACE, so that is corresponds to the new
CLI command. Renumber all of the bits in the bitmask used to enable
various kinds of tracing, and add a trace bitmap decoder in sqliteInt.h.
Changes to debugging logic only. No (intentional) changes to production code.
drh [Tue, 22 Nov 2022 15:43:16 +0000 (15:43 +0000)]
Since the memory registers used by the columns and functions of an
AggInfo object are sequential, it is not neecessary to remember each register
separately. We can simply remember the first one and do the math when
others are needed.
drh [Tue, 22 Nov 2022 13:33:58 +0000 (13:33 +0000)]
This is the first in what is anticipated to be a long sequence of incremental
changes aimed at improving aggregate query processing, and in particular
helping aggregate queries take better advantage of indexes on expression.
The end goal is to resolve ticket [99378177930f87bd], though it remains to
be seen whether or not I can get there with this approach.
drh [Mon, 21 Nov 2022 17:40:23 +0000 (17:40 +0000)]
Split out the debugging code that dumps an AggInfo object into a separate
subroutine called printAggInfo() so that it can be invoked interactively
during debugging. No changes to production code.