1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00
Commit Graph

214 Commits

Author SHA1 Message Date
dan
3f49c321e8 Fix a couple of problems with "RANGE BETWEEN <expr> PRECEDING AND <expr> PRECEDING" frames.
FossilOrigin-Name: 39225cc77579896214dceb93b7f224b4b3bc95b3505a2e19b41b0b18b184fbc4
2019-04-03 16:27:44 +00:00
drh
94809086e5 Use a separate bit on db->dbOptFlags to disable the xInverse optimization on
window functions, rather than reusing the query-flattener disable bit.

FossilOrigin-Name: bc0fb1c324be2fd668bc4398c7d364b7e3c5a98537fe5fb58a125b66f3e6d041
2019-04-02 17:45:56 +00:00
drh
495ed62e85 Frame range comparisons can never be NULL because the values will have
been checked for NULL prior to the test.

FossilOrigin-Name: fa37cf9a6aa3e4325674cb6af68f617d25e349c3f694d0117a19a36fc42daf15
2019-04-01 16:23:21 +00:00
drh
83c5bb997a Mark rowid-comparison opcodes as never-null for VDBE coverage tracking
purposes.

FossilOrigin-Name: a69bb4f257500e40ef4056d5628ef25266def5bcef07eebdb471a79fffe80237
2019-04-01 15:55:38 +00:00
drh
21826f44bf Improved VDBE branch coverage in the run-time frame-spec error detection
logic of window functions.

FossilOrigin-Name: f56d305a7bad6608d51d8c8cef417ddb66cff50f0a75d28554ea669e47f3d90d
2019-04-01 14:30:30 +00:00
drh
ce5752cd1f Add some missing VdbeCoverage() macros.
FossilOrigin-Name: d03b611302f68483770d49b113b4ed685ba03526d2007647c306f8ec7ae697d2
2019-03-31 18:17:00 +00:00
drh
6f88359df6 Fix issues with the previous check-in and add more VDBE branch coverage
testing macros.

FossilOrigin-Name: b5f72f10f2dfdbee9fe98c63ffb933e841203790746a920b99df14ca5c14127c
2019-03-30 20:37:04 +00:00
drh
bf00f6d7ec Enhanced VdbeCoverage() macros in the new windows function code.
FossilOrigin-Name: f24066f8dd847dfb656f26c4a8142e7fb6a412ffe325aea6254cb122cfbb3e1c
2019-03-30 20:10:11 +00:00
drh
fc15f4c528 Improved TreeView display of Window objects.
Change the Window.eType field to Window.eFrmType to avoid confusion with
other "eType" values.

FossilOrigin-Name: ec2f207dedb223077bbd3e4584499250eb12219712c917e930acccfa2c46e23b
2019-03-28 13:03:41 +00:00
mistachkin
ba9ee09598 Fix harmless compiler warnings seen with MSVC.
FossilOrigin-Name: 5be64ea8e33f632f9c337feac9b0663d8e6e59fc9a71e5d832d9fd905c06458e
2019-03-27 14:58:18 +00:00
dan
725b1cfc53 Fix a problem with window frames that use "BETWEEN <start> AND 0 PRECEDING".
FossilOrigin-Name: 7927b6b023502e990d23f30251b5b0918b547726b863bfb6747dcd7f1f71d19a
2019-03-26 16:47:17 +00:00
drh
d4a591dd6b Fix harmless compiler warnings.
FossilOrigin-Name: a063f7c426d1ac066bf05cc03288f49b1c92e06a8cb2bc271cce9bd3022a74ea
2019-03-26 16:21:11 +00:00
dan
c7694a6d1d Remove assert() statements based on the counter-factual proposition that 0 is not a valid cursor number.
FossilOrigin-Name: c7b336181aac6785a515f275c0f50ad4bf2dee20abde959b56d968a7fdce3e5b
2019-03-21 13:51:09 +00:00
dan
6603342f12 Fix a problem with EXCLUDE clauses on window frames with no ORDER BY.
FossilOrigin-Name: e0255063799a2a8531f0eaa8790334509591a5ababc5b915035b46d2faa80363
2019-03-19 19:19:53 +00:00
dan
1d4b25fa50 Add missing VdbeCoverage() macros to new code in window.c.
FossilOrigin-Name: 4f9b93e6cfa0b3b6ab8a126299c2b2a242f840453dc450e84d3df87576cf6cf8
2019-03-19 16:49:15 +00:00
dan
e5166e070a Revert the OP_MustBeInt opcode implementation on this branch so that it again matches trunk. The extra functionality is no longer required.
FossilOrigin-Name: c02f77b1b4d025d4243f883d6f3a2b3abcaf4944e0209f641b62c576415343dc
2019-03-19 11:56:39 +00:00
dan
0525b6f47f Add further tests for new window function functionality.
FossilOrigin-Name: 1fbddf01b1c3fff95b05e2f2f709754e2b514296060b4846518791e7161d9ddb
2019-03-18 21:19:40 +00:00
dan
108e6b2c87 Always evaluate window functions using the alternative path usually only used by EXCLUDE frames if the SQLITE_QueryFlattener test flag is set.
FossilOrigin-Name: 2879a691aca9304aea5acb46bab8e82bb2e08eb54201f3679d60bfc0e8383845
2019-03-18 18:55:35 +00:00
dan
bdabe742da Fixes for RANGE windows and NULL values.
FossilOrigin-Name: 723c84be3ec5ae941b7abd2442cdb76ca3bd76a5ce2d830b0e648c6e1424885a
2019-03-18 16:51:24 +00:00
dan
1e7cb19be3 Fix problems with RANGE windows and string, blob and NULL values.
FossilOrigin-Name: cebe09e11cc91d9776f259dd9b87e9c760a460f53ba6fa36481dfe58f77ad417
2019-03-16 20:29:54 +00:00
dan
bf84515a2b In order to identify the first row of each partition, check if the rowid in the ephemeral table is 1 instead of using a dedicated flag register.
FossilOrigin-Name: f2d5f7a24c7aa483c579706c5bd7268a74da6d53025d78fa8642908c2aed1707
2019-03-16 10:15:24 +00:00
dan
c782a81aa5 Implement the EXCLUDE clause for window frames.
FossilOrigin-Name: 9b43c3ee2e054b05715573f4f3893b84aabc5100832333c9a0f2a1628552a978
2019-03-15 20:46:19 +00:00
dan
d35300f9b6 Parse EXCLUDE clauses in window frames. They do not yet work.
FossilOrigin-Name: d03c7533a1e993f1b12392a5193b2127484307b27072236a1255e7a30849a381
2019-03-14 20:53:21 +00:00
dan
a0f6b83300 Add things to this branch that will be required to support the EXCLUDE clause.
FossilOrigin-Name: 7d66cd2013206ebad50c7cdb7dab9211fa8b47f5cb7067dcb314b3e0180875f8
2019-03-14 16:36:20 +00:00
dan
b6f2deac3c Avoid allocating excessive registers for the PARTITION BY expressions when processing window functions.
FossilOrigin-Name: 180be266238e18c01f8bd52c75dd9aa3e26e553620258141cd95189a0ae59ddb
2019-03-13 17:20:27 +00:00
dan
b560a7194d Remove rows from the ephemeral table used by window functions once they are no longer required.
FossilOrigin-Name: 6ad553192051eaa0c6d929baacde2de07b93c6d09de861028bbce55a2c9bfdd3
2019-03-13 15:29:14 +00:00
dan
d446165f7d Minor optimization in sqlite3WindowCodeStep().
FossilOrigin-Name: b1322ffb6e63a110998068bf4f0a903028bd4fc0464ae1e517d745fb46423f39
2019-03-13 08:28:51 +00:00
dan
bb40727857 Allow real values to be used in PRECEDING and FOLLOWING expressions for RANGE window frames.
FossilOrigin-Name: 25ff7091cb12c63b1864ce68a9151f8432af5804b5ae905a2175761ab4b9fdd8
2019-03-12 18:28:51 +00:00
dan
935d9d8260 Expand on header comment for sqlite3WindowCodeStep(). Further simplify the implementation of the same.
FossilOrigin-Name: 5129bcc996b3c9f78ab6b674a4364787e7b353b90f15f027cad4431012022c30
2019-03-12 15:21:51 +00:00
dan
cc7a850f2e Remove "cache mode" from the window frame code generator. Handle the same cases by editing the window frame specification itself.
FossilOrigin-Name: 081263538332bb9c07e62630629007ccbba31bef5dc890f60b4ba58a355f70ac
2019-03-11 19:50:54 +00:00
dan
a786e453a4 Simplify the windows frame code some. Add a comment explaining some of the VM code generated by sqlite3WindowCodeStep().
FossilOrigin-Name: 6bd1a07949ff3d394056bfcc813444401ef00806e3f0e0423ff6962541e84bdb
2019-03-11 18:17:04 +00:00
dan
71fddaf195 Fix problems with "RANGE ... ORDER BY <expr> DESC" window frames.
FossilOrigin-Name: e7bced731aa071c95bc398cdecd53c939841bf0c52fbcd06e47ba68f8c5cc35a
2019-03-11 11:12:34 +00:00
dan
72b9fdcf20 Add support for RANGE window frames. Some cases still do not work.
FossilOrigin-Name: ffc32b246d92d53c66094afe11950b53ffab6a1c230c602eebbfedafb2eb57f4
2019-03-09 20:49:17 +00:00
dan
6c75b39614 Finish consolidation of window frame code. Add untested support for GROUPS frames.
FossilOrigin-Name: 954bf369935083c188c3b14e77ed89fc5ec4323cc5b0c67e4a2e48fcc278df45
2019-03-08 20:02:52 +00:00
dan
54975cdff9 Fix other "ROWS BETWEEN" cases on this branch.
FossilOrigin-Name: a5f68f66472610b5beb4fe28669fbbfe83a32742be73cecad9b2ae28f8a17b30
2019-03-07 20:47:46 +00:00
dan
c813750b7b Modify new window functions function so that cursors are stepped immediately after each operation, instead of immediately before.
FossilOrigin-Name: 093d2b25f1b656bba57d665aac68109436861b157a5769432b612176dae3f6eb
2019-03-07 19:26:17 +00:00
dan
00267b8a7b Simplify the window function code generator some more.
FossilOrigin-Name: 45cbd3b4498cea8856f189e9d0a192556d4f15212055b8328a1beca6083fc47a
2019-03-06 21:04:11 +00:00
dan
b33487b0b6 Improvements to the way built-in window functions are handled.
FossilOrigin-Name: e8eee566dfca6f4c8af074731dfe91f7fbcd9ca72f0303235b52e4e2e80d5b71
2019-03-06 17:12:32 +00:00
dan
b25a214dec Extend windowCodeStep() to handle any ROWS PRECEDING/FOLLOWING frame specification.
FossilOrigin-Name: af0ea1363548461b2aad8fd54ee3f2f616111dcae2d6480f5294da44c87a0a5d
2019-03-05 19:29:36 +00:00
dan
680f6e8e2e Support some "ROWS BETWEEN N PRECEDING AND M FOLLOWING" window functions without caching entire partitions.
FossilOrigin-Name: e7a91f12282afb5d5d7d78397a11d18e0268ee0c931d85e21fce00d13929494e
2019-03-04 21:07:11 +00:00
dan
e7c9ca41b2 Add support for chaining of WINDOW definitions.
FossilOrigin-Name: c155125fd5dddb438c09d40f5137c47d88defb7a6ede4261f09d7bdaad250d37
2019-02-16 17:27:51 +00:00
drh
211a0857b9 Window functions that can abort should indicate this, so that if they are
used in DML statement, a statement journal will be used.

FossilOrigin-Name: 0ea05a0eb96acb860d8af2e788e29a5ae3b161e7892ab62f1ff2f3e722c0dcb6
2019-01-27 02:41:34 +00:00
drh
29c992cb04 Revamp the SrcList allocator routines to be methods of Parse instead of
being methods of the "sqlite3" object, so that they can leave better error
messages when the SrcList object grows too large.

FossilOrigin-Name: df08d472b090b212fb77ce2aae0e1ffe79ae5db4b1accf55e6fdb18e8b0a7098
2019-01-17 15:40:41 +00:00
dan
fb8ac325d7 Avoid a dangling pointer comparison when renaming a table that has a trigger
that itself contains a window function with an (illegal) column reference in a
FOLLOWING expression.

FossilOrigin-Name: d45bee36f2c1091a2d32c16ca8921bf4e7c9e40c46d0a36fbcb179ecfafcfbf0
2019-01-16 12:05:22 +00:00
drh
ec4ccdbcb1 A new implementation of sqlite3VdbeMakeLabel() is faster and makes fewer
memory allocations by deferring memory allocation until 
sqlite3VdbeResolveLabel() is called, at which point the code generator has
a better idea of how big the relocation table needs to be.
The sqlite3VdbeMakeLabel() routine now takes a Parse* parameter instead of
Vdbe*.

FossilOrigin-Name: 4a0929ac76d8aa5dd65eac3b83d6bbf41e505e01d175ca0fb2b19ba02d439415
2018-12-29 02:26:59 +00:00
drh
a838997544 Fix the sqlite3ExprDup() routine so that it makes complete duplications of
subqueries containing window functions.

FossilOrigin-Name: 940174543e87184a0278fcd02e8a096a11510174d9c1d65d21878819790ddaff
2018-12-06 22:04:19 +00:00
dan
0f5f54062c Fix a problem with using window functions in compound (UNION, INTERSECT etc.)
queries.

FossilOrigin-Name: 059ff53a46c7f1e4bf3e7dc558312beef67826c2753e2ab7e4e7df498b37b617
2018-10-23 13:48:19 +00:00
drh
eda079cd2c Combine the Expr.pTab and Expr.pWin fields into a union named "y". Add a new
EP_WinFunc property that is only true if Expr.y.pWin is a valid pointer.
This reduces the size of the Expr object by 8 bytes, reduces the overall
amount of code, and shaves over 1 million cycles off of the speed test.

FossilOrigin-Name: ad130bb86e74e6ce165fdbdce3a19699510f0e62071c1c7923b5a4538d888c7c
2018-09-20 19:02:15 +00:00
drh
954733b386 Improvements to the parser to increase coverage. Fix the parser so that
at least one expresssion is required after PARTITION BY and within the
list of expressions on VALUES().

FossilOrigin-Name: 02204f8b246c868846f39bd44f2e3bc0fab0275aa09ef3a0e5a8e3d58f484ca8
2018-07-27 23:33:16 +00:00
drh
9341916ed5 Adjustments to VdbeCoverage macros to deal with byte-code branches that
can never be taken in some directions.

FossilOrigin-Name: b170c0092b1d0c47dd700843f0c870e51181939607a897fbcae55a58042160f9
2018-07-11 03:27:52 +00:00