drh [Sat, 6 Feb 2021 14:37:36 +0000 (14:37 +0000)]
Fix the OSSFuzz-discovered shift problem from two days ago. This patch was
omitted from [078dbff04a95a001] apparently because I made the edit to
"sqlite3.c" rather than "resolve.c" where it belongs.
drh [Thu, 4 Feb 2021 23:20:13 +0000 (23:20 +0000)]
Change the RETURNING algorithm so that outputs accumulate in an ephemeral
table until all modifications have been completed, and only then do results
start being returned. This should help prevent problems with interleaved
sqlite3_step() calls on two separate DML statements. It also seems to be
closer to how PostgreSQL works, which might prevent compatibility problems.
drh [Thu, 4 Feb 2021 17:29:04 +0000 (17:29 +0000)]
Preliminary changes for a new implementation of RETURNING that captures all
results in a buffer and plays them all back after the DML statement
completes. This avoids problems with interleaved DML statements.
This particular check-in is a non-functional work in progress.
dan [Wed, 3 Feb 2021 14:20:56 +0000 (14:20 +0000)]
Avoid doing any foreign-key constraint related processing for an UPDATE statement that does not modify any columns that are part of FK constraints, even if the table has a self-referencing FK.
drh [Wed, 3 Feb 2021 00:55:34 +0000 (00:55 +0000)]
Modify the SQLITE_DBCONFIG_ENABLE_TRIGGER setting so that it only disables
main-schema triggers and allows TEMP trigger to continue operating. This is
safe, since only the application (not an attacker) can add TEMP triggers.
It will also all us to disengage SQLITE_DBCONFIG_ENABLE_TRIGGER on Fossil
databases since Fossil has no main-schema triggers but does use TEMP triggers.
drh [Sun, 31 Jan 2021 15:50:36 +0000 (15:50 +0000)]
New opcode OP_ChngCntRow used to output the result of PRAGMA change_count.
Only this new opcode, and not OP_ResultRow, checks for foreign key errors.
Faster performance, and now also works with RETURNING.
drh [Sun, 31 Jan 2021 12:41:20 +0000 (12:41 +0000)]
When setting the number of result columns in a RETURNING trigger, be sure
to set that value in the top-level bytecode program, not in the immediate
caller of the trigger.
drh [Sat, 30 Jan 2021 02:43:26 +0000 (02:43 +0000)]
Fix a memory deallocation problem that comes up when doing a RETURNING query
on a corrupt database. I think I fixed this before, but it got unfixed with
stale editor content.
drh [Fri, 29 Jan 2021 14:22:56 +0000 (14:22 +0000)]
Incorporate the sqlite3TriggerList() optimization from trunk. And move
the pReturning field to the uninitialized area in the Parse object, to
save memset() time.
drh [Sat, 16 Jan 2021 18:55:10 +0000 (18:55 +0000)]
Give the EXISTS-to-IN optimization the ability to handle some cases that
involve vector comparisons, instead of throwing a mysterious error in those
cases.
drh [Thu, 14 Jan 2021 20:57:47 +0000 (20:57 +0000)]
Improvements to the min/max optimization. Fix for a performance
regression introduced at [b8ba2f17f938c035] reported by
[forum:/forumpost/4050026ab8|forum post 4050026ab8]
dan [Thu, 14 Jan 2021 20:50:40 +0000 (20:50 +0000)]
Allow the planner to convert an EXISTS(SELECT...) expression in a WHERE clause to the equivalent IN(...) expression in situations where this is possible and advantageous.
drh [Thu, 14 Jan 2021 00:53:14 +0000 (00:53 +0000)]
The early-out of the inner loop on the min/max optimization was overly
aggressive for the cases where there is a join and outer loops contain
IN operators. Fix this. Test case in TH3.
drh [Wed, 13 Jan 2021 19:28:17 +0000 (19:28 +0000)]
Expand the number of optimization-disable bits from 16 to 32. Use one of
the new bits to disable the min/max optimization, so that we can more easily
verify that we get the same answer both with and within that optimization.
drh [Tue, 12 Jan 2021 20:16:31 +0000 (20:16 +0000)]
Lexer and grammar rules for a RETURNING clause on DELETE/INSERT/UPDATE.
Actually making this work, though, will involve a lot more code which will
likely slow down processing for the common case where there is no
RETURNING clause. Furthermore, RETURNING seems to be of limited usefulness
and it is not standard SQL. So we abandon it here. These experimental
changes are parked in a branch as an historical reference. If circumstances
changes, we might take up the cause again some day.
drh [Tue, 12 Jan 2021 15:30:01 +0000 (15:30 +0000)]
Fix a potential use-after-free following an OOM in sqlite3ParserAddCleanup()
and add a mechanism to detect situations where this might occur in the
future.
drh [Mon, 11 Jan 2021 20:37:02 +0000 (20:37 +0000)]
Add a linked list of ParseCleanup objects to the end of a Parse object and
use that list as a place to put other sub-objects that need to be deallocated.
Have a single such list for infrequently used sub-objects is more efficient
than doing an a separate check for each kind of sub-object.
drh [Sat, 9 Jan 2021 18:24:33 +0000 (18:24 +0000)]
More detailed compile-time testing before attempting to use atomic load
intrinsics. See
[forum:/forumpost/fc0237a39b30ac0a|forum post fc0237a39b30ac0a].
drh [Sat, 2 Jan 2021 23:56:37 +0000 (23:56 +0000)]
In Lemon, factor the parser stack overflow detection logic out of the
yy_reduce() subroutine and into the main parser routine, so that when overflow
is detected, it can exit immediately. This saves a single conditional in
the main loop of the parser.
drh [Fri, 1 Jan 2021 22:06:17 +0000 (22:06 +0000)]
Avoid allocating space to hold the prepared statements for CREATE statements
when parsing the schema of an existing database, since those prepared
statements are never used.. This helps to make startup faster,
drh [Fri, 1 Jan 2021 20:04:34 +0000 (20:04 +0000)]
Change the unions of the Table.addColOffset field from characters to bytes.
This makes the query that implements ALTER TABLE ADD COLUMN more complex and
slightly slower, but also makes CREATE TABLE statement parsing faster by
avoiding a call to sqlite3UtfCharLen(). Since, CREATE TABLE parsing is far
more common than ALTER TABLE, this is a net win for performance.