drh [Wed, 7 Dec 2022 00:14:25 +0000 (00:14 +0000)]
Fix a (harmless) off-by-one error in code generation that comes up when
doing a DISTINCT query against a virtual table with an OR term in the
WHERE clause and where the ORDER BY clause has 64 or more references to
the result set. [forum:/forumpost/dfe8084751|Forum post dfe8084751].
dan [Tue, 6 Dec 2022 18:48:06 +0000 (18:48 +0000)]
Have sqlite3_stmt_scanstatus_v2() return an NCYCLE value for all loops, not just virtual tables ones. The value returned is the sum of the NCYCLE counts for the various opcodes that move or read data from the table or index cursor associated with the loop.
drh [Tue, 6 Dec 2022 13:12:33 +0000 (13:12 +0000)]
In the unix backend, when implementing the defenses against small file
descriptors, delete a file just created if it was opened with
O_EXCL|O_CREAT so that it can be created again the next time through the
loop. Fix for the problem described by
[forum:/forumpost/699af709ab3a8ccf|forum post 699af709ab3a8ccf].
stephan [Mon, 5 Dec 2022 15:05:46 +0000 (15:05 +0000)]
Remove two features of jaccwabyt which were fundamentally flawed, along with approx. 250 lines of unit tests which heavily relied on them. Thankfully, none of the sqlite3.js-level code used those bits.
stephan [Mon, 5 Dec 2022 11:54:13 +0000 (11:54 +0000)]
Rename 'static-string' argument adapter to 'string:static'. Replace JS unit tests which were lost via editing a generated copy of tester1.js instead of the original tester1.c-pp.js input file.
stephan [Mon, 5 Dec 2022 11:30:39 +0000 (11:30 +0000)]
Export sqlite3_bind/value/result_pointer() to wasm. Add 'static-string' argument converter to support the lifetime requirements of bind/result_pointer()'s string argument. Correct an endless loop in wasm.cstrlen() when passed a non-C-string argument.
drh [Mon, 5 Dec 2022 02:42:30 +0000 (02:42 +0000)]
Use the smaller estimated row size for searching IPK tables, but use the
original larger row size estimate for scanning, since the leaves can have large
rows.
stephan [Sat, 3 Dec 2022 13:10:58 +0000 (13:10 +0000)]
Rename wasm.xWrap.resultAdapter() X:free entries to X:dealloc for consistency with wasm.dealloc(). Add an undocumented feature to replace wasm.alloc/dealloc/realloc() with the C-standard allocators (after an allocator misuse led down a several-hour rabbit hole trying to discover a mis-free() violation). Related test updates.
stephan [Fri, 2 Dec 2022 18:06:26 +0000 (18:06 +0000)]
OPFS VFS: translate createSyncAccessHandle() exceptions which appear to be locking violations to SQLITE_BUSY. This seems to improve concurrency considerably even with a reduced retry count of 5 (was 6).
drh [Fri, 2 Dec 2022 17:52:52 +0000 (17:52 +0000)]
For the sqlite3_bind and sqlite3_result interfaces for UTF16 strings, round
the number of bytes down to the next even number, to avoid creating a UTF16
string that is an odd number of bytes.
[forum:/forumpost/411199488d065f83|Forum post 411199488d065f83].
drh [Fri, 2 Dec 2022 15:31:47 +0000 (15:31 +0000)]
Use sqlite3_result_int64() instead of sqlite3_result_int() when returning
potentially large values from the DBSTAT virtual table, to avoid integer
overflows in the result.
[forum:/forumpost/ada2ab044f|Forum post ada2ab044f].
stephan [Fri, 2 Dec 2022 10:43:14 +0000 (10:43 +0000)]
wasm builds: explicitly set a default stack size because emsdk 3.1.27 reduced it from 4MB to only 64kb, leading to memory corruption when kvvfs is used (it requires at least twice that for I/O).
stephan [Fri, 2 Dec 2022 08:29:03 +0000 (08:29 +0000)]
sqlite3-wasm.c: code legibility and coding style tweaks. Increase SQLITE_DEFAULT_PAGE_SIZE from 4k to 8k, as that improves OPFS speedtest1 performance by roughly 12%.
stephan [Fri, 2 Dec 2022 07:14:56 +0000 (07:14 +0000)]
Expand JS tests for db export/import and document reason it cannot currently work with kvvfs. Fix a minor JS build dependencies bug. Update page title with PASS/FAIL prefix for tester1.js to improve overview when launching multiple test tabs. Add ability of tester1 should-run-test predicates to report why a given test is disabled.
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.