Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -420,10 +420,11 @@ $(TOP)/src/test_superlock.c \ $(TOP)/src/test_syscall.c \ $(TOP)/src/test_tclsh.c \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ + $(TOP)/src/test_vdbecov.c \ $(TOP)/src/test_vfs.c \ $(TOP)/src/test_windirent.c \ $(TOP)/src/test_window.c \ $(TOP)/src/test_wsd.c \ $(TOP)/ext/fts3/fts3_term.c \ Index: Makefile.msc ================================================================== --- Makefile.msc +++ Makefile.msc @@ -1515,10 +1515,11 @@ $(TOP)\src\test_superlock.c \ $(TOP)\src\test_syscall.c \ $(TOP)\src\test_tclsh.c \ $(TOP)\src\test_tclvar.c \ $(TOP)\src\test_thread.c \ + $(TOP)\src\test_vdbecov.c \ $(TOP)\src\test_vfs.c \ $(TOP)\src\test_windirent.c \ $(TOP)\src\test_window.c \ $(TOP)\src\test_wsd.c \ $(TOP)\ext\fts3\fts3_term.c \ Index: main.mk ================================================================== --- main.mk +++ main.mk @@ -346,10 +346,11 @@ $(TOP)/src/test_superlock.c \ $(TOP)/src/test_syscall.c \ $(TOP)/src/test_tclsh.c \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ + $(TOP)/src/test_vdbecov.c \ $(TOP)/src/test_vfs.c \ $(TOP)/src/test_windirent.c \ $(TOP)/src/test_window.c \ $(TOP)/src/test_wsd.c Index: src/test_tclsh.c ================================================================== --- src/test_tclsh.c +++ src/test_tclsh.c @@ -104,10 +104,11 @@ #ifdef SQLITE_ENABLE_ZIPVFS extern int Zipvfs_Init(Tcl_Interp*); #endif extern int TestExpert_Init(Tcl_Interp*); extern int Sqlitetest_window_Init(Tcl_Interp *); + extern int Sqlitetestvdbecov_Init(Tcl_Interp *); Tcl_CmdInfo cmdInfo; /* Since the primary use case for this binary is testing of SQLite, ** be sure to generate core files if we crash */ @@ -169,10 +170,11 @@ #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) Sqlitetestfts3_Init(interp); #endif TestExpert_Init(interp); Sqlitetest_window_Init(interp); + Sqlitetestvdbecov_Init(interp); Tcl_CreateObjCommand( interp, "load_testfixture_extensions", load_testfixture_extensions,0,0 ); return 0; ADDED src/test_vdbecov.c Index: src/test_vdbecov.c ================================================================== --- /dev/null +++ src/test_vdbecov.c @@ -0,0 +1,107 @@ +/* +** 2019 April 02 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +*/ +#if SQLITE_TEST /* This file is used for testing only */ + +#include "sqlite3.h" +#include "sqliteInt.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif + +#ifdef SQLITE_VDBE_COVERAGE + +static u8 aBranchArray[200000]; + +static void test_vdbe_branch( + void *pCtx, + unsigned int iSrc, + unsigned char iBranch, + unsigned char iType +){ + if( iSrc0} { output2 "Writing leaks.tcl..." sqlite3_memdebug_log sync memdebug_log_sql leaks.tcl } + } + if {[info commands vdbe_coverage]!=""} { + vdbe_coverage_report } foreach f [glob -nocomplain test.db-*-journal] { forcedelete $f } foreach f [glob -nocomplain test.db-mj*] { forcedelete $f } exit [expr {$nErr>0}] } + +proc vdbe_coverage_report {} { + puts "Writing vdbe coverage report to vdbe_coverage.txt" + set lSrc [list] + set iLine 0 + if {[file exists ../sqlite3.c]} { + set fd [open ../sqlite3.c] + set iLine + while { ![eof $fd] } { + set line [gets $fd] + incr iLine + if {[regexp {^/\** Begin file (.*\.c) \**/} $line -> file]} { + lappend lSrc [list $iLine $file] + } + } + close $fd + } + set fd [open vdbe_coverage.txt w] + foreach miss [vdbe_coverage report] { + foreach {line branch} $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" + } + close $fd +} # Display memory statistics for analysis and debugging purposes. # proc show_memstats {} { set x [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] Index: test/windowerr.tcl ================================================================== --- test/windowerr.tcl +++ test/windowerr.tcl @@ -52,9 +52,18 @@ } errorsql_test 2.2 { SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz); } + +errorsql_test 3.0 { + SELECT sum(a) OVER win FROM t1 + WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING) +} +errorsql_test 3.2 { + SELECT sum(a) OVER win FROM t1 + WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING) +} finish_test Index: test/windowerr.test ================================================================== --- test/windowerr.test +++ test/windowerr.test @@ -93,7 +93,19 @@ # PG says ERROR: column "xyz" does not exist do_test 2.2 { catch { execsql { SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz); } } } 1 + +# PG says ERROR: invalid input syntax for integer: "hello" +do_test 3.0 { catch { execsql { + SELECT sum(a) OVER win FROM t1 + WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING) +} } } 1 + +# PG says ERROR: argument of ROWS must be type bigint, not type bit +do_test 3.2 { catch { execsql { + SELECT sum(a) OVER win FROM t1 + WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING) +} } } 1 finish_test