-C Add\sTCL\stest\sbindings\sand\ssome\smore\stest\scases\sfor\sthe\snew\squery\sAPI.\s(CVS\s1467)
-D 2004-05-27T01:04:07
+C More\stest\scases\sfor\sthe\snew\squery\sAPI.\s(CVS\s1468)
+D 2004-05-27T01:49:51
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/sqliteInt.h 6b0d8d856c4af325eb5a00d1c32d89aacf432875
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c 86daf7bf6ba715bf0f0c7a47beb1d947a15cb868
-F src/test1.c 039659c18c6746199fe6e23863bb117a8e216f54
+F src/test1.c ff7cc8729c320aec038e7d9d116bed9eabd642d0
F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872
F src/test3.c 5e4a6d596f982f6f47a5f9f75ede9b4a3b739968
F src/test4.c 34848a9fd31aa65857b20a8bfc03aff77d8c3426
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/capi2.test 8fb64e8ab7f78b8254cd4d04bb96822167f731b2
-F test/capi3.test 64b7bad608d896468a5b4b926ed9037d112b6d77
+F test/capi3.test f207b48dfdedae3ffef715afc0e4fe268eb6af71
F test/conflict.test 0911bb2f079046914a6e9c3341b36658c4e2103e
F test/copy.test f07ea8d60878da7a67416ab62f78e9706b9d3c45
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 68ef17028621681f5d091e77d5df84f663a15e27
-R 7a2016da4fa120ff352ff7111a3e7361
+P d72adf0c522b442d5e1663862bdd639c282d4495
+R 2ba0c044593753a501ecb5b9d1ce6722
U danielk1977
-Z d6c93a1d5f40d138f387c99f637a146d
+Z 64c9fdf3b1584f065ec0b7238e3a9f4f
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test1.c,v 1.60 2004/05/27 01:04:07 danielk1977 Exp $
+** $Id: test1.c,v 1.61 2004/05/27 01:49:51 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
return TCL_OK;
}
+/*
+** Usage: sqlite3_column_blob STMT column
+*/
+static int test_column_blob(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3_stmt *pStmt;
+ int col;
+
+ int len;
+ void *pBlob;
+
+ if( objc!=3 ){
+ Tcl_AppendResult(interp, "wrong # args: should be \"",
+ Tcl_GetString(objv[0]), " STMT column", 0);
+ return TCL_ERROR;
+ }
+
+ if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;
+
+ pBlob = sqlite3_column_blob(pStmt, col);
+ len = sqlite3_column_bytes(pStmt, col);
+ Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pBlob, len));
+ return TCL_OK;
+}
+
/*
** Usage: sqlite3_column_double STMT column
**
{ "sqlite3_column_count", test_column_count ,0 },
{ "sqlite3_data_count", test_data_count ,0 },
{ "sqlite3_column_type", test_column_type ,0 },
- { "sqlite3_column_blob", test_column_name ,0 },
+ { "sqlite3_column_blob", test_column_blob ,0 },
{ "sqlite3_column_double", test_column_double ,0 },
{ "sqlite3_column_int64", test_column_int64 ,0 },
{ "sqlite3_column_int", test_stmt_int ,sqlite3_column_int },
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
-# $Id: capi3.test,v 1.6 2004/05/27 01:04:07 danielk1977 Exp $
+# $Id: capi3.test,v 1.7 2004/05/27 01:49:51 danielk1977 Exp $
#
set testdir [file dirname $argv0]
sqlite3_close $db2
} {}
-# The tests cases capi3-5.* test work as follows:
+# This proc is used to test the following API calls:
#
-# capi3-5.0: Prepare a statement, and check we can retrieve the number of
-# columns (before the statement is executed).
-# capi3-5.1: Check we can retrieve column names (before statement execution)
-# capi3-5.2: Check we can retrieve column names in UTF-16
+# sqlite3_column_count
+# sqlite3_column_name
+# sqlite3_column_name16
+# sqlite3_column_decltype
+# sqlite3_column_decltype16
#
-# capi3-5.1.3: Step the statement.
-# capi3-5.1.4: Check the types of the values.
-# capi3-5.1.5: Check the values can be retrieved as integers.
-# capi3-5.1.6: Check the values can be retrieved as UTF-8 text.
-# capi3-5.1.7: Check the values can be retrieved as floats.
-# capi3-5.1.8: Check the values can be retrieved as UTF-16 text.
-# capi3-5.1.9: Check the values can be retrieved as integers.
-# capi3-5.1.10: Check the values can be retrieved as floats.
-# capi3-5.1.11: Check the values can still be retrieved as UTF-8 text.
-# capi3-5.1.12: Check that the types of the values have not been altered by
-# retrieving the values as text.
+# $STMT is a compiled SQL statement. $test is a prefix
+# to use for test names within this proc. $names is a list
+# of the column names that should be returned by $STMT.
+# $decltypes is a list of column declaration types for $STMT.
#
-# Test cases capi3-5.2.3 - capi3-5.2.12 are a repeat of 1.3-1.12, with a
-# different row of data.
+# Example:
#
+# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
+# check_header test1.1 {1 2 3} {"" "" ""}
+#
+proc check_header {STMT test names decltypes} }
+
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set idxlist [list]
+ set numcols [sqlite3_column_count $STMT]
+ for {set i 0} {$i < $numcols} {incr i} {lappend idxlist $i}
+
+ # Column names in UTF-8
+ do_test $test.1 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ do_test $test.2 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-8
+ do_test $test.3 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]}
+ set cnamelist
+ } $names
+
+ # Column names in UTF-16
+ do_test $test.4 {
+ set cnamelist [list]
+ foreach i $idxlist {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]}
+ set cnamelist
+ } $names
+}
+
+# This proc is used to test the following APIs:
+#
+# sqlite3_data_count
+# sqlite3_column_type
+# sqlite3_column_int
+# sqlite3_column_text
+# sqlite3_column_text16
+# sqlite3_column_double
+#
+# $STMT is a compiled SQL statement for which the previous call
+# to sqlite3_step returned SQLITE_ROW. $test is a prefix to use
+# for test names within this proc. $types is a list of the
+# manifest types for the current row. $ints, $doubles and $strings
+# are lists of the integer, real and string representations of
+# the values in the current row.
+#
+# Example:
+#
+# set STMT [sqlite3_prepare "SELECT 'hello', 1.1, NULL" -1 DUMMY]
+# sqlite3_step $STMT
+# check_data test1.2 {TEXT REAL NULL} {0 1 0} {0 1.1 0} {hello 1.1 {}}
+#
+proc check_data {STMT test types ints doubles strings} {
-do_test capi3-5.0 {
- execsql {
- CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
- INSERT INTO t1 VALUES(1, 2, 3);
- INSERT INTO t1 VALUES('one', 'two', NULL);
- }
- set sql "SELECT * FROM t1"
- set STMT [sqlite3_prepare $DB $sql -1 TAIL]
-
- sqlite3_column_count $STMT
-} 3
-
-do_test capi3-5.1 {
- set cnamelist [list]
- foreach i {0 1 2} {lappend cnamelist [sqlite3_column_name $STMT $i]}
- set cnamelist
-} {a b c}
-
-do_test capi3-5.2 {
- set cnamelist [list]
- foreach i {0 1 2} {lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]}
- set cnamelist
-} {a b c}
-
-do_test capi3-5.1.3 {
- sqlite3_step $STMT
-} SQLITE_ROW
+ # Use the return value of sqlite3_column_count() to build
+ # a list of column indexes. i.e. If sqlite3_column_count
+ # is 3, build the list {0 1 2}.
+ set idxlist [list]
+ set numcols [sqlite3_data_count $STMT]
+ for {set i 0} {$i < $numcols} {incr i} {lappend idxlist $i}
# types
-do_test capi3-5.1.4 {
+do_test $test.1 {
set types [list]
- foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
set types
-} {INTEGER INTEGER TEXT}
+} $types
# Integers
-do_test capi3-5.1.5 {
+do_test $test.2 {
set ints [list]
- foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
+ foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
set ints
-} {1 2 3}
+} $ints
# UTF-8
-do_test capi3-5.1.6 {
+do_test $test.3 {
set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
set utf8
-} {1 2 3}
+} $strings
# Floats
-do_test capi3-5.1.7 {
+do_test $test.4 {
set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]}
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
set utf8
-} {1 2 3}
+} $doubles
# UTF-16
-do_test capi3-5.1.8 {
+do_test $test.5 {
set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [utf8 [sqlite3_column_data16 $STMT $i]]}
+ foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
set utf8
-} {1 2 3}
+} $strings
# Integers
-do_test capi3-5.1.9 {
+do_test $test.6 {
set ints [list]
- foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
+ foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
set ints
-} {1 2 3}
+} $ints
# Floats
-do_test capi3-5.1.10 {
+do_test $test.7 {
set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [sqlite3_column_double $STMT $i]}
+ foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
set utf8
-} {1 2 3}
+} $doubles
# UTF-8
-do_test capi3-5.1.11 {
+do_test $test.8 {
set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
+ foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
set utf8
-} {1 2 3}
+} $strings
# Types
-do_test capi3-5.1.12 {
+do_test $test.9 {
set types [list]
- foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
+ foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
set types
-} {INTEGER INTEGER TEXT}
+} $types
+
+}
+
+do_test capi3-5.0 {
+ execsql {
+ CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES('one', 'two', NULL);
+ }
+ set sql "SELECT * FROM t1"
+ set STMT [sqlite3_prepare $DB $sql -1 TAIL]
+ sqlite3_column_count $STMT
+} 3
+check_header $STMT capi3-5.1 {a b c} {VARIANT BLOB VARCHAR(16)}
-do_test capi3-5.9 {
+do_test capi3-5.2 {
sqlite3_step $STMT
} SQLITE_ROW
-do_test capi3-5.10 {
- set types [list]
- foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
- set types
-} {TEXT TEXT NULL}
-
-do_test capi3-5.11 {
- set ints [list]
- foreach i {0 1 2} {lappend ints [sqlite3_column_int $STMT $i]}
- set ints
-} {0 0 0}
-
-do_test capi3-5.12 {
- set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [sqlite3_column_data $STMT $i]}
- set utf8
-} {one two {}}
+check_header $STMT capi3-5.3 {a b c} {VARIANT BLOB VARCHAR(16)}
+check_data $STMT capi3-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1 2 3} {1 2 3}
-do_test capi3-5.13 {
- set utf8 [list]
- foreach i {0 1 2} {lappend utf8 [utf8 [sqlite3_column_data16 $STMT $i]]}
- set utf8
-} {one two {}}
+do_test capi3-5.5 {
+ sqlite3_step $STMT
+} SQLITE_ROW
-do_test capi3-5.14 {
- set types [list]
- foreach i {0 1 2} {lappend types [sqlite3_column_type $STMT $i]}
- set types
-} {TEXT TEXT NULL}
+check_header $STMT capi3-5.6 {a b c} {VARIANT BLOB VARCHAR(16)}
+check_data $STMT capi3-5.7 {TEXT TEXT NULL} {0 0 0} {0 0 0} {one two {}}
-do_test capi3-5.15 {
+do_test capi3-5.8 {
sqlite3_step $STMT
} SQLITE_DONE
-do_test capi3-5.99 {
+do_test capi3-5.9 {
sqlite3_finalize $STMT
-} {SQLITE_OK}
-
+} SQLITE_OK
db close
finish_test
-