Commit Graph

19367 Commits

Author SHA1 Message Date
dan
6b4b88208e Fix a crash caused by a LIKE pattern that consists of a single escape
character.

FossilOrigin-Name: bb9bfc3a12dfb89b1c58f5551cdc89ab7b0fbe03f285f2ed86611786ed02ffd9
2018-07-02 15:03:50 +00:00
dan
7262ca94cb 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
2018-07-02 12:07:32 +00:00
drh
9f607e9c23 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
2018-07-01 16:05:40 +00:00
dan
d2ac43ea38 Avoid a warning in fts5.c due to not using generated routine
sqlite3Fts5ParserFallback().

FossilOrigin-Name: 65ff5144a55f1ba2b2ef812a0c988fa2522441177038b8d686eb1d0c558c75d5
2018-06-30 20:26:52 +00:00
dan
9592320b91 Merge implementation of SQL window functions from the exp-window-functions
into trunk.

FossilOrigin-Name: 17198a1206e2fbc9e555881468e8c6980b00e25b5b78a6798a6264ca7384f1ca
2018-06-30 20:15:58 +00:00
dan
2b5f152601 Fix a minor problem in the code for determining whether or not an SQL
statement is SQLITE_TOOBIG.

FossilOrigin-Name: 763e6c9e2bbc0a6ef8d8361069bf7160790c9064f24f0e336b7ed85668735da9
2018-06-30 20:00:35 +00:00
dan
5001b3314d Merge all changes from the weak-fallback branch except those related to the
weak-fallback feature itself.

FossilOrigin-Name: aad718fb1afacf1c921966796ab1e149207c31b16409c5672f0371f4fb9d6565
2018-06-30 19:12:36 +00:00
dan
6e2210e0a1 Have the tokenizer handle fallback for tokens "OVER" and "FILTER" in the same
way as it does for "WINDOW".

FossilOrigin-Name: 12d819e1c17d8036900352b0989c4bfcbc34193c3735bb9af7ab051f0f129d3d
2018-06-30 18:54:56 +00:00
dan
34a7d790ba Further performance related tweaks for sqlite3RunParser().
FossilOrigin-Name: 5eb4776598f5bba7ef21a2c58c03105544da73d642d7ffc146f84eff1993d71e
2018-06-29 20:43:33 +00:00
dan
d437ac0c58 Further tweaks to sqlite3RunParser().
FossilOrigin-Name: eef61ffab7fa36b126f57bf7028dd35c67ed4617c47145be059f91e58023b0a4
2018-06-29 20:21:24 +00:00
dan
769309fcf3 Improve on the previous checkin. Still a bit slow.
FossilOrigin-Name: c1fb41aa7b7207b81ee1d5d32da3380b36d694033b87a2873981e0c6437ba956
2018-06-29 19:54:51 +00:00
dan
59ff42516c 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
2018-06-29 17:44:52 +00:00
dan
04a8e0cd54 Modifications to parse.y to better support backwards compatibility for the
"window" keyword.

FossilOrigin-Name: 7c4b879bdb10f30260f0fb28fcb559ab0949865d10f4ff2cf13834a326198998
2018-06-28 20:05:04 +00:00
drh
3773c25f16 Introduce the concept of "weak fallback" in the parser. A weak fallback
only occurs if a syntax error would result otherwise.

FossilOrigin-Name: c41d7079fb63831bd2f009b64cbf5a423e8119e6b841bfd9bd5a2d85fba3b142
2018-06-28 03:38:49 +00:00
dan
01e1229063 Add missing VdbeCoverage() and VdbeCoverageNeverTaken() macros to window.c.
FossilOrigin-Name: 4383cb68a1241768ddb3f180f8cbb9ea1638f8806210b10aac1384b8a7ecdca2
2018-06-27 20:24:59 +00:00
dan
f02cdd379a Avoid redundant ORDER BY operations when rewriting SELECT statements that
contain window functions.

FossilOrigin-Name: 336de43a47e206fe7629072e5b8c80d4ede17ead8ef4dcf5d8da6833ff22d2f9
2018-06-27 19:48:50 +00:00
dan
c994b0225b Merge latest trunk changes.
FossilOrigin-Name: d9f814b4437eae4c49ba8abec7b58ef9dbb49d4ba8d1c95e08a2e717ef3839ee
2018-06-26 20:19:44 +00:00
dan
e618dd9b5d Add documentation comment for sqlite3_create_window_function(). And further
tests.

FossilOrigin-Name: 3f2705b93368f7b0dfd2e03387c3d0b55eddb04940ec83e226e420d8ab10c77f
2018-06-25 20:34:28 +00:00
dan
867be212bc Fix another problem that could cause a crash when a window function was used
in a view.

FossilOrigin-Name: e954145a3addf60247954b9161473cd02ae2400f469840523093e25e23fbc54d
2018-06-25 11:42:08 +00:00
dan
c316307315 Fix problems with using window-functions in correlated sub-queries.
FossilOrigin-Name: 3e23cfc8133342a4de6813afdc33d726f06d625424b16d0999fb22be51bf8913
2018-06-23 19:29:56 +00:00
dan
efa3a3c9cc Fix a problem with using LIMIT in window-function queries.
FossilOrigin-Name: c1abd2dda4154cb573bdf627cdef794d3697f874c3b70357aaf5e4ed95ad1d5c
2018-06-23 16:26:20 +00:00
dan
ce1037352d Fix a problem with using a window-function SELECT as a FROM clause sub-query
in some circumstances.

FossilOrigin-Name: 11d733396f75ef1f206cd6f35630ff176484279861772918b9ea69412c13c62d
2018-06-23 07:59:39 +00:00
dan
67a9b8eded Omit all window-function related code when building with SQLITE_OMIT_WINDOWFUNC.
FossilOrigin-Name: 5f04b016467342b5a796bf702ed25b621eb86f2961c1e703d276c93f2cb6aa89
2018-06-22 20:51:35 +00:00
dan
17074e3a9e Merge latest trunk changes.
FossilOrigin-Name: ebe65b2386a6132f4ef2cce6668a2da7db0798a70d2fba652882d5bccfd6672b
2018-06-22 17:57:10 +00:00
drh
875ad8ceb1 Improved context for error_log message coming from sqlite3_prepare().
FossilOrigin-Name: fea7ade649ae72303078782f7bc510e0a17f082ffde10e769f1aeb1cf37b5554
2018-06-21 23:53:54 +00:00
dan
b7306f6f6e Fix a problem with handling single row partitions in the percent_rank() window
function.

FossilOrigin-Name: b84fbf16eac718c151731e2b2dcc73f2f2a144e3670f8566a30793f1e4e6a3ec
2018-06-21 19:20:39 +00:00
dan
9c27758eb4 Add tests to improve coverage of code in window.c. Fix a problem with "SELECT
row_number() OVER ()".

FossilOrigin-Name: f41b6b7317e2b5ac5721a3adff49f298ded29f9e0f887af98faeb0cb7e865ab6
2018-06-20 09:23:49 +00:00
dan
85b9a1c2fb Merge latest trunk changes with this branch.
FossilOrigin-Name: 6ad0e64b465959c50d4c895c053b15ee7efed11b6427604d2eab88635d9f7319
2018-06-19 19:15:25 +00:00
dan
cc4644183b 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
2018-06-19 18:11:05 +00:00
dan
6fb2b54ceb Fix a problem with using min() or max() as a window function.
FossilOrigin-Name: 801074ce63d3f4825cc9fa508c42629a9f74e7f9e35c5f238343bb1cff4fbae1
2018-06-19 17:13:11 +00:00
drh
ca5aa59453 Minor change to the input grammar to make the parser tables slightly smaller.
FossilOrigin-Name: 320fa69e6aa2a7d67f6444d6c13de9893e27b85c36a933b06da113d753b6aafc
2018-06-19 11:15:19 +00:00
dan
c95f38d456 Fix problems with using window functions in CREATE VIEW statements.
FossilOrigin-Name: 943bccd2a6bd4cf3e0534c1fa46885bfa2ba7b780ddcdff9f1ea4cbb3f04e786
2018-06-18 20:34:43 +00:00
dan
3a6b258ec3 Add test case for the fix in the previous commit.
FossilOrigin-Name: 39434262d5cf1af197ce0abb1f1ee84ee0797823e290a493c5bf8376fbe287a6
2018-06-18 20:08:08 +00:00
mistachkin
5bce7d8f6c Fix typo in the 'normalize' extension.
FossilOrigin-Name: 0c9163ea232d4008105939910565b0d1e533cbb38067d7900dc732b911786d37
2018-06-18 19:09:30 +00:00
dan
f87e10c75e Ensure that all four callbacks are provided when registering a window function
(otherwise SQLITE_MISUSE is returned).

FossilOrigin-Name: 5720dcd8b111b1f8712c8fb4b441ccb129e838db8c26a6e9e0f095dc6a851f6b
2018-06-18 17:36:41 +00:00
dan
660af939b0 Add new API function sqlite3_create_window_function(), for creating new
aggregate window functions.

FossilOrigin-Name: da03fb4318fd2613ec5c5b109a3974ac1120c19ed16bed4ca85bbdc4b35c998c
2018-06-18 16:55:22 +00:00
dan
13b08bb6ff Add extra OOM test.
FossilOrigin-Name: ac251f72608c27c1512a0b3457524f5378a0b13d93d829cf0ed8bc178bc54a73
2018-06-15 20:46:12 +00:00
dan
6fde1799f8 Fix another problem in lead()/lag(). And some errors that could occur
following OOM faults.

FossilOrigin-Name: fadd4dc119d8df0d871f4d839b7a11070e2ffb8927e84b3e7a94f34196db3de3
2018-06-15 19:01:35 +00:00
dan
e0a5e20fa8 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
2018-06-15 16:10:44 +00:00
dan
303451a8f7 Fix a problem with handling of statements containing two or more different
windows.

FossilOrigin-Name: 567e09ef2a8cd84a2481117e52595bed0f3b588745a9e441aae0f87680f3a2e8
2018-06-14 20:52:08 +00:00
dan
9a94722d48 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
2018-06-14 19:06:36 +00:00
dan
09882a75c4 Merge latest trunk changes into this branch.
FossilOrigin-Name: 5cf5f1808a51f9c2cfc98dd49b4f1ce860b53e935287f89868ce2fdbace8eb06
2018-06-14 14:30:51 +00:00
dan
54a9ab3f13 Improve comments and code legibility in new file window.c.
FossilOrigin-Name: bb915854d435bdd78f141d70e23527e97922ec176acd3ed8060c78dffc96bab8
2018-06-14 14:27:05 +00:00
dan
13078caac4 Fix problems with "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" window
frames.

FossilOrigin-Name: c34f31dbd79891249ee9485e91f6ea558ee1db62e04fb0fff2c051612b8fa5e7
2018-06-13 20:29:38 +00:00
drh
2f1f8801ed Output infinity as 1e999 in the ".dump" command of the command-line shell.
FossilOrigin-Name: ee431d55eba618cfba414c3946b3162bc205a70dd4e43d74a7623be332b94c92
2018-06-13 17:19:20 +00:00
drh
4449437b56 Pad out the sqlite3_value structure to be a multiple of 8 bytes.
FossilOrigin-Name: f76dc33bde4b2180b935d1261492d9535772ed37e54489c1a33e9f11c7c90433
2018-06-13 16:52:38 +00:00
dan
c5861ce88f Fix some test case numbers in expert1.test.
FossilOrigin-Name: b90c3c16c04589583d2d1619320bb45a0b012c5960f23bd4e3f9dbe7c84b2eae
2018-06-13 16:08:22 +00:00
dan
45f318275e Unless SQLITE_OMIT_AUTOINIT is defined, allow sqlite3_vfs_unregister() to be called before sqlite3_initialize().
FossilOrigin-Name: ab6c1ae46d992f91ce0995274f48d545eb02ba92544aee89b188f2fc92b66f2a
2018-06-13 11:41:54 +00:00
dan
466ea9b1e2 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
2018-06-13 11:11:13 +00:00
drh
ea74c1db64 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
2018-06-13 02:20:34 +00:00