]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
7 years agoFix another problem with reusing LSM cursors for range scans.
dan [Sat, 7 Jul 2018 20:26:30 +0000 (20:26 +0000)] 
Fix another problem with reusing LSM cursors for range scans.

FossilOrigin-Name: ae3fc7652f27ba0a86f4c26f64c2e148d9496a5edb7f54dc9980edd91c326e4f

7 years agoFix the JSON extension so that it can be compiled separately from the
drh [Sat, 7 Jul 2018 20:23:46 +0000 (20:23 +0000)] 
Fix the JSON extension so that it can be compiled separately from the
amalgamation.

FossilOrigin-Name: 4b8cfe7bfe5f049eb4607fd480429fcd2060e691891d8bffc9917f13fa373988

7 years agoFix an LSM problem caused by using the same cursor for equality and range
dan [Sat, 7 Jul 2018 20:13:32 +0000 (20:13 +0000)] 
Fix an LSM problem caused by using the same cursor for equality and range
scans.

FossilOrigin-Name: f05bead371d41ca5beef1f82e4c920c90e2eb9cd9fd537a5c91973bf9bd4eedb

7 years agoAdd ALWAYS() macros on results of sqlite3_aggregate_context() calls in
drh [Sat, 7 Jul 2018 19:47:21 +0000 (19:47 +0000)] 
Add ALWAYS() macros on results of sqlite3_aggregate_context() calls in
xInverse() implements, since they can never fail.

FossilOrigin-Name: fdef2a921d451c66ca535021d08af3ec1ab53283da2d2979378a799fd8731ef9

7 years agoAdd an assert() to help verify that OP_AggInverse is never called on an
drh [Sat, 7 Jul 2018 19:36:04 +0000 (19:36 +0000)] 
Add an assert() to help verify that OP_AggInverse is never called on an
accumulator that has not previously been processed by OP_AggStep.

FossilOrigin-Name: 4213889103fa37f3f11802aea81989522048a0752820603dd556f612128ddfee

7 years agoAdd missing VdbeCoverage() macro to window.c.
dan [Sat, 7 Jul 2018 17:38:49 +0000 (17:38 +0000)] 
Add missing VdbeCoverage() macro to window.c.

FossilOrigin-Name: 63f4d306ba19f6ba900a7d7480ccaa3d1e4a204e7c82bf5eb2e4bd849ef3a22f

7 years agoFix a problem with the handling of NULL values in the min() window function.
dan [Sat, 7 Jul 2018 17:30:44 +0000 (17:30 +0000)] 
Fix a problem with the handling of NULL values in the min() window function.

FossilOrigin-Name: b76f35b09235d44dc3d176377bbb9c18b7cdc9392800103ff53c54730a427a5c

7 years agoTry to improve the error messages for misformed frame specifications in
drh [Fri, 6 Jul 2018 17:19:20 +0000 (17:19 +0000)] 
Try to improve the error messages for misformed frame specifications in
window definitions.

FossilOrigin-Name: 927b95a0812787bcb3c28d1a0ea94717dc2cc60f6d480623f0c7cbce0c546fc9

7 years agoAlso disallow non-constant expressions in "<expr> PRECEDING" or "<expr>
dan [Fri, 6 Jul 2018 14:31:26 +0000 (14:31 +0000)] 
Also disallow non-constant expressions in "<expr> PRECEDING" or "<expr>
FOLLOWING" clauses.

FossilOrigin-Name: a6dffecc6b35c618cc5e5a06892765bdbec587dcd0ae8686c231a21516e38eab

7 years agoEnsure an error is returned if the user specifies an unsupported frame type.
dan [Fri, 6 Jul 2018 14:15:49 +0000 (14:15 +0000)] 
Ensure an error is returned if the user specifies an unsupported frame type.

FossilOrigin-Name: 0f3f8fcde1a535bcf93e23a68d2411c21785d8c0cac1f9481a06e7225755cdbc

7 years agoPrevent "UNBOUNDED FOLLOWING" from being used as the starting boundary of a
dan [Fri, 6 Jul 2018 13:48:09 +0000 (13:48 +0000)] 
Prevent "UNBOUNDED FOLLOWING" from being used as the starting boundary of a
window-frame. And "UNBOUNDED PRECEDING" from being used as the ending
boundary.

FossilOrigin-Name: e51fdf66a24c27ba6491391fffcc88fc5ca2ae79cfc4ab769a149b19c394e308

7 years agoRemove some bad assert() statements from the implementations of window
dan [Fri, 6 Jul 2018 13:25:02 +0000 (13:25 +0000)] 
Remove some bad assert() statements from the implementations of window
functions percent_rank() and cume_dist().

FossilOrigin-Name: 443f0c286f1659937fd61b4ef2de17d0d015369e5ff5249a9e0c3d0ee4925158

7 years agoReturn an error if DISTINCT is used with a window-function (.i.e.
dan [Fri, 6 Jul 2018 07:42:42 +0000 (07:42 +0000)] 
Return an error if DISTINCT is used with a window-function (.i.e.
"count(DISTINCT <expr>) OVER (...)".

FossilOrigin-Name: d59bcc8eea4fcf0ee3c2263d31ee42f9f26c28434d2f0045f2d3329f18791d1c

7 years agoUse separate opcodes, OP_AggValue and OP_AggInverse, for the new callbacks
drh [Thu, 5 Jul 2018 21:22:57 +0000 (21:22 +0000)] 
Use separate opcodes, OP_AggValue and OP_AggInverse, for the new callbacks
associated with Window Functions, for improved readability of EXPLAIN
output.

FossilOrigin-Name: fa6538050938ffeb042fbee31512514d6d3ace514b2a3dfd8365bbeb13f35a78

7 years agoUpdate the recipe for resetting a database using
dan [Thu, 5 Jul 2018 20:33:06 +0000 (20:33 +0000)] 
Update the recipe for resetting a database using
SQLITE_DBCONFIG_RESET_DATABASE.

FossilOrigin-Name: c43dd23fb00f7e0b6274de435d8e31f6a4cb74c3e86e8313a5098ff089e27574

7 years agoGet the json_group_array() and json_group_object() SQL functions working
drh [Thu, 5 Jul 2018 20:05:29 +0000 (20:05 +0000)] 
Get the json_group_array() and json_group_object() SQL functions working
as window functions.

FossilOrigin-Name: 916cdc83f5a45e0b6f61c52ff5fde70d54bcd0dfaa4a32f9ac709fe0ddbb480b

7 years agoReturn an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr>
dan [Thu, 5 Jul 2018 18:34:53 +0000 (18:34 +0000)] 
Return an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr>
FOLLOWING".

FossilOrigin-Name: 786c87ba4150509e141baab32c51e64bbd3ce323735e0f47d65ed54d14215bc4

7 years agoFix a problem in the xInverse method of window-function group_concat(1).
dan [Thu, 5 Jul 2018 18:19:29 +0000 (18:19 +0000)] 
Fix a problem in the xInverse method of window-function group_concat(1).

FossilOrigin-Name: 73391283101288251fe5d030ba12bcdabe8a781d41086afe3564c58c05d0fd5c

7 years agoFix the .dump command in the command-line shell so that it does not show
drh [Thu, 5 Jul 2018 17:35:46 +0000 (17:35 +0000)] 
Fix the .dump command in the command-line shell so that it does not show
extraneous SELECT statements when ".echo on" is enabled.

FossilOrigin-Name: 11763cac33fa809bcf0294d1a381394fcf860b020b51fff81217ee709ba99272

7 years agoIn wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
dan [Thu, 5 Jul 2018 17:16:55 +0000 (17:16 +0000)] 
In wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
upgrades from no transaction directly to a write transaction) hits an
SQLITE_BUSY_SNAPSHOT error, change the error code to SQLITE_BUSY to indicate
to the caller that the condition may be transient.

FossilOrigin-Name: e6108047cb136119d8ed19af010a669ed9750b4e7f991ccabc9e3d15774eda31

7 years agoFix a typo inside an assert() statement introduced by the previous commit. exp-busy-snapshot-fix
dan [Thu, 5 Jul 2018 17:03:43 +0000 (17:03 +0000)] 
Fix a typo inside an assert() statement introduced by the previous commit.

FossilOrigin-Name: e3357728472d5e57db6d7eef0ce008bdee071b5b07b60e242f383440eebe85bd

7 years agoIn wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
dan [Thu, 5 Jul 2018 15:46:55 +0000 (15:46 +0000)] 
In wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
upgrades from no transaction directly to a write transaction) hits an
SQLITE_BUSY_SNAPSHOT error, change the error code to SQLITE_BUSY to indicate
to the caller that the condition may be transient.

FossilOrigin-Name: 221ff63e7902226ebf728bb7442727420636831163708f360724506ce9487ab6

7 years agoTest that a race condition can cause a "BEGIN EXCLUSIVE" to return
dan [Tue, 3 Jul 2018 20:17:27 +0000 (20:17 +0000)] 
Test that a race condition can cause a "BEGIN EXCLUSIVE" to return
SQLITE_BUSY_SNAPSHOT in wal mode.

FossilOrigin-Name: 5a12db75d1da65daa92413a6b5892309e9d9479bb3610764e1015abe5bf28dbe

7 years agoFix a problem in the xInverse callback for the built-in sum() window function.
dan [Mon, 2 Jul 2018 17:45:59 +0000 (17:45 +0000)] 
Fix a problem in the xInverse callback for the built-in sum() window function.

FossilOrigin-Name: b6563647382634588ebe5c6a3c35c65a321dc1b3732c809d48ce46759b9dd80f

7 years agoFix a segfault caused by having identical window functions in the select-list
dan [Mon, 2 Jul 2018 17:14:37 +0000 (17:14 +0000)] 
Fix a segfault caused by having identical window functions in the select-list
and ORDER BY clause of a SELECT statement.

FossilOrigin-Name: 693b4350d741391226a33ab6a05eaad61e8ef1590176f01e8aed2a212e2d6419

7 years agoFix a crash caused by a LIKE pattern that consists of a single escape
dan [Mon, 2 Jul 2018 15:03:50 +0000 (15:03 +0000)] 
Fix a crash caused by a LIKE pattern that consists of a single escape
character.

FossilOrigin-Name: bb9bfc3a12dfb89b1c58f5551cdc89ab7b0fbe03f285f2ed86611786ed02ffd9

7 years agoFix a segfault caused by invoking a regular aggregate as a window-function.
dan [Mon, 2 Jul 2018 12:07:32 +0000 (12:07 +0000)] 
Fix a segfault caused by invoking a regular aggregate as a window-function.
And some problems with count(*) when used as a window-function.

FossilOrigin-Name: 4f3c8a82fd1c5b14d84f2301e34cfc8d52fe4b3a60840c39e895c11f2da529d9

7 years agoQuick patch to the Lemon parser template to avoid an array overread reported
drh [Sun, 1 Jul 2018 16:05:40 +0000 (16:05 +0000)] 
Quick patch to the Lemon parser template to avoid an array overread reported
by OSSFuzz.  A proper fix involves enhancements to the table generators in
Lemon to make the overread impossible.  That fix will take longer to
implement.  The current check-in is a stop-gap.

FossilOrigin-Name: 3f6730be4cb712a28401be6d96e56ccb3f2e98dd8961b477befec3f363715178

7 years agoAvoid a warning in fts5.c due to not using generated routine
dan [Sat, 30 Jun 2018 20:26:52 +0000 (20:26 +0000)] 
Avoid a warning in fts5.c due to not using generated routine
sqlite3Fts5ParserFallback().

FossilOrigin-Name: 65ff5144a55f1ba2b2ef812a0c988fa2522441177038b8d686eb1d0c558c75d5

7 years agoMerge implementation of SQL window functions from the exp-window-functions
dan [Sat, 30 Jun 2018 20:15:58 +0000 (20:15 +0000)] 
Merge implementation of SQL window functions from the exp-window-functions
into trunk.

FossilOrigin-Name: 17198a1206e2fbc9e555881468e8c6980b00e25b5b78a6798a6264ca7384f1ca

7 years agoFix a minor problem in the code for determining whether or not an SQL exp-window-functions
dan [Sat, 30 Jun 2018 20:00:35 +0000 (20:00 +0000)] 
Fix a minor problem in the code for determining whether or not an SQL
statement is SQLITE_TOOBIG.

FossilOrigin-Name: 763e6c9e2bbc0a6ef8d8361069bf7160790c9064f24f0e336b7ed85668735da9

7 years agoMerge all changes from the weak-fallback branch except those related to the
dan [Sat, 30 Jun 2018 19:12:36 +0000 (19:12 +0000)] 
Merge all changes from the weak-fallback branch except those related to the
weak-fallback feature itself.

FossilOrigin-Name: aad718fb1afacf1c921966796ab1e149207c31b16409c5672f0371f4fb9d6565

7 years agoHave the tokenizer handle fallback for tokens "OVER" and "FILTER" in the same weak-fallback
dan [Sat, 30 Jun 2018 18:54:56 +0000 (18:54 +0000)] 
Have the tokenizer handle fallback for tokens "OVER" and "FILTER" in the same
way as it does for "WINDOW".

FossilOrigin-Name: 12d819e1c17d8036900352b0989c4bfcbc34193c3735bb9af7ab051f0f129d3d

7 years agoFurther performance related tweaks for sqlite3RunParser().
dan [Fri, 29 Jun 2018 20:43:33 +0000 (20:43 +0000)] 
Further performance related tweaks for sqlite3RunParser().

FossilOrigin-Name: 5eb4776598f5bba7ef21a2c58c03105544da73d642d7ffc146f84eff1993d71e

7 years agoFurther tweaks to sqlite3RunParser().
dan [Fri, 29 Jun 2018 20:21:24 +0000 (20:21 +0000)] 
Further tweaks to sqlite3RunParser().

FossilOrigin-Name: eef61ffab7fa36b126f57bf7028dd35c67ed4617c47145be059f91e58023b0a4

7 years agoImprove on the previous checkin. Still a bit slow.
dan [Fri, 29 Jun 2018 19:54:51 +0000 (19:54 +0000)] 
Improve on the previous checkin. Still a bit slow.

FossilOrigin-Name: c1fb41aa7b7207b81ee1d5d32da3380b36d694033b87a2873981e0c6437ba956

7 years agoInstead of using a lemon %fallback directive, have the tokenizer try to figure
dan [Fri, 29 Jun 2018 17:44:52 +0000 (17:44 +0000)] 
Instead of using a lemon %fallback directive, have the tokenizer try to figure
out whether an instance of "WINDOW" should be TK_WINDOW or TK_ID.

FossilOrigin-Name: 022079cb0d67be5ac0a50dd9a4d41ee55ce8df681ecd0a544170d75fc8649978

7 years agoModifications to parse.y to better support backwards compatibility for the
dan [Thu, 28 Jun 2018 20:05:04 +0000 (20:05 +0000)] 
Modifications to parse.y to better support backwards compatibility for the
"window" keyword.

FossilOrigin-Name: 7c4b879bdb10f30260f0fb28fcb559ab0949865d10f4ff2cf13834a326198998

7 years agoIntroduce the concept of "weak fallback" in the parser. A weak fallback
drh [Thu, 28 Jun 2018 03:38:49 +0000 (03:38 +0000)] 
Introduce the concept of "weak fallback" in the parser.  A weak fallback
only occurs if a syntax error would result otherwise.

FossilOrigin-Name: c41d7079fb63831bd2f009b64cbf5a423e8119e6b841bfd9bd5a2d85fba3b142

7 years agoAdd missing VdbeCoverage() and VdbeCoverageNeverTaken() macros to window.c.
dan [Wed, 27 Jun 2018 20:24:59 +0000 (20:24 +0000)] 
Add missing VdbeCoverage() and VdbeCoverageNeverTaken() macros to window.c.

FossilOrigin-Name: 4383cb68a1241768ddb3f180f8cbb9ea1638f8806210b10aac1384b8a7ecdca2

7 years agoAvoid redundant ORDER BY operations when rewriting SELECT statements that
dan [Wed, 27 Jun 2018 19:48:50 +0000 (19:48 +0000)] 
Avoid redundant ORDER BY operations when rewriting SELECT statements that
contain window functions.

FossilOrigin-Name: 336de43a47e206fe7629072e5b8c80d4ede17ead8ef4dcf5d8da6833ff22d2f9

7 years agoMerge latest trunk changes.
dan [Tue, 26 Jun 2018 20:19:44 +0000 (20:19 +0000)] 
Merge latest trunk changes.

FossilOrigin-Name: d9f814b4437eae4c49ba8abec7b58ef9dbb49d4ba8d1c95e08a2e717ef3839ee

7 years agoAdd documentation comment for sqlite3_create_window_function(). And further
dan [Mon, 25 Jun 2018 20:34:28 +0000 (20:34 +0000)] 
Add documentation comment for sqlite3_create_window_function(). And further
tests.

FossilOrigin-Name: 3f2705b93368f7b0dfd2e03387c3d0b55eddb04940ec83e226e420d8ab10c77f

7 years agoFix another problem that could cause a crash when a window function was used
dan [Mon, 25 Jun 2018 11:42:08 +0000 (11:42 +0000)] 
Fix another problem that could cause a crash when a window function was used
in a view.

FossilOrigin-Name: e954145a3addf60247954b9161473cd02ae2400f469840523093e25e23fbc54d

7 years agoFix problems with using window-functions in correlated sub-queries.
dan [Sat, 23 Jun 2018 19:29:56 +0000 (19:29 +0000)] 
Fix problems with using window-functions in correlated sub-queries.

FossilOrigin-Name: 3e23cfc8133342a4de6813afdc33d726f06d625424b16d0999fb22be51bf8913

7 years agoFix a problem with using LIMIT in window-function queries.
dan [Sat, 23 Jun 2018 16:26:20 +0000 (16:26 +0000)] 
Fix a problem with using LIMIT in window-function queries.

FossilOrigin-Name: c1abd2dda4154cb573bdf627cdef794d3697f874c3b70357aaf5e4ed95ad1d5c

7 years agoFix a problem with using a window-function SELECT as a FROM clause sub-query
dan [Sat, 23 Jun 2018 07:59:39 +0000 (07:59 +0000)] 
Fix a problem with using a window-function SELECT as a FROM clause sub-query
in some circumstances.

FossilOrigin-Name: 11d733396f75ef1f206cd6f35630ff176484279861772918b9ea69412c13c62d

7 years agoOmit all window-function related code when building with SQLITE_OMIT_WINDOWFUNC.
dan [Fri, 22 Jun 2018 20:51:35 +0000 (20:51 +0000)] 
Omit all window-function related code when building with SQLITE_OMIT_WINDOWFUNC.

FossilOrigin-Name: 5f04b016467342b5a796bf702ed25b621eb86f2961c1e703d276c93f2cb6aa89

7 years agoMerge latest trunk changes.
dan [Fri, 22 Jun 2018 17:57:10 +0000 (17:57 +0000)] 
Merge latest trunk changes.

FossilOrigin-Name: ebe65b2386a6132f4ef2cce6668a2da7db0798a70d2fba652882d5bccfd6672b

7 years agoImproved context for error_log message coming from sqlite3_prepare().
drh [Thu, 21 Jun 2018 23:53:54 +0000 (23:53 +0000)] 
Improved context for error_log message coming from sqlite3_prepare().

FossilOrigin-Name: fea7ade649ae72303078782f7bc510e0a17f082ffde10e769f1aeb1cf37b5554

7 years agoFix a problem with handling single row partitions in the percent_rank() window
dan [Thu, 21 Jun 2018 19:20:39 +0000 (19:20 +0000)] 
Fix a problem with handling single row partitions in the percent_rank() window
function.

FossilOrigin-Name: b84fbf16eac718c151731e2b2dcc73f2f2a144e3670f8566a30793f1e4e6a3ec

7 years agoAdd tests to improve coverage of code in window.c. Fix a problem with "SELECT
dan [Wed, 20 Jun 2018 09:23:49 +0000 (09:23 +0000)] 
Add tests to improve coverage of code in window.c. Fix a problem with "SELECT
row_number() OVER ()".

FossilOrigin-Name: f41b6b7317e2b5ac5721a3adff49f298ded29f9e0f887af98faeb0cb7e865ab6

7 years agoMerge latest trunk changes with this branch.
dan [Tue, 19 Jun 2018 19:15:25 +0000 (19:15 +0000)] 
Merge latest trunk changes with this branch.

FossilOrigin-Name: 6ad0e64b465959c50d4c895c053b15ee7efed11b6427604d2eab88635d9f7319

7 years agoFix a problem caused by a sub-query containing a window function in the FROM
dan [Tue, 19 Jun 2018 18:11:05 +0000 (18:11 +0000)] 
Fix a problem caused by a sub-query containing a window function in the FROM
clause of a query that itself uses a window function.

FossilOrigin-Name: f4b1b6f85b53d72e735a1382f7c3de75af405a7878dd8cdcb10394e859ea3d69

7 years agoFix a problem with using min() or max() as a window function.
dan [Tue, 19 Jun 2018 17:13:11 +0000 (17:13 +0000)] 
Fix a problem with using min() or max() as a window function.

FossilOrigin-Name: 801074ce63d3f4825cc9fa508c42629a9f74e7f9e35c5f238343bb1cff4fbae1

7 years agoMinor change to the input grammar to make the parser tables slightly smaller.
drh [Tue, 19 Jun 2018 11:15:19 +0000 (11:15 +0000)] 
Minor change to the input grammar to make the parser tables slightly smaller.

FossilOrigin-Name: 320fa69e6aa2a7d67f6444d6c13de9893e27b85c36a933b06da113d753b6aafc

7 years agoFix problems with using window functions in CREATE VIEW statements.
dan [Mon, 18 Jun 2018 20:34:43 +0000 (20:34 +0000)] 
Fix problems with using window functions in CREATE VIEW statements.

FossilOrigin-Name: 943bccd2a6bd4cf3e0534c1fa46885bfa2ba7b780ddcdff9f1ea4cbb3f04e786

7 years agoAdd test case for the fix in the previous commit.
dan [Mon, 18 Jun 2018 20:08:08 +0000 (20:08 +0000)] 
Add test case for the fix in the previous commit.

FossilOrigin-Name: 39434262d5cf1af197ce0abb1f1ee84ee0797823e290a493c5bf8376fbe287a6

7 years agoFix typo in the 'normalize' extension.
mistachkin [Mon, 18 Jun 2018 19:09:30 +0000 (19:09 +0000)] 
Fix typo in the 'normalize' extension.

FossilOrigin-Name: 0c9163ea232d4008105939910565b0d1e533cbb38067d7900dc732b911786d37

7 years agoEnsure that all four callbacks are provided when registering a window function
dan [Mon, 18 Jun 2018 17:36:41 +0000 (17:36 +0000)] 
Ensure that all four callbacks are provided when registering a window function
(otherwise SQLITE_MISUSE is returned).

FossilOrigin-Name: 5720dcd8b111b1f8712c8fb4b441ccb129e838db8c26a6e9e0f095dc6a851f6b

7 years agoAdd new API function sqlite3_create_window_function(), for creating new
dan [Mon, 18 Jun 2018 16:55:22 +0000 (16:55 +0000)] 
Add new API function sqlite3_create_window_function(), for creating new
aggregate window functions.

FossilOrigin-Name: da03fb4318fd2613ec5c5b109a3974ac1120c19ed16bed4ca85bbdc4b35c998c

7 years agoAdd extra OOM test.
dan [Fri, 15 Jun 2018 20:46:12 +0000 (20:46 +0000)] 
Add extra OOM test.

FossilOrigin-Name: ac251f72608c27c1512a0b3457524f5378a0b13d93d829cf0ed8bc178bc54a73

7 years agoFix another problem in lead()/lag(). And some errors that could occur
dan [Fri, 15 Jun 2018 19:01:35 +0000 (19:01 +0000)] 
Fix another problem in lead()/lag(). And some errors that could occur
following OOM faults.

FossilOrigin-Name: fadd4dc119d8df0d871f4d839b7a11070e2ffb8927e84b3e7a94f34196db3de3

7 years agoFix a bug in the lead() and lag() window functions causing them to fail when
dan [Fri, 15 Jun 2018 16:10:44 +0000 (16:10 +0000)] 
Fix a bug in the lead() and lag() window functions causing them to fail when
used in queries featuring multiple window functions.

FossilOrigin-Name: 3839fb18f917e4f705821198d624b19d84eb07f1ee29ad23314ab7cec6bf6a2b

7 years agoFix a problem with handling of statements containing two or more different
dan [Thu, 14 Jun 2018 20:52:08 +0000 (20:52 +0000)] 
Fix a problem with handling of statements containing two or more different
windows.

FossilOrigin-Name: 567e09ef2a8cd84a2481117e52595bed0f3b588745a9e441aae0f87680f3a2e8

7 years agoFix problem with window functions min() and max() when used with a PARTITION
dan [Thu, 14 Jun 2018 19:06:36 +0000 (19:06 +0000)] 
Fix problem with window functions min() and max() when used with a PARTITION
clause and a frame starting point other than "UNBOUNDED PRECEDING".

FossilOrigin-Name: 43eb1e75a4d7ac0973ed8589bbaf379c24cdc8eacc4e613610d2d4c24d385dc1

7 years agoMerge latest trunk changes into this branch.
dan [Thu, 14 Jun 2018 14:30:51 +0000 (14:30 +0000)] 
Merge latest trunk changes into this branch.

FossilOrigin-Name: 5cf5f1808a51f9c2cfc98dd49b4f1ce860b53e935287f89868ce2fdbace8eb06

7 years agoImprove comments and code legibility in new file window.c.
dan [Thu, 14 Jun 2018 14:27:05 +0000 (14:27 +0000)] 
Improve comments and code legibility in new file window.c.

FossilOrigin-Name: bb915854d435bdd78f141d70e23527e97922ec176acd3ed8060c78dffc96bab8

7 years agoFix problems with "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" window
dan [Wed, 13 Jun 2018 20:29:38 +0000 (20:29 +0000)] 
Fix problems with "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" window
frames.

FossilOrigin-Name: c34f31dbd79891249ee9485e91f6ea558ee1db62e04fb0fff2c051612b8fa5e7

7 years agoOutput infinity as 1e999 in the ".dump" command of the command-line shell.
drh [Wed, 13 Jun 2018 17:19:20 +0000 (17:19 +0000)] 
Output infinity as 1e999 in the ".dump" command of the command-line shell.

FossilOrigin-Name: ee431d55eba618cfba414c3946b3162bc205a70dd4e43d74a7623be332b94c92

7 years agoPad out the sqlite3_value structure to be a multiple of 8 bytes.
drh [Wed, 13 Jun 2018 16:52:38 +0000 (16:52 +0000)] 
Pad out the sqlite3_value structure to be a multiple of 8 bytes.

FossilOrigin-Name: f76dc33bde4b2180b935d1261492d9535772ed37e54489c1a33e9f11c7c90433

7 years agoFix some test case numbers in expert1.test.
dan [Wed, 13 Jun 2018 16:08:22 +0000 (16:08 +0000)] 
Fix some test case numbers in expert1.test.

FossilOrigin-Name: b90c3c16c04589583d2d1619320bb45a0b012c5960f23bd4e3f9dbe7c84b2eae

7 years agoUnless SQLITE_OMIT_AUTOINIT is defined, allow sqlite3_vfs_unregister() to be called...
dan [Wed, 13 Jun 2018 11:41:54 +0000 (11:41 +0000)] 
Unless SQLITE_OMIT_AUTOINIT is defined, allow sqlite3_vfs_unregister() to be called before sqlite3_initialize().

FossilOrigin-Name: ab6c1ae46d992f91ce0995274f48d545eb02ba92544aee89b188f2fc92b66f2a

7 years agoCheck that malloc() has not already failed when invoking the xUpdate() method
dan [Wed, 13 Jun 2018 11:11:13 +0000 (11:11 +0000)] 
Check that malloc() has not already failed when invoking the xUpdate() method
of a virtual table implementation. This fixes an assert() failure in FTS5 that
could occur following an OOM condition.

FossilOrigin-Name: e9a7e4d58f3716991309ca0e3f080717e473c7c231685954aceee36172f19cf2

7 years agoAdd the unused SQLITE_CANTOPEN_DIRTYWAL result code. This code was used
drh [Wed, 13 Jun 2018 02:20:34 +0000 (02:20 +0000)] 
Add the unused SQLITE_CANTOPEN_DIRTYWAL result code.  This code was used
in some historical versions on the apple-osx branch but was removed
by check-in [27e20d699872b2b8].  Restore it so that old code that actually
references that result code will still compile.

FossilOrigin-Name: 9f40383eed936a6921ef8dc94775eb55d03a761f36eda7be1b9cdd0a0d30fa80

7 years agoFix another issue to do with window-functions in aggregate queries.
dan [Tue, 12 Jun 2018 20:53:38 +0000 (20:53 +0000)] 
Fix another issue to do with window-functions in aggregate queries.

FossilOrigin-Name: 6413e38a174044c28fa9b8b937e6c972d144547a246e6f2882e782538300d042

7 years agoDocumentation update: clarify that sqlite3_errcode() and related interfaces
drh [Tue, 12 Jun 2018 19:35:51 +0000 (19:35 +0000)] 
Documentation update: clarify that sqlite3_errcode() and related interfaces
do not themselves modify the error code.

FossilOrigin-Name: 858fc52b237702b5e0381eebf5c158bffd7371ff0053a8583b8c175f8f691c82

7 years agoDocumentation updates: clarify the behavior of sqlite3_column and
drh [Tue, 12 Jun 2018 19:22:30 +0000 (19:22 +0000)] 
Documentation updates: clarify the behavior of sqlite3_column and
sqlite3_value interfaces following an OOM error.

FossilOrigin-Name: 428c581e4bed1d140cfb670633c9c61b36be7bb30a862d2e1ae7eaee26dccb4f

7 years agoFix some problems with using window-functions in aggregate queries.
dan [Tue, 12 Jun 2018 18:40:17 +0000 (18:40 +0000)] 
Fix some problems with using window-functions in aggregate queries.

FossilOrigin-Name: fe7081e0952950f577234fcbb58f3c1efa4579267654fd2f713dc4804e470e7e

7 years agoImprovements to SCopy correctness tracking when SQLITE_DEBUG is enabled.
drh [Tue, 12 Jun 2018 13:52:23 +0000 (13:52 +0000)] 
Improvements to SCopy correctness tracking when SQLITE_DEBUG is enabled.

FossilOrigin-Name: b2973f2357a2c5e22e0d612c970adbc6d51cbc5e4ff7ac6d2b678722e553e8ec

7 years agoFix the "Synopsis" on the OP_BitNot opcode.
drh [Tue, 12 Jun 2018 13:16:57 +0000 (13:16 +0000)] 
Fix the "Synopsis" on the OP_BitNot opcode.

FossilOrigin-Name: acd78df61188591d33ddb9b1b8c16bcc015f4dffac66314529caa747d4395c70

7 years agoImprovements to the --enable and --disable options for the
drh [Mon, 11 Jun 2018 21:33:08 +0000 (21:33 +0000)] 
Improvements to the --enable and --disable options for the
amalgamation tarball.

FossilOrigin-Name: 02e337e0808947c7ef376b5a300cd3c461f1a368c9fe7ffd7ca5744f102641c2

7 years agoClarify the relationship between a Window object and its associated Expr.
dan [Mon, 11 Jun 2018 20:50:25 +0000 (20:50 +0000)] 
Clarify the relationship between a Window object and its associated Expr.

FossilOrigin-Name: 0cd55e98a478740032f5569ddc00fa5b0e063e90db6e00ac7598c9b7c2fffeee

7 years agoFix various --enable and --disable options on the top-level configure
drh [Mon, 11 Jun 2018 19:47:14 +0000 (19:47 +0000)] 
Fix various --enable and --disable options on the top-level configure
script.

FossilOrigin-Name: 6fd7e8ceb96981cff023653a54b85bea0e1da3d706cd9f4383f5c5533213ef4d

7 years agoFix handling of window frames containing negative number of rows. e.g. "ROWS x
dan [Mon, 11 Jun 2018 18:16:51 +0000 (18:16 +0000)] 
Fix handling of window frames containing negative number of rows. e.g. "ROWS x
PRECEDING AND y PRECEDING" where (x<y).

FossilOrigin-Name: b6d9c7eda853420ae46a05bd432711e8bf9ebaa448c7d90ccfc0bcc338a87706

7 years agoFix the column cache invalidation logic in the code for ROWID uniqueness
drh [Mon, 11 Jun 2018 18:06:48 +0000 (18:06 +0000)] 
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

7 years agoAdd the OP_SetTabCol and OP_VerifyTabCol opcodes, only when compiling with
drh [Mon, 11 Jun 2018 17:35:02 +0000 (17:35 +0000)] 
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

7 years agoStrengthen the sqlite3VdbeMemAboutToChange() run-time verification mechanism
drh [Mon, 11 Jun 2018 13:10:45 +0000 (13:10 +0000)] 
Strengthen the sqlite3VdbeMemAboutToChange() run-time verification mechanism
to better detect missed calls to AboutToChange().

FossilOrigin-Name: 793e942205a12eedb7ecc5ad8a27e3e52bbd4e1d50a0d1453d04a83ba728884e

7 years agoFix a typon in main.mk.
dan [Mon, 11 Jun 2018 11:19:35 +0000 (11:19 +0000)] 
Fix a typon in main.mk.

FossilOrigin-Name: e74f86f271d6ab1ecd17c1ee63ab2aa0885ca56624be7382872f04d46c48ed86

7 years agoAlways initialize the WhereClause.hasOr field that was added by check-in
drh [Mon, 11 Jun 2018 01:30:03 +0000 (01:30 +0000)] 
Always initialize the WhereClause.hasOr field that was added by check-in
[292724ffc4].  Error detected by OSSFuzz.

FossilOrigin-Name: 9faf41713e865f26485d9e90918d77c25be211384941eadda6a36237f52c25de

7 years agoUpdate Makefile.msc to include window.c in the build.
dan [Sun, 10 Jun 2018 07:42:35 +0000 (07:42 +0000)] 
Update Makefile.msc to include window.c in the build.

FossilOrigin-Name: 16db73842ade5eb0fe02f257b91d1c7b41d830d3f17f8638b8fbaed309d9a852

7 years agoFix a typo in the amalgamation autoconf file.
drh [Sat, 9 Jun 2018 20:52:45 +0000 (20:52 +0000)] 
Fix a typo in the amalgamation autoconf file.

FossilOrigin-Name: de0857f39620b7f5c921ddf8d11b11723b4ba3cfe52e43cf77e883697b7c1c4c

7 years agoMerge recent trunk changes with this branch.
dan [Sat, 9 Jun 2018 18:09:44 +0000 (18:09 +0000)] 
Merge recent trunk changes with this branch.

FossilOrigin-Name: c71f23590c25b4cecd27722e6c0fc8e3bf320d399c7d9398b7016dd5cf5b05eb

7 years agoUpdate the amalgamation build script to include window.c.
dan [Sat, 9 Jun 2018 17:58:51 +0000 (17:58 +0000)] 
Update the amalgamation build script to include window.c.

FossilOrigin-Name: 21d2f4a62eceab0de0b4669bf3e81eb71512211ed710ce0eb525695fb7309d6b

7 years agoAdd support for FILTER clause on aggregate window functions.
dan [Sat, 9 Jun 2018 17:43:45 +0000 (17:43 +0000)] 
Add support for FILTER clause on aggregate window functions.

FossilOrigin-Name: ceaf798ea09184bc0e7d3dcf3ad4d909d2e4e7018754a8417a813f33010140a7

7 years agoSlightly smaller and faster code by encapsulating wal-index hash table
drh [Sat, 9 Jun 2018 16:49:00 +0000 (16:49 +0000)] 
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

7 years agoImproved comments an presentation for the recent IN operator decision
drh [Sat, 9 Jun 2018 14:13:46 +0000 (14:13 +0000)] 
Improved comments an presentation for the recent IN operator decision
improvement.

FossilOrigin-Name: 31e480f68dfd887cfd9114f9f9fec53d751d3ecc27e36f55c0166b51b2fbb08c

7 years agoPerformance improvement to sqlite3WhereExprUsage().
drh [Sat, 9 Jun 2018 02:49:11 +0000 (02:49 +0000)] 
Performance improvement to sqlite3WhereExprUsage().

FossilOrigin-Name: fd0934139076848f2f2edfd3d74d54608531031a05a60ca6ac1d7016dcd538df

7 years agoCompute the bitmask of indexed columns for each index once when the Index
drh [Sat, 9 Jun 2018 01:12:08 +0000 (01:12 +0000)] 
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

7 years agoAvoid invoking the whereLoopAddOr() routine in the query planner if there
drh [Sat, 9 Jun 2018 00:09:58 +0000 (00:09 +0000)] 
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