1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

30215 Commits

Author SHA1 Message Date
dan
9b91aac83b Fix a problem with the fix in [5cb8e342e1].
FossilOrigin-Name: 043ff54fb746c54bc6cfa6aa8c8a32c876c09d36163125916ad01024b98d447b
2025-07-08 19:02:26 +00:00
dan
acd1d93497 Fix another problem with running fts5 integrity-check in SQLITE_DEBUG builds, this one causing an assert() failure.
FossilOrigin-Name: 5cb8e342e1d33a0fd04fd022900eeada46a2ee23f15c6abca1b37633e77429d6
2025-07-08 18:44:56 +00:00
drh
449b34571e Enable the EXISTS-to-JOIN optimization if the outer query has no
FROM clause.

FossilOrigin-Name: 1b9b124f9a35ebd1ac4ea70ef1ee08a4c82c11da690d4164f6b785a6fd9730d9
2025-07-08 17:28:09 +00:00
dan
9615cf93c8 If SQLITE_DEBUG is defined, fts5 does extra checks as part of integrity-check. Ensure that errors from these extra checks are only reported if the other, normal, tests all pass. This fixes a test case in fts5corrupt3.test that was failing if SQLITE_DEBUG was defined.
FossilOrigin-Name: 98a53fb276fa1fa733da2dd3255c35ce9f6af9b9feef6e76fb577b6d142167a2
2025-07-08 14:54:20 +00:00
drh
925b79039c Fix test case results in FTS5 that were changed error message improvements
in [48044a6b57c0a16c] but which were omitted from that check-in.

FossilOrigin-Name: e1f8e0240b14f1338e947634e840af785e5042a09cd365975e922a13a562f4cd
2025-07-08 12:37:25 +00:00
dan
7fc6e6a272 Only run preupdate-hook tests in incrblob4.test if the preupdate-hook is enabled in the build.
FossilOrigin-Name: 56314b6b53c86ae131f780e20b62bdeabccba6d62dda41becc1c4b2e87cee07b
2025-07-07 20:47:23 +00:00
drh
8c8443a38a Small performance optimization in the resolver.
FossilOrigin-Name: 840646df0696706bd4dd7a04dfc8b16ad80c24cbcbc57a22c9e65a93cc17af2b
2025-07-07 19:03:50 +00:00
drh
44a03671c4 Merge the latest trunk enhancements and fixes into the empty-table-optimizations branch.
FossilOrigin-Name: f15cdf07573c05276a13885d74bae21a93544766344f19ef939b7a69edd1073b
2025-07-07 18:35:51 +00:00
drh
0a5508aeb4 Rework the fix to the problem described by
[forum:/forumpost/b9647a113b465950|forum post b9647a113b] so that it
provides a more complete fix that covers cases that were not resolved by
the original fix, and so that it does not cause performance regressions.

FossilOrigin-Name: 28db0d152d90fb5e62d03ea5caceabe8901be98522aef3dc2b54564fbc35355d
2025-07-07 16:19:44 +00:00
drh
4fe1ac8fe1 Simplifications to the row-value IN operator logic. Do not let the query
planner accept a WhereLoop for a row-value IN operator that uses the same
index column more than once.

FossilOrigin-Name: d2adf61f21a3ce901a2b08199ad0de191e88ef16e097c5f7a75c95ad958eff12
2025-07-07 15:40:53 +00:00
stephan
24d290e7b0 Work around the Emscripten 4.10 regression described in [https://github.com/emscripten-core/emscripten/issues/24656 | Emscripten ticket #24656]. Problem reported off-list by BrickViking.
FossilOrigin-Name: c385475b250f3364507a95c5832137098a9bb7c7fc12ab3bb116e1fad7bb7645
2025-07-07 12:11:26 +00:00
dan
8504d37b99 Avoid invoking the preupdate hook from within sqlite3_blob_write() if the cursor is already invalid.
FossilOrigin-Name: 9f335b9a4e9e761a0c6afd6dc69665a24506141bde88530bf59fcbdf957ae881
2025-07-07 11:37:55 +00:00
drh
4aacd1ef8e Back out the fix at [ba7d5bad32ad6aac] because it does not always work and because
it causes a performance regression.  Add new test cases for row-value lookups of
indexes that contain redundant columns, three of which are currently failing.  This
branch is seeking an improved solution to the redundant index column problem for
row-value lookups.

FossilOrigin-Name: ad8ddcefab5cc526b1cd77731e00939c672e61ca83350d28961b67635d20da03
2025-07-07 10:54:00 +00:00
drh
0840460689 Fix parser error introduced by [325e547a2195571e]. See
[forum:/forumpost/095dbfc06e5b1f7e|forum post 095dbfc06e5].

FossilOrigin-Name: 4eefab44941fc6e17742fa49c8734e7f00a2177d82bc572e596228add53aad39
2025-07-07 02:18:27 +00:00
stephan
240319decd Remove some dead JS code and some extraneous debug output from test code.
FossilOrigin-Name: 6e73770a7f3845055e0130012d844c32c4a1bfdb87e8379c161e1a266a808143
2025-07-06 15:36:28 +00:00
stephan
787f4c3f09 JS doc additions.
FossilOrigin-Name: 7933505f0c1d25c6ee81ead8edc5ea649a84ec0582321bcf5ed4a17232750f90
2025-07-06 15:13:06 +00:00
stephan
4d453cc2ed Experimentally add sqlite3.oo1.DB/Stmt.wrapHandle(), which allow DB/Stmt instances to wrap a (sqlite3*)/(sqlite3_stmt*) optionally with or without taking ownership of it. The intent is to enable mix-and-match use of the C API, the oo1 API, and any other hypothetical API which exposes those pointers. oo1.Stmt.parameterCount is now a property access interceptor like Stmt.columnCount is, but that doesn't change how it's used.
FossilOrigin-Name: 1227543b87c3320d6b80e0f61b88ea53b68779966a0295c4d6a1db6369c48207
2025-07-06 15:01:44 +00:00
drh
c701d17366 Improvements to the EXPLAIN QUERY PLAN output for EXISTS-to-JOIN.
FossilOrigin-Name: 6b1ecbaa2ee405be040901dceac45d027d35c313622748ba4dbbd404e297a7fa
2025-07-06 01:19:09 +00:00
drh
8bc112e3e4 Enhance the EXISTS-to-JOIN optimization so that it works on EXISTS subqueries
that do not have a WHERE clause, and so that it works on nested EXISTS
subqueries.

FossilOrigin-Name: c1d5295724f9cf7f49e0786d28016eff2d268a2b670f934d24c76787626089db
2025-07-05 23:33:21 +00:00
stephan
27408ab9c9 Add 'reconfigure' target to Makefile.in to re-run the configure script with the same flags it was generated with.
FossilOrigin-Name: c60907e77b32824aaaf024d299cdaf161b5f64fc927ffe5d5455eeb5754e6b01
2025-07-04 18:32:18 +00:00
stephan
d9eae6b75a Propagate the -ldl and -lpthread flags, if needed, into sqlite3.pc, per request in [forum:44a58c807353162f | forum post 44a58c807353162f].
FossilOrigin-Name: 64f5f14322349b47451b8cac03bf8cd6f1ae45a8822e7f1ddee3d0b265047501
2025-07-04 17:20:37 +00:00
drh
45bc9b9f97 Merge fixes from trunk into the empty-table-optimizations branch
FossilOrigin-Name: 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b
2025-07-04 14:24:18 +00:00
drh
e33ea17d24 Fix harmless compiler warnings.
FossilOrigin-Name: 13af4acebe09b047756c22b800136cffaba532e7fcaa448a4edf4fedb94e9bbc
2025-07-04 12:25:24 +00:00
drh
a12e92d2f7 Remove an ALWAYS() added by [960a8e6fc91f4] that turns out to be false
in some cases of malformed SQL.

FossilOrigin-Name: cc8171461bf35f584888a24b844c8b79ad30155b19b61161e9f3abc276e8aae5
2025-07-04 11:48:11 +00:00
drh
478dfc7e74 Do not allow the EXISTS-to-JOIN optimization if the EXISTS clause is based
on a view, since that view might expand into a join.

FossilOrigin-Name: 872c41feddafcc21a02f1229ce017ceea9f8e309a4dd5b6e323477d67f975947
2025-07-04 11:06:34 +00:00
drh
1b62720fa8 Improve the early-termination optimization so that it works in queries
which use the LIKE optimization in the outer loop.

FossilOrigin-Name: b4e4d148243cfcb09aa0aaca30e83812b42e2780073e55c0e8c6e3da16243dfc
2025-07-04 10:26:55 +00:00
drh
1e3a862b79 Merge the latest trunk fixes and enhancements into the empty-table-optimizations branch
FossilOrigin-Name: d4f47e04f5880e99a53089e2dd5cde64a7ea44f059d9906b5d11324896546714
2025-07-03 20:51:08 +00:00
dan
bd05edd98f Fix a few cases where LIMIT clauses that were part of scalar sub-queries on virtual tables were not being passed to xBestIndex methods correctly.
FossilOrigin-Name: 960a8e6fc91f47add3a089dc6cef013109deadf809994c5149ad3bdfb3884de0
2025-07-03 16:05:41 +00:00
drh
a24a397b8b Improvements to sqlite3_vtab_rhs_value() logging in the
ext/misc/vtablog.c extension.

FossilOrigin-Name: 25131ee84f53dab1191e02c19cefd256aed2828c7edea325fcc0ba3b0a668583
2025-07-03 15:50:18 +00:00
dan
0e6e05d4d5 Make the value of an explicit LIMIT clause on a scalar sub-query available to xBestIndex for simple "LIMIT 0" and "LIMIT 1" queries.
FossilOrigin-Name: 33b6a63caafccc61b3193714911cd8b5dd9b7f1798054b8c7845b23688d531f2
2025-07-03 15:32:27 +00:00
dan
c525e6e817 Make handling of LIMIT clauses in correlated sub-queries on virtual tables more efficient.
FossilOrigin-Name: 7214cb2a5b35190a06a1040cd4c54f325d347f8d8e36a07fd76c0a421e266522
2025-07-03 14:28:47 +00:00
drh
1ff6f19d8b Enhancements to the xBestIndex output from the ext/misc/vtablog.c
extension.

FossilOrigin-Name: 8b31acc0b18f38eb4af6efebd1ea25cd65a146651101579aee20afd9ec6dc2de
2025-07-03 14:10:03 +00:00
drh
bfb4993364 Fix an uninitialized variable added yesterday by [d27d34fb746280e7].
This problem was discovered overnight by 
[https://github.com/google/oss-fuzz|OSSFuzz].

FossilOrigin-Name: 6db4703f1178fc808f3a75c355fb6638fb12c88f6e1ce7f579e200ced8089114
2025-07-03 11:52:17 +00:00
drh
debc8f7bb7 Minor tweaks to the exists-to-join optimization.
FossilOrigin-Name: 9cb600ad576c68647ed943a0773019312c5f01c9c1ca9ff0bf1214b03a531b48
2025-07-03 00:17:27 +00:00
drh
aa54d7a0ca Merge in the exists-to-join optimization that has been modified
to relax the requirement of having an indexed join constraint.

FossilOrigin-Name: 1c1aef2b7feae29066d0330699ab634ef41f5b60cdcd479a60cb1a5409553138
2025-07-02 20:46:02 +00:00
drh
eb27359e5e Fix VDBE coverage
FossilOrigin-Name: ff593a16d61cc5c588d1737deb822abb90b1759475a4cabfcf608978b1191487
2025-07-02 17:43:59 +00:00
drh
33f3273705 Early exit if one of the inner loops of a 3-way or larger join is an
empty table.

FossilOrigin-Name: eaad6ac707a5960d9518d4049b7b1759e7512727ce87be3c402408144bda0a97
2025-07-02 14:53:48 +00:00
drh
216676664d If the LHS for an EXCEPT or INTERSECT operator is empty, skip over the
computation of the RHS.

FossilOrigin-Name: 13f096ae8a850a05d4a8684561066f11693ee66289e6568c44ef32822cca06f6
2025-07-02 13:19:24 +00:00
drh
6245e5a46b Improve the bytecode for joins such that it exits earlier if it determines
that no output is possible.

FossilOrigin-Name: 2d2b61cba44a756a3a41ef5c95bbb0c0b7111f4b679c578fec9bd0b214cca367
2025-07-02 11:47:54 +00:00
drh
caf0473652 Ensure that Expr.op2 values for TK_AGG_FUNCTION nodes are adjusted when
query flattening.

FossilOrigin-Name: d27d34fb746280e7e81335db4e195914b15403ef0da7b2955550553dd78fbe9a
2025-07-02 02:03:43 +00:00
drh
2427ce16d9 Improved comments on bytecode used to implement aggregate queries, to aid
in debugging.

FossilOrigin-Name: a1a8b85cdba64a17dcdcd4e6b42b872957cec2dc05b0ac34dfcd82f59344034b
2025-07-01 23:17:36 +00:00
drh
46bfcc1a21 Improved byte-code comments for the short-circuit optimization of
[0083d5169a46104a], to aid in debugging.

FossilOrigin-Name: 113f9d10e347eeaa893ff8b47a461009e0b12589374b93cf3e0bddd19c702dea
2025-07-01 20:32:45 +00:00
drh
5e71497404 Cache and reuse virtual table cursors in the bytecode engine.
FossilOrigin-Name: 2d187d4232d750cb1840f1d89c8aed65962cb0883c1d7f91c554b451e475c514
2025-07-01 17:36:55 +00:00
dan
526399b0fd Avoid an assert() failure in fts5 that may occur when processing corrupt records.
FossilOrigin-Name: 8afd6ca85724a69970181042d6aac53742ea2b76ded5966b2541c3afe1121fb9
2025-07-01 16:21:47 +00:00
drh
e1910ed1d2 Merge trunk fixes into the empty-table-optimizations branch.
FossilOrigin-Name: 63306e447efb3ac17e789a331ed3bb65459eb8b79d66e9c185ba3bd852f34ce3
2025-07-01 15:13:37 +00:00
drh
d82c6a2cf7 When attempting to optimize "expr AND false" to "false" and
"expr IN ()" to "false", take care not to delete aggregate functions
in the "expr" as doing so can change the meaning of the query.
See [forum:/forumpost/f4878de3e7dd4764|forum thread f4878de3e7].

FossilOrigin-Name: 77397bd67d918db57d5ac545d6d963194806fdabcdaa8f822b6b09e4cfe8b715
2025-07-01 12:43:13 +00:00
drh
3d21dcc924 More aggressive optimization of addrHalt for RIGHT JOIN.
FossilOrigin-Name: 5e51d1c0dfcafef9e71c99de3f626dee157c935724b84c6e0c630299a880446f
2025-06-30 21:07:08 +00:00
drh
ba56f7020d Compute WhereLevel.addrBrk and .addrHalt early so that those labels can be
used to abort loops early.  Use this to improve performance on two more
of the cases described by [forum:/forumpost/52651713ac|forum post 52651713ac].

FossilOrigin-Name: 6fc0b9ac23be6840542982de4bb282ebca1db8b5ab3baefdde95a997c1506e81
2025-06-30 20:19:19 +00:00
drh
99f1aa03fb Strive to skip the evaluation of scalar subqueries that are part of a
larger expression if the result from the scalar subquery does not change the
result of the overall expression.

FossilOrigin-Name: 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296
2025-06-30 16:41:40 +00:00
stephan
1bd6b415e9 Correct ~/.local/config/... to ~/.config/... when looking for sqliterc when XDG_CONFIG_HOME is not set. Internal doc touchups.
FossilOrigin-Name: ebb346c5aa427b9e84a035278ee245d54810d9954efef12b898f2d7bc0ff630c
2025-06-30 15:56:10 +00:00