Commit Graph

19353 Commits

Author SHA1 Message Date
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
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