-C Remove\sthe\s'nMaster'\sargument\sfrom\svarious\spager\sand\sbtree\sfunctions.\s(CVS\s1737)
-D 2004-06-26T08:38:25
+C Minor\sfixes\srelated\sto\sthe\stests\sin\smisuse.test\s(CVS\s1738)
+D 2004-06-26T09:50:12
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
-F src/main.c 7a5afce156d14727a49b60ffe6ab21bcae27e6f3
+F src/main.c 7551892fd677fac1ddb1429f70bf53d7e01eeb93
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
F src/sqliteInt.h d1911e120fb20ff9ba4cf0115065ac6569268cec
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3
-F src/test1.c e4e0ae8af8040c848ef35f92e6a22b2245b9b873
+F src/test1.c 0eca68f6e70069aad7ad0fd91fda886926646786
F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40
F src/test3.c bacc42bf41fa04d6faf7dd104b595b8bafb9aec9
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293
-F test/capi2.test 9ad428f7f228142be1bd9e7d4a906d7d2fa53e6e
+F test/capi2.test fe61f341e953f73c29bacfcbdaf688cd7b0e0d38
F test/capi3.test 6528034f21c4e8e404032124cb58b14ce934598c
F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef
F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b
F test/collate5.test 1dd5f0f508c46667f9d4606c7950c414b0bdc0d5
F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
-F test/crash.test 14cc6a657532841fa179b6f8d4181ce680cabc4a
+F test/crash.test 062a108997c3f58a72e9add04d48e766468daf04
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d
F test/delete.test 4f0c86e2bebdc822d179c80697b1ceabe6bbcd07
F test/misc1.test a8eb48d38f7a64e75314a2946db68d2b77901b7d
F test/misc2.test 703734f5817215ca54e364833b3bf5ff36fcc21e
F test/misc3.test eb488314990bfc0959221a1acc465013238bf168
-F test/misuse.test 97456c4fa78be0c3151f41aa05c763b9f6b11f81
+F test/misuse.test 2a64ce711419f2fd12806ed95af930fd4e7bb8f3
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 64730a1c32955e5cc510b7632fed6b9929a4029a
F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 76da457b8fc8fe838226da14c31c315cf914a505
-R 98f9db5e6f42c5a7abb1dd3e9055572f
+P 4e20720984e1fd6822ead785d758374d2704b7fb
+R 49b5250eaaec471bbc6b3f93826e25f5
U danielk1977
-Z 119b2a1a08cb96489bfef6a509f0c0ea
+Z 797c0e00173b158ed66a18d7f85e63d1
-4e20720984e1fd6822ead785d758374d2704b7fb
\ No newline at end of file
+0af3ff39422e02afdfdaf2005ab5eb01b496dc72
\ No newline at end of file
** other files are for internal use by SQLite and should not be
** 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 "os.h"
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( db->pVdbe ){
sqlite3Error(db, SQLITE_BUSY,
*/
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) ){
return sqlite3ErrStr(db->errCode);
}
0, 'o', 0, 'f', 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->magic==SQLITE_MAGIC_ERROR ){
+ return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
+ }
if( !sqlite3_value_text16(db->pErr) ){
sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode),
SQLITE_UTF8, SQLITE_STATIC);
assert( ppStmt );
*ppStmt = 0;
if( sqlite3SafetyOn(db) ){
- rc = SQLITE_MISUSE;
- goto prepare_out;
+ return SQLITE_MISUSE;
}
memset(&sParse, 0, sizeof(sParse));
** is not included in the SQLite library. It is used for automated
** 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 "tcl.h"
# define PTR_FMT "%p"
#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(
sqlite *db, /* An open database */
const char *sqlFormat, /* printf-style format string for the SQL */
}
/*
-** 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.
** This is illegal and should set the SQLITE_MISUSE flag on the database.
**
** 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
** 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.
** The effect is similar to trying to use the same database connection from
** two threads at the same time.
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
sqlite3_create_function(db, "x_coalesce", -1, SQLITE_UTF8, 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);
return TCL_OK;
}
# 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.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]
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.
proc get_row_values {STMT} {
set VALUES [list]
#***********************************************************************
# 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]
source $testdir/tester.tcl
set f [open crash.tcl w]
puts $f "sqlite3_crashparams $crashdelay $cfile"
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 {"
puts $f "$sql"
do_test crash-4.0 {
file delete -force test2.db
file delete -force test2.db-journal
- sqlite3 db2 test2.db
- execsql {
- pragma default_cache_size = 10;
- pragma default_synchronous = full;
- } db2
- db2 close
execsql {
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;
}
expr [file size test2.db] / 1024
# This file implements tests for the SQLITE_MISUSE detection logic.
# 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]
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
#
do_test misuse-1.1 {
CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2);
}
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {
+ SELECT * FROM t1
+ }
} {0 {a b 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}}
do_test misuse-1.3 {
- sqlite_create_function $::DB
- sqlite_exec_printf $::DB {SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1} {}
+ sqlite3_create_function $::DB
+ catchsql2 {
+ SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1
+ }
} {0 {xyz 1}}
# Use the x_sqlite_exec() SQL function to simulate the effect of two
# they do not.
#
do_test misuse-1.4 {
- sqlite_exec_printf $::DB {
+ catchsql2 {
SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz;
- } {}
+ }
} {0 {xyz {1 2}}}
do_test misuse-1.5 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-1.6 {
catchsql {
}
} {1 2}
do_test misuse-2.2 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-2.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
- sqlite_create_function $::DB
+ sqlite3_create_function $::DB
}
} msg]
lappend v $msg
} {1 {library routine called out of sequence}}
do_test misuse-2.4 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
-} {21 {library routine called out of sequence}}
+ catchsql2 {SELECT * FROM t1}
+} {1 {library routine called out of sequence}}
do_test misuse-2.5 {
catchsql {
SELECT * FROM t1
}
} {1 2}
do_test misuse-3.2 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-3.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
- sqlite_create_aggregate $::DB
+ sqlite3_create_aggregate $::DB
}
} msg]
lappend v $msg
} {1 {library routine called out of sequence}}
do_test misuse-3.4 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
-} {21 {library routine called out of sequence}}
+ catchsql2 {SELECT * FROM t1}
+} {1 {library routine called out of sequence}}
do_test misuse-3.5 {
catchsql {
SELECT * FROM t1
# 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 {
db close
set ::DB [sqlite3 db test2.db]
}
} {1 2}
do_test misuse-4.2 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-4.3 {
set v [catch {
db eval {SELECT * FROM t1} {} {
- sqlite_close $::DB
+ set r [sqlite3_close $::DB]
}
} msg]
- lappend v $msg
-} {1 {library routine called out of sequence}}
+ lappend v $msg $r
+} {0 {} SQLITE_BUSY}
do_test misuse-4.4 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
-} {21 {library routine called out of sequence}}
+ sqlite3_close $::DB
+ catchsql2 {SELECT * FROM t1}
+} {1 {library routine called out of sequence}}
do_test misuse-4.5 {
catchsql {
SELECT * FROM t1
}
} {1 2}
do_test misuse-5.2 {
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
+ catchsql2 {SELECT * FROM t1}
} {0 {a b 1 2}}
do_test misuse-5.3 {
db close
- sqlite_exec_printf $::DB {SELECT * FROM t1} {}
-} {21 {library routine called out of sequence}}
+ set r [catch {
+ sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
+ } msg]
+ lappend r $msg
+} {1 {(21) library routine called out of sequence}}
finish_test