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].
drh [Mon, 6 Mar 2023 23:38:44 +0000 (23:38 +0000)]
Improvements to query invariant testing such that it uses the new
SQLITE_DBCONFIG_REVERSE_SCANORDER opcode to sqlite3_db_config() to make more
accurate judgements about when a query is ambiguous, and hence when query
invariant testing is approprate.
stephan [Sun, 5 Mar 2023 07:44:23 +0000 (07:44 +0000)]
Rename sqlite3-worker1-bundler-friendly.js to sqlite3-worker1-bundler-friendly.mjs and refactor it to work as an ES6 module, based on feedback in [forum post a255f89c2eadf4c4|forum:a255f89c2eadf4c4].
drh [Sat, 4 Mar 2023 15:36:51 +0000 (15:36 +0000)]
Fix to check-in [b9190d3da70c4171] - the agg-with-indexed-expr optimization
requested by ticket [99378177930f87bd] - that can cause an incorrect answer
if an aggregate subquery has a GROUP BY clause, and that GROUP BY contains a
term that is not in the result set, and the outer query makes use of expression
indexes. Problem reported by
[forum:/forumpost/a68313d054|forum post a68313d054].
drh [Fri, 3 Mar 2023 18:35:00 +0000 (18:35 +0000)]
Enhance PRAGMA integrity_check so that it can detect when there are extra
bytes at the end of an index record, which might cause OP_IdxRowid to
malfunction. dbsqlfuzz c1aa3986534d5feab8d21f28b3c1712df2ef358ba. Test case
in TH3.
dan [Fri, 3 Mar 2023 16:25:18 +0000 (16:25 +0000)]
When it is known when preparing a statement that X cannot be NULL, transform the expression (X IS NULL) to integer value 1 instead of 'true'. This is because under some circumstances, "Y IS TRUE" may not be equivalent to "Y IS 1".
drh [Thu, 2 Mar 2023 13:49:50 +0000 (13:49 +0000)]
When flattening the right operand of a LEFT JOIN
(check-in [41c27bc0ff1d3135]), ensure that the OP_IfNullRow opcode does not
NULL-out a subquery result that was computed within OP_Once. This fixes
the problem problem reported by
[forum:/forumpost/402f05296d|forum post 402f05296d].
stephan [Thu, 2 Mar 2023 06:58:55 +0000 (06:58 +0000)]
Resolve a parallel build timing issue when building sqlite3.c/h from ext/wasm. For the time being, do not add sqlite3_wasm_extra_init.c to fiddle.wasm because it can cause duplicate definitions of extensions which are already built into the shell (a better resolution for this conflict is pending). No longer add sqlite3_wasm_extra_init.c to speedtest1.wasm because it's useless there.
drh [Wed, 1 Mar 2023 20:23:46 +0000 (20:23 +0000)]
When flattening a view that is the right operand of a LEFT JOIN, using
the optimization of check-in [41c27bc0ff1d3135], always insert the
TK_IF_NULL_ROW expression nodes, even for TK_COLUMN expressions, as
the TK_COLUMN might be a column from an outer query and hence still need
to be NULLed out. This fixes the problem described by
[forum:/forumpost/26387ea7ef|forum post 26387ea7ef].
drh [Wed, 1 Mar 2023 15:21:53 +0000 (15:21 +0000)]
Follow-up to [bbaf1f2eb1e1637b]: Make sure subtypes do not cross a subquery
boundary even if the function that returned the value with a subtype is
buried down inside a larger expression. This fixes a problem identified
by [forum:/forumpost/37dd14a538|forum post 37dd14a538].
dan [Tue, 28 Feb 2023 19:39:59 +0000 (19:39 +0000)]
Add an sqlite3_db_config() option - SQLITE_DBCONFIG_STMT_SCANSTATS - for enabling and disabling the collection of sqlite3_stmt_scanstats() statistics in SQLITE_ENABLE_STMT_SCANSTATUS builds. Collection of statistics is disabled by default.
drh [Tue, 28 Feb 2023 14:28:54 +0000 (14:28 +0000)]
In the Bloom filter optimization, hash all strings and blobs into the same
value, because we do not know if two different strings might compare equal
even if they have different byte sequences, due to collating functions.
Formerly, the hash of a string or blob was just its length. This could
all be improved. Fix for the issue reported by
[forum:/forumpost/0846211821|forum post 0846211821].
drh [Mon, 27 Feb 2023 14:48:54 +0000 (14:48 +0000)]
Further to [46639f682975dac6], the parameters of a table valued function that
is on the left side of a RIGHT JOIN do not need to be in the ON clause. Add
new test cases and tags to associated test cases with the code.
stephan [Mon, 27 Feb 2023 07:12:28 +0000 (07:12 +0000)]
Extend wasm build to enable inclusion of client-custom C code, initialized via the SQLITE_EXTRA_INIT mechanism, per discussion in [forum:1e1c04f3ed1bc96b|forum post 1e1c04f3ed1bc96b].
drh [Sun, 26 Feb 2023 20:57:09 +0000 (20:57 +0000)]
When a table-valued function appears as the right table of a RIGHT JOIN,
the argument constraints on the table-valued function should be considered
part of the ON clause of the RIGHT JOIN. Fix for the problem reported
by [forum:/forumpost/422e635f3beafbf6|forum post 422e635f3beafbf6]. Test
cases in TH3. Possibly related to the enhancement at [501609eddf2a46d5].
drh [Sun, 26 Feb 2023 11:36:35 +0000 (11:36 +0000)]
In the [/info/7c2d3406000dc8ac|omit-unused-subquery-columns optimization], be
sure to remove the EP_Skip and EP_Unlikely flags from the result set expressions
that get nulled-out. dbsqlfuzz bf1d3ed6e0e0dd8766027797d43db40c776d2b15.