Commit Graph

22354 Commits

Author SHA1 Message Date
drh
340558540e Allow multiple recursive terms in the compound SELECT of a recursive CTE.
This facilitates writing a query to find find the connected components of
an undirected graph.

FossilOrigin-Name: 5481fa8c79c34f434e99ab633ff3d0942a309a74fb0cf38e3d3617b51d5d21dd
2020-10-19 01:23:48 +00:00
mistachkin
a00a016740 Fix harmless compiler warnings.
FossilOrigin-Name: 7f8802bb7be61fdf7c7a591945d533d848bc46d2989f7739dd9ad89e1b6a9c65
2020-10-18 18:35:34 +00:00
drh
ff01ee34c9 Fix the SQLITE_DESERIALIZE_FREEONCLOSE flag so that it works as it is
documented to work.
See [forum:/forumpost/ba1dff667a|forum post ba1dff667a]

FossilOrigin-Name: d6fac8a1d3efeb2c4f03dae437b5b314765c93770a70603803a8039291dbcabb
2020-10-17 22:13:16 +00:00
drh
e93986a93b Fix an incorrect printf() in debugging logic in where.c.
Problem reported [forum:/info/80a9c47769772207|by forum post 80a9c47769772207].

FossilOrigin-Name: 883da4dadc88809192e4ed2f753f8883471fb43aa330bc58b017c66e1acedc6c
2020-10-17 19:09:04 +00:00
drh
71cb422055 Minor fixes to the cksumvfs documentation in the header comment of the source
file.  Enhance speedtest1.c so that it can more easily do performance
comparisons of cksumvfs.

FossilOrigin-Name: ed3bb818f58b75c087f2875331ec944397b6c61a5b14d8af4b9ec6f376bd1872
2020-10-15 17:59:38 +00:00
drh
f8c4c3a09f The windows VFS accepts query parameter "exclusive=true" to cause it to
take a mandatory file lock, preventing other applications from even
reading the file.

FossilOrigin-Name: 05b573fdb27abec7d75aa1375325d45043cfd674f5b346fb341f001d7e04d160
2020-10-15 14:37:27 +00:00
mistachkin
d5157e01b8 Enhancements to TclKit batch tool for MSVC.
FossilOrigin-Name: 2a8a4552112be6e39e3475e9a8579582b5157086d3efd37971463c0e3958068d
2020-10-14 21:31:20 +00:00
mistachkin
05881886a6 Fix typo in a documentation comment.
FossilOrigin-Name: 462adc7d6b14de3862c2a3e57dba7efaf2ba9c104e1c127a5801a7b892059872
2020-10-14 21:30:56 +00:00
drh
7207be402d Enhanced documentation for sqlite3_vtab_nochange() to make it clear that
it is an optimization and that virtual table implementations should be
prepared for it to always return false.

FossilOrigin-Name: 3e2643619d122616663688533977d6c60d45a269b4e2bdc330fd3ee5d39f2e03
2020-10-14 15:46:29 +00:00
dan
f6b0464e36 Fix some fts5 problems with signed integer overflow causing segfaults in -ftrapv builds.
FossilOrigin-Name: 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca6409d5
2020-10-12 18:09:16 +00:00
drh
c6712647c6 Improved quoting of the table name argument for the ".import" command
of the CLI.  See [forum:34591fefbe|forum post 34591fefbe].

FossilOrigin-Name: ce97b56d63d6e03b909e049a0a62251d98c7bf643448193a28b42a5871899387
2020-10-12 17:57:29 +00:00
drh
c196219dd4 Add options --data-only and --nosys to the ".dump" command in the CLI.
FossilOrigin-Name: 57123b14a71027c21cb5eee089fcbc9330d07bf9091b01aecc4f9e3b9e4f7b09
2020-10-12 16:54:28 +00:00
dan
936a30598e Fix ALTER TABLE so that it can run even if the schema contains unknown collation sequences.
FossilOrigin-Name: bc4bb9433fed519386511796cce475d74100b8ed707cdbffd8cbdf683b0faf35
2020-10-12 15:27:50 +00:00
drh
bbb29ecfb4 Add the --nosys option to the .schema command in the CLI.
FossilOrigin-Name: b72ee694532c0c5d2285dd580154546eb592fd6892cad9ad7a49e98737adb974
2020-10-12 14:56:47 +00:00
dan
4d906f1b5a Fix UPDATE FROM statements on virtual tables that are declared WITHOUT ROWID.
FossilOrigin-Name: bcb0bc6a7b7006f07adb7266b1fecca39bf85a0adea6d78a341623a3546f2c2a
2020-10-12 14:29:11 +00:00
drh
1ca037f41e Fix BEGIN IMMEDIATE and BEGIN EXCLUSIVE so that they work even if one or
more of the database files in the connection are read-only.  Test cases
for this are in TH3.

FossilOrigin-Name: 2fa08c3963f008d4723c3f4f4496abcb6d4b575c85ba4a911a6aed5730b5948b
2020-10-12 13:24:00 +00:00
drh
0897c3c056 In the CSV extension, use SQLITE_TRANSIENT rather than SQLITE_STATIC on
return values that can in fact change.

FossilOrigin-Name: 54b54f02c66c5aeaa3504c52a04614e2fb4d7260da8367840d5ea5a71cdc2fda
2020-10-07 11:24:45 +00:00
dan
f46be6a1b9 Allow fts5 trigram tables created with detail=column or detail=none to optimize LIKE and GLOB queries. Allow case-insensitive tables to optimize GLOB as well as LIKE.
FossilOrigin-Name: 64782463be62b72b5cd0bfaa7c9b69aa487d807c5fe0e65a272080b7739fd21b
2020-10-05 16:41:56 +00:00
dan
a344ad47f3 Do not apply affinities when creating entries for automatic indexes on views. Fix for [95302bdb].
FossilOrigin-Name: df12f097224ebc9473d9e2a8933bd7efed6490d09af2c012c9b59a7892369b7f
2020-10-03 19:16:36 +00:00
dan
12a6a1eaf9 Fix a segfault caused by running "column LIKE NULL" against an fts5 table using the trigram tokenizer. Fix for [e33ee62575fc22].
FossilOrigin-Name: 6e72a08de764077f2bba6f7e3b99ea29001941671a971f2ccf7ceeb9c682fb1a
2020-10-03 17:06:02 +00:00
dan
95dca8d0cf FTS5 does not handle tokens that contain embedded nul characters. Prevent the trigram tokenizer from returning such tokens. Fix for [2ba5930b2].
FossilOrigin-Name: b1d048748c054575425a4bebf0c5d09962f9329d5ce6a978cf54e508b238584c
2020-10-03 14:36:06 +00:00
dan
7093a3be03 Fix some test code so that testfixture can build with SQLITE_OMIT_WAL defined.
FossilOrigin-Name: dd009cd7aec3598e930806907601f4f0f9b0021ea99fa6c5e29e88f1246066ed
2020-10-02 15:15:18 +00:00
drh
7d14ffe4e1 Additional corner-case fixes for the in-scan-vs-index or OP_SeekScan
optimization.

FossilOrigin-Name: ad5ab24ebd557e7af1d92ab3fbcb3747c04da5ad4ed779fb6391dc94042687dd
2020-10-02 13:48:57 +00:00
drh
64208b50ce Remove an incorrect assert() from the OP_SeekScan opcode.
FossilOrigin-Name: c0400f8c0bcb85ba39004feff753eae2f8e82065539e52b5788febd7644c417b
2020-10-02 12:49:06 +00:00
drh
9bb612f2c8 Fix a faulty assert() statement. Add new test cases.
FossilOrigin-Name: 80ecdb3da4558bb08ee3ec6edbde906ad5b3b8182e672b5ba0d5dfa8041cee0a
2020-10-02 12:42:51 +00:00
drh
04e70ce07d For the OP_SeekScan optimization, the OP_IdxGT does not necessarily come
right after the OP_SeekGE.   So use the P2 operand of OP_SeekScan to point
to the first instruction after OP_IdxGT.  Problem found by dbsqlfuzz.

FossilOrigin-Name: 091d71939411bf2079098f09ddc0525f11f380119fd27114e2b3eec9a8ac0db4
2020-10-02 11:55:07 +00:00
drh
4ad1a1c74c Disable the OP_SeekScan opcode of the in-scan-vs-index optimization when
in PRAGMA reverse_unordered_selects mode, as the OP_SeekScan only works
with forwards scans.  Thanks to OSSFuzz for pointing out the problem to
us.

FossilOrigin-Name: c75c3a3b756635bfdab44e4b56a337e4a88af3a8803cd3e9a67abf3d0d3450dc
2020-10-02 02:02:18 +00:00
dan
d7d406e81c Add experimental "trigram" tokenizer to fts5.
FossilOrigin-Name: c4e8ec7907de7cb9e610ef9f4930caf5c046618151fb4f61d5716b9fa3f31423
2020-10-01 17:24:36 +00:00
dan
a22c1c84cc Add the -trigram option to the fts5txt2db.tcl script.
FossilOrigin-Name: a394dd260252e7b7dcbc90fd321dfd40d9375f0598ea52b01001c568cbdbafce
2020-10-01 17:15:12 +00:00
dan
ccf578d435 Add tests for the trigram tokenizer. Fix minor issues.
FossilOrigin-Name: 897ced99b44085012aa44d3264940dcbd4c77b295a894a1b58fb2c03a0f7fee8
2020-10-01 16:10:22 +00:00
drh
deaa61072d Fix the OP_SeekScan opcode so that its variable names do not cause problems
for the test/vdbe-compress.tcl script.

FossilOrigin-Name: 7a78274a072324b94d6f79e5b7a198b2fa9321ff5d6a528b51f57d3ee95c765b
2020-10-01 15:46:21 +00:00
drh
644f43c0f7 Remove a debugging printf() accidentally left in the previous check-in.
FossilOrigin-Name: e9d1efa597fb073dc4bc4286e03059a350ed05d3e6476cd3247e6cde626f458b
2020-10-01 14:38:39 +00:00
drh
67306cb3b4 The IN-early-out optimization does not work for virtual tables. Do
not try to use it there.  Fix for ticket [2d5a3163563d559f].  Test
cases in TH3.

FossilOrigin-Name: dbec6910d9648f4907373c818a5cb347a2e487784208751ccecfacca752ff99d
2020-10-01 14:36:15 +00:00
dan
33a99fad08 Add experimental unicode-aware trigram tokenizer to fts5. And support for LIKE and GLOB optimizations for fts5 tables that use said tokenizer.
FossilOrigin-Name: 0d7810c1aea93c0a3da1ccc4911dbce8a1b6e1dbfe1ab7e800289a0c783b5985
2020-09-30 20:35:37 +00:00
drh
fad4dd0fd1 Improved query optimization for multi-column indexes where the second or
later columns are constrained by an IN operator and the earlier index columns
limit the search to a small number of rows.  Use the new OP_SeekScan opcode
which does scanning of the relevant range of the index but gives up and
falls back to doing a seek if the number of rows scanned grows to large,
in order to guard against pathological cases where the estimated number
of rows to be scanned is far too small.

FossilOrigin-Name: 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5
2020-09-30 18:06:51 +00:00
drh
4f65b3bbfb For the OP_SeekScan opcode, adjust the number of steps run before giving
up based on the estimated number of comparisons needed to perform a seek.

FossilOrigin-Name: dc4172e6b8e1f62dc7329a3adb2223f290bc4c8055c265e88182ef432f4bcf10
2020-09-30 18:03:22 +00:00
drh
395a60dad4 Back out the incorrect optimization of check-in [e51ecadcbdef5ce6] as
ticket [5c4e7aa793943803] reports a case where the optimization does not
work.

FossilOrigin-Name: 7395e96b8cc370c8ac2657fb805915b0992a15d80f8bf256d277b423fec64675
2020-09-30 17:32:22 +00:00
drh
af3711536b In the query flattener when substituting expression Y in place of expression X,
if X is marked has having come from an ON or USING clause of a LEFT JOIN, then
be sure that all subexpressions of Y, not just the root node of Y, are
similarly marked.  Otherwise, if Y is an AND operator, it will be split up
during WHERE clause analysis and the subexpressions will not get the special
treatment needed by LEFT JOIN ON/USING clauses.
Fix for ticket [66e4b0e271c47145].

FossilOrigin-Name: 69f9eb7343a416c5ab426c8e1b9f0ae576544b4ccc5d87f5481c8ff884f696e1
2020-09-30 15:36:03 +00:00
shearer
1e6c58dee2 Better understanding of savepoint code
FossilOrigin-Name: ce6d8d621505f25e4fd43e7cf27445e1a2ddd58d79108d63499c2ae30cc9f610
2020-09-30 09:17:53 +00:00
drh
a957e22fa4 Add an sqlite3FaultSim() call to btreeNext() to make it easier to
simulate I/O errors in calls to sqlite3BtreeNext(), and in OP_SeekScan.

FossilOrigin-Name: 29cca775d3f5411624f0a8d55d34a038a24f1009d25b097315adb64e70c4b299
2020-09-30 00:48:45 +00:00
drh
f287d00108 In the OP_SeekScan opcode, changes to pOp must occur after the call
to VdbeBranchTaken() so that the VdbeBranchTaken() attributes the branch
to the correct opcode.

FossilOrigin-Name: 61fbe7aa7cc0e8fe3e6b1c5aec277183d8cd7c86b1e835c38e0b37a9b8063343
2020-09-30 00:10:22 +00:00
drh
a54e1b1fc8 The OP_SeekScan opcode is a no-op if the cursor is not pointing to a valid
row upon entry.

FossilOrigin-Name: 4afc96b5fe80bd192a23e0230edc207e641931c3bf48296b1a385c786386f1b7
2020-09-29 23:52:25 +00:00
drh
0b2949c36e Coverage testing of the OP_SeekScan opcode. Fix a problem that comes up when
OP_SeekScan reaches the end of the table.

FossilOrigin-Name: 9e57e758a6a33f54d28a546b4eebfb5cfacef30dc4e0207e43bb9d2c06fc3439
2020-09-29 20:22:19 +00:00
drh
dfbaae7572 Improved comments on the new OP_SeekScan opcode.
FossilOrigin-Name: 6110fdd5bb7b4ae5c065404c802ae726362ef084966b73cffe58c4bfb98689d2
2020-09-29 17:29:11 +00:00
drh
c40076a8cf Improved performance by manually in-lining the sqlite3VdbeIdxKeyCompare()
routine for the OP_IdxGT opcode and its kin.

FossilOrigin-Name: 2206a2c848a122ee220c89427f9be0460cba0706f58852139d7b37184ce29a29
2020-09-29 16:05:09 +00:00
drh
46f0f4e56d Typo fix to repair the early-out optimization. Also avoid unnecessary
OP_SeekHit opcodes.

FossilOrigin-Name: 8fd7d8dfcd515aa6b65d6eb27b033d3b3a31db467b9100cc13c62bc60113019e
2020-09-29 15:32:54 +00:00
drh
f761d937c2 The OP_SeekScan opcode works, but using it requires disabling the
IN-earlyout optimization because the OP_IfNoHope opcode might move the
cursor.

FossilOrigin-Name: f3c36b840c9a29c0add28039db216f4207a308e5057fc76e3f0004024a8267ac
2020-09-29 01:48:46 +00:00
drh
68cf0ace3d Revisiting the IN-scan optimization to try to fix it for the corner case
where the statistics deceive the query planner into using a scan when
an indexed lookup would be better.  This check-in changes the code
generation to do the IN-scan using a new OP_SeekScan opcode.  That new
opcode is designed to abandon the scan and fall back to a seek if
it doesn't find a match quickly enough.  For this work-in-progress check-in, 
OP_SeekScan is still a no-op and OP_SeekGE still ends up doing all the work.

FossilOrigin-Name: d720b6981eeb0ffdb14494ca63eca298ee724ae4ad4863c7c7cbfdad7fa52519
2020-09-28 19:51:54 +00:00
drh
75fa266341 Small performance improvement and size reduction by reducing the size of
the WhereTerm object.

FossilOrigin-Name: 43f7ddad800acf40917c5cc3d926640dbec17c34d5f1cbbb74bd80f44eeed0a5
2020-09-28 15:49:43 +00:00
drh
f573b4fb94 Avoid the possibility of integer overflow on the --pagecache option to
the CLI. See [forum:10a2892377|forum post 10a2892377]

FossilOrigin-Name: d3d13df31a97648f952beb2e1a783f947a80ec843227985ad9ebd14452d2f654
2020-09-28 13:34:05 +00:00