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
drh
bb383df7c6
New test case that still hits an assertion fault, just to prove that the
...
previous checkin merely made the problem more obscure and did not completely
fix it.
FossilOrigin-Name: a9a3b532643b5f106509bb29c3e6bc9d41ec5b2da5a0cd4067898f376eb626a2
2018-12-06 19:56:20 +00:00
drh
11df7d2839
Simplify the query flattener so that it does not duplicate the WHERE clause
...
of subquery that is being incorporated into the outer query - copies it
directly. This is more efficient. And it also fixes the specific test case
show for ticket [f09fcd17810f65f71789525] but it does not resolve the more
general problem that sqlite3ExprDup() does not correctly duplicate expressions
that contain subqueries with window functions.
FossilOrigin-Name: f1b18d44ff855573542c1947a42d4025dff54cacc13dac14d044521762ea9736
2018-12-06 19:15:36 +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
d4cb09e3d2
Disable the ORDER BY LIMIT optimization in queries using window functions.
...
This fixes a problem that was introduced by check-in [206720129ed2fa8875a286]
which attempted to fix ticket [9936b2fa443fec03ff25f9]. This changes is
a fix for the follow-in tocket [510cde277783b5fb5de628].
FossilOrigin-Name: c6c9585f294710829ca24b64d70a36fd9f409261dd0661367c6c4198cdbc4c81
2018-09-17 15:19:13 +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