Commit Graph

17524 Commits

Author SHA1 Message Date
drh 1a17b44231 When doing a DISTINCT query using an index, try to use the index to skip ahead
to the next distinct element, rather than doing a full scan of the index.
(This is the "skip-ahead-distinct" optimization.)

FossilOrigin-Name: f489b5bb6b35665befdd411c2c55df5258e83cba265d8c4427ba22529cf882a4
2017-04-14 17:30:43 +00:00
drh 399c7e21e4 An initial attempt to optimize VIEWs that occur as the right operand of a
LEFT JOIN.  This particular check-in does not work correctly because it does
not deal with the case of columns in the VIEW that return non-NULL even when
all columns in the table of the VIEW are NULL because of the LEFT JOIN.

FossilOrigin-Name: 1838a59c8a1c151bd6fc822b0ffef661803cf0e4704c917e74a04567b81740b9
2017-04-14 17:18:45 +00:00
mistachkin b1ed717f18 Make USE_FULLWARN=1 the default for MSVC and fix harmless compiler warnings.
FossilOrigin-Name: 6bf673767b8e5cedef1acff795cbe524fab8db2525c06424db4e038934a33936
2017-04-14 14:50:34 +00:00
drh d97cda43ab Enhance the sqlite3TreeView() display for Expr objects so that it shows
the iRightJoinTable value for Expr nodes that have the EP_FromJoin property.

FossilOrigin-Name: 5159cb8f2bcfb1f7114786ba23082d2b91a26e3a7ddfae75f8bd362792949d5e
2017-04-14 14:02:14 +00:00
drh 46967de2ec Simplify the interface to the subst() routines that are part of the
query flattener by collecting common parameters into the SubstContext object
and passing around a pointer to that object.

FossilOrigin-Name: e651074be28b2077b8a298f513e2e699ceca99164ace9869ea50873c0637fd2e
2017-04-14 12:39:37 +00:00
drh 7c88bcd473 Remove an incorrect ALWAYS().
FossilOrigin-Name: f956f6ae6b0863c70c4a2b227338d5c332e87f2ec6f3fcdf2233c14c5b78ca2b
2017-04-14 12:27:45 +00:00
drh 571311502d Fix a couple of unreachable branches.
FossilOrigin-Name: 1aa0ea8db7580aff8bed2f78117ed50019e5545cef48cab782f512a2599fd0c5
2017-04-14 00:45:51 +00:00
drh 172806e489 Fix the skip-ahead-distinct optimization so that it works with indexes that
have repeated columns with different collating sequences.

FossilOrigin-Name: ce1e2b88777e00a82c04abe5ba35eec81b5f324e462f099cd00b21054f369688
2017-04-13 21:29:02 +00:00
drh c04ea80f64 Simplification of the skip-ahead-distinct logic. There is still an issue
with handling COLLATE.

FossilOrigin-Name: 57c5173b6376a76013b0611ce9770100bd8c04e80402e35d821d8614709f4795
2017-04-13 19:48:29 +00:00
dan a74f5c2923 New test cases and minor fixes for the optimization on this branch.
FossilOrigin-Name: 70ac9ea1a6cb2f4906f00f1a04f668e5ba5eeed8d4d0fa4be57a9c9eb0683697
2017-04-13 18:33:33 +00:00
dan d0a537100c Reinstate the SQLITE_API qualifier on the sqlite3_delete_database() method in
test_delete.c. Accidentally removed by the previous commit.

FossilOrigin-Name: 59c70108fd179932ccdd860f93e1cd68b77476d3b1af1af00cf6e378c9984862
2017-04-13 15:51:27 +00:00
dan 44ae27ac32 Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is
defined.

FossilOrigin-Name: fa9bb7b768027677f7e7d5a196ba5b245dfc8d8986ccd101c8dab671bd15719d
2017-04-13 15:36:47 +00:00
drh 839fa6d814 Only use the skip-ahead-distinct optimization if the index has been analyzed
and we know that a skip-head is likely to skip over at least 11 rows.  The
magic number 11 was determined by experimentation.

FossilOrigin-Name: 0cf16decd534bf2d66620c293f8c8987f356305f2d97f8fd12d260bda1571385
2017-04-13 13:01:59 +00:00
dan 929b695111 Allow a user column name to be used on the LHS of a MATCH operator in FTS5.
FossilOrigin-Name: 6f54ffd151b0eca6f9ef57ac54802584a839cfc7373f10c100fc18c855edcc0a
2017-04-13 09:45:21 +00:00
drh 8489bf5aff Forward port the skip-ahead-distinct branch which was abandoned for some reason
that I do not recall.  This port should have been achived by a merge of trunk
into the previous head of skip-ahead-distinct, but that did not work.  So I had
to manually "rebase" the changes.

FossilOrigin-Name: 132339a1fb0b9664df4d3eefbed6e77ef100ba95a91dcc622da7bd3fcdfcd6af
2017-04-13 01:19:30 +00:00
drh 8671538cad Fix a regression caused by the fix for ticket [6c9b5514077fed34551f98e64c09a1] -
control characters allowed in JSON.

FossilOrigin-Name: 8e7b611863247a3bf46a96ec4b47d24c0ae0d60c9cee968a1cfd1da157e7c9bb
2017-04-13 00:12:32 +00:00
dan 03155f659f Update fts5 to support "<colset> : ( <expr> )" for column filtering, as well
as "<colset> : NEAR(...)" and "<colset> : <phrase>".

FossilOrigin-Name: c847543f8bb1376fef52bca72b4191162a32eb7e6c5f0cd1aa0ab116b3183396
2017-04-12 17:50:12 +00:00
drh 26849e14c2 Improved \n and \r escapes in the ext/misc/dbdump.c utility function. The
implementation of dbdump.c now matches the implementation in the CLI.

FossilOrigin-Name: f2643315bb41a71eebd79f5d671f9163187e299a52ff8a481186f1e8fa7e5262
2017-04-12 17:38:24 +00:00
dan 15e0f3d901 Avoid updating unaffected indexes on a table as part of an UPDATE that
requires foreign key processing in some cases.

FossilOrigin-Name: 7aae5c0f99aa2fda85654242cfc9e23a0f981d9ce4ab17610d619cd208540b3d
2017-04-11 20:48:30 +00:00
dan 940b5eaa5e Avoid updating unaffected indexes on a table as part of an UPDATE that requires
foreign key processing in some cases.

FossilOrigin-Name: 477bea9ed0dd0fa69896bfd16d9b1d22170cbab784e3279ce65c29c47e032f34
2017-04-11 19:58:55 +00:00
drh ff6d50e973 Limit the depth of recursion for valid JSON in the JSON1 extension in order
to avoid using excess stack space in the recursive descent parser.
Fix for ticket [981329adeef51011052667a9].

FossilOrigin-Name: 1f68c184596912d742b50b1ca38252a9e783aacf121619a27b17a7ae9f6df041
2017-04-11 18:55:05 +00:00
drh e97c9ff49a Smaller and faster implementation of exprMightBeIndexed().
FossilOrigin-Name: 76cd611d41465fcec61c21520d55172cb236530f38386b7d4a5544ba87de2353
2017-04-11 18:06:48 +00:00
drh ef90a6b8dd Very slight smaller and faster sqlite3SelectNew()
FossilOrigin-Name: 4143650c4ce32289d2301cdfc69bb10877246420f656bed122886f6803fc956a
2017-04-11 16:44:39 +00:00
drh cbae543a5c Add an ALWAYS() around an unreachable condition in sqlite3VdbeMemGrow().
FossilOrigin-Name: 0f3eb61f44c94234ffc14c3a493a27ec62c0d1e2bb62798f36eafa98ddcdc58e
2017-04-11 12:20:54 +00:00
dan b8d29c2f75 Fix a segfault that could occur if an indexed expression was used in a
comparison operation within the result-set of a SELECT statement.

FossilOrigin-Name: d6bb7c42ff6309ce168ccdcf03b4cdabfccfc9e2a911d254ac7dc4fea4aa2bc1
2017-04-11 11:52:25 +00:00
drh d6e992cb1e When using an index on an expression, try to use the columns of the index
rather than pulling columns from the table and reevaluating the expression.

FossilOrigin-Name: a47efb7c8520a01110ce3b3531ebe1bab6720780d67fba001992c44c5807d332
2017-04-11 01:30:42 +00:00
drh eac5fc0476 Improved comments. Fix a problem when an indexed expression is used in an
ORDER BY clause.

FossilOrigin-Name: c59eaf2b7cd2596733f349fc0fe979f71fd29bd73152a0c57066e0b69d5b7a4a
2017-04-11 01:01:27 +00:00
drh 2f8b37850c Merge changes from trunk.
FossilOrigin-Name: 8978465f335925378d3aa99df6190ce6a1ee6b130205ccc493f2399803844760
2017-04-10 23:42:04 +00:00
drh 0415d826c0 Smaller and faster vdbeFreeOpArray()
FossilOrigin-Name: e052436d9f54b785facd661adc648512356b831c0547aa8f347ebf4bd8ef1254
2017-04-10 20:51:21 +00:00
drh 4c6463cc29 Slightly smaller and faster sqlite3VdbeMemGrow().
FossilOrigin-Name: efd1702ae8da8e0dd3d2ee7bd5a1bd8aeff2b370498e404041fcb406fdaf72e4
2017-04-10 20:27:54 +00:00
drh 2ac702d8c0 Add a new JSON test case to verify that all control characters are escaped
in the json_quote() function.

FossilOrigin-Name: 6ee12221fa252784c897a24ae8cff64dfe6149cbc9020abe14539df33202d892
2017-04-10 12:31:15 +00:00
drh e12e24ded8 Change the JSON extension so that it disallows control characters inside of
strings.  Fix for ticket [6c9b5514077fed34551f98e64c09a10dc2fc8e16].

FossilOrigin-Name: 475d8f82ec61a4ff3e6a7650731230ccecb6cc580d1397d189d0ba479d9bad4d
2017-04-10 12:25:05 +00:00
drh 7a6ea93fd8 Do not expose the name of the internal Mem object in the public interface
defined by sqlite3.h.

FossilOrigin-Name: 19dd753f9e50fee247b1ab141669817c7e88bc3f6d6065dba6c731db9f7a2409
2017-04-09 19:23:55 +00:00
drh 9fa866a8d9 Disallow leading zeros on numeric constants in JSON.
Fix for ticket [b93be8729a895a528e2]

FossilOrigin-Name: 204e72f0080e8f08f99978870bd3cb9d59b068ecffee82192d707c650548b43b
2017-04-08 18:18:22 +00:00
dan a34adaf667 Expand on the comment above OP_Destroy to explain why it throws an error if
there are any active reader VMs.

FossilOrigin-Name: b9a8c2b9bec9f537b2d5aff6659a5748b1f70b53519a1f9dfceb5209154eca8e
2017-04-08 14:11:47 +00:00
dan 5b09d13a58 Have the rtree module close any open blob-handle within the xSavepoint method.
This prevents such an open blob handle from interfering with DROP TABLE
operations.

FossilOrigin-Name: fa4416adc2a9a3a80db1d5befc0b95c3d0fc41affe38f7f2f45cdfae3f1b49eb
2017-04-08 13:52:41 +00:00
drh 13fe138b0a Fix the quoting mechanism for ".dump" so that it is not applied for the
".mode quote" output.

FossilOrigin-Name: 78c1e90305d48917d9423d8e50a7dfd15ec27aa93cb421610062229c7ede13a6
2017-04-08 13:42:55 +00:00
dan be0bc8bb4d Have fts5 close any open blob-handle when a new savepoint is opened. This
ensures that fts5 does not prevent DROP TABLE statements (which always open a
savepoint) from succeeding.

FossilOrigin-Name: a921ada89050ce1d162fd1b0056939573635e2cec7ac0c2a99ae924b3ae593f7
2017-04-08 09:12:20 +00:00
drh 297e2bdb8e Make sure the RTree sqlite3_blob handle is reset prior to renaming the table.
FossilOrigin-Name: 1cdae2db3c54970a1811e597065724578408c84d49d75b8fe25d56281ddc2e94
2017-04-08 01:09:14 +00:00
drh 72507d431b Fix the ".dump" command so that it works with ".headers on". Also fix the
display of ".mode insert" with ".headers on".

FossilOrigin-Name: a6ce57ee3c7f3527554a75cc1dd5ebcd33c944d4dca07b134d103596a2ae5b32
2017-04-08 00:55:13 +00:00
drh 98368eeb2c Use replace() instead of char() to quote newline and return characters in
strings in the output of .dump, to avoid excess expression complexity.

FossilOrigin-Name: 7307352988174a6c2756dbbe200bf62a45fb4cc1da7faa2c6b0f75e229eab703
2017-04-07 20:20:08 +00:00
drh f1824a77b0 Remove an unused token type.
FossilOrigin-Name: 13a422230dcf4a8a80434af97434d57e456dcaa6bf0c41e6859f37ded6fa96ca
2017-04-07 19:52:13 +00:00
drh aca19e19a8 Proof of concept for the ability to use the expression columns in an index
on expressions in place of equivalent expressions in the result set or in
the WHERE clause.  This check-in compiles but is mostly untested.

FossilOrigin-Name: a52ef2ad7c0e14b78b801f16a1f6ea8d8fa9ae5d7d810e18dd24c600b662a312
2017-04-07 19:41:31 +00:00
drh 6193d49cdf Use replace() instead of char() to quote newline and return characters in
strings in the output of .dump, to avoid excess expression complexity.

FossilOrigin-Name: 4c2b572969ea2ed2a925444ecfa356aa877018cbb9c4f57d081ab4b535cd1dd0
2017-04-07 11:45:58 +00:00
dan 54e2efcd2f Fix the ".lint fkey" shell command for cases where the child key is also an
INTEGER PRIMARY KEY.

FossilOrigin-Name: 48826b222c110a90996a84605318ea6b1e502b8c5129f4d561f8350dbdbcd264
2017-04-06 14:56:26 +00:00
dan 50da9382f9 Fix the ".lint fkey" shell tool command so that it works for foreign keys that
refer implicitly to primary key columns with non-BINARY default collation
sequences.

FossilOrigin-Name: 327eff25ba2420267cc8dc49dd3c3aab45f4bf9e060d1ad480e25d016d21f3ba
2017-04-06 12:06:56 +00:00
drh 6948ed5977 Remove a confusing and pointless sentence from the documentation for the
sqlite3_interrupt() interface.

FossilOrigin-Name: c5f1a2b6eb3df879d247a22b3f92f4f74fcf4f0d219450abc420ae6d02481324
2017-04-05 13:44:40 +00:00
drh dbd6a7dc06 Split off sqlite3DbFreeNN() from sqlite3DbFree() and use it in cases where
we know that the argument to be freed is never NULL.

FossilOrigin-Name: ad90e8bb5e47945607c8fb47b6ade8cfc52a9b684805cc40132629be0ecc14cc
2017-04-05 12:39:49 +00:00
drh ac48b751e2 Save a few bytes and a few CPU cycles in sqlite3ExprListDelete() routine.
FossilOrigin-Name: 9e6c939144a129b36bb119120442a4a021e00187783da211315d4bb13acd7c3a
2017-04-05 11:57:56 +00:00
drh f4dd26c5a0 Remove a conditional made unreachable by the previous ExprList enhancement.
FossilOrigin-Name: a1cf44763277b6c745b5b5509ca9129b6c3231608b4d1c8aec2815b64b5a2a07
2017-04-05 11:49:06 +00:00