SQLite

Check-in [786c87ba41]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Return an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr> FOLLOWING".
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 786c87ba4150509e141baab32c51e64bbd3ce323735e0f47d65ed54d14215bc4
User & Date: dan 2018-07-05 18:34:53.220
Context
2018-07-05
20:05
Get the json_group_array() and json_group_object() SQL functions working as window functions. (check-in: 916cdc83f5 user: drh tags: trunk)
18:34
Return an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr> FOLLOWING". (check-in: 786c87ba41 user: dan tags: trunk)
18:19
Fix a problem in the xInverse method of window-function group_concat(1). (check-in: 7339128310 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/window.c.
833
834
835
836
837
838
839







840

841
842
843
844
845
846
847
*/
Window *sqlite3WindowAlloc(
  Parse *pParse, 
  int eType,
  int eStart, Expr *pStart,
  int eEnd, Expr *pEnd
){







  Window *pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));


  if( pWin ){
    assert( eType );
    pWin->eType = eType;
    pWin->eStart = eStart;
    pWin->eEnd = eEnd;
    pWin->pEnd = pEnd;







>
>
>
>
>
>
>
|
>







833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
*/
Window *sqlite3WindowAlloc(
  Parse *pParse, 
  int eType,
  int eStart, Expr *pStart,
  int eEnd, Expr *pEnd
){
  Window *pWin = 0;

  if( eType==TK_RANGE && (pStart || pEnd) ){
    sqlite3ErrorMsg(pParse, "RANGE %s is only supported with UNBOUNDED",
        (pStart ? "PRECEDING" : "FOLLOWING")
    );
  }else{
    pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  }

  if( pWin ){
    assert( eType );
    pWin->eType = eType;
    pWin->eStart = eStart;
    pWin->eEnd = eEnd;
    pWin->pEnd = pEnd;
Changes to test/window6.test.
213
214
215
216
217
218
219










220
221

do_execsql_test 9.0 {
  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
  SELECT x, group_concat(x) OVER (ORDER BY x ROWS 2 PRECEDING)
  FROM c;
} {
  1 1  2 1,2  3 1,2,3  4 2,3,4  5 3,4,5
}











finish_test








>
>
>
>
>
>
>
>
>
>


>
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
do_execsql_test 9.0 {
  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
  SELECT x, group_concat(x) OVER (ORDER BY x ROWS 2 PRECEDING)
  FROM c;
} {
  1 1  2 1,2  3 1,2,3  4 2,3,4  5 3,4,5
}
do_catchsql_test 9.1 {
  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
  SELECT x, group_concat(x) OVER (ORDER BY x RANGE 2 PRECEDING)
  FROM c;
} {1 {RANGE PRECEDING is only supported with UNBOUNDED}}
do_catchsql_test 9.2 {
  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
  SELECT x, group_concat(x) OVER (ORDER BY x RANGE BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING)
  FROM c;
} {1 {RANGE FOLLOWING is only supported with UNBOUNDED}}

finish_test