/ Check-in [fe8aaf0c]
Login

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

Overview
Comment:Fix a bad assert() in window.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fe8aaf0c806413965f50a03e34b5fdfaaa8b09dc0af73f41e830f7b664bd1ced
User & Date: dan 2018-07-09 06:51:36
Context
2018-07-09
13:31
Throw an error if the second argument passed to nth_value() is not a positive integer. check-in: 1a06e57a user: dan tags: trunk
06:51
Fix a bad assert() in window.c. check-in: fe8aaf0c user: dan tags: trunk
02:37
Simplification to the logic that detects misuse of the application-defined function creation interfaces. check-in: 8f21d778 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/window.c.

  1113   1113              || pWin->pFunc->zName==lagName
  1114   1114       ){
  1115   1115         /* no-op */
  1116   1116       }else{
  1117   1117         int addrIf = 0;
  1118   1118         if( pWin->pFilter ){
  1119   1119           int regTmp;
  1120         -        assert( nArg==pWin->pOwner->x.pList->nExpr );
         1120  +        assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
         1121  +        assert( nArg || pWin->pOwner->x.pList==0 );
  1121   1122           if( csr>0 ){
  1122   1123             regTmp = sqlite3GetTempReg(pParse);
  1123   1124             sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
  1124   1125           }else{
  1125   1126             regTmp = regArg + nArg;
  1126   1127           }
  1127   1128           addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
................................................................................
  1128   1129           VdbeCoverage(v);
  1129   1130           if( csr>0 ){
  1130   1131             sqlite3ReleaseTempReg(pParse, regTmp);
  1131   1132           }
  1132   1133         }
  1133   1134         if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
  1134   1135           CollSeq *pColl;
         1136  +        assert( nArg>0 );
  1135   1137           pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
  1136   1138           sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
  1137   1139         }
  1138   1140         sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep, 
  1139   1141                           bInverse, regArg, pWin->regAccum);
  1140   1142         sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
  1141   1143         sqlite3VdbeChangeP5(v, (u8)nArg);

Changes to test/window6.test.

   272    272   do_catchsql_test 9.8.2 {
   273    273     WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
   274    274     SELECT count() OVER (
   275    275         ORDER BY x ROWS BETWEEN 2 PRECEDING AND a FOLLOWING
   276    276     ) FROM c;
   277    277   } {1 {frame ending offset must be a non-negative integer}}
   278    278   
          279  +do_execsql_test 10.0 {
          280  +  WITH t1(a,b) AS (VALUES(1,2))
          281  +  SELECT count() FILTER (where b<>5) OVER w1
          282  +    FROM t1
          283  +    WINDOW w1 AS (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING);
          284  +} {1}
   279    285   
   280    286   finish_test