Only invoke sqlite3VdbeClearObject() from a single location, so that the
compiler is more likely to in-line the code. Performance increase and
size reduction.
Omit the Vdbe.runOnlyOnce flag (simplifying the prepared statement
implementation) and accomplish the same result by adding an "OP_Expire 1 1"
opcode to prepared statements that would normally have runOnlyOnce set.
In-line the sqlite3VdbeSerialPut() routine into the OP_MakeRecord opcode.
This allows some duplicate comparisons to be omitted, resulting in a size
reduction and performance increase.
New macro ROUND8P() which works like ROUND8() but assumes that the input is
already a multiple of the size of a pointer. It becomes a no-op for
64-bit machines, giving a small size reduction and speed boost.
Provide and use a version of sqlite3VdbeFreeCursor() that guarantees the
cursor pointer is not NULL. This saves a few bytes of code space and a
few CPU cycles.
Refactor the Vdbe.iVdbeMagic field into Vdbe.eVdbeState. Split the RUNNING
state into separate RUNNING and READY. This gives a size reduction and
performance increase.
Have the sqlite3_context object carry the encoding for the prepared statement
that it represents, so that sqlite3_result() and similar can set the encoding
according to the prepared statement, even if the database encoding has
changed.
dbsqlfuzz c409b10d0a6bccf78ab00f47e1d29d42ee5b3565
drh [Thu, 31 Mar 2022 11:12:56 +0000 (11:12 +0000)]
Refinement to [3f9887d4a58cbfdb]: The SQLITE_CONSTRAINT error should only
be returned if the prepared statement came from sqlite3_prepare_v2(). The
legacy sqlite3_prepare() is documented to return only SQLITE_ERROR.
drh [Tue, 29 Mar 2022 22:57:00 +0000 (22:57 +0000)]
In setResultStrOrError(), if the input string pointer is NULL and hence the
value gets set to an SQL NULL, then the Mem.enc field is uninitialized. So
do not read it. This is a harmless OSSFuzz/ASAN found problem.
drh [Tue, 29 Mar 2022 01:43:09 +0000 (01:43 +0000)]
Fix the sqlite3_result_xxxxx() routines so that they all check for and
perform any necessary text encoding conversions and check for oversize
strings and BLOBs. Thus those checks can be done where they are most
efficient and avoided in cases like OP_Function where they are more
expensive.
drh [Fri, 25 Mar 2022 01:23:37 +0000 (01:23 +0000)]
Fix the Bloom-filter optimization so that it does not use IS NULL or
IS NOT NULL constraints from the WHERE clause when operating on a LEFT JOIN.
[forum:/forumpost/031e262a89b6a9d2|Forum thread 031e262a89b6a9d2].
drh [Wed, 23 Mar 2022 10:04:52 +0000 (10:04 +0000)]
Use trickery to code the UTF-8 BOM for the --bom option on .output, .once,
and .excel in the CLI, to work around a warning in some Microsoft compilers.
[https://fossil-scm.org/forum/forumpost/bd0844268f0fab71|Fossil forum post bd0844268f0fab71].
drh [Mon, 21 Mar 2022 18:17:09 +0000 (18:17 +0000)]
Strengthen the defenses against corrupt databases in the
sqlite3BtreeInsert() function of the btree module.
[forum:/forumpost/c7ec29905f|Forum post c7ec29905f].
drh [Mon, 21 Mar 2022 13:47:15 +0000 (13:47 +0000)]
Fix the assert() that attempts to verify that the table-reference to
index-reference translator finds all required translations.
[forum:/forumpost/929168fdd6|Forum post 929168fdd6].
drh [Mon, 14 Mar 2022 16:54:05 +0000 (16:54 +0000)]
Foreign key constraint failures should return SQLITE_CONSTRAINT_FOREIGNKEY
even if there is a RETURNING clause. See
[forum:/forumpost/e6be6e82c86aa59b|forum thread e6be6e82c86aa59b].
drh [Thu, 10 Mar 2022 16:26:00 +0000 (16:26 +0000)]
Prevent a NULL-pointer dereference when trying to parse a illegal
schema entry that contains a window function while doing a RENAME COLUMN.
[forum:/forumpost/ec2a2e0deb|Forum post ec2a2e0deb].
drh [Wed, 9 Mar 2022 12:20:40 +0000 (12:20 +0000)]
Improve the defenses against bad pathnames input into the findCreateFileMode()
function of os_unix.c in order to quiet static-analyzer warnings. There
are no demonstrated problems in the prior code, but this change makes the code
easier to prove correct and more robust against future changes.
drh [Mon, 7 Mar 2022 17:19:40 +0000 (17:19 +0000)]
In the stay-on-last-page optimization for sqlite3BtreeIndexMoveto()
(check-in [0057bbb508e7662b] about 16 hours ago), be sure
to clear the BTCF_ValidOvfl flag, since the overflow cache is invalidated
by the search on the last page. OSSFuzz issue 45329.
drh [Mon, 7 Mar 2022 16:22:31 +0000 (16:22 +0000)]
Do not allocate new Trigger objects in the parser following a syntax error,
to avoid violating invariants associated with Expr nodes. See
[forum:/forumpost/2024e94071ef1531|forum thread 2024e94071ef1531] for more
information.
drh [Mon, 7 Mar 2022 14:51:29 +0000 (14:51 +0000)]
Fix the code generated for vector IN operator constraints on virtual tables
so that they work even if the "omit" field in the sqlite3_index_info object
is off. This has apparently never worked correctly before. Presumably, nobody
has ever before written a virtual table that can use vector IN operator
constraints and that relies on bytecode to double-check the constraints.
Test cases in TH3. Problem discovered by
dbsqlfuzz cab8e26194a40147627094f3c6849c0a7b1e0310.
drh [Mon, 7 Mar 2022 01:29:36 +0000 (01:29 +0000)]
Optimizations to sqlite3BtreeIndexMoveto() avoid unnecessary comparisons if
the cursor is already near the end of the table and is not moving far. This
case is more common that you would expect. The optimization saves almost
4 million CPU cycles.
drh [Sat, 5 Mar 2022 20:12:53 +0000 (20:12 +0000)]
Fix the 'localtime' modifier in date/time functions so that it preserves
fractional seconds.
[forum:/forumpost/2ffbaa2c3fd7fb82|Forum post 2ffbaa2c3fd7fb82].
drh [Sat, 5 Mar 2022 14:44:12 +0000 (14:44 +0000)]
Fix the sqlite_offset() function so that it gives the correct answer even
if the argument is a virtual column in an index-only query. Test cases
in TH3.
drh [Fri, 4 Mar 2022 20:54:09 +0000 (20:54 +0000)]
Do try to evaluate the Bloom filter on a LEFT JOIN early, as doing so
essentially converts it into an INNER JOIN. See
[forum:/forumpost/544af7eee2|forum thread 544af7eee2].