/ Check-in [e74c6e91]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Further window frame tests and fixes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | exp-window-functions
Files: files | file ages | folders
SHA3-256: e74c6e91859ec395c12ba2742542ff176a1d8364dcfb66b862240746bef54efc
User & Date: dan 2018-05-28 18:30:45
Context
2018-05-30
20:44
Allow min() and max() to be used as window functions. check-in: c16125a8 user: dan tags: exp-window-functions
2018-05-28
18:30
Further window frame tests and fixes. check-in: e74c6e91 user: dan tags: exp-window-functions
2018-05-26
21:17
More fixes for different window frame types. check-in: 2c85668a user: dan tags: exp-window-functions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/window.c.

   108    108         sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
   109    109       }
   110    110       sqlite3VdbeAddOp3(v, OP_AggStep0, bInverse, reg, pWin->regAccum);
   111    111       sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
   112    112       sqlite3VdbeChangeP5(v, (u8)pWin->nArg);
   113    113     }
   114    114   }
          115  +
          116  +static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
          117  +  Vdbe *v = sqlite3GetVdbe(pParse);
          118  +  Window *pWin;
          119  +
          120  +  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
          121  +    if( bFinal==0 ){
          122  +      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
          123  +    }
          124  +    sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, pWin->nArg);
          125  +    sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
          126  +    if( bFinal ){
          127  +      sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
          128  +    }else{
          129  +      sqlite3VdbeChangeP3(v, -1, pWin->regResult);
          130  +    }
          131  +  }
          132  +}
          133  +
   115    134   
   116    135   /*
   117    136   ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
   118    137   ** ----------------------------------------------------
   119    138   **
   120    139   ** Pseudo-code for the implementation of this window frame type is as
   121    140   ** follows. sqlite3WhereBegin() has already been called to generate the
................................................................................
   268    287     int addrIfPos1;
   269    288     int addrIfPos2;
   270    289   
   271    290     int regPeer = 0;                 /* Number of peers in current group */
   272    291     int regPeerVal = 0;              /* Array of values identifying peer group */
   273    292     int iPeer = 0;                   /* Column offset in eph-table of peer vals */
   274    293     int nPeerVal;                    /* Number of peer values */
          294  +  int bRange = 0;
   275    295   
   276    296     assert( pMWin->eStart==TK_PRECEDING 
   277    297          || pMWin->eStart==TK_CURRENT 
   278    298          || pMWin->eStart==TK_FOLLOWING 
   279    299          || pMWin->eStart==TK_UNBOUNDED 
   280    300     );
   281    301     assert( pMWin->eEnd==TK_FOLLOWING 
   282    302          || pMWin->eEnd==TK_CURRENT 
   283    303          || pMWin->eEnd==TK_UNBOUNDED 
   284    304          || pMWin->eEnd==TK_PRECEDING 
   285    305     );
          306  +
          307  +  if( pMWin->eType==TK_RANGE 
          308  +   && pMWin->eStart==TK_CURRENT 
          309  +   && pMWin->eEnd==TK_UNBOUNDED
          310  +  ){
          311  +    bRange = 1;
          312  +  }
   286    313   
   287    314     pParse->nMem += nSub + 2;
   288    315   
   289    316     /* Allocate register and label for the "flush_partition" sub-routine. */
   290    317     regFlushPart = ++pParse->nMem;
   291    318     lblFlushPart = sqlite3VdbeMakeLabel(v);
   292    319     lblFlushDone = sqlite3VdbeMakeLabel(v);
................................................................................
   382    409   
   383    410     if( pMWin->eEnd==TK_FOLLOWING ){
   384    411       addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
   385    412     }
   386    413     if( pMWin->eStart==TK_FOLLOWING ){
   387    414       addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
   388    415     }
   389         -  if( pMWin->eType==TK_RANGE ){
          416  +  if( bRange ){
   390    417       assert( pMWin->eStart==TK_CURRENT && pMWin->pOrderBy );
   391    418       regPeer = ++pParse->nMem;
   392    419       regPeerVal = pParse->nMem+1;
   393    420       iPeer = pMWin->nBufferCol + (pMWin->pPartition?pMWin->pPartition->nExpr:0);
   394    421       nPeerVal = pMWin->pOrderBy->nExpr;
   395    422       pParse->nMem += (2 * nPeerVal);
   396    423       for(k=0; k<nPeerVal; k++){
   397    424         sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, iPeer+k, regPeerVal+k);
   398    425       }
   399    426       sqlite3VdbeAddOp2(v, OP_Integer, 0, regPeer);
   400    427     }
   401         -  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
   402         -    sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
   403         -    sqlite3VdbeAddOp3(v, 
   404         -        OP_AggFinal, pWin->regAccum, pWin->nArg, pWin->regResult
   405         -    );
   406         -    sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
   407         -  }
   408         -  if( pMWin->eType==TK_RANGE ){
          428  +  windowAggFinal(pParse, pMWin, 0);
          429  +  if( bRange ){
   409    430       sqlite3VdbeAddOp2(v, OP_AddImm, regPeer, 1);
   410    431     }
   411    432     sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
   412    433     sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
   413    434     sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
   414         -  if( pMWin->eType==TK_RANGE ){
          435  +  if( bRange ){
   415    436       KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy,0,0);
   416    437       int addrJump = sqlite3VdbeCurrentAddr(v)-4;
   417    438       for(k=0; k<nPeerVal; k++){
   418    439         int iOut = regPeerVal + nPeerVal + k;
   419    440         sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, iPeer+k, iOut);
   420    441       }
   421    442       sqlite3VdbeAddOp3(v, OP_Compare, regPeerVal, regPeerVal+nPeerVal, nPeerVal);
................................................................................
   431    452      || pMWin->eStart==TK_PRECEDING 
   432    453      || pMWin->eStart==TK_FOLLOWING 
   433    454     ){
   434    455       int addrJumpHere = 0;
   435    456       if( pMWin->eStart==TK_PRECEDING ){
   436    457         addrJumpHere = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
   437    458       }
   438         -    if( pMWin->eType==TK_RANGE ){
          459  +    if( bRange ){
   439    460         sqlite3VdbeAddOp3(v, OP_IfPos, regPeer, sqlite3VdbeCurrentAddr(v)+2, 1);
   440    461         addrJumpHere = sqlite3VdbeAddOp0(v, OP_Goto);
   441    462       }
   442    463       sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
   443    464       windowAggStep(pParse, pMWin, csrStart, 1, reg);
   444         -    if( pMWin->eType==TK_RANGE ){
          465  +    if( bRange ){
   445    466         sqlite3VdbeAddOp2(v, OP_Goto, 0, addrJumpHere-1);
   446    467       }
   447    468       if( addrJumpHere ){
   448    469         sqlite3VdbeJumpHere(v, addrJumpHere);
   449    470       }
   450    471     }
   451    472     if( pMWin->eEnd==TK_FOLLOWING ){
................................................................................
   495    516     int k;
   496    517     int iSubCsr = p->pSrc->a[0].iCursor;
   497    518     int nSub = p->pSrc->a[0].pTab->nCol;
   498    519     int reg = pParse->nMem+1;
   499    520     int regRecord = reg+nSub;
   500    521     int regRowid = regRecord+1;
   501    522     int addr;
          523  +  ExprList *pPart = pMWin->pPartition;
          524  +  ExprList *pOrderBy = pMWin->pOrderBy;
   502    525   
   503    526     assert( pMWin->eType==TK_RANGE 
   504    527         || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
   505    528     );
          529  +
          530  +  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
          531  +       || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
          532  +       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
          533  +       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)
          534  +  );
          535  +
          536  +  if( pMWin->eEnd==TK_UNBOUNDED ){
          537  +    pOrderBy = 0;
          538  +  }
   506    539   
   507    540     pParse->nMem += nSub + 2;
   508    541   
   509    542     /* Martial the row returned by the sub-select into an array of 
   510    543     ** registers. */
   511    544     for(k=0; k<nSub; k++){
   512    545       sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
   513    546     }
   514    547   
   515    548     /* Check if this is the start of a new partition or peer group. */
   516         -  if( pMWin->regPart ){
   517         -    ExprList *pPart = pMWin->pPartition;
          549  +  if( pPart || pOrderBy ){
   518    550       int nPart = (pPart ? pPart->nExpr : 0);
   519         -    ExprList *pOrderBy = pMWin->pOrderBy;
   520         -    int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
   521    551       int addrGoto = 0;
   522    552       int addrJump = 0;
          553  +    int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
   523    554   
   524    555       if( pPart ){
   525    556         int regNewPart = reg + pMWin->nBufferCol;
   526    557         KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
   527    558         addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
   528    559         sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
   529    560         addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
   530         -      for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
   531         -        sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, pWin->nArg);
   532         -        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
   533         -        sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
   534         -      }
          561  +      windowAggFinal(pParse, pMWin, 1);
   535    562         if( pOrderBy ){
   536    563           addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
   537    564         }
   538    565       }
   539    566   
   540    567       if( pOrderBy ){
   541    568         int regNewPeer = reg + pMWin->nBufferCol + nPart;
................................................................................
   546    573           KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
   547    574           addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
   548    575           sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
   549    576           addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
   550    577         }else{
   551    578           addrJump = 0;
   552    579         }
   553         -      for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
   554         -        sqlite3VdbeAddOp3(v, 
   555         -            OP_AggFinal, pWin->regAccum, pWin->nArg, pWin->regResult
   556         -        );
   557         -        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
   558         -      }
          580  +      windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
   559    581         if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
   560    582       }
   561    583   
   562    584       sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
   563    585       sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
   564    586       sqlite3VdbeAddOp3(
   565    587           v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
................................................................................
   584    606     }
   585    607     sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
   586    608     sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
   587    609   
   588    610     /* End the database scan loop. */
   589    611     sqlite3WhereEnd(pWInfo);
   590    612   
   591         -  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
   592         -    sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, pWin->nArg);
   593         -    sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
   594         -    sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
   595         -  }
          613  +  windowAggFinal(pParse, pMWin, 1);
   596    614     sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
   597    615   }
   598    616   
   599    617   
   600    618   /*
   601    619   ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
   602    620   **
................................................................................
   658    676     int regGosub, 
   659    677     int addrGosub,
   660    678     int *pbLoop
   661    679   ){
   662    680     Window *pMWin = p->pWin;
   663    681   
   664    682     if( (pMWin->eType==TK_ROWS 
   665         -   && (pMWin->eStart!=TK_UNBOUNDED || pMWin->eEnd!=TK_CURRENT))
   666         -   || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
          683  +   && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy))
          684  +   || (pMWin->eStart==TK_CURRENT&&pMWin->eEnd==TK_UNBOUNDED&&pMWin->pOrderBy)
   667    685     ){
   668    686       *pbLoop = 0;
   669    687       windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
   670    688       return;
   671    689     }
   672    690   
   673    691     *pbLoop = 1;
   674    692     windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
   675    693   }
   676    694   
   677    695   

Changes to test/window2.tcl.

   427    427   
   428    428   execsql_test 4.3 {
   429    429     SELECT b, sum(b) OVER (
   430    430       ORDER BY b
   431    431       ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
   432    432     ) FROM t2 ORDER BY b;
   433    433   }
          434  +
          435  +execsql_test 4.4 {
          436  +  SELECT b, sum(b) OVER (
          437  +    ORDER BY b
          438  +    RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          439  +  ) FROM t2 ORDER BY b;
          440  +}
          441  +
          442  +execsql_test 4.5 {
          443  +  SELECT b, sum(b) OVER (
          444  +    ORDER BY b
          445  +    RANGE BETWEEN CURRENT ROW AND CURRENT ROW
          446  +  ) FROM t2 ORDER BY b;
          447  +}
          448  +
          449  +execsql_test 4.6.1 {
          450  +  SELECT b, sum(b) OVER (
          451  +    RANGE BETWEEN CURRENT ROW AND CURRENT ROW
          452  +  ) FROM t2 ORDER BY b;
          453  +}
          454  +execsql_test 4.6.2 {
          455  +  SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
          456  +}
          457  +execsql_test 4.6.3 {
          458  +  SELECT b, sum(b) OVER (
          459  +    RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          460  +  ) FROM t2 ORDER BY b;
          461  +}
          462  +execsql_test 4.6.4 {
          463  +  SELECT b, sum(b) OVER (
          464  +    RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          465  +  ) FROM t2 ORDER BY b;
          466  +}
          467  +
          468  +execsql_test 4.7.1 {
          469  +  SELECT b, sum(b) OVER (
          470  +    ROWS BETWEEN CURRENT ROW AND CURRENT ROW
          471  +  ) FROM t2 ORDER BY 1, 2;
          472  +}
          473  +execsql_test 4.7.2 {
          474  +  SELECT b, sum(b) OVER (
          475  +    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
          476  +  ) FROM t2 ORDER BY 1, 2;
          477  +}
          478  +execsql_test 4.7.3 {
          479  +  SELECT b, sum(b) OVER (
          480  +    ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          481  +  ) FROM t2 ORDER BY 1, 2;
          482  +}
          483  +execsql_test 4.7.4 {
          484  +  SELECT b, sum(b) OVER (
          485  +    ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          486  +  ) FROM t2 ORDER BY 1, 2;
          487  +}
          488  +
          489  +execsql_test 4.8.1 {
          490  +  SELECT b, sum(b) OVER (
          491  +    ORDER BY a
          492  +    ROWS BETWEEN CURRENT ROW AND CURRENT ROW
          493  +  ) FROM t2 ORDER BY 1, 2;
          494  +}
          495  +execsql_test 4.8.2 {
          496  +  SELECT b, sum(b) OVER (
          497  +    ORDER BY a
          498  +    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
          499  +  ) FROM t2 ORDER BY 1, 2;
          500  +}
          501  +execsql_test 4.8.3 {
          502  +  SELECT b, sum(b) OVER (
          503  +    ORDER BY a
          504  +    ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          505  +  ) FROM t2 ORDER BY 1, 2;
          506  +}
          507  +execsql_test 4.8.4 {
          508  +  SELECT b, sum(b) OVER (
          509  +    ORDER BY a
          510  +    ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          511  +  ) FROM t2 ORDER BY 1, 2;
          512  +}
   434    513   
   435    514   
   436    515   
   437    516   finish_test
   438    517   
   439    518   

Changes to test/window2.test.

   341    341       ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
   342    342     ) FROM t2 ORDER BY b;
   343    343   } {0 0   1 1   1 2   2 4   2 6   2 8   3 11   3 14   4 18   5 23   6 29   7 36   7 43   7 50   8 58   8 66   8 74   9 83   9 92   9 101   10 111   11 122   11 133   12 145   12 157   12 169   13 182   13 195   14 209   15 224   15 239   15 254   16 270   16 286   16 302   17 319   19 338   20 358   21 379   21 400   22 422   22 444   23 467   23 490   23 513   24 537   25 562   26 588   26 614   26 640   27 667   27 694   28 722   29 751   29 780   29 809   30 839   30 869   30 899   31 930   31 961   32 993   33 1026   33 1059   33 1092   33 1125   33 1158   34 1192   34 1226   34 1260   34 1294   35 1329   35 1364   36 1400   36 1436   36 1472   36 1508   37 1545   37 1582   38 1620   38 1658   39 1697   39 1736   39 1775   40 1815   41 1856   41 1897   41 1938   42 1980   43 2023   43 2066   44 2110   44 2154   46 2200   46 2246   47 2293   47 2340   47 2387   47 2434   49 2483   50 2533   51 2584   52 2636   53 2689   54 2743   55 2798   55 2853   56 2909   56 2965   56 3021   57 3078   58 3136   58 3194   58 3252   58 3310   59 3369   59 3428   59 3487   59 3546   60 3606   61 3667   61 3728   62 3790   62 3852   63 3915   64 3979   65 4044   65 4109   65 4174   66 4240   67 4307   68 4375   69 4444   70 4514   72 4586   72 4658   72 4730   73 4803   73 4876   73 4949   74 5023   74 5097   74 5171   74 5245   74 5319   75 5394   75 5469   75 5544   76 5620   77 5697   77 5774   78 5852   78 5930   79 6009   80 6089   80 6169   81 6250   81 6331   81 6412   82 6494   83 6577   84 6661   84 6745   84 6829   84 6913   85 6998   85 7083   85 7168   86 7254   87 7341   87 7428   88 7516   89 7605   89 7694   89 7783   90 7873   90 7963   90 8053   91 8144   91 8235   91 8326   91 8417   91 8508   93 8601   93 8694   93 8787   94 8881   95 8976   95 9071   95 9166   96 9262   96 9358   96 9454   97 9551   97 9648   98 9746   98 9844   99 9943   99 10042   99 10141}
   344    344   
   345    345   do_execsql_test 4.4 {
   346    346     SELECT b, sum(b) OVER (
   347    347       ORDER BY b
   348         -    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
          348  +    RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          349  +  ) FROM t2 ORDER BY b;
          350  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          351  +
          352  +do_execsql_test 4.5 {
          353  +  SELECT b, sum(b) OVER (
          354  +    ORDER BY b
          355  +    RANGE BETWEEN CURRENT ROW AND CURRENT ROW
          356  +  ) FROM t2 ORDER BY b;
          357  +} {0 0   1 2   1 2   2 6   2 6   2 6   3 6   3 6   4 4   5 5   6 6   7 21   7 21   7 21   8 24   8 24   8 24   9 27   9 27   9 27   10 10   11 22   11 22   12 36   12 36   12 36   13 26   13 26   14 14   15 45   15 45   15 45   16 48   16 48   16 48   17 17   19 19   20 20   21 42   21 42   22 44   22 44   23 69   23 69   23 69   24 24   25 25   26 78   26 78   26 78   27 54   27 54   28 28   29 87   29 87   29 87   30 90   30 90   30 90   31 62   31 62   32 32   33 165   33 165   33 165   33 165   33 165   34 136   34 136   34 136   34 136   35 70   35 70   36 144   36 144   36 144   36 144   37 74   37 74   38 76   38 76   39 117   39 117   39 117   40 40   41 123   41 123   41 123   42 42   43 86   43 86   44 88   44 88   46 92   46 92   47 188   47 188   47 188   47 188   49 49   50 50   51 51   52 52   53 53   54 54   55 110   55 110   56 168   56 168   56 168   57 57   58 232   58 232   58 232   58 232   59 236   59 236   59 236   59 236   60 60   61 122   61 122   62 124   62 124   63 63   64 64   65 195   65 195   65 195   66 66   67 67   68 68   69 69   70 70   72 216   72 216   72 216   73 219   73 219   73 219   74 370   74 370   74 370   74 370   74 370   75 225   75 225   75 225   76 76   77 154   77 154   78 156   78 156   79 79   80 160   80 160   81 243   81 243   81 243   82 82   83 83   84 336   84 336   84 336   84 336   85 255   85 255   85 255   86 86   87 174   87 174   88 88   89 267   89 267   89 267   90 270   90 270   90 270   91 455   91 455   91 455   91 455   91 455   93 279   93 279   93 279   94 94   95 285   95 285   95 285   96 288   96 288   96 288   97 194   97 194   98 196   98 196   99 297   99 297   99 297}
          358  +
          359  +do_execsql_test 4.6.1 {
          360  +  SELECT b, sum(b) OVER (
          361  +    RANGE BETWEEN CURRENT ROW AND CURRENT ROW
          362  +  ) FROM t2 ORDER BY b;
          363  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          364  +
          365  +do_execsql_test 4.6.2 {
          366  +  SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
          367  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          368  +
          369  +do_execsql_test 4.6.3 {
          370  +  SELECT b, sum(b) OVER (
          371  +    RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          372  +  ) FROM t2 ORDER BY b;
          373  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          374  +
          375  +do_execsql_test 4.6.4 {
          376  +  SELECT b, sum(b) OVER (
          377  +    RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
   349    378     ) FROM t2 ORDER BY b;
   350         -} {0 0   1 1   1 2   2 4   2 6   2 8   3 11   3 14   4 18   5 23   6 29   7 36   7 43   7 50   8 58   8 66   8 74   9 83   9 92   9 101   10 111   11 122   11 133   12 145   12 157   12 169   13 182   13 195   14 209   15 224   15 239   15 254   16 270   16 286   16 302   17 319   19 338   20 358   21 379   21 400   22 422   22 444   23 467   23 490   23 513   24 537   25 562   26 588   26 614   26 640   27 667   27 694   28 722   29 751   29 780   29 809   30 839   30 869   30 899   31 930   31 961   32 993   33 1026   33 1059   33 1092   33 1125   33 1158   34 1192   34 1226   34 1260   34 1294   35 1329   35 1364   36 1400   36 1436   36 1472   36 1508   37 1545   37 1582   38 1620   38 1658   39 1697   39 1736   39 1775   40 1815   41 1856   41 1897   41 1938   42 1980   43 2023   43 2066   44 2110   44 2154   46 2200   46 2246   47 2293   47 2340   47 2387   47 2434   49 2483   50 2533   51 2584   52 2636   53 2689   54 2743   55 2798   55 2853   56 2909   56 2965   56 3021   57 3078   58 3136   58 3194   58 3252   58 3310   59 3369   59 3428   59 3487   59 3546   60 3606   61 3667   61 3728   62 3790   62 3852   63 3915   64 3979   65 4044   65 4109   65 4174   66 4240   67 4307   68 4375   69 4444   70 4514   72 4586   72 4658   72 4730   73 4803   73 4876   73 4949   74 5023   74 5097   74 5171   74 5245   74 5319   75 5394   75 5469   75 5544   76 5620   77 5697   77 5774   78 5852   78 5930   79 6009   80 6089   80 6169   81 6250   81 6331   81 6412   82 6494   83 6577   84 6661   84 6745   84 6829   84 6913   85 6998   85 7083   85 7168   86 7254   87 7341   87 7428   88 7516   89 7605   89 7694   89 7783   90 7873   90 7963   90 8053   91 8144   91 8235   91 8326   91 8417   91 8508   93 8601   93 8694   93 8787   94 8881   95 8976   95 9071   95 9166   96 9262   96 9358   96 9454   97 9551   97 9648   98 9746   98 9844   99 9943   99 10042   99 10141}
          379  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          380  +
          381  +do_execsql_test 4.7.1 {
          382  +  SELECT b, sum(b) OVER (
          383  +    ROWS BETWEEN CURRENT ROW AND CURRENT ROW
          384  +  ) FROM t2 ORDER BY 1, 2;
          385  +} {0 0   1 1   1 1   2 2   2 2   2 2   3 3   3 3   4 4   5 5   6 6   7 7   7 7   7 7   8 8   8 8   8 8   9 9   9 9   9 9   10 10   11 11   11 11   12 12   12 12   12 12   13 13   13 13   14 14   15 15   15 15   15 15   16 16   16 16   16 16   17 17   19 19   20 20   21 21   21 21   22 22   22 22   23 23   23 23   23 23   24 24   25 25   26 26   26 26   26 26   27 27   27 27   28 28   29 29   29 29   29 29   30 30   30 30   30 30   31 31   31 31   32 32   33 33   33 33   33 33   33 33   33 33   34 34   34 34   34 34   34 34   35 35   35 35   36 36   36 36   36 36   36 36   37 37   37 37   38 38   38 38   39 39   39 39   39 39   40 40   41 41   41 41   41 41   42 42   43 43   43 43   44 44   44 44   46 46   46 46   47 47   47 47   47 47   47 47   49 49   50 50   51 51   52 52   53 53   54 54   55 55   55 55   56 56   56 56   56 56   57 57   58 58   58 58   58 58   58 58   59 59   59 59   59 59   59 59   60 60   61 61   61 61   62 62   62 62   63 63   64 64   65 65   65 65   65 65   66 66   67 67   68 68   69 69   70 70   72 72   72 72   72 72   73 73   73 73   73 73   74 74   74 74   74 74   74 74   74 74   75 75   75 75   75 75   76 76   77 77   77 77   78 78   78 78   79 79   80 80   80 80   81 81   81 81   81 81   82 82   83 83   84 84   84 84   84 84   84 84   85 85   85 85   85 85   86 86   87 87   87 87   88 88   89 89   89 89   89 89   90 90   90 90   90 90   91 91   91 91   91 91   91 91   91 91   93 93   93 93   93 93   94 94   95 95   95 95   95 95   96 96   96 96   96 96   97 97   97 97   98 98   98 98   99 99   99 99   99 99}
          386  +
          387  +do_execsql_test 4.7.2 {
          388  +  SELECT b, sum(b) OVER (
          389  +    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
          390  +  ) FROM t2 ORDER BY 1, 2;
          391  +} {0 0   1 3379   1 5443   2 372   2 4473   2 7074   3 2916   3 9096   4 4049   5 5643   6 1047   7 2205   7 7081   7 10141   8 1553   8 5926   8 6422   9 4883   9 7932   9 8497   10 9544   11 5727   11 6433   12 2825   12 5918   12 8582   13 5190   13 8570   14 8596   15 3189   15 6023   15 8924   16 1942   16 1958   16 3590   17 10134   19 7474   20 5946   21 5464   21 9682   22 3029   22 6140   23 212   23 1926   23 8520   24 2626   25 3331   26 337   26 7539   26 7565   27 1270   27 10035   28 3217   29 1649   29 4355   29 7326   30 4215   30 9400   30 9853   31 5977   31 6008   32 2857   33 370   33 4326   33 8175   33 8909   33 9661   34 6414   34 6516   34 8958   34 9925   35 2151   35 5638   36 3701   36 7818   36 8785   36 8994   37 4597   37 8557   38 735   38 9891   39 842   39 7513   39 9721   40 3475   41 115   41 4874   41 5906   42 4185   43 2754   43 3518   44 7072   44 9765   46 1041   46 1316   47 2198   47 3378   47 7612   47 7923   49 6482   50 9450   51 5778   52 9370   53 4408   54 1448   55 3174   55 6876   56 2913   56 3435   56 3574   57 7223   58 5248   58 7876   58 9318   58 9823   59 697   59 2813   59 6665   59 7455   60 6821   61 2426   61 4944   62 904   62 8658   63 4471   64 8407   65 2116   65 5177   65 5603   66 8142   67 1620   68 803   69 9260   70 7396   72 4833   72 8004   72 8076   73 5017   73 5716   73 6213   74 74   74 189   74 2365   74 5538   74 7297   75 3665   75 6951   75 8343   76 3964   77 1903   77 7028   78 1394   78 4293   79 6292   80 4677   80 7692   81 542   81 4045   81 8488   82 10117   83 10008   84 1826   84 4761   84 9534   84 9628   85 2602   85 2711   85 7166   86 2291   87 4560   87 5865   88 6380   89 461   89 3306   89 3790   90 3119   90 6606   90 7782   91 995   91 2517   91 3007   91 8749   91 8876   93 1742   93 2051   93 8268   94 4143   95 5112   95 6118   95 9191   96 638   96 5344   96 6761   97 1243   97 1545   98 3888   98 5442   99 311   99 1146   99 9093}
          392  +
          393  +do_execsql_test 4.7.3 {
          394  +  SELECT b, sum(b) OVER (
          395  +    ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          396  +  ) FROM t2 ORDER BY 1, 2;
          397  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          398  +
          399  +do_execsql_test 4.7.4 {
          400  +  SELECT b, sum(b) OVER (
          401  +    ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          402  +  ) FROM t2 ORDER BY 1, 2;
          403  +} {0 10141   1 4699   1 6763   2 3069   2 5670   2 9771   3 1048   3 7228   4 6096   5 4503   6 9100   7 7   7 3067   7 7943   8 3727   8 4223   8 8596   9 1653   9 2218   9 5267   10 607   11 3719   11 4425   12 1571   12 4235   12 7328   13 1584   13 4964   14 1559   15 1232   15 4133   15 6967   16 6567   16 8199   16 8215   17 24   19 2686   20 4215   21 480   21 4698   22 4023   22 7134   23 1644   23 8238   23 9952   24 7539   25 6835   26 2602   26 2628   26 9830   27 133   27 8898   28 6952   29 2844   29 5815   29 8521   30 318   30 771   30 5956   31 4164   31 4195   32 7316   33 513   33 1265   33 1999   33 5848   33 9804   34 250   34 1217   34 3659   34 3761   35 4538   35 8025   36 1183   36 1392   36 2359   36 6476   37 1621   37 5581   38 288   38 9444   39 459   39 2667   39 9338   40 6706   41 4276   41 5308   41 10067   42 5998   43 6666   43 7430   44 420   44 3113   46 8871   46 9146   47 2265   47 2576   47 6810   47 7990   49 3708   50 741   51 4414   52 823   53 5786   54 8747   55 3320   55 7022   56 6623   56 6762   56 7284   57 2975   58 376   58 881   58 2323   58 4951   59 2745   59 3535   59 7387   59 9503   60 3380   61 5258   61 7776   62 1545   62 9299   63 5733   64 1798   65 4603   65 5029   65 8090   66 2065   67 8588   68 9406   69 950   70 2815   72 2137   72 2209   72 5380   73 4001   73 4498   73 5197   74 2918   74 4677   74 7850   74 10026   74 10141   75 1873   75 3265   75 6551   76 6253   77 3190   77 8315   78 5926   78 8825   79 3928   80 2529   80 5544   81 1734   81 6177   81 9680   82 106   83 216   84 597   84 691   84 5464   84 8399   85 3060   85 7515   85 7624   86 7936   87 4363   87 5668   88 3849   89 6440   89 6924   89 9769   90 2449   90 3625   90 7112   91 1356   91 1483   91 7225   91 7715   91 9237   93 1966   93 8183   93 8492   94 6092   95 1045   95 4118   95 5124   96 3476   96 4893   96 9599   97 8693   97 8995   98 4797   98 6351   99 1147   99 9094   99 9929}
          404  +
          405  +do_execsql_test 4.8.1 {
          406  +  SELECT b, sum(b) OVER (
          407  +    ORDER BY a
          408  +    ROWS BETWEEN CURRENT ROW AND CURRENT ROW
          409  +  ) FROM t2 ORDER BY 1, 2;
          410  +} {0 0   1 1   1 1   2 2   2 2   2 2   3 3   3 3   4 4   5 5   6 6   7 7   7 7   7 7   8 8   8 8   8 8   9 9   9 9   9 9   10 10   11 11   11 11   12 12   12 12   12 12   13 13   13 13   14 14   15 15   15 15   15 15   16 16   16 16   16 16   17 17   19 19   20 20   21 21   21 21   22 22   22 22   23 23   23 23   23 23   24 24   25 25   26 26   26 26   26 26   27 27   27 27   28 28   29 29   29 29   29 29   30 30   30 30   30 30   31 31   31 31   32 32   33 33   33 33   33 33   33 33   33 33   34 34   34 34   34 34   34 34   35 35   35 35   36 36   36 36   36 36   36 36   37 37   37 37   38 38   38 38   39 39   39 39   39 39   40 40   41 41   41 41   41 41   42 42   43 43   43 43   44 44   44 44   46 46   46 46   47 47   47 47   47 47   47 47   49 49   50 50   51 51   52 52   53 53   54 54   55 55   55 55   56 56   56 56   56 56   57 57   58 58   58 58   58 58   58 58   59 59   59 59   59 59   59 59   60 60   61 61   61 61   62 62   62 62   63 63   64 64   65 65   65 65   65 65   66 66   67 67   68 68   69 69   70 70   72 72   72 72   72 72   73 73   73 73   73 73   74 74   74 74   74 74   74 74   74 74   75 75   75 75   75 75   76 76   77 77   77 77   78 78   78 78   79 79   80 80   80 80   81 81   81 81   81 81   82 82   83 83   84 84   84 84   84 84   84 84   85 85   85 85   85 85   86 86   87 87   87 87   88 88   89 89   89 89   89 89   90 90   90 90   90 90   91 91   91 91   91 91   91 91   91 91   93 93   93 93   93 93   94 94   95 95   95 95   95 95   96 96   96 96   96 96   97 97   97 97   98 98   98 98   99 99   99 99   99 99}
          411  +
          412  +do_execsql_test 4.8.2 {
          413  +  SELECT b, sum(b) OVER (
          414  +    ORDER BY a
          415  +    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
          416  +  ) FROM t2 ORDER BY 1, 2;
          417  +} {0 0   1 3379   1 5443   2 372   2 4473   2 7074   3 2916   3 9096   4 4049   5 5643   6 1047   7 2205   7 7081   7 10141   8 1553   8 5926   8 6422   9 4883   9 7932   9 8497   10 9544   11 5727   11 6433   12 2825   12 5918   12 8582   13 5190   13 8570   14 8596   15 3189   15 6023   15 8924   16 1942   16 1958   16 3590   17 10134   19 7474   20 5946   21 5464   21 9682   22 3029   22 6140   23 212   23 1926   23 8520   24 2626   25 3331   26 337   26 7539   26 7565   27 1270   27 10035   28 3217   29 1649   29 4355   29 7326   30 4215   30 9400   30 9853   31 5977   31 6008   32 2857   33 370   33 4326   33 8175   33 8909   33 9661   34 6414   34 6516   34 8958   34 9925   35 2151   35 5638   36 3701   36 7818   36 8785   36 8994   37 4597   37 8557   38 735   38 9891   39 842   39 7513   39 9721   40 3475   41 115   41 4874   41 5906   42 4185   43 2754   43 3518   44 7072   44 9765   46 1041   46 1316   47 2198   47 3378   47 7612   47 7923   49 6482   50 9450   51 5778   52 9370   53 4408   54 1448   55 3174   55 6876   56 2913   56 3435   56 3574   57 7223   58 5248   58 7876   58 9318   58 9823   59 697   59 2813   59 6665   59 7455   60 6821   61 2426   61 4944   62 904   62 8658   63 4471   64 8407   65 2116   65 5177   65 5603   66 8142   67 1620   68 803   69 9260   70 7396   72 4833   72 8004   72 8076   73 5017   73 5716   73 6213   74 74   74 189   74 2365   74 5538   74 7297   75 3665   75 6951   75 8343   76 3964   77 1903   77 7028   78 1394   78 4293   79 6292   80 4677   80 7692   81 542   81 4045   81 8488   82 10117   83 10008   84 1826   84 4761   84 9534   84 9628   85 2602   85 2711   85 7166   86 2291   87 4560   87 5865   88 6380   89 461   89 3306   89 3790   90 3119   90 6606   90 7782   91 995   91 2517   91 3007   91 8749   91 8876   93 1742   93 2051   93 8268   94 4143   95 5112   95 6118   95 9191   96 638   96 5344   96 6761   97 1243   97 1545   98 3888   98 5442   99 311   99 1146   99 9093}
          418  +
          419  +do_execsql_test 4.8.3 {
          420  +  SELECT b, sum(b) OVER (
          421  +    ORDER BY a
          422  +    ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
          423  +  ) FROM t2 ORDER BY 1, 2;
          424  +} {0 10141   1 10141   1 10141   2 10141   2 10141   2 10141   3 10141   3 10141   4 10141   5 10141   6 10141   7 10141   7 10141   7 10141   8 10141   8 10141   8 10141   9 10141   9 10141   9 10141   10 10141   11 10141   11 10141   12 10141   12 10141   12 10141   13 10141   13 10141   14 10141   15 10141   15 10141   15 10141   16 10141   16 10141   16 10141   17 10141   19 10141   20 10141   21 10141   21 10141   22 10141   22 10141   23 10141   23 10141   23 10141   24 10141   25 10141   26 10141   26 10141   26 10141   27 10141   27 10141   28 10141   29 10141   29 10141   29 10141   30 10141   30 10141   30 10141   31 10141   31 10141   32 10141   33 10141   33 10141   33 10141   33 10141   33 10141   34 10141   34 10141   34 10141   34 10141   35 10141   35 10141   36 10141   36 10141   36 10141   36 10141   37 10141   37 10141   38 10141   38 10141   39 10141   39 10141   39 10141   40 10141   41 10141   41 10141   41 10141   42 10141   43 10141   43 10141   44 10141   44 10141   46 10141   46 10141   47 10141   47 10141   47 10141   47 10141   49 10141   50 10141   51 10141   52 10141   53 10141   54 10141   55 10141   55 10141   56 10141   56 10141   56 10141   57 10141   58 10141   58 10141   58 10141   58 10141   59 10141   59 10141   59 10141   59 10141   60 10141   61 10141   61 10141   62 10141   62 10141   63 10141   64 10141   65 10141   65 10141   65 10141   66 10141   67 10141   68 10141   69 10141   70 10141   72 10141   72 10141   72 10141   73 10141   73 10141   73 10141   74 10141   74 10141   74 10141   74 10141   74 10141   75 10141   75 10141   75 10141   76 10141   77 10141   77 10141   78 10141   78 10141   79 10141   80 10141   80 10141   81 10141   81 10141   81 10141   82 10141   83 10141   84 10141   84 10141   84 10141   84 10141   85 10141   85 10141   85 10141   86 10141   87 10141   87 10141   88 10141   89 10141   89 10141   89 10141   90 10141   90 10141   90 10141   91 10141   91 10141   91 10141   91 10141   91 10141   93 10141   93 10141   93 10141   94 10141   95 10141   95 10141   95 10141   96 10141   96 10141   96 10141   97 10141   97 10141   98 10141   98 10141   99 10141   99 10141   99 10141}
          425  +
          426  +do_execsql_test 4.8.4 {
          427  +  SELECT b, sum(b) OVER (
          428  +    ORDER BY a
          429  +    ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
          430  +  ) FROM t2 ORDER BY 1, 2;
          431  +} {0 10141   1 4699   1 6763   2 3069   2 5670   2 9771   3 1048   3 7228   4 6096   5 4503   6 9100   7 7   7 3067   7 7943   8 3727   8 4223   8 8596   9 1653   9 2218   9 5267   10 607   11 3719   11 4425   12 1571   12 4235   12 7328   13 1584   13 4964   14 1559   15 1232   15 4133   15 6967   16 6567   16 8199   16 8215   17 24   19 2686   20 4215   21 480   21 4698   22 4023   22 7134   23 1644   23 8238   23 9952   24 7539   25 6835   26 2602   26 2628   26 9830   27 133   27 8898   28 6952   29 2844   29 5815   29 8521   30 318   30 771   30 5956   31 4164   31 4195   32 7316   33 513   33 1265   33 1999   33 5848   33 9804   34 250   34 1217   34 3659   34 3761   35 4538   35 8025   36 1183   36 1392   36 2359   36 6476   37 1621   37 5581   38 288   38 9444   39 459   39 2667   39 9338   40 6706   41 4276   41 5308   41 10067   42 5998   43 6666   43 7430   44 420   44 3113   46 8871   46 9146   47 2265   47 2576   47 6810   47 7990   49 3708   50 741   51 4414   52 823   53 5786   54 8747   55 3320   55 7022   56 6623   56 6762   56 7284   57 2975   58 376   58 881   58 2323   58 4951   59 2745   59 3535   59 7387   59 9503   60 3380   61 5258   61 7776   62 1545   62 9299   63 5733   64 1798   65 4603   65 5029   65 8090   66 2065   67 8588   68 9406   69 950   70 2815   72 2137   72 2209   72 5380   73 4001   73 4498   73 5197   74 2918   74 4677   74 7850   74 10026   74 10141   75 1873   75 3265   75 6551   76 6253   77 3190   77 8315   78 5926   78 8825   79 3928   80 2529   80 5544   81 1734   81 6177   81 9680   82 106   83 216   84 597   84 691   84 5464   84 8399   85 3060   85 7515   85 7624   86 7936   87 4363   87 5668   88 3849   89 6440   89 6924   89 9769   90 2449   90 3625   90 7112   91 1356   91 1483   91 7225   91 7715   91 9237   93 1966   93 8183   93 8492   94 6092   95 1045   95 4118   95 5124   96 3476   96 4893   96 9599   97 8693   97 8995   98 4797   98 6351   99 1147   99 9094   99 9929}
   351    432   
   352    433   finish_test