Commit Graph

90 Commits

Author SHA1 Message Date
dan
e734207a79 Fix some test scripts that were failing with SQLITE_OMIT_VIRTUALTABLE builds.
FossilOrigin-Name: 81c118d90b281b30f40b3eeefaeb2c8350aa40080b4fe7de8f21d263986c6acb
2023-02-06 10:47:57 +00:00
drh
f7af9ba13c Additional tweaks to the enhancement at [609fbb94b8f01d67] to further reduce
the cost estimate for constructing an automatic index on an ephemeral table,
in order to resolve the performance problem described by
[forum:/forumpost/1d571c0296|forum post 1d571c0296].

FossilOrigin-Name: bf1aae7a8c7f2c74681aa29baa35259d10ce6a1737d2607def6bf27fed592131
2023-01-30 20:44:54 +00:00
drh
b54f71e205 Fix a (harmless) off-by-one error in code generation that comes up when
doing a DISTINCT query against a virtual table with an OR term in the
WHERE clause and where the ORDER BY clause has 64 or more references to
the result set.  [forum:/forumpost/dfe8084751|Forum post dfe8084751].

FossilOrigin-Name: 04af7ef77043702f93cbff23548610759786893bd3d4d6fc08181e1e249c6663
2022-12-07 00:14:25 +00:00
drh
1edd0a089c Tuning the query planner by adjusting the weights that predict the relative
performance of sorting and index lookup.

FossilOrigin-Name: 9f2806da4d88beceac2e81e05421f00481dd3dd100b096cd2ae6c828adb42ca7
2022-12-03 00:52:21 +00:00
drh
cc212e4450 Fix a bug in the sqlite3WhereMalloc() routines that were added by
chekc-in [f237e1d8cc41b937].  The bug was detected by dbsqlfuzz
test case 4c5e3e89bc251d28378be88233f531b84ec66901.

FossilOrigin-Name: 764b71267e0b31ff7eaf2a0def7526a1a02dce4d5b456dea060d97ed342efdd1
2022-05-10 23:28:12 +00:00
drh
6134b2dff2 Fix handling of "continue" and "break" from inside the loop for the right
operand of a RIGHT JOIN.

FossilOrigin-Name: b6e773a26c2c6ee76ea61acb059b4e676d07ea62f6db9c513638f8986557cf04
2022-04-11 17:27:38 +00:00
dan
619a5f5572 Exclude two recently added tests in where.test from valgrind runs. They fail due to the subtly different handling of real numbers under valgrind.
FossilOrigin-Name: e842d2085b295ef1c927611f5d3b211fb6b513ca2676c074fe90331da81734eb
2021-11-23 11:34:43 +00:00
drh
de3246176b More precision in comparing integers and floating point values while
processing the integer primary key for OP_SeekGE and similar.
[forum:/forumpost/2bdb86a068|Forum post 2bdb86a068].

FossilOrigin-Name: f9c6426de3b413ff8fcf04a00931ca5f123f996c572b35181af114afa8d811d7
2021-07-19 20:52:31 +00:00
drh
8210233c7b Revise tests cases to align with the new EXPLAIN QUERY PLAN output.
FossilOrigin-Name: 50fbd532602d2c316813046ed6be8be2991c281eb5f295c4c28520a0de73862c
2021-03-20 15:11:29 +00:00
drh
fa17e134b2 Improvements to the IN-early-out optimization so that it works more
efficiently when there are two or more indexed IN clauses on a single table.

FossilOrigin-Name: 35505c68c1945c35babd2496e02bc4907a15c8e7b8d77f05f230bd0e9d4891d7
2020-09-01 01:52:03 +00:00
drh
346a70ca1e Provide "sqlite_schema" as an alternative name to the table that holds the
database schema.

FossilOrigin-Name: 61782a7ae3c25cf59d7a676cb295eb024d17c46e532ae78c6fe871a91d712fa9
2020-06-15 20:27:35 +00:00
drh
3e36480232 Fix the OP_SeekGE, OP_SeekGT, OP_SeekLE, and OP_SeekLT opcodes so that they
preserve the datatype of the value in the register used as the key.
Ticket [d9f584e936c7a8d0]

FossilOrigin-Name: 81b9f0f55042777b37de78069f7089041a9ee21dd0a0c86b879053fb46e140b4
2019-08-22 00:53:16 +00:00
drh
175b8f06f7 Remove support for STAT3. The sqlite_stat3 tables are ignored, if they
exist.  STAT4 continues to work as it always has, and as it is a superset of
STAT3 is the recommended replacement.

FossilOrigin-Name: 1e17ea2fd1df4ad49138c787c8fe3207dd0c25c93f9001d52a9b69f8c12e841c
2019-08-08 15:24:17 +00:00
dan
6cf3009f6c Add further tests so that veryquick.test covers all vdbe branches.
FossilOrigin-Name: cbc67de5a3937fa65811ed7c13e870699c895660dc2132cf9d3cf5d83364e344
2019-04-05 20:47:15 +00:00
drh
bc0a55cf0b Check-in [fa792714ae62fa980] is not a valid fix for ticket
[df46dfb631f75694], as the new test case in this check-in demonstrates.
The fix here causes test cases for the [df46dfb631f75694] bug to fail
again, so this check-in is on a branch.  A new fix is needed for
[df46dfb631f75694].

FossilOrigin-Name: 0d456456da6e25b20d9d27ca95f1013082bca52ee74ee9bf91732a9fa843ea45
2019-02-22 21:33:56 +00:00
drh
383bb4fa62 Disable the IS NOT NULL optimization when the IS NOT NULL operator is part
of the ON clause of a LEFT JOIN. Fix for ticket [65eb38f6e46de8c75e188a17ec].

FossilOrigin-Name: af39661e60f562b9eb10343fd83e8fe21be4d7276111e7853c1179a24cab09ce
2018-11-05 07:53:17 +00:00
drh
f559ed3400 Add a small cost penalty to sorting to bias the query planner in favor of
plans that do not require a final sorting pass.

FossilOrigin-Name: 85b9beb4605eb0cfe2ed063c2a1925186c9e37031f78c875e60a347cce891638
2018-07-28 21:01:55 +00:00
drh
056f5396fe Test cases.
FossilOrigin-Name: 085e863713a3f2d420c0076b275a6ac445a59d4d93f9eb0e8503b4e3f5589249
2018-06-07 16:07:00 +00:00
dan
ccb9eb782c Remove a recently added NEVER() macro from a branch that can be taken in
obscure circumstances.

FossilOrigin-Name: 2aa210030ae414782adab9291cc43a149a780f39bd3d306dc2892a8c20422a51
2018-04-24 18:59:18 +00:00
drh
c447595df5 Do not attempt to use terms from the WHERE clause to drive indexes on the
right table of a LEFT JOIN.  Fix for ticket [4ba5abf65c5b0f9a96a7a40cd18b]

FossilOrigin-Name: aeb694e3f787f1f8b55650c17f90c197eee3f7f9b890a88f458c33e43009a082
2018-04-24 17:34:03 +00:00
drh
cb23e5d5d1 All the OR optimization to proceed even if the OR is also converted into
an IN operator.

FossilOrigin-Name: e252c6540db266b93beeb47a8f7dbf3b275f8c782cd2d36ba4c00648c382f63f
2018-04-24 16:41:37 +00:00
drh
c9eaeef1fe Remove a debuggin "exit" command mistakenly left in the "where.test" module.
FossilOrigin-Name: beda0b8c76c2c7328a44156257c978cf8f5df59b
2016-02-26 04:04:07 +00:00
drh
8c098e61b6 Fix an incorrect cost computation for sorting (introduced just a few
check-ins ago).  Should be NlogN, not NloglogN.

FossilOrigin-Name: 2459d3238853951bc3a507dd975e7ec921cf8446
2016-02-25 23:21:41 +00:00
drh
b1d607de25 Improvements and simplifications to the equality seek logic. Tests are
adjusted so that they all pass now.

FossilOrigin-Name: 997ce6c90b454c03cc2ef6934752ee8dd2e520e3
2015-11-05 22:30:54 +00:00
drh
edb04ed946 Continue to support the (broken) legacy syntax of allowing strings for
column names in CREATE INDEX statements and in UNIQUE and PRIMARY KEY
constraints.

FossilOrigin-Name: 3d3df79bfaf9dbc7aa711c08a19d2f6dbe744b32
2015-09-04 12:54:01 +00:00
drh
e0cc3c296c Add testcase() macros and comments and a few test-cases.
FossilOrigin-Name: 24263d08b11c88416d270013bdaf5ff45125cb4d
2015-05-13 17:54:08 +00:00
drh
cfc6ca4179 Seek past NULLs in a top-constrained search. Avoid checking for NULLs in
the body of the search.

FossilOrigin-Name: e07a32f30862acf3b322d4d8deb015846d6f8f5f
2014-02-14 23:49:13 +00:00
drh
165674d8db Fix test cases so that they work when the query planner uses index size
estimates to determine whether or not to try an covering index scan.

FossilOrigin-Name: 2f394de88f23dacd3c61e586a4214ffc6f927d97
2013-10-04 15:58:59 +00:00
drh
67a5ec7b54 Make sure the omit-noop-left-join optimization is not applied if columns
of the LEFT JOIN are used in the ORDER BY clause.  
Ticket [be84e357c035]

FossilOrigin-Name: 0303d6bc7112e6f810ae1bd75cafc5ffc51f5212
2013-09-03 14:03:47 +00:00
drh
4fe425ad79 "make test" now passing.
FossilOrigin-Name: addd7f466d6ff55f82d907286650c26b06e9397b
2013-06-12 17:08:06 +00:00
drh
8a4380d761 Fixes to EXPLAIN QUERY PLAN output. Change weights back to something closer
to what they are in legacy.  More test case fixes.

FossilOrigin-Name: 36373b85f9a97840aa06e24ae31c12fcfbae084e
2013-06-11 02:32:50 +00:00
drh
6fa978dade Futher simplifications to the NGQP. Fix some test cases to use
EXPLAIN QUERY PLAN rather than the (now obsolete) sqlite_query_plan
global variable.

FossilOrigin-Name: ae985db4fa08b5efbef5a834e852f0b05101264b
2013-05-30 19:29:19 +00:00
drh
2d96b934c8 Loop through the elements on the RHS of an IN operator in reverse order when
the ORDER BY clauses specifies DESC.

FossilOrigin-Name: f78395c8896666bb1359b83fbcd58d5e3dbc39d3
2013-02-08 18:48:23 +00:00
drh
1b8fc65b92 Allow an index to be used for sorting even if prior terms of the index
are constrained by IN operators.

FossilOrigin-Name: 98bf668ab1a8683b46ee8c94cb60f8215aabc517
2013-02-07 21:15:14 +00:00
dan
e825831ee4 Disable a couple of tests in where.test when running the "no_optimization" permutation.
FossilOrigin-Name: 5e961e37c5357776bcb44c473cb5ee4b59561f07
2012-12-05 19:04:32 +00:00
drh
6f0e400cba Fix a query planner problem that only occurs when covering-index-scan is
disabled.  Fix to tests whose output changed due to the new and more
aggressive ORDER BY optimization.

FossilOrigin-Name: 0f9bb90100aa304a7f28023ca4173e68b445e8bd
2012-10-03 12:38:19 +00:00
drh
a9e3fc05f5 Fix some corner case behavior in the new ORDER BY optimization logic.
Remove the SQLITE_OrderByIdx bit from the 
SQLITE_TESTCTRL_OPTIMIZATIONS mask, since enabling it caused many
TH3 tests to fail when the NO_OPT configuration parameter was engaged,
and since there really isn't any need to turn that optimization off.
The SQLITE_OrderByIdxJoin bit remains.

FossilOrigin-Name: 98b633717a1c9a08f6a1d00bc6bc891564ae7e9b
2012-09-27 23:27:23 +00:00
drh
5343b2d4a8 More test cases an bug fixes for the ORDER BY optimization of joins. All
veryquick tests now pass.

FossilOrigin-Name: 0d573320057b0903a5589cabfb1b1ece1c57958e
2012-09-27 19:53:38 +00:00
drh
3f4d1d1b02 Attempt to use a covering index even on a full table scan, under the theory
that the index will be smaller and require less disk I/O and thus be faster.

FossilOrigin-Name: cfaa7bc12847a7006ccc93815f2395ad5259744a
2012-09-15 18:45:54 +00:00
dan
99f8fb66a4 Fix for 2a5629202f. When considering whether or not a UNIQUE index may be used to optimize an ORDER BY clause, do not assume that all index entries are distinct unless there is some reason to believe that the index contains no NULL values.
FossilOrigin-Name: 9870e4c4fef10112c987c40cb1b95255a7214202
2012-04-20 15:24:53 +00:00
danielk1977
3072c5ea11 Fix a bug reported on the mailing list triggered by the pattern "SELECT <col>, (SELECT ... FROM tbl WHERE rowid > <col>) FROM ...". (CVS 5855)
FossilOrigin-Name: 6c918c4eb9362ebfdbe0486515679102b2862970
2008-11-03 09:06:05 +00:00
drh
d1d384888b Add the experimental sqlite3_stmt_status() interface. (CVS 5781)
FossilOrigin-Name: de473efb35ffdf9a8222a70a84dfd7d3198c87c1
2008-10-07 23:46:38 +00:00
danielk1977
2d60549926 Fix a bug in where.c where a non-temp register was being incorrectly deallocated. Ticket #3408. (CVS 5758)
FossilOrigin-Name: 59d2e89e2181c26b18eac68ccc80ea3018f70a5e
2008-10-01 08:43:03 +00:00
drh
588a9a1a1c Defer deleting Table objects associated with flattened subqueries until
all code has been generated, in case some expression node still references
the Table object.  Ticket #3346. (CVS 5650)

FossilOrigin-Name: d04d70336727a0db959c672e6c22cdaa0505dce5
2008-09-01 15:52:10 +00:00
drh
85e9e22b33 Increased test coverage. (CVS 5414)
FossilOrigin-Name: 7cf91e08c08ce515c24c738c7d079f5b81eebee6
2008-07-15 00:27:34 +00:00
drh
e8f52c5089 Remove leftover debugging commands (breakpoint and btree_breakpoint) from
test scripts. (CVS 5400)

FossilOrigin-Name: dcb160249fa2d592ad09b8b0052102dc44a93511
2008-07-12 14:52:20 +00:00
danielk1977
21de2e755c When using an index to scan a database table, read column data from the index in preference to the table. This increases the likelihood that the table will not be required at all. (CVS 4580)
FossilOrigin-Name: 061608c72ac0a96eacf3b64d638235e4739f96ba
2007-11-29 17:43:27 +00:00
danielk1977
c9cf6e3d31 Fix for #2445. A bug in the lookupName() logic that could cause a crash when a WHERE clause used an alias to refer to an expression in the result-set of the SELECT, and that expression was itself a reference to a table column. (CVS 4122)
FossilOrigin-Name: 044ca1c72a8f4632dc2e6a94690d164d3560ee38
2007-06-25 16:29:33 +00:00
drh
4f07e5fbdf Remove terms with operator TK_AS from the expression tree. Ticket #2356. (CVS 3991)
FossilOrigin-Name: 5627ff74be9242418434a06fe5c104d1f9128cab
2007-05-14 11:34:46 +00:00
drh
32ffdb7393 Additional tests to give full coverage testing to ticket #2211. (CVS 3630)
FossilOrigin-Name: ecb1f2fd7b96797459287eaab95693ae17ec2079
2007-02-06 23:41:34 +00:00