Allow special floating-point value names in JSON: "inf", "-inf", "infinity",
"-infinity", "nan", "qnan", and "snan". All are converted into valid JSON
values: 9e999, -9e999, or null. Requires the SQLITE_ENABLE_JSON_NAN_INF
compile-time option to operate.
Improved error messages from PRAGMA integrity_check. Identify the root of
the tree when a problem is found in a b-tree, making it easier to track the
problem to a specific table or index.
drh [Wed, 29 Mar 2023 11:36:24 +0000 (11:36 +0000)]
Enhance PRAGMA integrity_check so that it can detect that a NOT NULL column
contains a NaN value and report that as an error.
dbsqlfuzz f144b642fe6f1a1c196f258ac6e60118a0cb59b2.
drh [Tue, 28 Mar 2023 16:02:28 +0000 (16:02 +0000)]
Fix a weird corner case in aggregate function processing that results from the
recent addition of support for index expressions on aggregate queries.
[forum:/forumpost/bad532820c|Forum post bad532820c].
drh [Tue, 28 Mar 2023 11:18:04 +0000 (11:18 +0000)]
Fix multiple problems with RETURNING on a DML statement against a view,
all inspired by [forum:/forumpost/dc3b92cfa0|forum post dc3b92cfa0].
(1) Do not allow a RETURNING clause to trick the code generator into thinking
that the view being updated has an INSTEAD OF trigger.
(2) Generate all result columns for a view in a DML statement.
(3) The automatic covering index for a view should cover all result columns
of the view.
stephan [Mon, 27 Mar 2023 13:57:08 +0000 (13:57 +0000)]
Remove a meaningless JS test. Add a timer to the OPFS async-side worker loader in an attempt to catch a browser-specific quirk in which the worker loading silently fails, per discussion in/around [forum post a708c98dcb3ef|forum:a708c98dcb3ef].
drh [Mon, 27 Mar 2023 13:24:02 +0000 (13:24 +0000)]
Do not allow constant factoring during PRAGMA integrity_check, since the
constants might be stored in registers that are later reused for other
purposes. dbsqlfuzz dc9ab26037cf5ef797d28cd1ae0855ade584216d. Problem
discovered by a new assert() statement added in [6f8b97f31a4c8552].
drh [Sun, 26 Mar 2023 16:36:27 +0000 (16:36 +0000)]
Improvements to register allocation, especially in the ANALYZE command.
New assert() statements added to help verify that memory allocation is
correct, and to help fuzzer find lingering errors.
drh [Sun, 26 Mar 2023 11:54:51 +0000 (11:54 +0000)]
Disable factoring of constant values during ANALYZE. This is a temporary
fix for [forum:/forumpost/07de5f6216|forum post 07de5f6216]. The register
allocation logic in ANALYZE needs to be completely refactored, but that will
take longer. This check-in will serve to resolve the issue until a better
fix can be devised.
drh [Sat, 25 Mar 2023 23:52:05 +0000 (23:52 +0000)]
When the left table of a RIGHT JOIN is used inside an aggregate function and the left table employs an index on expressions, then make sure the expressions evaluate to NULL for the cases where the left table should be NULL. Fix for
[forum:/forumpost/9b491e1deb|forum post 9b491e1deb].
drh [Sat, 25 Mar 2023 22:37:23 +0000 (22:37 +0000)]
When reading sqlite_stat4 data during query planning, be sure to expand
zeroblobs prior to running comparisons. Fix for the issue identified
by [forum:/forumpost/5275207102|forum post 5275207102].
drh [Sat, 25 Mar 2023 21:01:11 +0000 (21:01 +0000)]
When the left table of a RIGHT JOIN is used inside an aggregate function
and the left table employs an index on expressions, then make sure the
expressions evaluate to NULL for the cases where the left table should be
NULL. Proposed fix for [forum:/forumpost/9b491e1deb|forum post 9b491e1deb].
More testing an analysis needed - there is a FIXME in this check-in.
drh [Sat, 25 Mar 2023 19:44:25 +0000 (19:44 +0000)]
In the byte-code, when the result of an expression needs to be in a particular
register, always use the sqlite3ExprCode() routine because it has the smarts
to know whether to use OP_Copy or OP_SCopy. Do not try to OP_SCopy inline
because an OP_Copy might be required. Fix for the problem identified by
[forum:/forumpost/5522082cfc|forum post 5522082cfc].
drh [Sat, 25 Mar 2023 18:31:24 +0000 (18:31 +0000)]
The fix at [2bf5413dc2c19d5f] was incomplete in that it failed to clear
the reusable register cache that might contain registers in the STAT4
buffer region. This additional change corrects the problem.
[forum:/forumpost/83cb4a95a0|Forum post 83cb4a95a0]. Test case in TH3.
drh [Sat, 25 Mar 2023 03:17:08 +0000 (03:17 +0000)]
Tighter constraints on the maximum length of the filename handed over
to sqlite3_load_extension(), due to
[forum:/forumpost/a43074729e|forum post a43074729e]. This is a
follow-on to [01f3877c7172d522] and
[forum:/forumpost/08a0d6d9bf|forum post 08a0d6d9bf].
drh [Fri, 24 Mar 2023 21:35:48 +0000 (21:35 +0000)]
Fix possible integer overflow in bounds checking for the debugging function
"shell_int32()" found in the CLI. This change does not affect the core
SQLite. [forum:/forumpost/be9c294ee0|Forum post be9c294ee0].
drh [Fri, 24 Mar 2023 20:35:56 +0000 (20:35 +0000)]
Fix the handling of indexed expressions in an outer query that appear as
corelated values inside an aggregate function within a subquery.
[forum:/forumpost/79cf371080|Forum post 79cf371080].
drh [Fri, 24 Mar 2023 16:57:21 +0000 (16:57 +0000)]
Fix byte-code register allocation in ANALYZE for STAT4 when there multiple
indexes with differing numbers of columns.
[forum:/forumpost/bc39e531e5|forum post bc39e531e5].
drh [Thu, 23 Mar 2023 10:54:07 +0000 (10:54 +0000)]
The attempt to bring STAT4 up to 100% MC/DC at [55a26c67ed4a3a93] and
at [168fa2fb22b8c1ad] are incorrect. Back them out and replace them with
a simple NEVER() macro. Error reported by
[forum:/forumpost/dc4854437b|forum post dc4854437b].
drh [Wed, 22 Mar 2023 16:01:06 +0000 (16:01 +0000)]
In the CLI, the magic parameter :inf and :nan bind floating point values
Infinity and NaN, respectively, as an add to testing SQLite's handling of
those quantities.
dan [Mon, 20 Mar 2023 14:59:19 +0000 (14:59 +0000)]
Fix a problem causing a cursor to retain an out-of-date cell-info cache when processing a DISTINCT query on values that are identical according to their collation sequence, but different on disk. [forum:/forumpost/e132e6cde44fb505|Forum post e123e6cde4].
drh [Mon, 20 Mar 2023 00:53:56 +0000 (00:53 +0000)]
Expression errors in generated columns should not generate non-negative
sqlite3_error_offset() returns. Second of two defenses against
[33aa4c0de8a62e33].
drh [Mon, 20 Mar 2023 00:48:40 +0000 (00:48 +0000)]
When reporting errors in the CLI, ignore the output of sqlite3_error_offset()
if the value returned is clearly out-of-range. One of two lines of defense
against [33aa4c0de8a62e33].
drh [Sun, 19 Mar 2023 21:48:55 +0000 (21:48 +0000)]
Increase the size of ref-count values in the pager layer to 64-bits, to avoid
any reasonable possiblity of overflowing the counters.
There is a performance and memory penality for this.
[forum:/forumpost/b741f15a35|Forum post b741f15a35].
drh [Fri, 17 Mar 2023 10:43:05 +0000 (10:43 +0000)]
Ensure that an error does not delete the Table object out from under
the xConstruct method of a virtual table.
dbsqlfuzz 7cc8804a1c6d4e3d554d79096e6ea75a7c1c7d2d
drh [Fri, 17 Mar 2023 00:01:32 +0000 (00:01 +0000)]
Fix assert() statements that would (incorrectly) fire if an IF NOT EXISTS
trigger that already exists contained two or more RETURNING clauses.
Tickets [89d259d45b855a0d] and [d15b3a4ea901ef0d].
drh [Thu, 16 Mar 2023 20:54:29 +0000 (20:54 +0000)]
Correctly handle SELECT DISTINCT ... ORDER BY when all of the result set terms
are constant and there are more result set terms than ORDER BY terms.
Fix for these tickets: [c36cdb4afd504dc1], [4051a7f931d9ba24],
[d6fd512f50513ab7].
drh [Thu, 16 Mar 2023 11:50:44 +0000 (11:50 +0000)]
Update the tracing output for the query-invariant checker such that it shows
the SQL that is run to verify that a found query-invariant discrepency is
valid. Changes to testing logic only.
drh [Thu, 16 Mar 2023 10:17:30 +0000 (10:17 +0000)]
Do not use the one-pass optimization on an UPDATE if there is a subquery
in the WHERE clause, since if the subquery is hidden behind a short-circuit
operator, the subquery might not be evaluated until after one or more rows
have been updated. Fix for the problem reported by
[forum:/forumpost/0007d1fdb1|forum post 0007d1fdb1]. This is the same
problem that was fixed by [73f0036f045bf371] only for UPDATE instead of
DELETE.
drh [Thu, 16 Mar 2023 09:07:46 +0000 (09:07 +0000)]
Remove a NEVER() from btreeNext() that dbsqlfuzz 460aa158f9a2c41145831cc924296cde1f312b3f
found could sometimes be reached. I will find a way to test that branch
later.
drh [Wed, 15 Mar 2023 17:58:51 +0000 (17:58 +0000)]
Disallow the one-pass optimization for DELETE if the WHERE clause contains
a subquery. Fix for the problem reported by
[forum:/forumpost/e61252062c9d286d|forum post e61252062c9d286d]. This fix
is more restrictive than necessary. It could be relaxed if the subquery does
not involve the table that is the subject of the DELETE.
stephan [Thu, 9 Mar 2023 08:51:04 +0000 (08:51 +0000)]
Experimental addition of sqlite3-node.mjs, for node.js, based on feedback from [forum:ac7a94d4f77db235|forum post ac7a94d4f77db235] and related off-list discussions. Build changes only - no code changes.
drh [Wed, 8 Mar 2023 23:05:18 +0000 (23:05 +0000)]
Fix a possible NULL pointer dereference due to the sqlite3_interrupt()
enhancement at [bd8fa10e59f58886]. Reported by
[forum:/forumpost/f5a2b1db87|forum post f5a2b1db87].
dan [Wed, 8 Mar 2023 18:03:04 +0000 (18:03 +0000)]
Add the SQLITE_CHANGESETAPPLY_IGNORENOOP flag, which may be passed to sqlite3changeset_apply_v2() to have it ignore changes that would be no-ops if applied to the database (e.g. deleting a row that has already been deleted), instead of considering them conflicts.
drh [Wed, 8 Mar 2023 14:28:09 +0000 (14:28 +0000)]
Change to [44135d6ea84f7ba6] that retains the historical datatype ("INT", not "NUM") for a table created as follows: "CREATE TABLE t1 AS SELECT CAST(123 AS INT) AS value;". The use of FLEXNUM only occurs on compound queries.
stephan [Wed, 8 Mar 2023 10:05:42 +0000 (10:05 +0000)]
Extend wasm build to support a custom sqlite3.c to support building against sqlite3-see.c. The JS code now binds the SEE-specific functions if it detects an SEE build.
drh [Tue, 7 Mar 2023 23:47:38 +0000 (23:47 +0000)]
Fix a bug introduced 4 days ago by [e95439119ac200cb]: do not set the
Expr.affExpr field of a generated column expression if the expression is a
RAISE() function, as affExpr has a different meaning for RAISE.
[forum:/forumpost/b312e075b5|Forum post b312e075b5].
drh [Tue, 7 Mar 2023 19:39:18 +0000 (19:39 +0000)]
A proposed change to [44135d6ea84f7ba6] that retains the
historical datatype ("INT", not "NUM") for a table created as follows:
"<tt>CREATE TABLE t1 AS SELECT CAST(123 AS INT) AS value;</tt>".
stephan [Tue, 7 Mar 2023 19:23:36 +0000 (19:23 +0000)]
Improve how sqlite3.initWorker1API() determines whether it's running in a Worker thread. Based on feedback in [forum:ac7a94d4f77db235|forum post ac7a94d4f77db235].
stephan [Tue, 7 Mar 2023 19:12:06 +0000 (19:12 +0000)]
Replace use of 'self' in JS code with 'globalThis', as that works in browsers and node environments. Avoid using globalThis.location if it's not set (e.g. in node). Based on feedback in [forum:ac7a94d4f77db235|forum post ac7a94d4f77db235]. Minor JS build tweaks.
stephan [Tue, 7 Mar 2023 12:59:20 +0000 (12:59 +0000)]
In the JS sqlite3.vfs/vtab utility APIs, use a local reference to StructBinder instead of sqlite3.StructBinder, as that object is removed from the sqlite3 namespace during the final steps of API initialization. Based on feedback from [forum:d19d96183badca70|forum post d19d96183badca70].