stephan [Fri, 4 Jul 2025 10:10:32 +0000 (10:10 +0000)]
Tweak for coverage testing of valueToTextV2(). This changes passes through coverage testing but doesn't look quite right to me, in that this part now differs from its counterpart in valueToText() (which doesn't need this to get coverage for what amounts to the same path).
Fix an uninitialized variable added yesterday by [d27d34fb746280e7].
This problem was discovered overnight by
[https://github.com/google/oss-fuzz|OSSFuzz].
stephan [Wed, 2 Jul 2025 13:24:50 +0000 (13:24 +0000)]
Per /chat and forum discussions: (A) Remove the value type output pointer from text/blob_v2(). (B) Teach blob_v2() to return an opaque non-NULL pointer for length-0 blobs.
stephan [Wed, 2 Jul 2025 07:52:30 +0000 (07:52 +0000)]
Add test1.c tcl bindings for sqlite3_column_text/blob_v2(). Replace, essentially randomly, some of the v1 API calls in capi2.test and capi2.test with the v2 calls to ensure identical results. Add a couple new tests comparing results between v1 and v2.
stephan [Tue, 1 Jul 2025 21:06:58 +0000 (21:06 +0000)]
Have sqlite3_value/column_text/blob_v2() return MISUSE for a NULL input object or output target only if SQLITE_ENABLE_API_ARMOR is in effect, for consistency with their sibling APIs.
stephan [Tue, 1 Jul 2025 20:56:49 +0000 (20:56 +0000)]
Have sqlite3_value/column_text/blob_v2() unconditionally return MISUSE for a NULL input object or output target, rather than only when API_ARMOR is in effect. This is debatable.
stephan [Tue, 1 Jul 2025 16:38:58 +0000 (16:38 +0000)]
Experimentally add another output pointer to the text/blob_v2() family which gets the sqlite3_value_type() assigned to it if it's not NULL, based on feedback in the forum.
When attempting to optimize "expr AND false" to "false" and
"expr IN ()" to "false", take care not to delete aggregate functions
in the "expr" as doing so can change the meaning of the query.
See [forum:/forumpost/f4878de3e7dd4764|forum thread f4878de3e7].
stephan [Tue, 1 Jul 2025 09:02:27 +0000 (09:02 +0000)]
Add tests which demonstrate the difference in behavior for zero-length results in sqlite3_value_text_v2() (empty string) vs sqlite3_value_blob_v2() (NULL).
stephan [Mon, 30 Jun 2025 23:17:57 +0000 (23:17 +0000)]
Restart this branch using a different take: add new "v2" routines instead of refactoring the old ones, which eliminating any performance impact or risk of behavior change for existing APIs. None of this code is actually called from anywhere yet.
drh [Mon, 30 Jun 2025 20:19:19 +0000 (20:19 +0000)]
Compute WhereLevel.addrBrk and .addrHalt early so that those labels can be
used to abort loops early. Use this to improve performance on two more
of the cases described by [forum:/forumpost/52651713ac|forum post 52651713ac].
drh [Mon, 30 Jun 2025 16:41:40 +0000 (16:41 +0000)]
Strive to skip the evaluation of scalar subqueries that are part of a
larger expression if the result from the scalar subquery does not change the
result of the overall expression.
drh [Mon, 30 Jun 2025 10:30:47 +0000 (10:30 +0000)]
Factor out the code that tries to avoid evaluating subquery operands if the
other operand is NULL into a subroutine, so that it can be more easily reused
by other parts of the code generator.
drh [Sat, 28 Jun 2025 17:59:15 +0000 (17:59 +0000)]
Improve the bytecode generated for comparisons so that if one operand is
a subquery and the other operand evaluates to NULL, the subquery operand
is not even computed. This fixes 5 of the 12 slow queries described
in [forum:/forumpost/52651713ac|forum post 52651713ac].
drh [Tue, 24 Jun 2025 15:58:32 +0000 (15:58 +0000)]
Range check the column index on the sqlite3_preupdate_old() interface
and return SQLITE_MISUSE if too large.
[forum:/forumpost/b617e497287235d0|Forum post b617e49728].
stephan [Sat, 21 Jun 2025 14:38:53 +0000 (14:38 +0000)]
Rework how JS's oo1.DB.exec() flags its Stmt objects to make certain Stmt APIs illegal (i.e. throwing) if called while that Stmt is being step()ped by DB.exec() (which can happen via client-provided per-result-row callbacks). This is an internal change only - the API is unaffected. Remove some unrelated dead code.
stephan [Thu, 19 Jun 2025 10:25:50 +0000 (10:25 +0000)]
Expose the column metadata APIs to WASM (which does not require a non-default sqlite3.c build, contrary to my prior mistaken claims). This adds only 424 bytes to sqlite3.wasm and 660 bytes to sqlite3.js.
stephan [Wed, 18 Jun 2025 15:37:04 +0000 (15:37 +0000)]
Export the column-metadata APIs to WASM. Doing so requires a non-default build of sqlite3.c, so this is a proof-of-concept branch saved just in case SQLITE_ENABLE_COLUMN_METADATA ever becomes the default for sqlite3.c.
stephan [Wed, 18 Jun 2025 15:22:50 +0000 (15:22 +0000)]
Add the --enable-column-metadata flag to the configure script (off by default). It's only available in the canonical build, not the autoconf build, because it changes how sqlite3.c gets generated.
stephan [Wed, 18 Jun 2025 14:17:18 +0000 (14:17 +0000)]
Eliminate configure/build discrepancies in how 'make tclextension-...' works vs other makefile-side handling of the extension, conforming to the former.
drh [Wed, 18 Jun 2025 14:14:46 +0000 (14:14 +0000)]
Change the definition of SQLITE_DYNAMIC to a function that has exactly
the same type as sqlite3_destructor_type, in an effort to work around
possible legacy compiler bugs.
stephan [Wed, 18 Jun 2025 11:11:30 +0000 (11:11 +0000)]
Add the --tclConfig.sh FILE flag to buildtclext.tcl to eliminate the discrepancy between the configure-time-detected tclConfig.sh and the one auto-detected by the tclextension family of makefile targets. Add the tclextension-all target to run all of the various tclextension-... targets in their natural order to facilitate testing changes like this one. Update the --help text to note that --with-tclsh should only be used if there's a specific need, and that --with-tcl is generall preferred. This is in response to [https://github.com/termux/termux-packages/issues/23268 | Termux ticket 23268].
stephan [Tue, 17 Jun 2025 20:50:51 +0000 (20:50 +0000)]
tea: remove the vsatisfies 8.6- enforcement from the extension because at least one platform with tcl 8.6 is inexplicably failing it. [forum:fde857fb8101a4be | Forum post fde857fb8101a4be]
stephan [Tue, 17 Jun 2025 14:37:31 +0000 (14:37 +0000)]
proj.tcl portability fixes and cleanups suggested in [forum:7b218c3c9f|forum post 7b218c3c9f]. Branching so that it can be tested on msys/cygwin/haiku before committing to it.
dan [Tue, 17 Jun 2025 11:36:39 +0000 (11:36 +0000)]
Avoid writing frames with no checksums into the wal file if a savepoint is rolled back after dirty pages have already been spilled into the wal file. Possible fix for [forum:/forumpost/b490f726db | forum post b490f726db].
drh [Mon, 16 Jun 2025 17:36:11 +0000 (17:36 +0000)]
Fix an issue going back to version 3.39.0 with transitive IS constraints
in queries that make use of RIGHT JOIN. Problem reported by
[forum:/forumpost/68f29a2005|forum post 68f29a2005].
drh [Mon, 16 Jun 2025 15:34:26 +0000 (15:34 +0000)]
Make the show-%p-az-zero hack of the previous check-in configurable at
run-time using the 0x100000 bit of either .treetrace or .wheretrace.
As before, this is all a no-op except for debugging builds.
dan [Thu, 12 Jun 2025 07:35:38 +0000 (07:35 +0000)]
Have sqlite3_setlk_timeout() take the database handle mutex. This fixes an assert() failure that could occur if sqlite3_setlk_timeout() were called on a threadsafe handle.
drh [Tue, 10 Jun 2025 19:52:21 +0000 (19:52 +0000)]
Improved selection of the divisor when subdividing nested Bitvec objects.
This fixes a potential stack overflow that can occur when the database size
is within 60 pages of the maximum allowed by the file format.
drh [Tue, 10 Jun 2025 16:02:29 +0000 (16:02 +0000)]
Improved diagnostics for Bitvec: Add the sqlite3ShowBitvec() routine that
can be called from a debugger (only available with SQLITE_DEBUG). Add new
output opcodes for sqlite3BitvecBuiltinTest().
drh [Fri, 6 Jun 2025 23:02:03 +0000 (23:02 +0000)]
Update the "msort" function in Lemon so that it works with lists of any
length, and also so that the sort is stable. This patch was motivated by
[forum:/forumpost/63750d717c9ed961|forum post 63750d717c] but was
independently developed, then tested by temporarily setting LISTSIZE to 2.