/ Check-in [b36813d6]
Login

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

Overview
Comment:Add a test case to cover a missed VDBE branch generated by window.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b36813d6467c82159bd3bb69d34ac28fc161a13052ca67d7cf9ad75e2aaea9d5
User & Date: dan 2019-04-01 18:43:09
Context
2019-04-01
19:42
Improvements to the sqlite3ExprImpliesNonNullRow() theorem prover. check-in: 3fde6276 user: drh tags: trunk
18:43
Add a test case to cover a missed VDBE branch generated by window.c. check-in: b36813d6 user: dan tags: trunk
17:24
If the library is built with SQLITE_VDBE_COVERAGE defined, have the Tcl tests generate a vdbe coverage report in file testdir/vdbe_coverage.txt. check-in: f0ed7146 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_vdbecov.c.

    32     32     unsigned char iType
    33     33   ){
    34     34     if( iSrc<sizeof(aBranchArray) ){
    35     35       aBranchArray[iSrc] |= iBranch;
    36     36     }
    37     37   }
    38     38   
    39         -static void appendToList(Tcl_Obj *pList, int iLine, int iPath){
           39  +static void appendToList(
           40  +  Tcl_Obj *pList, 
           41  +  int iLine, 
           42  +  int iPath, 
           43  +  const char *zNever
           44  +){
    40     45     Tcl_Obj *pNew = Tcl_NewObj();
    41     46     Tcl_IncrRefCount(pNew);
    42     47     Tcl_ListObjAppendElement(0, pNew, Tcl_NewIntObj(iLine));
    43     48     Tcl_ListObjAppendElement(0, pNew, Tcl_NewIntObj(iPath));
           49  +  Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zNever, -1));
    44     50     Tcl_ListObjAppendElement(0, pList, pNew);
    45     51     Tcl_DecrRefCount(pNew);
    46     52   }
    47     53   
    48     54   
    49     55   static int SQLITE_TCLAPI test_vdbe_coverage(
    50     56     ClientData cd,
................................................................................
    72     78         break;
    73     79       case 1: {     /* report */
    74     80         int i;
    75     81         Tcl_Obj *pRes = Tcl_NewObj();
    76     82         Tcl_IncrRefCount(pRes);
    77     83         for(i=0; i<sizeof(aBranchArray); i++){
    78     84           u8 b = aBranchArray[i];
           85  +        int bFlag = ((b >> 4)==4);
    79     86           if( b ){
    80         -          if( (b & 0x01)==0 ) appendToList(pRes, i, 0);
    81         -          if( (b & 0x02)==0 ) appendToList(pRes, i, 1);
    82         -          if( (b & 0x04)==0 ) appendToList(pRes, i, 2);
           87  +          if( (b & 0x01)==0 ){
           88  +            appendToList(pRes, i, 0, bFlag ? "less than" : "falls through");
           89  +          }
           90  +          if( (b & 0x02)==0 ){
           91  +            appendToList(pRes, i, 1, bFlag ? "equal" : "taken");
           92  +          }
           93  +          if( (b & 0x04)==0 ){
           94  +            appendToList(pRes, i, 2, bFlag ? "greater-than" : "NULL");
           95  +          }
    83     96           }
    84     97         }
    85     98         Tcl_SetObjResult(interp, pRes);
    86     99         Tcl_DecrRefCount(pRes);
    87    100         break;
    88    101       };
    89    102         

Changes to test/tester.tcl.

  1326   1326           lappend lSrc [list $iLine $file]
  1327   1327         }
  1328   1328       }
  1329   1329       close $fd
  1330   1330     }
  1331   1331     set fd [open vdbe_coverage.txt w]
  1332   1332     foreach miss [vdbe_coverage report] {
  1333         -    foreach {line branch} $miss {}
         1333  +    foreach {line branch never} $miss {}
  1334   1334       set nextfile ""
  1335   1335       while {[llength $lSrc]>0 && [lindex $lSrc 0 0] < $line} {
  1336   1336         set nextfile [lindex $lSrc 0 1]
  1337   1337         set lSrc [lrange $lSrc 1 end]
  1338   1338       }
  1339   1339       if {$nextfile != ""} {
  1340   1340         puts $fd ""
  1341   1341         puts $fd "### $nextfile ###"
  1342   1342       }
  1343         -    puts $fd "Vdbe branch $line: path $branch never taken"
         1343  +    puts $fd "Vdbe branch $line: never $never (path $branch)"
  1344   1344     }
  1345   1345     close $fd
  1346   1346   }
  1347   1347   
  1348   1348   # Display memory statistics for analysis and debugging purposes.
  1349   1349   #
  1350   1350   proc show_memstats {} {

Changes to test/window1.test.

  1063   1063     INSERT INTO t1 VALUES(1), (1), (2), (3), (3), (3), (3), (4), (4);
  1064   1064   
  1065   1065     SELECT c, c IN ( 
  1066   1066       SELECT row_number() OVER () FROM ( SELECT 1 FROM t1 WHERE x=c )
  1067   1067     ) FROM t2
  1068   1068   } {1 1  2 0  3 1  4 0}
  1069   1069   
         1070  +#-------------------------------------------------------------------------
         1071  +reset_db
         1072  +do_execsql_test 27.0 {
         1073  +  CREATE TABLE t1(x);
         1074  +  INSERT INTO t1 VALUES(NULL), (1), (2), (3), (4), (5);
         1075  +}
         1076  +do_execsql_test 27.1 {
         1077  +  SELECT min(x) FROM t1;
         1078  +} {1}
         1079  +do_execsql_test 27.2 {
         1080  +  SELECT min(x) OVER win FROM t1
         1081  +  WINDOW win AS (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
         1082  +} {1 1 1 2 3 4}
  1070   1083   
  1071   1084   
  1072   1085   finish_test
  1073   1086   
  1074   1087