mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Get the non-callback API working with the EXPLAIN keyword and for PRAGMAs.
Tickets #258 and #257. Update the API documentation on the sqlite_changes() routine to explain how it works with the non-callback API. Ticket #250. (CVS 875) FossilOrigin-Name: 620e1065e978545dd7bf6fa6fad1e6b93918dbf8
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script testing the callback-free C/C++ API.
|
||||
#
|
||||
# $Id: capi2.test,v 1.4 2003/02/16 22:21:33 drh Exp $
|
||||
# $Id: capi2.test,v 1.5 2003/03/01 19:45:35 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -389,6 +389,60 @@ do_test capi2-6.28 {
|
||||
do_test capi2-6.99 {
|
||||
list [catch {sqlite_finalize $VM1} msg] [set msg]
|
||||
} {0 {}}
|
||||
execsql {ROLLBACK}
|
||||
|
||||
do_test capi2-7.1 {
|
||||
stepsql $DB {
|
||||
SELECT * FROM t1
|
||||
}
|
||||
} {0 1 2 3}
|
||||
do_test capi2-7.2 {
|
||||
stepsql $DB {
|
||||
PRAGMA count_changes=on
|
||||
}
|
||||
} {0}
|
||||
do_test capi2-7.3 {
|
||||
stepsql $DB {
|
||||
UPDATE t1 SET a=a+10;
|
||||
}
|
||||
} {0 1}
|
||||
do_test capi2-7.4 {
|
||||
stepsql $DB {
|
||||
INSERT INTO t1 SELECT a+1,b+1,c+1 FROM t1;
|
||||
}
|
||||
} {0 1}
|
||||
do_test capi2-7.5 {
|
||||
stepsql $DB {
|
||||
UPDATE t1 SET a=a+10;
|
||||
}
|
||||
} {0 2}
|
||||
do_test capi2-7.6 {
|
||||
stepsql $DB {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {0 21 2 3 22 3 4}
|
||||
do_test capi2-7.7 {
|
||||
stepsql $DB {
|
||||
INSERT INTO t1 SELECT a+2,b+2,c+2 FROM t1;
|
||||
}
|
||||
} {0 2}
|
||||
do_test capi2-7.8 {
|
||||
stepsql $DB {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {0 21 2 3 22 3 4 23 4 5 24 5 6}
|
||||
do_test capi2-7.9 {
|
||||
stepsql $DB {
|
||||
UPDATE t1 SET a=a-20;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {0 4 1 2 3 2 3 4 3 4 5 4 5 6}
|
||||
do_test capi2-7.10 {
|
||||
set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]
|
||||
lindex $x 0
|
||||
} {0}
|
||||
|
||||
|
||||
|
||||
db2 close
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements some common TCL routines used for regression
|
||||
# testing the SQLite library
|
||||
#
|
||||
# $Id: tester.tcl,v 1.24 2003/02/16 22:21:33 drh Exp $
|
||||
# $Id: tester.tcl,v 1.25 2003/03/01 19:45:35 drh Exp $
|
||||
|
||||
# Make sure tclsqlite was compiled correctly. Abort now with an
|
||||
# error message if not.
|
||||
@ -214,6 +214,26 @@ proc execsql2 {sql} {
|
||||
return $result
|
||||
}
|
||||
|
||||
# Use the non-callback API to execute multiple SQL statements
|
||||
#
|
||||
proc stepsql {dbptr sql} {
|
||||
set sql [string trim $sql]
|
||||
set r 0
|
||||
while {[string length $sql]>0} {
|
||||
if {[catch {sqlite_compile $dbptr $sql sqltail} vm]} {
|
||||
return [list 1 $vm]
|
||||
}
|
||||
set sql [string trim $sqltail]
|
||||
while {[sqlite_step $vm N VAL COL]=="SQLITE_ROW"} {
|
||||
foreach v $VAL {lappend r $v}
|
||||
}
|
||||
if {[catch {sqlite_finalize $vm} errmsg]} {
|
||||
return [list 1 $errmsg]
|
||||
}
|
||||
}
|
||||
return $r
|
||||
}
|
||||
|
||||
# Delete a file or directory
|
||||
#
|
||||
proc forcedelete {filename} {
|
||||
|
Reference in New Issue
Block a user