1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Minor fixes related to the tests in misuse.test (CVS 1738)

FossilOrigin-Name: 0af3ff39422e02afdfdaf2005ab5eb01b496dc72
This commit is contained in:
danielk1977
2004-06-26 09:50:11 +00:00
parent 40b38dcdf8
commit e35ee196dc
7 changed files with 95 additions and 84 deletions

View File

@ -1,5 +1,5 @@
C Remove\sthe\s'nMaster'\sargument\sfrom\svarious\spager\sand\sbtree\sfunctions.\s(CVS\s1737) C Minor\sfixes\srelated\sto\sthe\stests\sin\smisuse.test\s(CVS\s1738)
D 2004-06-26T08:38:25 D 2004-06-26T09:50:12
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -38,7 +38,7 @@ F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18 F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
F src/main.c 7a5afce156d14727a49b60ffe6ab21bcae27e6f3 F src/main.c 7551892fd677fac1ddb1429f70bf53d7e01eeb93
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345 F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
@ -62,7 +62,7 @@ F src/sqlite.h.in b70fded2bdfeaddfb06adea3888118b722975136
F src/sqliteInt.h d1911e120fb20ff9ba4cf0115065ac6569268cec F src/sqliteInt.h d1911e120fb20ff9ba4cf0115065ac6569268cec
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3 F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3
F src/test1.c e4e0ae8af8040c848ef35f92e6a22b2245b9b873 F src/test1.c 0eca68f6e70069aad7ad0fd91fda886926646786
F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40 F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40
F src/test3.c bacc42bf41fa04d6faf7dd104b595b8bafb9aec9 F src/test3.c bacc42bf41fa04d6faf7dd104b595b8bafb9aec9
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
@ -95,7 +95,7 @@ F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2 F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293 F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293
F test/capi2.test 9ad428f7f228142be1bd9e7d4a906d7d2fa53e6e F test/capi2.test fe61f341e953f73c29bacfcbdaf688cd7b0e0d38
F test/capi3.test 6528034f21c4e8e404032124cb58b14ce934598c F test/capi3.test 6528034f21c4e8e404032124cb58b14ce934598c
F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef
F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b
@ -104,7 +104,7 @@ F test/collate4.test 0e9fc08ffcf6eddf72e354a15de06688fa86db31
F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5 F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5
F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675 F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87 F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
F test/crash.test 14cc6a657532841fa179b6f8d4181ce680cabc4a F test/crash.test 062a108997c3f58a72e9add04d48e766468daf04
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d
F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07 F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07
@ -136,7 +136,7 @@ F test/minmax.test 3f87d1d49f7e9aa9ae80d35c47a1f5b034557899
F test/misc1.test a8eb48d38f7a64e75314a2946db68d2b77901b7d F test/misc1.test a8eb48d38f7a64e75314a2946db68d2b77901b7d
F test/misc2.test 703734f5817215ca54e364833b3bf5ff36fcc21e F test/misc2.test 703734f5817215ca54e364833b3bf5ff36fcc21e
F test/misc3.test eb488314990bfc0959221a1acc465013238bf168 F test/misc3.test eb488314990bfc0959221a1acc465013238bf168
F test/misuse.test 97456c4fa78be0c3151f41aa05c763b9f6b11f81 F test/misuse.test 2a64ce711419f2fd12806ed95af930fd4e7bb8f3
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 64730a1c32955e5cc510b7632fed6b9929a4029a F test/null.test 64730a1c32955e5cc510b7632fed6b9929a4029a
F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a
@ -229,7 +229,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 76da457b8fc8fe838226da14c31c315cf914a505 P 4e20720984e1fd6822ead785d758374d2704b7fb
R 98f9db5e6f42c5a7abb1dd3e9055572f R 49b5250eaaec471bbc6b3f93826e25f5
U danielk1977 U danielk1977
Z 119b2a1a08cb96489bfef6a509f0c0ea Z 797c0e00173b158ed66a18d7f85e63d1

View File

@ -1 +1 @@
4e20720984e1fd6822ead785d758374d2704b7fb 0af3ff39422e02afdfdaf2005ab5eb01b496dc72

View File

@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.234 2004/06/26 06:37:07 danielk1977 Exp $ ** $Id: main.c,v 1.235 2004/06/26 09:50:12 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@ -459,6 +459,13 @@ int sqlite3_close(sqlite *db){
return SQLITE_OK; return SQLITE_OK;
} }
if( db->magic!=SQLITE_MAGIC_CLOSED &&
db->magic!=SQLITE_MAGIC_OPEN &&
db->magic!=SQLITE_MAGIC_BUSY
){
return SQLITE_MISUSE;
}
/* If there are any outstanding VMs, return SQLITE_BUSY. */ /* If there are any outstanding VMs, return SQLITE_BUSY. */
if( db->pVdbe ){ if( db->pVdbe ){
sqlite3Error(db, SQLITE_BUSY, sqlite3Error(db, SQLITE_BUSY,
@ -837,6 +844,9 @@ const char *sqlite3_errmsg(sqlite3 *db){
*/ */
return sqlite3ErrStr(SQLITE_NOMEM); return sqlite3ErrStr(SQLITE_NOMEM);
} }
if( db->magic!=SQLITE_MAGIC_OPEN && db->magic!=SQLITE_MAGIC_BUSY ){
return sqlite3ErrStr(SQLITE_MISUSE);
}
if( !sqlite3_value_text(db->pErr) ){ if( !sqlite3_value_text(db->pErr) ){
return sqlite3ErrStr(db->errCode); return sqlite3ErrStr(db->errCode);
} }
@ -858,8 +868,19 @@ const void *sqlite3_errmsg16(sqlite3 *db){
0, 'o', 0, 'f', 0, ' ', 0, 'o', 0, 'f', 0, ' ',
0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0 0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0
}; };
static char misuseBe [] = {
0, 'l', 0, 'i', 0, 'b', 0, 'r', 0, 'a', 0, 'r', 0, 'y', 0, ' ',
0, 'r', 0, 'o', 0, 'u', 0, 't', 0, 'i', 0, 'n', 0, 'e', 0, ' ',
0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, 'e', 0, 'd', 0, ' ',
0, 'o', 0, 'u', 0, 't', 0, ' ',
0, 'o', 0, 'f', 0, ' ',
0, 's', 0, 'e', 0, 'q', 0, 'u', 0, 'e', 0, 'n', 0, 'c', 0, 'e', 0, 0, 0
};
if( db && db->pErr ){ if( db && db->pErr ){
if( db->magic==SQLITE_MAGIC_ERROR ){
return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
}
if( !sqlite3_value_text16(db->pErr) ){ if( !sqlite3_value_text16(db->pErr) ){
sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode), sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode),
SQLITE_UTF8, SQLITE_STATIC); SQLITE_UTF8, SQLITE_STATIC);
@ -926,8 +947,7 @@ int sqlite3_prepare(
assert( ppStmt ); assert( ppStmt );
*ppStmt = 0; *ppStmt = 0;
if( sqlite3SafetyOn(db) ){ if( sqlite3SafetyOn(db) ){
rc = SQLITE_MISUSE; return SQLITE_MISUSE;
goto prepare_out;
} }
memset(&sParse, 0, sizeof(sParse)); memset(&sParse, 0, sizeof(sParse));

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.88 2004/06/25 12:08:47 danielk1977 Exp $ ** $Id: test1.c,v 1.89 2004/06/26 09:50:12 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@ -27,14 +27,6 @@
# define PTR_FMT "%p" # define PTR_FMT "%p"
#endif #endif
int sqlite3_exec_printf(
sqlite *db, /* An open database */
const char *sqlFormat, /* printf-style format string for the SQL */
sqlite_callback xCallback, /* Callback function */
void *pArg, /* 1st argument to callback function */
char **errmsg, /* Error msg written here */
... /* Arguments to the format string. */
);
int sqlite3_exec_printf( int sqlite3_exec_printf(
sqlite *db, /* An open database */ sqlite *db, /* An open database */
const char *sqlFormat, /* printf-style format string for the SQL */ const char *sqlFormat, /* printf-style format string for the SQL */
@ -399,7 +391,7 @@ static int execFuncCallback(void *pData, int argc, char **argv, char **NotUsed){
} }
/* /*
** Implementation of the x_sqlite3_exec() function. This function takes ** Implementation of the x_sqlite_exec() function. This function takes
** a single argument and attempts to execute that argument as SQL code. ** a single argument and attempts to execute that argument as SQL code.
** This is illegal and should set the SQLITE_MISUSE flag on the database. ** This is illegal and should set the SQLITE_MISUSE flag on the database.
** **
@ -429,7 +421,7 @@ static void sqlite3ExecFunc(
** Call the sqlite3_create_function API on the given database in order ** Call the sqlite3_create_function API on the given database in order
** to create a function named "x_coalesce". This function does the same thing ** to create a function named "x_coalesce". This function does the same thing
** as the "coalesce" function. This function also registers an SQL function ** as the "coalesce" function. This function also registers an SQL function
** named "x_sqlite3_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() ** named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec()
** in this way is illegal recursion and should raise an SQLITE_MISUSE error. ** in this way is illegal recursion and should raise an SQLITE_MISUSE error.
** The effect is similar to trying to use the same database connection from ** The effect is similar to trying to use the same database connection from
** two threads at the same time. ** two threads at the same time.
@ -454,7 +446,7 @@ static int test_create_function(
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sqlite3_create_function(db, "x_coalesce", -1, SQLITE_UTF8, 0, sqlite3_create_function(db, "x_coalesce", -1, SQLITE_UTF8, 0,
ifnullFunc, 0, 0); ifnullFunc, 0, 0);
sqlite3_create_function(db, "x_sqlite3_exec", 1, SQLITE_UTF8, db, sqlite3_create_function(db, "x_sqlite_exec", 1, SQLITE_UTF8, db,
sqlite3ExecFunc, 0, 0); sqlite3ExecFunc, 0, 0);
return TCL_OK; return TCL_OK;
} }

View File

@ -11,36 +11,12 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API. # focus of this script testing the callback-free C/C++ API.
# #
# $Id: capi2.test,v 1.16 2004/06/21 07:36:33 danielk1977 Exp $ # $Id: capi2.test,v 1.17 2004/06/26 09:50:12 danielk1977 Exp $
# #
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# proc sqlite_step {stmt N VALS COLS} {
# upvar $VALS vals
# upvar $COLS cols
# upvar $N n
# set vals [list]
# set cols [list]
#
# set n [sqlite3_column_count $stmt]
#
# set rc [sqlite3_step $stmt]
# for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
# lappend cols [sqlite3_column_name $stmt $i]
# }
# for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
# lappend cols [sqlite3_column_decltype $stmt $i]
# }
#
# for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
# lappend vals [sqlite3_column_text $stmt $i]
# }
#
# return $rc
# }
# Return the text values from the current row pointed at by STMT as a list. # Return the text values from the current row pointed at by STMT as a list.
proc get_row_values {STMT} { proc get_row_values {STMT} {
set VALUES [list] set VALUES [list]

View File

@ -10,7 +10,7 @@
#*********************************************************************** #***********************************************************************
# This file implements regression tests for SQLite library. # This file implements regression tests for SQLite library.
# #
# $Id: crash.test,v 1.4 2004/06/25 06:23:23 danielk1977 Exp $ # $Id: crash.test,v 1.5 2004/06/26 09:50:12 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -37,7 +37,6 @@ proc crashsql {crashdelay crashfile sql} {
set f [open crash.tcl w] set f [open crash.tcl w]
puts $f "sqlite3_crashparams $crashdelay $cfile" puts $f "sqlite3_crashparams $crashdelay $cfile"
puts $f "sqlite3 db test.db" puts $f "sqlite3 db test.db"
puts $f "db eval {pragma synchronous = full}"
puts $f "db eval {pragma cache_size = 10}" puts $f "db eval {pragma cache_size = 10}"
puts $f "db eval {" puts $f "db eval {"
puts $f "$sql" puts $f "$sql"
@ -232,14 +231,9 @@ for {set i 1} {$i < $repeats} {incr i} {
do_test crash-4.0 { do_test crash-4.0 {
file delete -force test2.db file delete -force test2.db
file delete -force test2.db-journal file delete -force test2.db-journal
sqlite3 db2 test2.db
execsql {
pragma default_cache_size = 10;
pragma default_synchronous = full;
} db2
db2 close
execsql { execsql {
ATTACH 'test2.db' AS aux; ATTACH 'test2.db' AS aux;
PRAGMA aux.default_cache_size = 10;
CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc; CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;
} }
expr [file size test2.db] / 1024 expr [file size test2.db] / 1024

View File

@ -13,11 +13,28 @@
# This file implements tests for the SQLITE_MISUSE detection logic. # This file implements tests for the SQLITE_MISUSE detection logic.
# This test file leaks memory and file descriptors. # This test file leaks memory and file descriptors.
# #
# $Id: misuse.test,v 1.5 2004/06/19 00:16:31 drh Exp $ # $Id: misuse.test,v 1.6 2004/06/26 09:50:12 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
proc catchsql2 {sql} {
set r [
catch {
set res [list]
db eval $sql data {
if { $res==[list] } {
foreach f $data(*) {lappend res $f}
}
foreach f $data(*) {lappend res $data($f)}
}
set res
} msg
]
lappend r $msg
}
# Make sure the test logic works # Make sure the test logic works
# #
do_test misuse-1.1 { do_test misuse-1.1 {
@ -28,14 +45,20 @@ do_test misuse-1.1 {
CREATE TABLE t1(a,b); CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2); INSERT INTO t1 VALUES(1,2);
} }
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {
SELECT * FROM t1
}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-1.2 { do_test misuse-1.2 {
sqlite_exec_printf $::DB {SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1} {} catchsql2 {
SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
}
} {1 {no such function: x_coalesce}} } {1 {no such function: x_coalesce}}
do_test misuse-1.3 { do_test misuse-1.3 {
sqlite_create_function $::DB sqlite3_create_function $::DB
sqlite_exec_printf $::DB {SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1} {} catchsql2 {
SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
}
} {0 {xyz 1}} } {0 {xyz 1}}
# Use the x_sqlite_exec() SQL function to simulate the effect of two # Use the x_sqlite_exec() SQL function to simulate the effect of two
@ -46,12 +69,12 @@ do_test misuse-1.3 {
# they do not. # they do not.
# #
do_test misuse-1.4 { do_test misuse-1.4 {
sqlite_exec_printf $::DB { catchsql2 {
SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz; SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz;
} {} }
} {0 {xyz {1 2}}} } {0 {xyz {1 2}}}
do_test misuse-1.5 { do_test misuse-1.5 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-1.6 { do_test misuse-1.6 {
catchsql { catchsql {
@ -69,19 +92,19 @@ do_test misuse-2.1 {
} }
} {1 2} } {1 2}
do_test misuse-2.2 { do_test misuse-2.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-2.3 { do_test misuse-2.3 {
set v [catch { set v [catch {
db eval {SELECT * FROM t1} {} { db eval {SELECT * FROM t1} {} {
sqlite_create_function $::DB sqlite3_create_function $::DB
} }
} msg] } msg]
lappend v $msg lappend v $msg
} {1 {library routine called out of sequence}} } {1 {library routine called out of sequence}}
do_test misuse-2.4 { do_test misuse-2.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {21 {library routine called out of sequence}} } {1 {library routine called out of sequence}}
do_test misuse-2.5 { do_test misuse-2.5 {
catchsql { catchsql {
SELECT * FROM t1 SELECT * FROM t1
@ -98,19 +121,19 @@ do_test misuse-3.1 {
} }
} {1 2} } {1 2}
do_test misuse-3.2 { do_test misuse-3.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-3.3 { do_test misuse-3.3 {
set v [catch { set v [catch {
db eval {SELECT * FROM t1} {} { db eval {SELECT * FROM t1} {} {
sqlite_create_aggregate $::DB sqlite3_create_aggregate $::DB
} }
} msg] } msg]
lappend v $msg lappend v $msg
} {1 {library routine called out of sequence}} } {1 {library routine called out of sequence}}
do_test misuse-3.4 { do_test misuse-3.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {21 {library routine called out of sequence}} } {1 {library routine called out of sequence}}
do_test misuse-3.5 { do_test misuse-3.5 {
catchsql { catchsql {
SELECT * FROM t1 SELECT * FROM t1
@ -119,6 +142,8 @@ do_test misuse-3.5 {
# Attempt to close the database from an sqlite_exec callback. # Attempt to close the database from an sqlite_exec callback.
# #
# Update for v3: The db cannot be closed because there are active
# VMs. The sqlite3_close call would return SQLITE_BUSY.
do_test misuse-4.1 { do_test misuse-4.1 {
db close db close
set ::DB [sqlite3 db test2.db] set ::DB [sqlite3 db test2.db]
@ -127,19 +152,20 @@ do_test misuse-4.1 {
} }
} {1 2} } {1 2}
do_test misuse-4.2 { do_test misuse-4.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-4.3 { do_test misuse-4.3 {
set v [catch { set v [catch {
db eval {SELECT * FROM t1} {} { db eval {SELECT * FROM t1} {} {
sqlite_close $::DB set r [sqlite3_close $::DB]
} }
} msg] } msg]
lappend v $msg lappend v $msg $r
} {1 {library routine called out of sequence}} } {0 {} SQLITE_BUSY}
do_test misuse-4.4 { do_test misuse-4.4 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} sqlite3_close $::DB
} {21 {library routine called out of sequence}} catchsql2 {SELECT * FROM t1}
} {1 {library routine called out of sequence}}
do_test misuse-4.5 { do_test misuse-4.5 {
catchsql { catchsql {
SELECT * FROM t1 SELECT * FROM t1
@ -156,11 +182,14 @@ do_test misuse-5.1 {
} }
} {1 2} } {1 2}
do_test misuse-5.2 { do_test misuse-5.2 {
sqlite_exec_printf $::DB {SELECT * FROM t1} {} catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}} } {0 {a b 1 2}}
do_test misuse-5.3 { do_test misuse-5.3 {
db close db close
sqlite_exec_printf $::DB {SELECT * FROM t1} {} set r [catch {
} {21 {library routine called out of sequence}} sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
} msg]
lappend r $msg
} {1 {(21) library routine called out of sequence}}
finish_test finish_test