Commit Graph

19367 Commits

Author SHA1 Message Date
dan
c0bb4459d3 Fix another issue to do with window-functions in aggregate queries.
FossilOrigin-Name: 6413e38a174044c28fa9b8b937e6c972d144547a246e6f2882e782538300d042
2018-06-12 20:53:38 +00:00
drh
5174f17485 Documentation update: clarify that sqlite3_errcode() and related interfaces
do not themselves modify the error code.

FossilOrigin-Name: 858fc52b237702b5e0381eebf5c158bffd7371ff0053a8583b8c175f8f691c82
2018-06-12 19:35:51 +00:00
drh
3086529f7c Documentation updates: clarify the behavior of sqlite3_column and
sqlite3_value interfaces following an OOM error.

FossilOrigin-Name: 428c581e4bed1d140cfb670633c9c61b36be7bb30a862d2e1ae7eaee26dccb4f
2018-06-12 19:22:30 +00:00
dan
7392569f5e Fix some problems with using window-functions in aggregate queries.
FossilOrigin-Name: fe7081e0952950f577234fcbb58f3c1efa4579267654fd2f713dc4804e470e7e
2018-06-12 18:40:17 +00:00
drh
58773a533c Improvements to SCopy correctness tracking when SQLITE_DEBUG is enabled.
FossilOrigin-Name: b2973f2357a2c5e22e0d612c970adbc6d51cbc5e4ff7ac6d2b678722e553e8ec
2018-06-12 13:52:23 +00:00
drh
cd9e01427d Fix the "Synopsis" on the OP_BitNot opcode.
FossilOrigin-Name: acd78df61188591d33ddb9b1b8c16bcc015f4dffac66314529caa747d4395c70
2018-06-12 13:16:57 +00:00
drh
dd2a8f5ee9 Improvements to the --enable and --disable options for the
amalgamation tarball.

FossilOrigin-Name: 02e337e0808947c7ef376b5a300cd3c461f1a368c9fe7ffd7ca5744f102641c2
2018-06-11 21:33:08 +00:00
dan
2a11bb23eb Clarify the relationship between a Window object and its associated Expr.
FossilOrigin-Name: 0cd55e98a478740032f5569ddc00fa5b0e063e90db6e00ac7598c9b7c2fffeee
2018-06-11 20:50:25 +00:00
drh
8fa622d62b Fix various --enable and --disable options on the top-level configure
script.

FossilOrigin-Name: 6fd7e8ceb96981cff023653a54b85bea0e1da3d706cd9f4383f5c5533213ef4d
2018-06-11 19:47:14 +00:00
dan
26522d1c45 Fix handling of window frames containing negative number of rows. e.g. "ROWS x
PRECEDING AND y PRECEDING" where (x<y).

FossilOrigin-Name: b6d9c7eda853420ae46a05bd432711e8bf9ebaa448c7d90ccfc0bcc338a87706
2018-06-11 18:16:51 +00:00
drh
ea64715976 Fix the column cache invalidation logic in the code for ROWID uniqueness
constraint checking in the INSERT command.  This fixes ticket
[c2432ef9089ee73bd].

FossilOrigin-Name: 0b485a571c805a5bc431a231a196ff6034342c6548d92b09c52814dd57c89c75
2018-06-11 18:06:48 +00:00
drh
299bf7c2f0 Add the OP_SetTabCol and OP_VerifyTabCol opcodes, only when compiling with
SQLITE_DEBUG, to do run-time verification of the column cache.

FossilOrigin-Name: b37614a3670770919a7c7f8157c5fd6578d736447998640b52e5cef8174cadc2
2018-06-11 17:35:02 +00:00
drh
8d7b212c4c Strengthen the sqlite3VdbeMemAboutToChange() run-time verification mechanism
to better detect missed calls to AboutToChange().

FossilOrigin-Name: 793e942205a12eedb7ecc5ad8a27e3e52bbd4e1d50a0d1453d04a83ba728884e
2018-06-11 13:10:45 +00:00
dan
72a9f0233b Fix a typon in main.mk.
FossilOrigin-Name: e74f86f271d6ab1ecd17c1ee63ab2aa0885ca56624be7382872f04d46c48ed86
2018-06-11 11:19:35 +00:00
drh
9c3549aa2f Always initialize the WhereClause.hasOr field that was added by check-in
[292724ffc4].  Error detected by OSSFuzz.

FossilOrigin-Name: 9faf41713e865f26485d9e90918d77c25be211384941eadda6a36237f52c25de
2018-06-11 01:30:03 +00:00
dan
980cf25b10 Update Makefile.msc to include window.c in the build.
FossilOrigin-Name: 16db73842ade5eb0fe02f257b91d1c7b41d830d3f17f8638b8fbaed309d9a852
2018-06-10 07:42:35 +00:00
drh
074544d181 Fix a typo in the amalgamation autoconf file.
FossilOrigin-Name: de0857f39620b7f5c921ddf8d11b11723b4ba3cfe52e43cf77e883697b7c1c4c
2018-06-09 20:52:45 +00:00
dan
96f55d0fa5 Merge recent trunk changes with this branch.
FossilOrigin-Name: c71f23590c25b4cecd27722e6c0fc8e3bf320d399c7d9398b7016dd5cf5b05eb
2018-06-09 18:09:44 +00:00
dan
d31e7addd6 Update the amalgamation build script to include window.c.
FossilOrigin-Name: 21d2f4a62eceab0de0b4669bf3e81eb71512211ed710ce0eb525695fb7309d6b
2018-06-09 17:58:51 +00:00
dan
8b98560d6e Add support for FILTER clause on aggregate window functions.
FossilOrigin-Name: ceaf798ea09184bc0e7d3dcf3ad4d909d2e4e7018754a8417a813f33010140a7
2018-06-09 17:43:45 +00:00
drh
4ece2f2657 Slightly smaller and faster code by encapsulating wal-index hash table
location information in a separate WalHashLoc object rather than passing
around the various elements as separate variables.

FossilOrigin-Name: 538a365b7a32ab7fa84f59d7556242cfb59b76d287b6417eb3a823197a354e8e
2018-06-09 16:49:00 +00:00
drh
a46ba6cca5 Improved comments an presentation for the recent IN operator decision
improvement.

FossilOrigin-Name: 31e480f68dfd887cfd9114f9f9fec53d751d3ecc27e36f55c0166b51b2fbb08c
2018-06-09 14:13:46 +00:00
drh
ccf6db5e64 Performance improvement to sqlite3WhereExprUsage().
FossilOrigin-Name: fd0934139076848f2f2edfd3d74d54608531031a05a60ca6ac1d7016dcd538df
2018-06-09 02:49:11 +00:00
drh
1fe3ac7347 Compute the bitmask of indexed columns for each index once when the Index
objecct is constructed, instead of recomputing it every time it is needed.

FossilOrigin-Name: d735872ec383bbd220b08c61d25db9ff3675d2542b9e7867e7d6323a12e0cc23
2018-06-09 01:12:08 +00:00
drh
da230bd484 Avoid invoking the whereLoopAddOr() routine in the query planner if there
are no OR operators in the WHERE clause, thus speeding up query planning
slightly.

FossilOrigin-Name: 292724ffc4bfca435fff309383d488ffdbe1e314e5eb26da21cf2f621b64bce5
2018-06-09 00:09:58 +00:00
drh
7128b7c1f4 When the query planner has the opportunity to use an IN operater constraint
on a term of an index other than the left-most term, use the estimated number
of elements on the right-hand side of the IN operator to determine if makes
sense to use the IN operator with index looks, or to just do a scan over the
range of the table identified by the index terms to the left.   Only do this
if sqlite_stat1 measurements are available as otherwise the performance
estimates will not be accurate enough to discern the best plan.  Bias the
decision slightly in favor of using index lookups on each element of the IN
operator.

FossilOrigin-Name: 2cbbabdf5ef624d809fbb40d2d312a29e0b5f02756fc0dbf6985fc8b0c8d1ade
2018-06-08 23:23:53 +00:00
drh
6d6decb8d9 Only choose to scan an IN operator rather than use an index if we have
real STAT1 data to suggest it is advantageous.

FossilOrigin-Name: 30e874661dcc1a2ecb40df2ef74582151d85bb36c754a38548829a3b6285f18d
2018-06-08 21:21:01 +00:00
dan
e3bf632cc2 Add support for the WINDOW clause.
FossilOrigin-Name: 19c983b511f1c823fdfb051713681b4c779f02fa83b41189afca0a9b8b72048d
2018-06-08 20:58:27 +00:00
drh
982c41977c Merge the btreeNext() assertion bug fix from trunk.
FossilOrigin-Name: 11bd66e09035039fbfc4c5631196962dd3f2e6634f5123a7b2fec17aeaaab07b
2018-06-08 19:54:07 +00:00
drh
f3cd0c82df Fix an assert() that can be false for a corrupt database and a strange query
that uses a recursive SQL function to delete content from a corrupt database
file while it is being queried.

FossilOrigin-Name: 99057383acc8f92093530e216c621d40386a06fe98131ff0af6df524d80a6410
2018-06-08 19:13:57 +00:00
drh
da4c409aea Consider doing a partial table scan to fulfill an IN operator rather
than using an index.  Try to pick the plan with the lowest cost.

FossilOrigin-Name: 1fa40a78fef4516c39b217bff67efe7e7d2077cca00aae0ef5c2c9cff94f008b
2018-06-08 18:22:10 +00:00
dan
dacf1de95c Do not flatten sub-queries that contain window functions.
FossilOrigin-Name: 236cb75bd1f0d5eb86aa5f52d8d548e7263c34633833dcea9dfc934f142113b8
2018-06-08 16:11:55 +00:00
dan
03854d2ecc Fixes to allow group_concat() to be used as a window function.
FossilOrigin-Name: 89bbc9ba8f66853a7530453f146c9df1baacd8558468016cefa7602911f7578a
2018-06-08 11:45:28 +00:00
dan
07509f8c1e Merge latest trunk changes with this branch.
FossilOrigin-Name: 251022034219819a1dc356542770ff46e3147a080f072eb20af6106771dadd92
2018-06-07 20:35:28 +00:00
dan
fe4e25a0f6 Add window functions lag() and lead().
FossilOrigin-Name: ef34207073c21ce8618486777671ae78d23f290acd6d3c37e91a49b69cb506ac
2018-06-07 20:08:59 +00:00
drh
83193d0133 The IN-early-out optimization: When doing a look-up on a multi-column index
and an IN operator is used on a column other than the left-most column, then
if no rows match against the first IN value, check to make sure there exist
rows that match the columns to the right before continuing with the next IN
value.

FossilOrigin-Name: 09fffbdf9f2f6ce31a22d5a6df7a45f19a16628da622f12d6e33171cce09fb21
2018-06-07 18:13:49 +00:00
drh
cf025a8c18 Fix the assert()s in the byte-code engine that prove that cursors
are unidirectional.

FossilOrigin-Name: 4b0b4e14039469b656662312a5f80f086ede293e9ad04c7bc99a202b683a1e55
2018-06-07 18:01:21 +00:00
dan
7095c002b8 Add support for window function first_value().
FossilOrigin-Name: 060b26402880daab085ad01f5f0dbde957c7a22cd219be5b8ec94fba883051a0
2018-06-07 17:45:22 +00:00
drh
f1949b6634 Remove the NextIfOpen and PrevIfOpen opcodes which are no longer needed
when the IN-early-out optimization is working.

FossilOrigin-Name: 439c8162272795b422a0e01b01b832fbc12b39914c9632a674162af8bdecff98
2018-06-07 17:32:59 +00:00
drh
056f5396fe Test cases.
FossilOrigin-Name: 085e863713a3f2d420c0076b275a6ac445a59d4d93f9eb0e8503b4e3f5589249
2018-06-07 16:07:00 +00:00
dan
2e60568fef Fix problems with the nth_value() function.
FossilOrigin-Name: 63002b9a090397668b94fe341a035c42f84e4837af85395bce4cd1c2777c5209
2018-06-07 15:54:26 +00:00
drh
64c1f77a8e Merge the ".stat/.eqp" CLI fix from trunk.
FossilOrigin-Name: a91cad3381bb843d6f58975251bf99f0fa1a1398fae53d97a98a6c8ee65e718e
2018-06-07 15:28:40 +00:00
drh
3c49eaf4be Avoid using a prepared statement for ".stats on" after it has been closed
by the ".eqp full" logic.  Fix for ticket [7be932dfa60a8a6b3b26bcf76].

FossilOrigin-Name: bb87c054b1b76959e46258ac66b24027f468b390a4148ac67f208a1fbeda4060
2018-06-07 15:23:43 +00:00
drh
f7b0a5f3c3 Add the WHERE_IN_EARLYOUT flag and use it to clarify the logic of this
optimization.

FossilOrigin-Name: 522f1eacc20f11002cad58232a7c2610f369568653510e54f46088f579f778dc
2018-06-07 14:59:22 +00:00
drh
bd573c459b Merge recent trunk enhancements.
FossilOrigin-Name: e9d7bf4f7b9d6f8dabc4c95d43ebf12f2149bed1c5e750048b1b684128073c38
2018-06-07 14:32:16 +00:00
drh
df12595c09 Change a comma into a logically equivalent but semantically clearer semicolon.
FossilOrigin-Name: 71f97f0f82b3abfb07feb78d64a182fc50ff396e85d6f5aac479dbf58ba4d00a
2018-06-06 23:31:26 +00:00
drh
6eb3480bd7 More space and performance enhancements to sqlite3VdbeRecordCompare().
FossilOrigin-Name: 83a60ff056a63f18479030e9dfb10926fbb0d906d51f2cf88233098e15c75534
2018-06-06 20:55:10 +00:00
dan
ec891fd40c Add implementation of nth_value() window function.
FossilOrigin-Name: eb1fb420ac70857e7ca4cbad78be15a27bee8f915ba2da080c7efa1879c06c31
2018-06-06 20:51:02 +00:00
drh
d882108a01 Small performance optimization in sqlite3VdbeRecordCompareWithSkip() for
the common case where the comparison is equal.

FossilOrigin-Name: 1e616e256a4fb1b64271706fdfa77dc5790eba0a2f0e619544e169bc61d7c805
2018-06-06 20:29:19 +00:00
drh
4011c44322 Rearrange the order of some checks in the integrity_check pragma for a very
slight performance gain.

FossilOrigin-Name: 4b853f020570bf4af1b14e03f35764c7d7a03a40af58efc783e06f2b883cef78
2018-06-06 19:48:19 +00:00