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].
drh [Fri, 4 Mar 2022 16:28:24 +0000 (16:28 +0000)]
When setting an sqlite3_value object to a pointer value, make sure any prior
memory allocations associated with that object have been cleared first.
dbsqlfuzz 33f842d1a09afaad5f078c3e1162a54b78e5f2ab.
drh [Thu, 3 Mar 2022 16:48:35 +0000 (16:48 +0000)]
Make sure the xParseCell and xCellSize methods of the MemPage object are
initialized consistently even if the page is detected as being corrupt.
dbsqlfuzz fd21f341f3b4f582401d2feb2a1c0c4cc2c26caa.
drh [Thu, 3 Mar 2022 15:59:22 +0000 (15:59 +0000)]
Fix for the problem identified in
[forum:/forumpost/0cd8e058bf|forum post 0cd8e058bf]:
When evaluating an multi-index OR, do not push down auxiliary WHERE clause
terms that involve subqueries into the OR-subqueries. Otherwise, the
covering-index optimizer might convert table-references into index-references
for the particular OR index that is active for the branch in which the
subquery subroutine is coded, and those index-references
will not work if the subquery subroutine is invoked from a different OR branch
that uses a different index.
drh [Thu, 3 Mar 2022 15:00:44 +0000 (15:00 +0000)]
Add the new OP_BeginSubrtn opcode (which is really an alias for OP_Integer)
and make other changes so that the span of a subroutine that implements
a subquery is more readily apparent in bytecode listings.
drh [Wed, 2 Mar 2022 21:04:10 +0000 (21:04 +0000)]
Bloom filter pull-down optimization is incompatible with Skip-Scan.
Make sure the query planner does not try to to both.
[forum:/info/50a1bbe08ce4c29c|Forum post 50a1bbe08ce4c29c].
drh [Tue, 1 Mar 2022 20:15:04 +0000 (20:15 +0000)]
The MemPage.aDataEnd field should point to the end of the data buffer for
the page, not just the end of the usable portion of that buffer. The purpose
aDataEnd is to detect cells that overflow the page, and that won't work on a
page with reserved bytes and a cell that starts in the reserved region, unless
the boundary is at the very end of the page. Chromium issue 1276294.
drh [Tue, 1 Mar 2022 16:22:54 +0000 (16:22 +0000)]
Fix two assert() statements in btree.c which were not true in the case of
a corrupt database file.
[forum:/forumpost/14819f2063|Forum post 14819f2063].
drh [Tue, 1 Mar 2022 14:13:32 +0000 (14:13 +0000)]
Increase the max_page_count on ROLLBACK, if necessary, so that it is sufficient
to cover the entire database. Fix for the problem identified by
[forum:/forumpost/3b9e894312|forum post 3b9e894312].
drh [Mon, 28 Feb 2022 16:44:58 +0000 (16:44 +0000)]
Fix the Xfer-optimization on the INSERT statement so that it is omitted if
there is a RETURNING clause, since that optimization is not able to deal
with RETURNING. See [forum:/forumpost/595e132f71|forum thread 595e132f71]
for details.
drh [Mon, 28 Feb 2022 12:08:09 +0000 (12:08 +0000)]
The performance increase in the previous check-in of this branch was due to
the revised loop in initMemArray() and reordering fields of Mem - not the
call the memcpy(). Changing the code to avoid memcpy() results in an even
better gain, and code that is far less dodgy.
drh [Mon, 28 Feb 2022 03:25:13 +0000 (03:25 +0000)]
An optimization to initMemArray() saves almost 500K cycles. But it seems a
little dodgy. I want to think about this more before merging to trunk.
Perhaps there is a cleaner way to accomplish the same.
drh [Sat, 26 Feb 2022 14:39:08 +0000 (14:39 +0000)]
Allow the OP_Column opcode to read rows that are larger than
SQLITE_LIMIT_LENGTH as long as the specific field being read out is
less than or equal to SQLITE_LIMIT_LENGTH.
drh [Fri, 25 Feb 2022 01:23:17 +0000 (01:23 +0000)]
Invoking SQLITE_TESTCTRL_INTERNAL_FUNCTIONS causes the flags field of the
PRAGMA function_list to show all bits, including internal-use-only bits,
rather than just the bits that are part of the API.
drh [Thu, 24 Feb 2022 14:44:23 +0000 (14:44 +0000)]
Change the OP_Next and OP_Prev opcodes so that they invoke
sqlite3BtreeNext() and sqlite3BtreePrevious() directly rather than through
a function pointer, for improved performance and a decrease in code size.
drh [Wed, 23 Feb 2022 22:56:10 +0000 (22:56 +0000)]
Add a new subclass for MemPage.xCellSize specifically for the case of a leaf
page in a B+Tree, that is optimized for that cases. This gains a half million
cycles or more at the cost of less than 200 bytes of code space.
drh [Wed, 23 Feb 2022 17:00:44 +0000 (17:00 +0000)]
Store the page number for the PENDING_BYTE page in the Pager object, rather
than computing the page number every time it is needed, because it turns out
that number is needed quite frequently. This saves a few hundred thousand
CPU cycles and a few bytes of code space.
drh [Tue, 22 Feb 2022 15:47:55 +0000 (15:47 +0000)]
Fix an undersized memory allocation in the test harness for RTREE. This
error was in test logic only, not in the SQLite library itself.
[forum:/forumpost/35470a0a72a005e1|forum post 35470a0a72a005e1]
drh [Thu, 17 Feb 2022 17:24:39 +0000 (17:24 +0000)]
Enhance the documentation on sqlite3_stmt_readonly() to explain that
EXPLAIN and EXPLAIN QUERY PLAN do not affect the return value. Add test
cases to verify this. Add new test cases and requirements marks for
complete requirements test coverage on this interface.
drh [Tue, 15 Feb 2022 13:23:09 +0000 (13:23 +0000)]
Improved rendering of floating point numbers without a fractional part in
".dump" output from the CLI.
[forum:/forumpost/550d877659f37cb2|Forum post 550d877659f37cb2].
drh [Mon, 14 Feb 2022 18:18:56 +0000 (18:18 +0000)]
Minor correction to the early corruption detection added by
[a6fda39e81d0da98|check-in a6fda39e81d0da98] so that it works even if
the page being cleared in page 1 of the database.
drh [Fri, 11 Feb 2022 17:33:02 +0000 (17:33 +0000)]
Fix an assert() in the pager by adding "|| CORRUPT_DB", in as much as the
assert() is not necessarily true if the database size in the header is
wrong. dbsqlfuzz f2f996065b90988aa9b0ae425b66dbb296546a08.