Commit Graph

11053 Commits

Author SHA1 Message Date
drh
74f91d4462 Add in the cost of doing a table lookup on OR searches. Make test case
changes to deal with difference in STAT3 behavior.

FossilOrigin-Name: d97898e8e3990ae8c1882c9102b57692d8810730
2013-06-19 18:01:44 +00:00
drh
2daffdf0b5 Only default HAVE_POSIX_FALLOCATE on for linux, and then only if it is not
previously defined.

FossilOrigin-Name: 2b2ade92788be623af6f57e37d98994be2cec142
2013-06-19 14:49:14 +00:00
drh
7fb1b30118 Only enable posix_fallocate by default on linux and mac.
FossilOrigin-Name: b9b30d4f9845d212e2d3206abbf2795099e5d71d
2013-06-19 14:28:34 +00:00
drh
ad01d892a7 Additional compiler warning fixes.
FossilOrigin-Name: 8d2ae8e2f343f82f6fba6d0e89cee7f15b444aa3
2013-06-19 13:59:49 +00:00
drh
e8ae583ebd Fix a harmless uninitialized variable warning.
FossilOrigin-Name: 9d3ef3bd2c6281784a537a22a87279f420649935
2013-06-19 13:32:46 +00:00
drh
dbb80234da Simplify and add invariants to the WhereLoop merging logic inside of
whereLoopInsert().

FossilOrigin-Name: 8f27f35f288434b9e7bc503c608f1e2b590ade4d
2013-06-19 12:34:13 +00:00
drh
c7f0d229a7 Fix compiler warnings. Fix a harmless off-by-one error in the solver.
FossilOrigin-Name: 10021941d0258951b916e788881df140113f0597
2013-06-19 03:27:12 +00:00
drh
4a5acf8e5c Adjustments to testcase() macros for improved testability.
FossilOrigin-Name: 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f
2013-06-18 20:06:23 +00:00
drh
81186b4392 Remove some redundant and unreachable code.
FossilOrigin-Name: 4c6d58d75d51e1ce829aec214617c3a89e784a2d
2013-06-18 01:52:41 +00:00
drh
7963b0e853 Add more testcase() macros. Fix a memory leak following OOM in the
virtual table analysis logic.

FossilOrigin-Name: b61402af690ac08b68974f3c807096b0cffd9bc0
2013-06-17 21:37:40 +00:00
drh
93ec45d560 Simplifications to the NGQP. Add the queryplantest makefile target. Add
testcase() macros in the NGQP.

FossilOrigin-Name: eaf1f1b405ec2c498092527fae00e5dbe9e176c1
2013-06-17 18:20:48 +00:00
drh
75bf6b984a Use automatic indices on subqueries of the FROM clause when appropriate.
FossilOrigin-Name: e8f124284ee0d0e373dc4431668630f1e17015c1
2013-06-17 14:18:21 +00:00
drh
613ba1ea9c Fix compiler warnings.
FossilOrigin-Name: 3e8ac46918c68723bd199dbec8b0901457d524a9
2013-06-15 15:11:45 +00:00
drh
f003076032 Comment tweaks in where.c. No changes to code.
FossilOrigin-Name: cecc5fdd5d8fbad7d9e8c275b9ba9ade3dbee8ef
2013-06-14 13:27:01 +00:00
drh
b8916be945 Add a new ORDER BY optimization that bypasses ORDER BY terms that are
constrained by == and IS NULL terms of the WHERE clause.

FossilOrigin-Name: b920bb70bb009b7c54e7667544c9810c5ee25e19
2013-06-14 02:51:48 +00:00
drh
6d38147c19 An index might be useful for ORDER BY if any indexed column is in the
ORDER BY clause, not just the first indexed column.

FossilOrigin-Name: ade473b5ae3fe2162b0ec29731d8e864a9301e07
2013-06-13 17:58:08 +00:00
drh
53cfbe92d1 Make sure that disabling the covering index scan optimization does not
prevent a covering index from being used to satisfy an ORDER BY clause.

FossilOrigin-Name: e8b7ea8202c443bfc8a978588c7d2cfaa14a8fea
2013-06-13 17:28:22 +00:00
drh
bbe8b24b8d Restore the ability to do a BETWEEN query on the rowid. Also fix a
nearby comment.

FossilOrigin-Name: 459a7b9068310b36fed950940d251c4b798ffc58
2013-06-13 15:50:59 +00:00
drh
e1e2e9acd6 Make the MIN() and MAX() macros available in sqliteInt.h. Add TUNING
comments to the NGQP and adjust costs slightly.

FossilOrigin-Name: 3a72af2a95b04b8e195ef17cb3e9d9021a4f0915
2013-06-13 15:16:53 +00:00
drh
12ffbc7e69 Fix an off-by-one error in the WhereCost to integer conversion.
FossilOrigin-Name: b5ca80d924f8c6d31f036247ba6e20d234f4482e
2013-06-13 14:51:53 +00:00
drh
ec3e641a3c Add a prototype for an extension that sits in between the SQLite native code
virtual table interface and a CLR IDisposable object.

FossilOrigin-Name: 10bba8d0821159a45c6a0d6c3cef897cb4d4e9a6
2013-06-13 00:32:29 +00:00
drh
3b48e8c91a Activate the one-pass optimization. Update comments, especially the
descriptions of the various objects.

FossilOrigin-Name: e120c558a5bafc0f0d2cc12ee5c9d36e20cc642d
2013-06-12 20:18:16 +00:00
drh
95ed68df55 Bug fixes in the handling of virtual tables.
FossilOrigin-Name: 25c0f7292a20c0db6ef176966d9987f29c7d73e5
2013-06-12 17:55:50 +00:00
drh
37ca04880a Merge all changes from trunk.
FossilOrigin-Name: f2e15b1974e55373b5819e3b2326653f890f409f
2013-06-12 17:17:45 +00:00
drh
4fe425ad79 "make test" now passing.
FossilOrigin-Name: addd7f466d6ff55f82d907286650c26b06e9397b
2013-06-12 17:08:06 +00:00
drh
fd5874d23d Add the "queryplanner" test permutation. Continuing refinements to NGQP.
FossilOrigin-Name: 25e2cde105a19293bdb9c001b48624e5d7f8c4e5
2013-06-12 14:52:39 +00:00
drh
e217efc822 Continue refining the NGQP
FossilOrigin-Name: 40567fddd468d00295275af8df09a7a1785e684a
2013-06-12 03:48:41 +00:00
drh
4f402f26b1 Improved processing of DISTINCT.
FossilOrigin-Name: ba897100fed291d2025f68d09334f9985312298b
2013-06-11 18:59:38 +00:00
dan
5f0b33c2cb Add the SQLITE_FTS3_MAX_EXPR_DEPTH compile time option.
FossilOrigin-Name: 24fc9d4438a5615dd20af5419456166df83a72ea
2013-06-11 14:22:11 +00:00
drh
8e23daf372 Fix the Parse.nQueryLoop state variable to work with NGQP.
FossilOrigin-Name: f1cac24f06b9c71cfa472fdcf2da4cd8689a7cc3
2013-06-11 13:30:04 +00:00
drh
8b76656ad4 Use a logarithmic rather than linear cost and row-count measures.
Do not report row count estimates in EQP output.

FossilOrigin-Name: b777b1097dcf9dfeb1b86c71e1b5f6918d68c975
2013-06-11 02:36:41 +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
8636e9c55c Handle virtual tables correctly when using logarithmic costs. Fixes
to test cases.

FossilOrigin-Name: e612664aa2e24ed5e222be2c7fe16e210ac9bded
2013-06-11 01:50:08 +00:00
drh
5822d6feb2 Fix test cases for the new EXPLAIN QUERY PLAN format. Add the
wherecosttest tool.  Other fixes to logarithm cost.

FossilOrigin-Name: aa580e368e3c398b8377b80342dfdd906324c248
2013-06-10 23:30:09 +00:00
drh
c63367ef68 Fix some minor issues with logarithmic cost in NGQP.
FossilOrigin-Name: 69cf877283d362915edddf1822fbf7a9f86278b3
2013-06-10 20:46:50 +00:00
drh
b8a8e8a5d2 First attempt to store costs and row counts as a logarithm.
FossilOrigin-Name: 9e8109673c3a87e379f5a5a97a8b0d5a1afe853d
2013-06-10 19:12:39 +00:00
drh
3b75ffaaca Simplification and performance tweak to the high-speed NGQP bypass.
FossilOrigin-Name: 0f8a38ee54208d6a477aa2482cd277b4808450f0
2013-06-10 14:56:25 +00:00
drh
43b85ef5c6 Performance improvements for whereScan methods.
FossilOrigin-Name: aae14350a37ad50e4607953ab496cba006032873
2013-06-10 12:34:45 +00:00
drh
cb0071429f Add a high-speed bypass for the NGQP for the common case of a simply query
with quality constraints that outputs a single row.

FossilOrigin-Name: 8d1ba309211e8afa8be5520bbc1eecf6deacae07
2013-06-10 12:17:03 +00:00
drh
92a121f46e Minor problems in the high-speed NGQP fixed.
FossilOrigin-Name: 20eeccf1f24dd762f1bee9c3fe628c70ff01627f
2013-06-10 12:15:47 +00:00
drh
f710305f87 Fix the memory leak in CREATE TABLE that occurs if there are two or more
COLLATE clauses on the same column.

FossilOrigin-Name: 7e3820e5b989426c64af46f6bf862b91366ae954
2013-06-09 20:22:41 +00:00
drh
09081862cf Add test cases to demonstrate the memory leak on the COLLATE clause.
FossilOrigin-Name: 0a60212c9c8404ee079985a58094ed2b2b554d48
2013-06-09 20:16:26 +00:00
drh
60c96cd789 High-speed version of NGQP. Still has some minor problems.
FossilOrigin-Name: db2415fa677b84cd0f6dd424283c94e98d246e3b
2013-06-09 17:21:25 +00:00
drh
fe685c83d3 Candidate fix for a memory leak that occurs if a CREATE TABLE statement
contains two or more COLLATE clauses on the same column definition.

FossilOrigin-Name: 60fc77bc537b099bdd48916746109d0332f839af
2013-06-08 19:58:27 +00:00
mistachkin
753050871a Improve manual cleaning step performed by the multi-platform build tool for MSVC.
FossilOrigin-Name: d5bc1fe1c461bdb3d889ab2e50feb944881822a4
2013-06-07 22:12:20 +00:00
drh
23fec451a6 Must faster computation of estimated logarithm.
FossilOrigin-Name: dfbca3acaeb862f24f25e7810a16ff2066111ff4
2013-06-07 02:04:19 +00:00
drh
a20141593a Further prepare-time performance improvements.
FossilOrigin-Name: 02741d177bfc2fca23bc99974cd899eba13cb59a
2013-06-07 00:29:23 +00:00
drh
13e11b4356 Performance improvements.
FossilOrigin-Name: 9f8e84ab9874a8af826763b1669adb57abd493ea
2013-06-06 23:44:25 +00:00
drh
4efc9298fb Improved management of the space to hold WhereLoop.aLTerm[].
FossilOrigin-Name: d4141ecbea3abbe83525910684fbd89eb74eeb34
2013-06-06 23:02:03 +00:00
drh
e3be82cf18 Remove some commented-out code that was mistakenly left in the previous
check-in.

FossilOrigin-Name: b4a5dbad36bceabc5c5350e7676af6ad42de04eb
2013-06-06 19:25:42 +00:00
drh
70d1834483 Clean up and reorganize the elements of the various objects in the
analysis tree for the NGQP.

FossilOrigin-Name: bfc76ae1e94fc5b7fd2c9484a36a8dfe6655d165
2013-06-06 19:16:33 +00:00
drh
6f32848d61 Move the definitions of the WhereLevel and WhereInfo objects out of
sqliteInt.h and into where.c.  This will facilitate future refactoring
of the internal query planner data structures.

FossilOrigin-Name: 1574653b9b4522b489d4c62d9cf70166bb3bddfd
2013-06-05 23:39:34 +00:00
drh
783dece5d6 Performance improvement for the OR-clause analysis in the NGQP.
FossilOrigin-Name: 9b1c4954e468d0acfb5787e6bff56d50a3e7bc1a
2013-06-05 17:53:43 +00:00
drh
e9d935a8aa Minor performance tuning of the NGQP.
FossilOrigin-Name: cbef38c2d123e7d5a02c2a2450e8b329e3e96ee9
2013-06-05 16:19:59 +00:00
dan
f2c9229f73 Up until now the fts4 "unicode61" tokenizer has treated all private use codepoints except the first and last of each of the three ranges as alphanumeric (eligible to be part of tokens). This commit fixes this so that all private use codepoints are considered alphanumeric. In other words, it fixes the handling of codepoints 0xE000, 0xF8FF, 0xF0000, 0xFFFFD, 0x100000 and 0x10FFFD.
FossilOrigin-Name: 6cfd9af5250029c0d275be027b4208c48954a8a1
2013-06-05 16:17:21 +00:00
drh
cd0f407c3f Performance tweak to whereLoopInsert().
FossilOrigin-Name: 1c4a78807b7a28c9976ca8c5722ff4e2e8755b7e
2013-06-05 12:47:59 +00:00
drh
6f403ca450 Add a test case contributed on the mailing list
that works in NGQP but fails in legacy.

FossilOrigin-Name: 96afe50866a08ed14e911c3c955030f7ab83a3ed
2013-06-05 12:18:15 +00:00
drh
e353ee3898 Update some variable names and comments in the ORDER BY optimizer. Fix a
bug in the ORDER BY optimizer dealing with IS NULL constraints.  Updates
to test cases.

FossilOrigin-Name: cf96eb5945a9bab71104cb1581ee13ab30022566
2013-06-04 23:40:53 +00:00
drh
d84ce35bfd Restore the PRAGMA reverse_unordered_selects behavior.
FossilOrigin-Name: f49cd6c4e752e39801f9d5de0bc370d26f43837c
2013-06-04 18:27:41 +00:00
drh
907717fe07 Get the index-only optimization working for OR queries.
FossilOrigin-Name: 774d5ff857cfad3471401ed518ed0959eb912e6c
2013-06-04 18:03:22 +00:00
drh
aec93a1f2d Test case updates.
FossilOrigin-Name: 0360fec7c093870269211447e9642b5ee34ff778
2013-06-04 15:31:16 +00:00
drh
ee73b87181 Better determination of when an index is UNIQUE.
FossilOrigin-Name: 63fd025ad98c33826342824c51436ac92e2bb579
2013-06-04 13:37:26 +00:00
drh
73843cac73 Increase the estimated full-scan cost for an FTS3 table.
FossilOrigin-Name: 8d9f29f847f38612447c79a5fb366a9143ef6205
2013-06-04 13:07:44 +00:00
drh
ef71c1f090 Fix a display issue with EXPLAIN QUERY PLAN.
FossilOrigin-Name: ff2fa407558360f2499b6df0392ab3cdb4788dec
2013-06-04 12:58:02 +00:00
drh
7699d1c4e5 Refactor the ORDER BY optimizer in the NGQP so that it is easier to maintain
and so that it can support optimizing out GROUP BY and DISTINCT clauses.

FossilOrigin-Name: e605c468e3a1163167831c4a6220825c0b5d083b
2013-06-04 12:42:29 +00:00
drh
7c171098b7 Remove more vestiges of sqlite_query_plan from the test cases.
FossilOrigin-Name: eb27086e8a8a4d5fcb2ea358256a555e34339423
2013-06-03 22:08:20 +00:00
drh
a3855653ed Adjust the xBestIndex methods on both the fuzzer and transitive_closure
virtual tables so that an unused MATCH operator gets a really large cost.
Remove ambiguities from the fuzzer test cases.

FossilOrigin-Name: e2c1af78b65a8ace976fa6c035db212e1ffc79b8
2013-06-03 21:25:28 +00:00
drh
45c154ac90 Pull in recent trunk changes. Fix the ORDER BY optimizer so that it is better
able to deal with COLLATE clauses.  Clean up ambiguities in the descidx1.test
script.

FossilOrigin-Name: 6bc71dfcf0ef757c5c2b426dd8fddc1e5ae0f598
2013-06-03 20:46:35 +00:00
drh
f5ad80397d Fix a typo in a collating function inside the e_reindex.test script.
FossilOrigin-Name: 4d74fccf02134a998a84097b021ba9d501e34ff0
2013-06-03 20:39:15 +00:00
drh
e3b7c9216c Do not use an index fullscan for an UPDATE or DELETE or if disabled by
sqlite3_test_control() or sqlite3_config().

FossilOrigin-Name: fabb21854e662b1d8e5631e79f828d5322ceb595
2013-06-03 19:17:40 +00:00
drh
74990dce64 Resolve ambiguities in test cases in collate2.test.
FossilOrigin-Name: dcbbcb2e6c85780276cb3a392549f70e21e94408
2013-06-03 19:01:26 +00:00
drh
d2b113bc33 Fix a bug in the transitive_closure virtual table that NGQP exposes.
Update between.test module to avoid using sqlite_query_plan.

FossilOrigin-Name: aa66b864204b4b8717d845499132b987eb8ef924
2013-06-03 18:50:15 +00:00
drh
44dc8e822b Fix EXPLAIN QUERY PLAN row counts for the rtree virtual table tests.
FossilOrigin-Name: 15328987cc876d7a4e34561b6b0e08937aefe4be
2013-06-03 18:14:31 +00:00
drh
6f2bfad24b Update the NGQP to make use of STAT3 information if it is available.
FossilOrigin-Name: ff134e6ee95d41b0e59e03bba7e94bc15b04ff8c
2013-06-03 17:35:22 +00:00
drh
3b1d808fab Honor the orderByConsumed boolean returned from virtual table query planner.
FossilOrigin-Name: aaf7f5896d3523531e1a9a1b90c4ad326f0c8fc7
2013-06-03 16:56:37 +00:00
drh
5298630631 Fix to the logic that disables constraints on virtual tables.
FossilOrigin-Name: 62d382406b28c1347e13114f42215939ddfd7a9d
2013-06-03 16:03:16 +00:00
drh
3a5ba8b1b7 Fix an issue that was causing ORDER BY DESC to come out in ascending order.
FossilOrigin-Name: 029840124022387a8f6d2e1a685a003688d0ef3a
2013-06-03 15:34:48 +00:00
drh
d108d74d48 Virtual tables now always report 25 rows instead of 0 rows in the
EXPLAIN QUERY PLAN output.  Adjust tests accordingly.

FossilOrigin-Name: 7d91f688815597ff65ec04b7daa21cb9e5d6bf98
2013-06-03 15:24:11 +00:00
drh
21f7ff7d22 Set the WHERE_UNIQUE flag on loops that can only run once.
FossilOrigin-Name: 510f4d8ecf6eb284f14b91951e7236505bd71203
2013-06-03 15:07:23 +00:00
drh
6186b30901 Add test cases to verify that ticket [bc1aea7b725f2761] has been fixed in
the NGQP.

FossilOrigin-Name: 9b97af94ae7b1624ef1f5adee58010593fbb8b1c
2013-06-03 14:15:34 +00:00
drh
348d19c0c4 Enhance the shell to provide more flexibility when entering numeric arguments
on dot-commands.  In particular, allow hexadecimal arguments to .wheretrace
and .testctrl commands.  Cherrypick from [b9578c371ee5].

FossilOrigin-Name: 3bd5ad095b23102dd3379cb62997cbf23cc67b7a
2013-06-03 12:47:43 +00:00
drh
0e85ccfca5 Further improvements to error handling of the run-time loading of SQLite
into TCL.

FossilOrigin-Name: 7cc0c4ee11ad250fa848e7da4713d70fc0fa3715
2013-06-03 12:34:46 +00:00
drh
75b9340520 The NGQP might not find a solution if INDEXED BY constraints on the query
are set wrong.  If that is the case, print a "no query solution" error
and abort before trying to use the non-existant solution.

FossilOrigin-Name: 42511a7e12a70cf3436d25e4d069e5d309dfd678
2013-05-31 20:43:57 +00:00
drh
79a13bfd1e Do not search using ON clause constraints of LEFT JOINs to the right of
the table.

FossilOrigin-Name: 723f901a63313b64a9f10516711fb6136526b79b
2013-05-31 20:28:28 +00:00
drh
a1f4124cf8 Make sure a unique cursor number is allocated for automatic indices.
FossilOrigin-Name: 433d1aecd399590b767ebf07b32023fb718a6574
2013-05-31 20:00:58 +00:00
drh
0edc94dcc7 Do not attempt to generate code in the NGQP if there have been prior errors,
since with prior errors some of the expressions might not be fully 
named resolved.

FossilOrigin-Name: 665e4291c6e78f11d7181c18c5f2418d1adfcb1c
2013-05-31 19:14:56 +00:00
drh
76f4cfb2e6 Fix a problem with code generation on LEFT JOIN of tables without an index.
FossilOrigin-Name: 0b1bee92a0d25f409d5a95f484b05ddf10ae945f
2013-05-31 18:20:52 +00:00
drh
e22501721f Another virtual table fix in NGQP.
FossilOrigin-Name: 2f2ce4167728399cc30bef045aab500940af978c
2013-05-31 18:13:50 +00:00
drh
7e47cb8b75 Fix problems in the virtual table logic for NGQP.
FossilOrigin-Name: 23af28e24b8f7ffacd006978b25bab990a43b8c5
2013-05-31 17:55:27 +00:00
drh
8030dc7b1f Remove the definitions of objects that are no longer used: WhereCost,
WherePlan, and WhereBestIdx.

FossilOrigin-Name: 816f8add7e60de2ef8df4fdac090c244f8dbda39
2013-05-31 15:50:39 +00:00
drh
6dc8cbe0d4 Improved handling of errors when doing run-time loading of an SQLite
shared-library into TCL.

FossilOrigin-Name: b3f23d186425d2362b756708cbaf422ba3c751f9
2013-05-31 15:36:07 +00:00
drh
ae70cf1816 Allow tracing of whereLoopInsert() when the 0x8 bit is set on ".wheretrace".
Remove the use of sqlite_query_plan from where2.test.  Fix a bug in the
code generator for OR clause optimizations.

FossilOrigin-Name: 707f0323264c35be14847a6adc49a0dc5eaf4ad2
2013-05-31 15:18:46 +00:00
drh
84f1414b1a Enhance the shell to provide more flexibility when entering numeric arguments
on dot-commands.  In particular, allow hex arguments to .wheretrace.

FossilOrigin-Name: b9578c371ee569dca6a0964019959a93407c8ef9
2013-05-31 14:31:11 +00:00
drh
0afb423fd3 Futher enhancements to the ORDER BY optimizer.
FossilOrigin-Name: d8efa5f8b60bc4c8df8bfad077f87f76f7ee9bf6
2013-05-31 13:36:32 +00:00
drh
d044d209f3 Improved detection of unnecessary ORDER BY clauses.
FossilOrigin-Name: 58805eb36b9975706e2c4e382689519454e9a504
2013-05-31 12:43:55 +00:00
drh
53b52f7f2e Fix the constructAutomaticIndex() routine so that it works with NGQP.
FossilOrigin-Name: 5e1e61399513b4a95fd93df2377a2603f1670063
2013-05-31 11:57:39 +00:00
drh
dc3cd4b020 Improvements to the ORDER BY suppressor in the NGQP.
FossilOrigin-Name: 24a2e9ddcecd3926817d77abbb75d068ee7140ad
2013-05-30 23:21:20 +00:00
drh
1b0f026dbb Incremental check-in with various NGQP fixes. Many tests still fail.
FossilOrigin-Name: a51d8c92496436488e1a6eabd85785e8fedf2736
2013-05-30 22:27:09 +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
70bdcc738e The expected result in a test case can be of the form "*glob*" or "~*glob*" to
match or not match the GLOB pattern.  This is useful for matching
EXPLAIN QUERY PLAN output that contains regular expression syntax characters
like "?", "(", and ")".

FossilOrigin-Name: a3b4e261bd7e278f150872cce7b020af5ad8d2ed
2013-05-30 19:28:34 +00:00