dan
27da907f8e
Fix a problem causing queries containing window functions to ignore collation sequences under some circumstances.
...
FossilOrigin-Name: e6c2192ef88e9990c8b91755c8e779f09e23f936a17123d8e42059257b756ed7
2020-07-13 15:20:27 +00:00
dan
46daa99b8d
Avoid rewriting compound SELECT statements that use a different collation sequence for ORDER BY and record processing a second time if they contain window functions. Fix for [b706351c].
...
FossilOrigin-Name: 32a88bdd4be5acdc1b80856bf6e32724dc3a467d5050bec0fe1a3dfedcc06f34
2020-06-11 15:53:54 +00:00
dan
f65e379919
Ensure that the "push-down" optimization does not push constraints down into compound queries if any of the component queries uses window functions.
...
FossilOrigin-Name: 094dcfe779613301521e8bb990432df187b3686add75a3420b4a193f02f3467f
2020-06-10 10:58:15 +00:00
drh
bf7909734a
AggInfo objects might be referenced even after the sqlite3Select() function
...
that created them has exited. So AggInfo cannot be a stack variable. And it
must not be freed until the Parse object is destroyed.
FossilOrigin-Name: 3c840b4df306e2db1da08673e9ede973b4cb6d2b3f9eeeab5835e39452ee3056
2020-06-07 20:18:07 +00:00
drh
896366282d
Alternative fix to ticket [c8d3b9f0a750a529]: Prior to deleting or modifying
...
an Expr not that is referenced by an AggInfo, modify the AggInfo to get its
own copy of the original Expr.
FossilOrigin-Name: 7682d8a768fbccfe0cc956e9f6481637146e1ab9763b248ff11052761ce32e32
2020-06-07 17:33:18 +00:00
drh
c37577bb2d
When rewriting a query for window functions, if the rewrite changes the
...
depth of TK_AGG_FUNCTION nodes, be sure to adjust the Expr.op2 field
appropriately. Fix for ticket [7a5279a25c57adf1]
FossilOrigin-Name: ad7bb70af9bb68d192137188bb2528f1e9e43ad164c925174ca1dafc9e1f5339
2020-05-24 03:38:37 +00:00
dan
efa78884a8
Fix a problem handling constant integer expressions with collation sequences in PARTITION BY clauses.
...
FossilOrigin-Name: 155e6649efe8614718be7ac6c3cccf5b073ae57496dc220db5e4313621f5188e
2020-05-11 10:55:24 +00:00
drh
c415d91007
In the event of a semantic error in an aggregate query, early-out the
...
resetAccumulator() function to prevent problems due to incomplete or
incorrect initialization of the AggInfo object.
Fix for ticket [af4556bb5c285c08].
FossilOrigin-Name: 4a302b42c7bf5e11ddb5522ca999f74aba397d3a7eb91b1844bb02852f772441
2020-04-03 13:19:03 +00:00
dan
0a21ea997d
Fix a problem with window functions occuring within sub-selects that are part of an OR term in a WHERE clause of the outer SELECT.
...
FossilOrigin-Name: 1e174ed0d29366eb56ad1a0cc8defcb440b426bfd9525aed2f93468248606efc
2020-02-29 17:19:42 +00:00
dan
fbb6e9ff48
Fix an assert() in window.c that could fail with some obscure SELECT statements that use window functions.
...
FossilOrigin-Name: 83dc55679a91bf5d1d13706088ce58eed02b9aad1ad0ae237966e78e0d769663
2020-01-09 20:11:29 +00:00
dan
aa328b6ab1
Ensure that when a Select object is reset a new, empty, SrcList is allocated.
...
FossilOrigin-Name: 4889cbf898d7ec54f061b21b6d3621b22fc482cbeaa7115d40995a4cc30e41db
2020-01-03 13:55:14 +00:00
dan
4ea562ee70
Ensure that when code for a scalar SELECT featuring window functions is generated more than once by the planner, separate ephemeral tables are opened for each instance.
...
FossilOrigin-Name: ce1417325273aba866767349b55d9bbfb61a08e716bebda2122918a9657ee38c
2020-01-01 20:17:15 +00:00
dan
997d7434b7
Do not attempt to flatten compound sub-queries in a FROM clause into the parent if any component of the sub-query uses a window function.
...
FossilOrigin-Name: eeb76f621de2f930a548db0fbb9fe25b4479b73581826b8dfa2e63cd1f1ab783
2019-12-28 18:25:51 +00:00
dan
b4b3630657
Remove a NEVER() that is no longer true. Fix for [36ffedcb9].
...
FossilOrigin-Name: 597896ed0ae9e2960a8f39576bd7f77a11dccc1da84b6a44ebb5c38d90ebc330
2019-12-27 20:06:32 +00:00
dan
e3735bf466
Fix a problem involving window function aliases being referenced from sub-selects.
...
FossilOrigin-Name: e3b5fc05c00fc58be7a7c94ce1d97a5b05113f39aba03df64aab08364f85616b
2019-12-27 19:46:07 +00:00
drh
6473ba95a0
Add a missing "ifcapable rtree {...}" line to the window1.test test module.
...
FossilOrigin-Name: 4e6fbb1a5100fe29209bcf668fbecf3a733034b84925265d8a15b0a84baf6cf0
2019-12-27 18:15:04 +00:00
dan
431704375e
Fix a problem with window functions in aggregate queries that do not have GROUP BY clauses.
...
FossilOrigin-Name: 99609786f485653464d1caef1d207ae299d28c925bff3e8e94891759b4765dcc
2019-12-27 16:25:56 +00:00
dan
d8d2fb9222
Do not mistake constant integers in a PARTITION BY expression for references to ORDER BY style references to values returned by the SELECT statement.
...
FossilOrigin-Name: 45c64d39d5afed7fdc6b1de19408559740d1fba1f5e0269ab68b132366a289e4
2019-12-27 15:31:47 +00:00
dan
5e484cb3eb
When determining if an aggregate within a sub-query should be processed as part of the sub-query or an outer query, consider any FILTER clause in the same way as the arguments to the aggregate.
...
FossilOrigin-Name: 1ffc045d2bbeeda9c13a3a3585538ff6434fc852b0ae6679d3c8b9f606bf92e6
2019-12-27 08:57:08 +00:00
drh
a9ebfe2030
When the sqlite3WindowRewrite() routine detects and error, have it convert
...
the SELECT statement into just "SELECT null" so that it does not leave the
parse tree in a goofy state that can cause problems with subsequent code
before the stack has a chance to unwind and report the error.
Ticket [d87336c81c7d0873]
FossilOrigin-Name: fa58aad48a788802b13a819e49f9b8787f713bbe395c46c7295e821c52c81738
2019-12-25 23:54:21 +00:00
dan
1d24a53125
Fix a case in which SQLite could fail to identify "x BETWEEN ? AND ?" being true as implying that x is not null. Ticket [dfd66334].
...
FossilOrigin-Name: 2f17974912ec5e99089dc0da803e7ff1bf033377a49762d2689a812c005f2641
2019-12-23 15:17:11 +00:00
dan
2811ea6be7
For expressions like (x, y) IN (SELECT ...) where the SELECT uses window-functions, require that all columns on the LHS be indexed before an index can be used. Fix for [d9ed4ebe].
...
FossilOrigin-Name: 0b1dbd60f5db3abe2097dbc0b6de9671685ca5eaf7d3fc8e3f87ff5065a9d114
2019-12-23 14:20:46 +00:00
drh
8cc8feae7e
When computing dependencies on WHERE-clause terms, be sure to take into
...
account the FILTER clause of aggregate functions. Problem reported by
Manuel Rigger.
FossilOrigin-Name: 3cc2b5709e66ef605c3b85ed13ae6cc9c3090e864ebc18859db36284b8f715b6
2019-12-20 15:35:56 +00:00
drh
8c72afaf33
Add a test case for fix in check-in [1ca0bd982ab1183b]
...
FossilOrigin-Name: 519864da8bb671941a64bf333c2086ad9a068b5f85759e7abd368f0706d3aefd
2019-12-18 09:17:55 +00:00
drh
29cdbadf8a
Correctly deal with multi-row VALUES clauses that contain window functions.
...
FossilOrigin-Name: 26d991f214db143976e2593d3564b5003eb3539a2728d1a0ccae2a2accece76f
2019-12-07 13:42:47 +00:00
dan
fcc057db25
Fix a double-free that could occur when a component of a compound SELECT with an ORDER BY clause uses named window definitions.
...
FossilOrigin-Name: 92893b7980cbb0c6e26bc0b21390a717193205c9897fea5f26476462928897f9
2019-12-04 01:42:07 +00:00
dan
62be2dc753
Avoid evaluating PARTITION BY or ORDER BY expressions multiple times for window function queries that use multiple window functions with the same window-definition.
...
FossilOrigin-Name: 57070c68bbe15fc1d19a765182432e844c082909bdbc63b58fd86b96e2c521dd
2019-11-23 15:10:28 +00:00
dan
e59c562b3f
Fix a crash that could occur if a sub-select that uses both DISTINCT and window functions also used an ORDER BY that is the same as its select list.
...
FossilOrigin-Name: bcdd66c1691955c697f3d756c2b035acfe98f6aad72e90b0021bab6e9023b3ba
2019-11-22 10:14:01 +00:00
drh
47bcc34271
Fix a potential NULL pointer dereference on a RENAME TABLE that references
...
a VIEW with a logic error in a window function in the ORDER BY clause.
FossilOrigin-Name: 0adb273f7e7671efb0e0a1619887e369500dfd2db7ef1b1e125c2414ea96e96f
2019-11-16 11:33:39 +00:00
dan
3703edf110
Be sure to rewrite column references inside FILTER clauses and window frame definitions when flattening queries. Fix for [1079ad19].
...
FossilOrigin-Name: ccba7202b69d239724c3b589439c9c3b0e1bba237accfeb11c39d492522b8719
2019-10-10 15:17:09 +00:00
drh
b555b0806e
Fix a new problem in the BETWEEN operator when applied to a window function.
...
The problem was introduced yesterday by check-in [7ef7b23cbb1b9ace].
FossilOrigin-Name: 47e23064ba0205148f89e12803a62d5a4d6d2054f593f60c031e815112170b9b
2019-07-19 01:11:27 +00:00
dan
8f245174a3
Fix a typo in test file window1.test.
...
FossilOrigin-Name: 8c80e81d01abde9a5032cdc1a492d0fccd8db139f78d2db9413a60cfdc8e0f64
2019-07-13 17:54:24 +00:00
dan
5e61c1b741
Fix error handling for the case where a window function is passed the wrong number of arguments.
...
FossilOrigin-Name: 871796bb19e61c1282d8ac97a82d8b57bde50f2a2a08004ab53136d77c138df4
2019-07-13 17:45:25 +00:00
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
dan
afb3f3c72c
Add a test case to cover a missed VDBE branch generated by window.c.
...
FossilOrigin-Name: b36813d6467c82159bd3bb69d34ac28fc161a13052ca67d7cf9ad75e2aaea9d5
2019-04-01 18:43:09 +00:00
dan
781b7ac3f6
Fix a problem with a window function in a correlated sub-query where at least one reference to the outer SELECT appears in a FROM clause sub-select.
...
FossilOrigin-Name: 9aca86f98388ff66b2bccb3fbfc486a3931398d2a8da139f905826ae2cdbb205
2019-03-22 13:56:49 +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
8eff0cc326
Add tests to ensure that the window functions implementation is not generating code for unnecessary sorts.
...
FossilOrigin-Name: e195948a6876efe01b5cf2ed67bc9015a781fda39dca668099cb7edc1d331818
2019-03-19 17:45:31 +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
ced89124d8
Ensure that all the new window-function keywords can still be used as SQL identifiers.
...
FossilOrigin-Name: a6d61dfd4780eccfce5f7a5ead6c04e3b78bc4a461551fd7dd602550e0d51084
2019-03-19 06:40:29 +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
db7d895e9d
Merge latest trunk changes into this branch.
...
FossilOrigin-Name: 0b904517bd6c4c59082381577246d3d2351b4265fc9151438ee4c33cf16f2eb1
2019-03-13 17:31:20 +00:00
dan
9e24439c2f
Fix a crash that could occur if the RHS of an IN expression is a correlated sub-query that refers to the outer query from within a window frame definition only.
...
FossilOrigin-Name: 0524aaaf45681437c2dca3d31ff26a65bee7bd2074730277c29136635ee0be0f
2019-03-12 09:49:10 +00:00
dan
4e72e62f3b
Merge trunk changes into this branch.
...
FossilOrigin-Name: 9b4d561f68febdab6624d8c567fb4357bf67dda500664cf708d16a76f37b8ec1
2019-03-04 21:08:53 +00:00
dan
f030b37682
Internally, remove all references to a Window object that belongs to an expression in an ORDER BY clause if that expression is converted to an alias of a result-set expression. Fix for [4feb3159c6].
...
FossilOrigin-Name: 579b66eaa0816561c6e47ea116b46f229188f0fc84c1173bfe0d21df2dff9a9a
2019-02-22 19:24:16 +00:00
dan
e7c9ca41b2
Add support for chaining of WINDOW definitions.
...
FossilOrigin-Name: c155125fd5dddb438c09d40f5137c47d88defb7a6ede4261f09d7bdaad250d37
2019-02-16 17:27:51 +00:00
dan
d99950310f
Fix problems with sub-selects in WINDOW definitions. Also rename-column operations when the column being renamed appears in a WINDOW definition that is part of a VIEW or TRIGGER.
...
FossilOrigin-Name: 0387cb3add992b2028efe4f2100188d8f9fdfdcb233329857aa4b46a293cfc97
2019-01-23 16:59:24 +00:00
dan
97c8cb3ed8
Ensure that when a new cursor is opened by OP_OpenDup, any existing cursor
...
with the same id opened by a previous OP_OpenDup is closed first.
FossilOrigin-Name: 5c188361a91407805c0feb4bf6d3214522ce3e55013efcf63a4613ecd416bcbc
2019-01-01 18:00:17 +00:00
drh
4afdfa195b
Fix the OP_OpenEphemeral opcode in the bytecode engine so that if it is called
...
a second or subsequent time, it merely clears the existing table rather than
creating a new one. Proposed fix for ticket [d0866b26f83e9c55e30de0821f5d].
FossilOrigin-Name: 4678cb1044f0b4dc813e48f3bd0f85240a66e2ecf8763280d66726cc031c93a7
2018-12-31 16:36:42 +00:00
drh
3a07548b0d
Remove unnecessary whitespace from testcase result strings.
...
FossilOrigin-Name: ad70f03ceda74163903d247a975666b35fae722a27c48dd3efd31c1164b5627e
2018-12-22 15:46:23 +00:00