SQLite

Check-in [b36813d646]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b36813d6467c82159bd3bb69d34ac28fc161a13052ca67d7cf9ad75e2aaea9d5
User & Date: dan 2019-04-01 18:43:09.978
Context
2019-04-01
19:42
Improvements to the sqlite3ExprImpliesNonNullRow() theorem prover. (check-in: 3fde627616 user: drh tags: trunk)
18:43
Add a test case to cover a missed VDBE branch generated by window.c. (check-in: b36813d646 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: f0ed714637 user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/test_vdbecov.c.
32
33
34
35
36
37
38
39






40
41
42
43

44
45
46
47
48
49
50
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







-
+
+
+
+
+
+




+







  unsigned char iType
){
  if( iSrc<sizeof(aBranchArray) ){
    aBranchArray[iSrc] |= iBranch;
  }
}

static void appendToList(Tcl_Obj *pList, int iLine, int iPath){
static void appendToList(
  Tcl_Obj *pList, 
  int iLine, 
  int iPath, 
  const char *zNever
){
  Tcl_Obj *pNew = Tcl_NewObj();
  Tcl_IncrRefCount(pNew);
  Tcl_ListObjAppendElement(0, pNew, Tcl_NewIntObj(iLine));
  Tcl_ListObjAppendElement(0, pNew, Tcl_NewIntObj(iPath));
  Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zNever, -1));
  Tcl_ListObjAppendElement(0, pList, pNew);
  Tcl_DecrRefCount(pNew);
}


static int SQLITE_TCLAPI test_vdbe_coverage(
  ClientData cd,
72
73
74
75
76
77
78

79
80
81
82









83
84
85
86
87
88
89
78
79
80
81
82
83
84
85
86



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102







+

-
-
-
+
+
+
+
+
+
+
+
+







      break;
    case 1: {     /* report */
      int i;
      Tcl_Obj *pRes = Tcl_NewObj();
      Tcl_IncrRefCount(pRes);
      for(i=0; i<sizeof(aBranchArray); i++){
        u8 b = aBranchArray[i];
        int bFlag = ((b >> 4)==4);
        if( b ){
          if( (b & 0x01)==0 ) appendToList(pRes, i, 0);
          if( (b & 0x02)==0 ) appendToList(pRes, i, 1);
          if( (b & 0x04)==0 ) appendToList(pRes, i, 2);
          if( (b & 0x01)==0 ){
            appendToList(pRes, i, 0, bFlag ? "less than" : "falls through");
          }
          if( (b & 0x02)==0 ){
            appendToList(pRes, i, 1, bFlag ? "equal" : "taken");
          }
          if( (b & 0x04)==0 ){
            appendToList(pRes, i, 2, bFlag ? "greater-than" : "NULL");
          }
        }
      }
      Tcl_SetObjResult(interp, pRes);
      Tcl_DecrRefCount(pRes);
      break;
    };
      
Changes to test/tester.tcl.
1326
1327
1328
1329
1330
1331
1332
1333

1334
1335
1336
1337
1338
1339
1340
1341
1342
1343

1344
1345
1346
1347
1348
1349
1350
1326
1327
1328
1329
1330
1331
1332

1333
1334
1335
1336
1337
1338
1339
1340
1341
1342

1343
1344
1345
1346
1347
1348
1349
1350







-
+









-
+







        lappend lSrc [list $iLine $file]
      }
    }
    close $fd
  }
  set fd [open vdbe_coverage.txt w]
  foreach miss [vdbe_coverage report] {
    foreach {line branch} $miss {}
    foreach {line branch never} $miss {}
    set nextfile ""
    while {[llength $lSrc]>0 && [lindex $lSrc 0 0] < $line} {
      set nextfile [lindex $lSrc 0 1]
      set lSrc [lrange $lSrc 1 end]
    }
    if {$nextfile != ""} {
      puts $fd ""
      puts $fd "### $nextfile ###"
    }
    puts $fd "Vdbe branch $line: path $branch never taken"
    puts $fd "Vdbe branch $line: never $never (path $branch)"
  }
  close $fd
}

# Display memory statistics for analysis and debugging purposes.
#
proc show_memstats {} {
Changes to test/window1.test.
1063
1064
1065
1066
1067
1068
1069













1070
1071
1072
1073
1074
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087







+
+
+
+
+
+
+
+
+
+
+
+
+





  INSERT INTO t1 VALUES(1), (1), (2), (3), (3), (3), (3), (4), (4);

  SELECT c, c IN ( 
    SELECT row_number() OVER () FROM ( SELECT 1 FROM t1 WHERE x=c )
  ) FROM t2
} {1 1  2 0  3 1  4 0}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 27.0 {
  CREATE TABLE t1(x);
  INSERT INTO t1 VALUES(NULL), (1), (2), (3), (4), (5);
}
do_execsql_test 27.1 {
  SELECT min(x) FROM t1;
} {1}
do_execsql_test 27.2 {
  SELECT min(x) OVER win FROM t1
  WINDOW win AS (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
} {1 1 1 2 3 4}


finish_test