]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
3 years agoPrevious check-in accidentally inverted a test on an assert(). Fix that. right-join-fix
drh [Thu, 14 Apr 2022 14:19:23 +0000 (14:19 +0000)] 
Previous check-in accidentally inverted a test on an assert().  Fix that.

FossilOrigin-Name: 5ec4f806c569428851b6f0159451aa3ed66b3bc61a845fd7c543cffb694b882d

3 years agoFix assert() statements associated with artifical null-value cursors
drh [Thu, 14 Apr 2022 12:59:25 +0000 (12:59 +0000)] 
Fix assert() statements associated with artifical null-value cursors
created by RIGHT JOIN.

FossilOrigin-Name: f5bce5f152259767497ae6826c558003822d976b3f35f4d74edee59a3490efb2

3 years agoFix a harmless (false-positive) unused variable compiler warning on MSVC.
drh [Wed, 13 Apr 2022 19:00:57 +0000 (19:00 +0000)] 
Fix a harmless (false-positive) unused variable compiler warning on MSVC.

FossilOrigin-Name: 63b04c63de680261a0d3eaf27154a1e8e77e3e166c3f2dbaea985603991c74f7

3 years agoMake the sqlite3TreeViewSrcList() routine a no-op if called with a
drh [Wed, 13 Apr 2022 18:32:04 +0000 (18:32 +0000)] 
Make the sqlite3TreeViewSrcList() routine a no-op if called with a
NULL SrcList object.

FossilOrigin-Name: 185d2720e7775e3060a1647353c10aada435244db53a0732ee786788a6ecae3f

3 years agoFix an assert() in OP_Column so that it accounts for the new type of
drh [Wed, 13 Apr 2022 18:20:23 +0000 (18:20 +0000)] 
Fix an assert() in OP_Column so that it accounts for the new type of
pseudo-cursor that always returns NULL for any column.

FossilOrigin-Name: 371ddc97bef8e0d88ad965f00d27e010880174312ea36c4f1165dcf08441f40a

3 years agoIf the OP_NullRow opcode is given a cursor that has not yet been opened,
drh [Wed, 13 Apr 2022 17:41:03 +0000 (17:41 +0000)] 
If the OP_NullRow opcode is given a cursor that has not yet been opened,
then go automatically open it to a special pseudo-cursor that allows returns
NULL for every column.  Used by the new RIGHT JOIN implementation.

FossilOrigin-Name: 4526c5d316508093b7f3aeda1ce9d16ceb0be79842015a6d51f28c22b4473ca2

3 years agoMove the explain comment for the RIGHT-JOIN post-processing loop to the
drh [Wed, 13 Apr 2022 16:46:35 +0000 (16:46 +0000)] 
Move the explain comment for the RIGHT-JOIN post-processing loop to the
verify beginning of the loop - to make the start of the loop clearer to
human bytecode readers.

FossilOrigin-Name: 7ed2a271e6fcbb5e69a7f3a88d3f45fe6318819c0cc6a0dcc06c3dae5aa1503f

3 years agoAdd support for RIGHT and FULL OUTER JOINs.
drh [Wed, 13 Apr 2022 12:34:54 +0000 (12:34 +0000)] 
Add support for RIGHT and FULL OUTER JOINs.

FossilOrigin-Name: fa9d206f904280e3eafc6f4ba6c0c7325948364c62eeeb9f0fdc5825d622ec35

3 years agoThe rows of a RIGHT JOIN might come out in any arbitrary order. So disable
drh [Wed, 13 Apr 2022 12:12:01 +0000 (12:12 +0000)] 
The rows of a RIGHT JOIN might come out in any arbitrary order.  So disable
the ORDER-BY/GROUP-BY optimizations if a RIGHT JOIN is involved.

FossilOrigin-Name: d168f245ecf497368feea4697769930c00420ef47a584904dac85371b61fb78a

3 years agoFix an assert() in btree.c that might not be true for a corrupt database file.
drh [Wed, 13 Apr 2022 10:49:50 +0000 (10:49 +0000)] 
Fix an assert() in btree.c that might not be true for a corrupt database file.

FossilOrigin-Name: dbd8e2e46cfb2de0ebdbb62cda2fe669df3eda98f5d6112d541f581995b1361d

3 years agoAdd missing VdbeCoverage() macros on new branch byte-code opcodes.
drh [Wed, 13 Apr 2022 01:52:32 +0000 (01:52 +0000)] 
Add missing VdbeCoverage() macros on new branch byte-code opcodes.

FossilOrigin-Name: 218c7167e562f5c327124f02a92de85079315320a221fb0508310d927596b14c

3 years agoEnsure that the JT_LTORJ bit in the SrcItem.fg.jointype is preserved during
drh [Tue, 12 Apr 2022 20:20:54 +0000 (20:20 +0000)] 
Ensure that the JT_LTORJ bit in the SrcItem.fg.jointype is preserved during
query flattening.

FossilOrigin-Name: 61259050152321bc57dbdfdc3edcabb4f18c021b1ee0491c1e04ae24c7a59d89

3 years agoFor the bad join type error message "unknown or unsupported join type"
drh [Tue, 12 Apr 2022 18:40:14 +0000 (18:40 +0000)] 
For the bad join type error message "unknown or unsupported join type"
remove the "or unsupported" clause, because we now support all valid join
types.

FossilOrigin-Name: ab0a0562dd3594cf50ee56f6b3a5847fa5dcadf69146d560e3e7a95651b8f405

3 years agoFactor out the RIGHT JOIN non-matched row loop from sqlite3WhereEnd(). This
drh [Tue, 12 Apr 2022 18:04:29 +0000 (18:04 +0000)] 
Factor out the RIGHT JOIN non-matched row loop from sqlite3WhereEnd().  This
reduces the register pressure on that routine and helps it to run faster
in the common case where there is no RIGHT JOIN.

FossilOrigin-Name: beeecf1604d4fb11e45058f48cb2289c6542e0bc218d63a245198113d8d5476b

3 years agoMerge the latest enhancements from trunk into the right-join branch.
drh [Tue, 12 Apr 2022 17:43:30 +0000 (17:43 +0000)] 
Merge the latest enhancements from trunk into the right-join branch.

FossilOrigin-Name: b3e57ba120067c79e0398e39da9f00ecb11a5e18c36479da4c36a39e88a78a27

3 years agoEarlier detection of corruption in balance_nonroot(). dbsqlfuzz 9191ade77ebd3b7a3356e...
dan [Tue, 12 Apr 2022 17:02:27 +0000 (17:02 +0000)] 
Earlier detection of corruption in balance_nonroot(). dbsqlfuzz 9191ade77ebd3b7a3356e074957aa85b0c669d14.

FossilOrigin-Name: bff4f083eb1c35544988493a5d73a42e646c4250b841f5aae38c2183f0867a0e

3 years agoThe multi-index OR optimization does not work for RIGHT join, so disallow it.
drh [Tue, 12 Apr 2022 14:23:45 +0000 (14:23 +0000)] 
The multi-index OR optimization does not work for RIGHT join, so disallow it.

FossilOrigin-Name: 34c2f7b237fa4e0e1cd94fb9c44ebe194b86b88dc575055cc46c7f3695d02756

3 years agoAlways explicitly set each table cursor to NullRow before doing the RIGHT-JOIN
drh [Tue, 12 Apr 2022 13:46:21 +0000 (13:46 +0000)] 
Always explicitly set each table cursor to NullRow before doing the RIGHT-JOIN
unmatched row pass.  This is a cheap opcode, and it adds an extra layer of
defense against incorrect results.

FossilOrigin-Name: a3d14e61ca22167296fee125a3e9aa63413408955e03bb3f9d85fa9f22df1b79

3 years agoModify utility function sqlite3SetString() so that it may be used safely on Parse...
dan [Tue, 12 Apr 2022 11:02:06 +0000 (11:02 +0000)] 
Modify utility function sqlite3SetString() so that it may be used safely on Parse.zErrMsg. Fuzzer test case "crash-1604e5d76c92574e21e437049dab9b672e06b767.txt".

FossilOrigin-Name: 09c5a4ec13b02efd6207e26dab7beaf184f0d8ccea0bd0dfe94fc803fe5636ce

3 years agoFix RIGHT JOIN for virtual tables.
drh [Mon, 11 Apr 2022 21:00:38 +0000 (21:00 +0000)] 
Fix RIGHT JOIN for virtual tables.

FossilOrigin-Name: 75a9116e98b9ac5c1a4c62a01143a016d9ba6a0b495ff7af7468c11947a3e888

3 years agoThe query flattener must add TK_IF_NULL_ROW opcodes on substituted values
drh [Mon, 11 Apr 2022 20:15:52 +0000 (20:15 +0000)] 
The query flattener must add TK_IF_NULL_ROW opcodes on substituted values
that land on the left operand of a RIGHT JOIN, just as it already does for
the right operand of a LEFT JOIN.

FossilOrigin-Name: 8e02cdf5b1128f5e5b82d93903063415ec312694e5ccdd19e99fa35433f1b68a

3 years agoNew test cases added.
drh [Mon, 11 Apr 2022 18:54:23 +0000 (18:54 +0000)] 
New test cases added.

FossilOrigin-Name: bdd1499c0fa4f8aadf4857a0ccc0d839c250369f29766ebef80330964905e63b

3 years agoFix handling of "continue" and "break" from inside the loop for the right
drh [Mon, 11 Apr 2022 17:27:38 +0000 (17:27 +0000)] 
Fix handling of "continue" and "break" from inside the loop for the right
operand of a RIGHT JOIN.

FossilOrigin-Name: b6e773a26c2c6ee76ea61acb059b4e676d07ea62f6db9c513638f8986557cf04

3 years agoDo not attempt the LEFT JOIN strength reduction optimization on a FULL JOIN.
drh [Mon, 11 Apr 2022 14:43:11 +0000 (14:43 +0000)] 
Do not attempt the LEFT JOIN strength reduction optimization on a FULL JOIN.

FossilOrigin-Name: 7ef3e99a73d70405a185d5d31f2d97d3bd99568fd6f10941e75d6c0baa27dc4f

3 years agoShow LEFT and RIGHT JOIN processing in the EXPLAIN QUERY PLAN output.
drh [Mon, 11 Apr 2022 14:26:37 +0000 (14:26 +0000)] 
Show LEFT and RIGHT JOIN processing in the EXPLAIN QUERY PLAN output.

FossilOrigin-Name: d91faeffea5cf0585fb71e5311fdcc6b8be85c7e9c732050b4448e617c970101

3 years agoNew test cases.
drh [Mon, 11 Apr 2022 13:13:57 +0000 (13:13 +0000)] 
New test cases.

FossilOrigin-Name: d5f6791b86f946b348f5ddc9cedc0df4a86b17854a97554140799caf74c602f3

3 years agoMake a distinction between (1) WHERE clause constraints, (2) ON/USING
drh [Mon, 11 Apr 2022 12:38:06 +0000 (12:38 +0000)] 
Make a distinction between (1) WHERE clause constraints, (2) ON/USING
constraints on outer joins, and (3) ON/USING clause constraints on inner
joins.  Formerly, there was no distinctionb between 1 and 3, but RIGHT JOIN
needs to know the difference.  Make RIGHT JOIN aware of this difference and
add test cases.

FossilOrigin-Name: 0f6f61c3664cc87209c2a6f9b6df3a750d1510723fcde209c33db8feaf48bcf3

3 years agoFix some comments that refer to LEFT JOIN that should refer to OUTER JOIN.
drh [Mon, 11 Apr 2022 11:59:25 +0000 (11:59 +0000)] 
Fix some comments that refer to LEFT JOIN that should refer to OUTER JOIN.
No changes to code.

FossilOrigin-Name: 5be5ede5cca1cd5ef863fe0feb2b4a990f4a42865281a6c2e4eb816f48847dc6

3 years agoMerge the Expr.w.iJoin name change from trunk into the right-join branch.
drh [Mon, 11 Apr 2022 11:48:17 +0000 (11:48 +0000)] 
Merge the Expr.w.iJoin name change from trunk into the right-join branch.

FossilOrigin-Name: 29927926eb32acd963e2c496ad67d55177615ec4150fd218afaf2f9a730cabec

3 years agoRename the Expr.w.iRightJoinTable to just Expr.w.iJoin, so that the words
drh [Mon, 11 Apr 2022 11:25:28 +0000 (11:25 +0000)] 
Rename the Expr.w.iRightJoinTable to just Expr.w.iJoin, so that the words
"RightJoin" in the former name do not lead readers to believe that this has
something to do with RIGHT JOINs in particular.

FossilOrigin-Name: e8c00442d2daedec079748d13147bf73b0ec3c3cf432bce2cdccb706bdff2853

3 years agoEnsure that the JT_LTORJ flag is preserved when flattening a subquery that
drh [Mon, 11 Apr 2022 10:38:28 +0000 (10:38 +0000)] 
Ensure that the JT_LTORJ flag is preserved when flattening a subquery that
is on the left side of a RIGHT JOIN.

FossilOrigin-Name: ccb61fb1f30e2741b19c1a0cbd2951715224852c86234a3c6a4bbd2e1187634a

3 years agoShow the JT_LTORJ flag in TreeView debugging output.
drh [Mon, 11 Apr 2022 00:54:30 +0000 (00:54 +0000)] 
Show the JT_LTORJ flag in TreeView debugging output.

FossilOrigin-Name: 21eb44919f38abad30b75181ca8aec38b453b94dba2815caf7e946e07faa40d7

3 years agoDo not allow query flattening nor the push-down optimization on the
drh [Mon, 11 Apr 2022 00:21:53 +0000 (00:21 +0000)] 
Do not allow query flattening nor the push-down optimization on the
right operand of a RIGHT JOIN.

FossilOrigin-Name: 5aa0c9ea9cf53c13bf266278b479b2e7af3aa5c6b144bd49ff155a4eb3c23c96

3 years agoCannot use an automatic index on the right table of a RIGHT JOIN because
drh [Sun, 10 Apr 2022 23:48:47 +0000 (23:48 +0000)] 
Cannot use an automatic index on the right table of a RIGHT JOIN because
automatic indexes must be WHERE_IDX_ONLY, but the RIGHT JOIN post-processing
does not know how to work with an index-only scan.

FossilOrigin-Name: beb4401dc09fb68e85ddcf3f99598527691535d0eb7693168f440e5a5a076e3f

3 years agoRevisit [f84b2beca7197589]: disallow co-routine implementations of tables
drh [Sun, 10 Apr 2022 23:01:20 +0000 (23:01 +0000)] 
Revisit [f84b2beca7197589]: disallow co-routine implementations of tables
that are to the left of a RIGHT JOIN, to avoid other complications.

FossilOrigin-Name: cf00ebfc4b77f45ec466b0d57d7c22c7f48acab19e4e55b168eb4b53f390d887

3 years agoMinor improvements to the sqlite3SrcListShiftJoinType() routine. This started
drh [Sun, 10 Apr 2022 20:28:41 +0000 (20:28 +0000)] 
Minor improvements to the sqlite3SrcListShiftJoinType() routine.  This started
out to be an effort to convert RIGHT JOIN to LEFT JOIN if the join was on
the first pair of relations, but that messes up the "*" expansion and so won't
work.

FossilOrigin-Name: a48902c71ed30c83de7dbd26d1c7956136c35dc53b1076bc8b1ebcba568a3fd3

3 years agoWhen the left-most table of a RIGHT JOIN is implemented as a co-routine,
drh [Sun, 10 Apr 2022 19:51:22 +0000 (19:51 +0000)] 
When the left-most table of a RIGHT JOIN is implemented as a co-routine,
make sure all its columns are flushed to NULL when it finishes so that
they appear to be NULL during the RIGHT JOIN post-processing.

FossilOrigin-Name: f84b2beca719758979d7a5a63c3d16d5121a7518b3fbe5039af474a83dd569c2

3 years agoMore test cases and bug fixes.
drh [Sun, 10 Apr 2022 17:14:48 +0000 (17:14 +0000)] 
More test cases and bug fixes.

FossilOrigin-Name: 140e97fde94fdc3babdd456ce1b22900ead0e40e2afe63d89d21ccdbf141b607

3 years agoMore RIGHT JOIN test cases and a bug fix.
drh [Sun, 10 Apr 2022 16:13:37 +0000 (16:13 +0000)] 
More RIGHT JOIN test cases and a bug fix.

FossilOrigin-Name: 19e8ad690a140ca40838bf31a377c19010fcbbc2554a4f1746737543043e334b

3 years agoAdd a simple test case. (It is not difficult to create additional test
drh [Sat, 9 Apr 2022 20:11:05 +0000 (20:11 +0000)] 
Add a simple test case.  (It is not difficult to create additional test
cases that assert, at this point.)

FossilOrigin-Name: f2201d5dcfc552bdddd0780b3f466bdaa886e557f147335c085395bfc001f6b0

3 years agoFix .import bug reported at https://sqlite.org/forum/forumpost/14db09d7e765b819 ...
larrybr [Sat, 9 Apr 2022 18:51:49 +0000 (18:51 +0000)] 
Fix .import bug reported at https://sqlite.org/forum/forumpost/14db09d7e765b819 . zAutoColumn made to deliver characters, not bytes.

FossilOrigin-Name: 21e96600d90c1cda84777abe22a11058eba46c9faefeb05f8c31bc0e7fa84b19

3 years agoBug fixes. A basic FULL OUTER JOIN now works.
drh [Sat, 9 Apr 2022 18:48:11 +0000 (18:48 +0000)] 
Bug fixes.  A basic FULL OUTER JOIN now works.

FossilOrigin-Name: 34bbeeb77bd530b2b1f0390e9e552f65ae35f09a74d80a09dd327e64f9be51a1

3 years agoAdd byte-code that computes unmatched rows on the right table of a RIGHT JOIN.
drh [Sat, 9 Apr 2022 14:48:35 +0000 (14:48 +0000)] 
Add byte-code that computes unmatched rows on the right table of a RIGHT JOIN.
Compiles, and the code looks semi-reasonable, but still does not run.
Incremental check-in.

FossilOrigin-Name: 2db5a498e74241dd19ef51c601f1a2b3b687faed3e1be2d1e3ada737406ac8e9

3 years agoThe interior of the RIGHT JOIN loop is now a subroutine.
drh [Sat, 9 Apr 2022 12:27:20 +0000 (12:27 +0000)] 
The interior of the RIGHT JOIN loop is now a subroutine.

FossilOrigin-Name: 549f5a7ee639de80f049445002f58e93c805f9a3d3db1987ec9d139ccef4805e

3 years agoA few bits and bobs of code generation toward getting RIGHT JOIN to work.
drh [Sat, 9 Apr 2022 03:16:26 +0000 (03:16 +0000)] 
A few bits and bobs of code generation toward getting RIGHT JOIN to work.
Much more remains to do.

FossilOrigin-Name: 55b4543122646997d928598343bc467c993f971e86e9037c85430cc948750576

3 years agoMerge the sqlite3WhereMalloc() routine from trunk into the right-join branch.
drh [Sat, 9 Apr 2022 03:12:52 +0000 (03:12 +0000)] 
Merge the sqlite3WhereMalloc() routine from trunk into the right-join branch.

FossilOrigin-Name: b1b3845aa38f469a27f07c8f6e8a98334f7967b19661ee4cf155d6997afd9d4c

3 years agoThe sqlite3WhereMalloc() routine allocates memory that is automatically
drh [Sat, 9 Apr 2022 03:06:01 +0000 (03:06 +0000)] 
The sqlite3WhereMalloc() routine allocates memory that is automatically
deleted when the corresponding WhereInfo object is destroyed.

FossilOrigin-Name: f237e1d8cc41b937f34288daebfacf5f7b0990a807a805e0cb6b45bc730192d6

3 years agoPreliminary code to support RIGHT JOIN. Everything seems to work, except that
drh [Fri, 8 Apr 2022 19:20:12 +0000 (19:20 +0000)] 
Preliminary code to support RIGHT JOIN. Everything seems to work, except that
the code to compute the unmatched rows for the RIGHT JOIN has not yet been
added, so the result of a RIGHT JOIN is currently the same as an INNER JOIN.

FossilOrigin-Name: 415abd6731b8e8a605adabfa6066c8a852a8531c300df41325d5f7e75cae5a70

3 years agoEnhance the sqlite_dbpage fix at [/info/642a0b4752743216|check-in 642a0b4752743]
drh [Fri, 8 Apr 2022 17:01:29 +0000 (17:01 +0000)] 
Enhance the sqlite_dbpage fix at [/info/642a0b4752743216|check-in 642a0b4752743]
from about a month ago such that it still takes a transaction on all attached
databases, but it only starts a read transaction for read-only operations,
rather than starting a write transaction for everything.

FossilOrigin-Name: 8efd61e8518594e3e9c84681fc35796a78fe8885a97ad4dd19f1573ee8065b18

3 years agoImproved explanation and commentary on the sqlite3JoinType() routine. One
drh [Fri, 8 Apr 2022 15:11:10 +0000 (15:11 +0000)] 
Improved explanation and commentary on the sqlite3JoinType() routine.  One
of the error messages changes slightly, but besides that everything works
the same.

FossilOrigin-Name: 48f2e5a1fbaa8ceb32e08066766be74233b0c67ab430bbf7adfdff42cdb7b8ec

3 years agoFix two unreachable branches introduced by the recent
drh [Thu, 7 Apr 2022 20:45:38 +0000 (20:45 +0000)] 
Fix two unreachable branches introduced by the recent
sqlite3TriggersExist() optimization.

FossilOrigin-Name: 1b5475d212cf9de0bff69eee8c607b4fcd8e04bf4df72171429e7609c4153951

3 years agoEnhance the EXPLAIN output formatting in the CLI so that the subroutine that
drh [Thu, 7 Apr 2022 19:06:31 +0000 (19:06 +0000)] 
Enhance the EXPLAIN output formatting in the CLI so that the subroutine that
implements the loop body for the multi-index OR optimization is indented.

FossilOrigin-Name: c2965fea9df7076b235d3eadaf84f0a36242476d0329030b0e57557b66e2540c

3 years agoThe ".testctrl optimizations 0x400000" command disables the generation of
drh [Thu, 7 Apr 2022 18:17:56 +0000 (18:17 +0000)] 
The ".testctrl optimizations 0x400000" command disables the generation of
OP_ReleaseReg opcodes.  OP_ReleaseReg opcodes are usually only generated for
SQLITE_DEBUG builds and are used to verify that registers are descoped
propertly.  But they can get in the way of code understanding when studying
bytecode dumps.  So this new optimization setting is provided to
temporarily turn OP_ReleaseReg opcodes off.

FossilOrigin-Name: fa5276725f246cef9d58b27c1e617ee3f873f7a9b88284a4e8fc453ebda338bc

3 years agoFix the parsing of C-style comments in Lemon, as reported by
drh [Thu, 7 Apr 2022 14:13:32 +0000 (14:13 +0000)] 
Fix the parsing of C-style comments in Lemon, as reported by
[forum:/forumpost/b6edc69548|forum post b6edc69548].  This has no affect
on SQLite itself.

FossilOrigin-Name: 201569e09b000919ccb463bd581fb2ecd5320e7f584fdb1bc2aaba111061d5c3

3 years agoOptimization to sqlite3TriggersExist() saves over 700K CPU cycles.
drh [Thu, 7 Apr 2022 14:03:07 +0000 (14:03 +0000)] 
Optimization to sqlite3TriggersExist() saves over 700K CPU cycles.

FossilOrigin-Name: 5043a3507e0781878e0e1bea5095a33273958820baead4af8fc2929e9d7c07ee

3 years agoAvoid compiler warnings about the new sqlite3Show() debugging routines
drh [Thu, 7 Apr 2022 13:48:34 +0000 (13:48 +0000)] 
Avoid compiler warnings about the new sqlite3Show() debugging routines
begin "defined but not used".

FossilOrigin-Name: 47ddc26974fbad8233c953d435e79d4f5dd5e09fbd684ea5f4ad32f4cae6cae6

3 years agoOmit an unnecessary initialization in tokenExpr().
drh [Thu, 7 Apr 2022 12:10:00 +0000 (12:10 +0000)] 
Omit an unnecessary initialization in tokenExpr().

FossilOrigin-Name: 8f6ae686019c61a03fe70eb78d2b529b1cf126215b45513a97cfdf7086f82f54

3 years agoFix harmless compiler warnings.
drh [Thu, 7 Apr 2022 10:11:35 +0000 (10:11 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 61095b5bcb5c30d29f03efa5b4809e3a0b780ed57e35227c292aab9dd1cfe3f6

3 years agoImproved technique for parsing the ON and USING clauses of a join is faster
drh [Thu, 7 Apr 2022 01:11:13 +0000 (01:11 +0000)] 
Improved technique for parsing the ON and USING clauses of a join is faster
and uses less memory.

FossilOrigin-Name: 158156a3e3d50042cafc75dea3aaaa68b1f2efb9c3d178518ea6e68e32e0d21c

3 years agoFaster parsing of the FROM clause in joins for the common case where there
drh [Wed, 6 Apr 2022 19:46:20 +0000 (19:46 +0000)] 
Faster parsing of the FROM clause in joins for the common case where there
is no INDEXED BY clause.

FossilOrigin-Name: 848b7a0ea99ddc52091b78313f018c07d00a0e28aa6da8c1cae709c1d03468fe

3 years agoImprovements to the display of AST for DML statements.
drh [Wed, 6 Apr 2022 18:30:17 +0000 (18:30 +0000)] 
Improvements to the display of AST for DML statements.

FossilOrigin-Name: 84c239a071cfaf8af107646f01ef269e2915fd2384e95927d484f2e408ba6bbf

3 years agoAttempt to show triggers in the TreeView output from DELETE, INSERT, and
drh [Wed, 6 Apr 2022 15:41:53 +0000 (15:41 +0000)] 
Attempt to show triggers in the TreeView output from DELETE, INSERT, and
UPDATE statements.

FossilOrigin-Name: b0939d6f4d94b45dce53ace6295508a67d574cc72bd6977623bf77065b3c4e64

3 years agoCorrections and updates to the header comment describing the
drh [Wed, 6 Apr 2022 12:54:41 +0000 (12:54 +0000)] 
Corrections and updates to the header comment describing the
TriggerStep object.  No changes to code.

FossilOrigin-Name: abb34c0830a49d4f4e277ddd17e710529e87cba7061f3546079dbba2f82b020e

3 years agoAdd the sqlite3Show() family of debugging interfaces under SQLITE_DEBUG.
drh [Wed, 6 Apr 2022 12:25:04 +0000 (12:25 +0000)] 
Add the sqlite3Show() family of debugging interfaces under SQLITE_DEBUG.
No changes to deliverable builds.  Rename SQLITE_ENABLE_SELECTTRACE to
SQLITE_ENABLE_TREETRACE in ctime.c.

FossilOrigin-Name: bc33168cf1f48caf848c2dc5c3ae15e4efff8c0378f944eb5398a245139a2b35

3 years agoRename debugging defines and variables from SELECTTRACE to TREETRACE (and
drh [Wed, 6 Apr 2022 11:08:38 +0000 (11:08 +0000)] 
Rename debugging defines and variables from SELECTTRACE to TREETRACE (and
similar) since the functionality has how expanded to include data structures
beyond SELECT statements.  Should not affect deliverable builds.

FossilOrigin-Name: 393fa32e188a017f431372b54037cb31e885030542f00d0bfd59da9d9db5c014

3 years agoAdd additional tree display routines for DELETE and UPDATE. No changes
drh [Wed, 6 Apr 2022 10:37:44 +0000 (10:37 +0000)] 
Add additional tree display routines for DELETE and UPDATE.  No changes
to deliverable code.

FossilOrigin-Name: fbd288ff3d4ea47cd324b5952e7754a465901844f2d950f0860d4488d5b6eb9f

3 years agoAdd new diagnostic "sqlite3TreeView" routines for IdList, Upsert, and for
drh [Wed, 6 Apr 2022 00:29:21 +0000 (00:29 +0000)] 
Add new diagnostic "sqlite3TreeView" routines for IdList, Upsert, and for
INSERT statements.  This is all debugging code.  There are no changes to
release builds.

FossilOrigin-Name: f3084122039bcb30c8617f5f432009a49be8b488235850a1f10ef862c91560b2

3 years agoSmall performance and size improvement to OP_Found.
drh [Mon, 4 Apr 2022 20:20:22 +0000 (20:20 +0000)] 
Small performance and size improvement to OP_Found.

FossilOrigin-Name: 81587a18b7c0516628453000172a0c58e74ee173c15f655d035799d84d4e2d81

3 years agoTag an always-taken branch using ALWAYS().
drh [Mon, 4 Apr 2022 19:58:55 +0000 (19:58 +0000)] 
Tag an always-taken branch using ALWAYS().

FossilOrigin-Name: ad8bc3d7443ff57ce5a8756428e717ac42ec0295191a9b4d7ae44846d8fa03a2

3 years agoOptimizations to the OP_Found opcode save about 600K cycles in speedtest1.
drh [Mon, 4 Apr 2022 19:43:57 +0000 (19:43 +0000)] 
Optimizations to the OP_Found opcode save about 600K cycles in speedtest1.

FossilOrigin-Name: 5c3357ad62843fe982b9c2d31dbf02018f2948ceab2c85dac917cd9ce1e97dd6

3 years agoUse unpacked keys for OP_Found in foreign key processing.
drh [Mon, 4 Apr 2022 18:17:59 +0000 (18:17 +0000)] 
Use unpacked keys for OP_Found in foreign key processing.

FossilOrigin-Name: 328dc76657eb5317f0201859d2b3abe6918103b894f7beaed0aca3058a9f2b64

3 years agoWhen constructing the JSON Path for the "fullpath" column of the
drh [Mon, 4 Apr 2022 15:15:45 +0000 (15:15 +0000)] 
When constructing the JSON Path for the "fullpath" column of the
json_tree() and json_each() table-valued functions, be sure to quote
object labels where necessary.

FossilOrigin-Name: 0fbbe7881cadf0b3c211653c7a0797e0a90c7c24da78ecc8a27140c05f89f2ed

3 years agoFix the JSON Path parser so that it will accept zero-length object labels.
drh [Mon, 4 Apr 2022 14:24:14 +0000 (14:24 +0000)] 
Fix the JSON Path parser so that it will accept zero-length object labels.
[forum/forumpost/c082aeab43|Forum thread c082aeab43].

FossilOrigin-Name: 84fe95d2a5b4d232d657e3b8110027a698a9bcd597f205cc535cfa97bc299f21

3 years agoPerformance optimization and stronger assert()s in the comparison opcodes.
drh [Mon, 4 Apr 2022 11:38:49 +0000 (11:38 +0000)] 
Performance optimization and stronger assert()s in the comparison opcodes.

FossilOrigin-Name: e0305e640b9078c7eed9ab0bcc14f4515b54e7cd9ade3306bc2d1660f05b2725

3 years agoOnly invoke sqlite3VdbeClearObject() from a single location, so that the
drh [Mon, 4 Apr 2022 01:12:11 +0000 (01:12 +0000)] 
Only invoke sqlite3VdbeClearObject() from a single location, so that the
compiler is more likely to in-line the code.  Performance increase and
size reduction.

FossilOrigin-Name: c6947a96e61f71aa61ca3d70d9e2612d784ab04d60fa88852b03cfce86b1bf2b

3 years agoPerformance optimization in the sqlite3VdbeHalt() routine.
drh [Sun, 3 Apr 2022 22:35:13 +0000 (22:35 +0000)] 
Performance optimization in the sqlite3VdbeHalt() routine.

FossilOrigin-Name: 9564d72a0820dbcb38f905fcd42ed4c858ea8fb5f648b189ceb65380a14a785b

3 years agoPerformance optimization and size reduction in the OP_Halt opcode.
drh [Sun, 3 Apr 2022 20:39:48 +0000 (20:39 +0000)] 
Performance optimization and size reduction in the OP_Halt opcode.

FossilOrigin-Name: 21948e6e1ccd2ce128742415d21759604ecb8902226ec4707dbd75585450f208

3 years agoOmit the Vdbe.runOnlyOnce flag (simplifying the prepared statement
drh [Sun, 3 Apr 2022 19:13:40 +0000 (19:13 +0000)] 
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.

FossilOrigin-Name: 6e20e1c46d17ac6aba21e02b57649af51cfa415d83d0c001b30677d2fd1f1dc1

3 years agoPerformance optimization and slight size reduction in the OP_Transaction
drh [Sun, 3 Apr 2022 10:42:06 +0000 (10:42 +0000)] 
Performance optimization and slight size reduction in the OP_Transaction
opcode.

FossilOrigin-Name: 7bee8c195f3fc27aaab13e493ad446a4f19201de3ac064ed6d8a3cbda7c69ee1

3 years agoExpand the getVarint32() macro in a few places, as the C-compiler seems to
drh [Sat, 2 Apr 2022 22:47:47 +0000 (22:47 +0000)] 
Expand the getVarint32() macro in a few places, as the C-compiler seems to
be able to optimize better when that macro is expanded manually.

FossilOrigin-Name: cd4fe34b98bf5ce26f3596c717edb73932f3b46ad6e9b4934d06b7b3c176a0d6

3 years agoFix harmless compiler warnings.
drh [Sat, 2 Apr 2022 20:08:48 +0000 (20:08 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 8a3a3486358d076c34e515ac92663a04f0c7ff10f405094cb5b6ada0d5f05cdc

3 years agoEnsure that a zero-blob does not cause in invocation of memcpy() with a
drh [Sat, 2 Apr 2022 19:21:58 +0000 (19:21 +0000)] 
Ensure that a zero-blob does not cause in invocation of memcpy() with a
zero length and a NULL source pointer.

FossilOrigin-Name: 35441eb5e1447e01f2031837a4ede705bce34f87be27912278cc730abce6cf05

3 years agoMinor loop optimization in OP_MakeRecord.
drh [Sat, 2 Apr 2022 15:19:02 +0000 (15:19 +0000)] 
Minor loop optimization in OP_MakeRecord.

FossilOrigin-Name: 4350983b37879d3280432d90fef04f5cc4be1b3110b5435123d897e31b34db8a

3 years agoIn-line the sqlite3VdbeSerialPut() routine into the OP_MakeRecord opcode.
drh [Sat, 2 Apr 2022 14:30:58 +0000 (14:30 +0000)] 
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.

FossilOrigin-Name: 6f4d6f212a3558c27be6e9dcf71cec43c424d445e5889c6e91dde84a19c5a2c1

3 years agoThe putVarint32() macro does not optimize well. So expand it into in-line
drh [Fri, 1 Apr 2022 21:01:37 +0000 (21:01 +0000)] 
The putVarint32() macro does not optimize well.  So expand it into in-line
code in places were performance is an issue.

FossilOrigin-Name: 390c239e53cf936a97b268dce8171f0b17050542ae64735ca8ef375fec2c9544

3 years agoLoop optimization in the OP_MakeRecord opcode.
drh [Fri, 1 Apr 2022 20:39:40 +0000 (20:39 +0000)] 
Loop optimization in the OP_MakeRecord opcode.

FossilOrigin-Name: 47a61fbd63928021098fbe492283f1afda7c293b3b2706c001192ae4ff1b2cbe

3 years agoIt is not necessary to de-ephermeralize the output registers in the
drh [Fri, 1 Apr 2022 20:19:36 +0000 (20:19 +0000)] 
It is not necessary to de-ephermeralize the output registers in the
OP_ResultRow opcode.  Omit that step for a size reduction and performance
increase.

FossilOrigin-Name: 8a07745aed1d0a4eead55d43f1923597b12371f307ecf5bc19c5a1db9a107a50

3 years agoThere is no need for sqlite3_step() to check for an OOM condition prior
drh [Fri, 1 Apr 2022 19:13:39 +0000 (19:13 +0000)] 
There is no need for sqlite3_step() to check for an OOM condition prior
to starting up.

FossilOrigin-Name: 44be7f46ba89289683ed0e123169ca9adb1018de03071d66de480c910a23d074

3 years agoOmit the Vdbe.doingRerun field for a slight size reduction and performance gain.
drh [Fri, 1 Apr 2022 19:04:13 +0000 (19:04 +0000)] 
Omit the Vdbe.doingRerun field for a slight size reduction and performance gain.

FossilOrigin-Name: e93297a9d775688e6274c54ba75b19fc1fe8b29b73b9b5e7f94f3f2ca37f045f

3 years agoNew macro ROUND8P() which works like ROUND8() but assumes that the input is
drh [Fri, 1 Apr 2022 18:45:11 +0000 (18:45 +0000)] 
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.

FossilOrigin-Name: d126f304cde66ebfe21a4967c22dcba0bac27cbce56318b14bd50051e49c978c

3 years agoProvide and use a version of sqlite3VdbeFreeCursor() that guarantees the
drh [Fri, 1 Apr 2022 18:19:04 +0000 (18:19 +0000)] 
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.

FossilOrigin-Name: cb5e6f8e265c91221227e5f15b95798c688773262407dd138d414103184702f6

3 years agoRemove an unnecessary branch from sqlite3VdbeReset().
drh [Fri, 1 Apr 2022 17:23:17 +0000 (17:23 +0000)] 
Remove an unnecessary branch from sqlite3VdbeReset().

FossilOrigin-Name: a7d79560a0efd6221ba59ce84bcb4fa94024a901ac4a45e192ddecc6e1b5c78c

3 years agoRefactor the Vdbe.iVdbeMagic field into Vdbe.eVdbeState. Split the RUNNING
drh [Fri, 1 Apr 2022 17:01:57 +0000 (17:01 +0000)] 
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.

FossilOrigin-Name: 5a50a42fde9477868fad31099f5fe976437825fac44f8b3a4cf6c739c7667bbb

3 years agoAvoid a harmless uninitialized variable warning in PRAGMA incremental_vacuum.
drh [Fri, 1 Apr 2022 16:22:41 +0000 (16:22 +0000)] 
Avoid a harmless uninitialized variable warning in PRAGMA incremental_vacuum.

FossilOrigin-Name: 6d976f90dfe4886c3f4c062151af5c5ca7454d34b71172401b8c67acd2d663a0

3 years agoHave the sqlite3_context object carry the encoding for the prepared statement
drh [Fri, 1 Apr 2022 15:31:58 +0000 (15:31 +0000)] 
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

FossilOrigin-Name: d4e19314f564126e180e091f9135c7bc55a10442edb46fbd3a4cfad21201dfa6

3 years agoSplit out the RUN state into separate READY and RUN states. vdbe-state-refactor
drh [Thu, 31 Mar 2022 21:15:09 +0000 (21:15 +0000)] 
Split out the RUN state into separate READY and RUN states.

FossilOrigin-Name: d698826b08b88e227eb83f84b3cdb19f17306b532eccfa162090abccdf3c63d8

3 years agoRename Vdbe.iVdbeMagic to eVdbeState. Remove unnecessary states. This is
drh [Thu, 31 Mar 2022 20:04:49 +0000 (20:04 +0000)] 
Rename Vdbe.iVdbeMagic to eVdbeState.  Remove unnecessary states.  This is
a preliminary step toward splitting RUN_STATE out into several other states.

FossilOrigin-Name: ff91191d232305d44ae6c0fbca2542a749422dc716fa1fd5d54f58c7d6052c14

3 years agoFix harmless compiler warnings.
drh [Thu, 31 Mar 2022 16:09:13 +0000 (16:09 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: b916087aacba53530d2bd19eef2a4fd7a253bf7fa87b49e0df17f7987d7164ae

3 years agoRefinement to [3f9887d4a58cbfdb]: The SQLITE_CONSTRAINT error should only
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.

FossilOrigin-Name: f2d9262e4427ab37ba26c004fc7a4790c86c1856d695a6b4ec3e72732ea54c09

3 years agoFaster and slightly smaller implementation of sqlite3Step().
drh [Wed, 30 Mar 2022 17:56:27 +0000 (17:56 +0000)] 
Faster and slightly smaller implementation of sqlite3Step().

FossilOrigin-Name: c6901a8c78838228f8135c9346b214e638b72086fd85367b9ff482273e62ece6