2004-05-20 15:00:52 +04:00
|
|
|
# 2003 January 29
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The
|
|
|
|
# focus of this script testing the callback-free C/C++ API.
|
|
|
|
#
|
2009-01-09 05:49:31 +03:00
|
|
|
# $Id: capi3.test,v 1.70 2009/01/09 02:49:32 drh Exp $
|
2004-05-20 15:00:52 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2010-06-22 17:46:43 +04:00
|
|
|
# Do not use a codec for tests in this file, as the database file is
|
|
|
|
# manipulated directly using tcl scripts (using the [hexio_write] command).
|
|
|
|
#
|
|
|
|
do_not_use_codec
|
|
|
|
|
2004-05-20 15:00:52 +04:00
|
|
|
# Return the UTF-16 representation of the supplied UTF-8 string $str.
|
|
|
|
# If $nt is true, append two 0x00 bytes as a nul terminator.
|
|
|
|
proc utf16 {str {nt 1}} {
|
|
|
|
set r [encoding convertto unicode $str]
|
|
|
|
if {$nt} {
|
|
|
|
append r "\x00\x00"
|
|
|
|
}
|
|
|
|
return $r
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return the UTF-8 representation of the supplied UTF-16 string $str.
|
|
|
|
proc utf8 {str} {
|
|
|
|
# If $str ends in two 0x00 0x00 bytes, knock these off before
|
|
|
|
# converting to UTF-8 using TCL.
|
|
|
|
binary scan $str \c* vals
|
|
|
|
if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
|
|
|
|
set str [binary format \c* [lrange $vals 0 end-2]]
|
|
|
|
}
|
|
|
|
|
|
|
|
set r [encoding convertfrom unicode $str]
|
|
|
|
return $r
|
|
|
|
}
|
|
|
|
|
|
|
|
# These tests complement those in capi2.test. They are organized
|
|
|
|
# as follows:
|
|
|
|
#
|
|
|
|
# capi3-1.*: Test sqlite3_prepare
|
|
|
|
# capi3-2.*: Test sqlite3_prepare16
|
2004-05-21 05:47:26 +04:00
|
|
|
# capi3-3.*: Test sqlite3_open
|
|
|
|
# capi3-4.*: Test sqlite3_open16
|
2004-05-26 14:11:05 +04:00
|
|
|
# capi3-5.*: Test the various sqlite3_result_* APIs
|
2004-06-19 07:33:57 +04:00
|
|
|
# capi3-6.*: Test that sqlite3_close fails if there are outstanding VMs.
|
2004-05-20 15:00:52 +04:00
|
|
|
#
|
|
|
|
|
2006-01-03 03:33:50 +03:00
|
|
|
set DB [sqlite3_connection_pointer db]
|
2004-05-20 15:00:52 +04:00
|
|
|
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-1.0 {
|
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 1
|
2004-05-20 15:00:52 +04:00
|
|
|
do_test capi3-1.1 {
|
|
|
|
set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL]
|
2004-05-21 14:08:53 +04:00
|
|
|
sqlite3_finalize $STMT
|
2004-05-20 15:00:52 +04:00
|
|
|
set TAIL
|
|
|
|
} {}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-1.2.1 {
|
2004-05-20 15:00:52 +04:00
|
|
|
sqlite3_errcode $DB
|
|
|
|
} {SQLITE_OK}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-1.2.2 {
|
|
|
|
sqlite3_extended_errcode $DB
|
|
|
|
} {SQLITE_OK}
|
2004-05-20 15:00:52 +04:00
|
|
|
do_test capi3-1.3 {
|
|
|
|
sqlite3_errmsg $DB
|
|
|
|
} {not an error}
|
|
|
|
do_test capi3-1.4 {
|
|
|
|
set sql {SELECT name FROM sqlite_master;SELECT 10}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
2004-05-21 14:08:53 +04:00
|
|
|
sqlite3_finalize $STMT
|
2004-05-20 15:00:52 +04:00
|
|
|
set TAIL
|
|
|
|
} {SELECT 10}
|
|
|
|
do_test capi3-1.5 {
|
2008-04-03 18:36:25 +04:00
|
|
|
set sql {SELECT name FROM sqlite_master;SELECT 10}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql [string length $sql] TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set TAIL
|
|
|
|
} {SELECT 10}
|
|
|
|
do_test capi3-1.6 {
|
|
|
|
set sql {SELECT name FROM sqlite_master;SELECT 10}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql [expr [string length $sql]+1] TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set TAIL
|
|
|
|
} {SELECT 10}
|
|
|
|
|
|
|
|
do_test capi3-1.7 {
|
2004-05-20 15:00:52 +04:00
|
|
|
set sql {SELECT namex FROM sqlite_master}
|
|
|
|
catch {
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
}
|
|
|
|
} {1}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-1.8.1 {
|
2004-05-20 15:00:52 +04:00
|
|
|
sqlite3_errcode $DB
|
|
|
|
} {SQLITE_ERROR}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-1.8.2 {
|
|
|
|
sqlite3_extended_errcode $DB
|
|
|
|
} {SQLITE_ERROR}
|
2008-04-03 18:36:25 +04:00
|
|
|
do_test capi3-1.9 {
|
2004-05-20 15:00:52 +04:00
|
|
|
sqlite3_errmsg $DB
|
|
|
|
} {no such column: namex}
|
|
|
|
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
2006-01-13 04:25:05 +03:00
|
|
|
do_test capi3-2.1 {
|
|
|
|
set sql16 [utf16 {SELECT name FROM sqlite_master}]
|
|
|
|
set STMT [sqlite3_prepare16 $DB $sql16 -1 ::TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
utf8 $::TAIL
|
|
|
|
} {}
|
|
|
|
do_test capi3-2.2 {
|
|
|
|
set sql [utf16 {SELECT name FROM sqlite_master;SELECT 10}]
|
2004-05-20 15:00:52 +04:00
|
|
|
set STMT [sqlite3_prepare16 $DB $sql -1 TAIL]
|
2006-01-13 04:25:05 +03:00
|
|
|
sqlite3_finalize $STMT
|
|
|
|
utf8 $TAIL
|
|
|
|
} {SELECT 10}
|
|
|
|
do_test capi3-2.3 {
|
|
|
|
set sql [utf16 {SELECT namex FROM sqlite_master}]
|
|
|
|
catch {
|
2009-01-09 05:49:31 +03:00
|
|
|
set STMT [sqlite3_prepare16 $DB $sql -1]
|
2006-01-13 04:25:05 +03:00
|
|
|
}
|
|
|
|
} {1}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-2.4.1 {
|
2006-01-13 04:25:05 +03:00
|
|
|
sqlite3_errcode $DB
|
|
|
|
} {SQLITE_ERROR}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-2.4.2 {
|
|
|
|
sqlite3_extended_errcode $DB
|
|
|
|
} {SQLITE_ERROR}
|
2006-01-13 04:25:05 +03:00
|
|
|
do_test capi3-2.5 {
|
|
|
|
sqlite3_errmsg $DB
|
|
|
|
} {no such column: namex}
|
2006-01-17 12:35:01 +03:00
|
|
|
|
|
|
|
ifcapable schema_pragmas {
|
|
|
|
do_test capi3-2.6 {
|
|
|
|
execsql {CREATE TABLE tablename(x)}
|
2009-01-09 05:49:31 +03:00
|
|
|
set sql16 [utf16 {PRAGMA table_info("TableName"); --excess text}]
|
|
|
|
set STMT [sqlite3_prepare16 $DB $sql16 -1]
|
2006-01-17 12:35:01 +03:00
|
|
|
sqlite3_step $STMT
|
|
|
|
} SQLITE_ROW
|
|
|
|
do_test capi3-2.7 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} SQLITE_DONE
|
|
|
|
do_test capi3-2.8 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} SQLITE_OK
|
|
|
|
}
|
|
|
|
|
2004-11-14 07:04:17 +03:00
|
|
|
} ;# endif utf16
|
2004-05-20 15:00:52 +04:00
|
|
|
|
2004-05-21 05:47:26 +04:00
|
|
|
# rename sqlite3_open sqlite3_open_old
|
|
|
|
# proc sqlite3_open {fname options} {sqlite3_open_new $fname $options}
|
|
|
|
|
|
|
|
do_test capi3-3.1 {
|
|
|
|
set db2 [sqlite3_open test.db {}]
|
|
|
|
sqlite3_errcode $db2
|
|
|
|
} {SQLITE_OK}
|
|
|
|
# FIX ME: Should test the db handle works.
|
|
|
|
do_test capi3-3.2 {
|
|
|
|
sqlite3_close $db2
|
2004-06-19 07:33:57 +04:00
|
|
|
} {SQLITE_OK}
|
2004-05-21 05:47:26 +04:00
|
|
|
do_test capi3-3.3 {
|
|
|
|
catch {
|
|
|
|
set db2 [sqlite3_open /bogus/path/test.db {}]
|
|
|
|
}
|
2008-10-30 18:03:15 +03:00
|
|
|
sqlite3_extended_errcode $db2
|
2004-05-21 05:47:26 +04:00
|
|
|
} {SQLITE_CANTOPEN}
|
|
|
|
do_test capi3-3.4 {
|
|
|
|
sqlite3_errmsg $db2
|
|
|
|
} {unable to open database file}
|
2004-06-19 07:33:57 +04:00
|
|
|
do_test capi3-3.5 {
|
2004-05-21 05:47:26 +04:00
|
|
|
sqlite3_close $db2
|
2004-06-19 07:33:57 +04:00
|
|
|
} {SQLITE_OK}
|
2007-01-04 02:37:28 +03:00
|
|
|
do_test capi3-3.6.1-misuse {
|
2004-06-29 12:59:35 +04:00
|
|
|
sqlite3_close $db2
|
|
|
|
} {SQLITE_MISUSE}
|
2007-01-04 02:37:28 +03:00
|
|
|
do_test capi3-3.6.2-misuse {
|
2004-06-29 17:18:23 +04:00
|
|
|
sqlite3_errmsg $db2
|
|
|
|
} {library routine called out of sequence}
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
2007-01-04 02:37:28 +03:00
|
|
|
do_test capi3-3.6.3-misuse {
|
2004-11-14 07:04:17 +03:00
|
|
|
utf8 [sqlite3_errmsg16 $db2]
|
|
|
|
} {library routine called out of sequence}
|
|
|
|
}
|
2004-05-21 05:47:26 +04:00
|
|
|
|
2008-02-22 00:30:07 +03:00
|
|
|
do_test capi3-3.7 {
|
|
|
|
set db2 [sqlite3_open]
|
|
|
|
sqlite3_errcode $db2
|
|
|
|
} {SQLITE_OK}
|
|
|
|
do_test capi3-3.8 {
|
|
|
|
sqlite3_close $db2
|
|
|
|
} {SQLITE_OK}
|
|
|
|
|
2004-05-21 05:47:26 +04:00
|
|
|
# rename sqlite3_open ""
|
|
|
|
# rename sqlite3_open_old sqlite3_open
|
|
|
|
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
2004-05-21 05:47:26 +04:00
|
|
|
do_test capi3-4.1 {
|
|
|
|
set db2 [sqlite3_open16 [utf16 test.db] {}]
|
|
|
|
sqlite3_errcode $db2
|
|
|
|
} {SQLITE_OK}
|
|
|
|
# FIX ME: Should test the db handle works.
|
|
|
|
do_test capi3-4.2 {
|
|
|
|
sqlite3_close $db2
|
2004-06-19 07:33:57 +04:00
|
|
|
} {SQLITE_OK}
|
2004-05-21 05:47:26 +04:00
|
|
|
do_test capi3-4.3 {
|
|
|
|
catch {
|
|
|
|
set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}]
|
|
|
|
}
|
|
|
|
sqlite3_errcode $db2
|
|
|
|
} {SQLITE_CANTOPEN}
|
|
|
|
do_test capi3-4.4 {
|
|
|
|
utf8 [sqlite3_errmsg16 $db2]
|
|
|
|
} {unable to open database file}
|
2004-05-27 13:28:41 +04:00
|
|
|
do_test capi3-4.5 {
|
2004-05-21 05:47:26 +04:00
|
|
|
sqlite3_close $db2
|
2004-06-19 07:33:57 +04:00
|
|
|
} {SQLITE_OK}
|
2004-11-14 07:04:17 +03:00
|
|
|
} ;# utf16
|
2004-05-21 05:47:26 +04:00
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
# This proc is used to test the following API calls:
|
2004-05-26 14:11:05 +04:00
|
|
|
#
|
2004-05-27 05:49:51 +04:00
|
|
|
# sqlite3_column_count
|
|
|
|
# sqlite3_column_name
|
|
|
|
# sqlite3_column_name16
|
|
|
|
# sqlite3_column_decltype
|
|
|
|
# sqlite3_column_decltype16
|
2004-05-26 14:11:05 +04:00
|
|
|
#
|
2004-05-27 05:49:51 +04:00
|
|
|
# $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.
|
2004-05-27 05:04:07 +04:00
|
|
|
#
|
2004-05-27 05:49:51 +04:00
|
|
|
# Example:
|
2004-05-26 14:11:05 +04:00
|
|
|
#
|
2004-05-27 05:49:51 +04:00
|
|
|
# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
|
|
|
|
# check_header test1.1 {1 2 3} {"" "" ""}
|
|
|
|
#
|
2004-05-27 13:28:41 +04:00
|
|
|
proc check_header {STMT test names decltypes} {
|
2004-05-27 05:49:51 +04:00
|
|
|
|
|
|
|
# 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}.
|
2004-05-27 13:28:41 +04:00
|
|
|
set ::idxlist [list]
|
2004-06-28 17:09:11 +04:00
|
|
|
set ::numcols [sqlite3_column_count $STMT]
|
|
|
|
for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
|
2004-05-27 05:49:51 +04:00
|
|
|
|
|
|
|
# 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
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.2 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $names
|
|
|
|
}
|
2004-05-27 05:49:51 +04:00
|
|
|
|
|
|
|
# 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
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.4 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $names
|
|
|
|
}
|
2004-05-28 17:13:02 +04:00
|
|
|
|
|
|
|
# Column names in UTF-8
|
|
|
|
do_test $test.5 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]}
|
|
|
|
set cnamelist
|
|
|
|
} $decltypes
|
|
|
|
|
|
|
|
# Column declaration types in UTF-16
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.6 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $decltypes
|
|
|
|
}
|
2004-05-28 17:13:02 +04:00
|
|
|
|
2004-06-28 17:09:11 +04:00
|
|
|
|
|
|
|
# Test some out of range conditions:
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.7 {
|
|
|
|
list \
|
|
|
|
[sqlite3_column_name $STMT -1] \
|
|
|
|
[sqlite3_column_name16 $STMT -1] \
|
|
|
|
[sqlite3_column_decltype $STMT -1] \
|
|
|
|
[sqlite3_column_decltype16 $STMT -1] \
|
|
|
|
[sqlite3_column_name $STMT $numcols] \
|
|
|
|
[sqlite3_column_name16 $STMT $numcols] \
|
|
|
|
[sqlite3_column_decltype $STMT $numcols] \
|
|
|
|
[sqlite3_column_decltype16 $STMT $numcols]
|
|
|
|
} {{} {} {} {} {} {} {} {}}
|
|
|
|
}
|
2004-05-27 05:49:51 +04:00
|
|
|
}
|
|
|
|
|
2006-02-10 05:27:42 +03:00
|
|
|
# This proc is used to test the following API calls:
|
|
|
|
#
|
|
|
|
# sqlite3_column_origin_name
|
|
|
|
# sqlite3_column_origin_name16
|
|
|
|
# sqlite3_column_table_name
|
|
|
|
# sqlite3_column_table_name16
|
|
|
|
# sqlite3_column_database_name
|
|
|
|
# sqlite3_column_database_name16
|
|
|
|
#
|
|
|
|
# $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.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
#
|
|
|
|
# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
|
|
|
|
# check_header test1.1 {1 2 3} {"" "" ""}
|
|
|
|
#
|
|
|
|
proc check_origin_header {STMT test dbs tables cols} {
|
2006-02-10 10:07:14 +03:00
|
|
|
# If sqlite3_column_origin_name() and friends are not compiled into
|
|
|
|
# this build, this proc is a no-op.
|
2007-08-13 00:07:58 +04:00
|
|
|
ifcapable columnmetadata {
|
2006-02-10 10:07:14 +03:00
|
|
|
# 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}
|
|
|
|
|
|
|
|
# Database names in UTF-8
|
|
|
|
do_test $test.8 {
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
2006-02-10 10:07:14 +03:00
|
|
|
lappend cnamelist [sqlite3_column_database_name $STMT $i]
|
|
|
|
}
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist
|
|
|
|
} $dbs
|
2006-02-10 10:07:14 +03:00
|
|
|
|
|
|
|
# Database names in UTF-16
|
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.9 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_database_name16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $dbs
|
|
|
|
}
|
|
|
|
|
|
|
|
# Table names in UTF-8
|
|
|
|
do_test $test.10 {
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
2006-02-10 10:07:14 +03:00
|
|
|
lappend cnamelist [sqlite3_column_table_name $STMT $i]
|
|
|
|
}
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist
|
|
|
|
} $tables
|
2006-02-10 10:07:14 +03:00
|
|
|
|
|
|
|
# Table names in UTF-16
|
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.11 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_table_name16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $tables
|
|
|
|
}
|
|
|
|
|
|
|
|
# Origin names in UTF-8
|
|
|
|
do_test $test.12 {
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
2006-02-10 10:07:14 +03:00
|
|
|
lappend cnamelist [sqlite3_column_origin_name $STMT $i]
|
|
|
|
}
|
2006-02-10 05:27:42 +03:00
|
|
|
set cnamelist
|
|
|
|
} $cols
|
2006-02-10 10:07:14 +03:00
|
|
|
|
|
|
|
# Origin declaration types in UTF-16
|
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.13 {
|
|
|
|
set cnamelist [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend cnamelist [utf8 [sqlite3_column_origin_name16 $STMT $i]]
|
|
|
|
}
|
|
|
|
set cnamelist
|
|
|
|
} $cols
|
|
|
|
}
|
2006-02-10 05:27:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
# 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} {
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
# 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}.
|
2004-05-27 13:28:41 +04:00
|
|
|
set ::idxlist [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
set numcols [sqlite3_data_count $STMT]
|
2004-05-27 13:28:41 +04:00
|
|
|
for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:04:07 +04:00
|
|
|
# types
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test $test.1 {
|
2004-05-26 14:11:05 +04:00
|
|
|
set types [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
|
2004-05-26 14:11:05 +04:00
|
|
|
set types
|
2004-05-27 05:49:51 +04:00
|
|
|
} $types
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:04:07 +04:00
|
|
|
# Integers
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test $test.2 {
|
2004-05-26 14:11:05 +04:00
|
|
|
set ints [list]
|
2004-06-28 17:09:11 +04:00
|
|
|
foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}
|
2004-05-26 14:11:05 +04:00
|
|
|
set ints
|
2004-05-27 05:49:51 +04:00
|
|
|
} $ints
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-06-28 17:09:11 +04:00
|
|
|
# bytes
|
|
|
|
set lens [list]
|
|
|
|
foreach i $::idxlist {
|
|
|
|
lappend lens [string length [lindex $strings $i]]
|
|
|
|
}
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test $test.3 {
|
2004-06-28 17:09:11 +04:00
|
|
|
set bytes [list]
|
|
|
|
set lens [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend bytes [sqlite3_column_bytes $STMT $i]
|
|
|
|
}
|
|
|
|
set bytes
|
|
|
|
} $lens
|
|
|
|
|
|
|
|
# bytes16
|
2004-11-15 00:56:29 +03:00
|
|
|
ifcapable {utf16} {
|
2004-06-28 17:09:11 +04:00
|
|
|
set lens [list]
|
2004-11-15 00:56:29 +03:00
|
|
|
foreach i $::idxlist {
|
|
|
|
lappend lens [expr 2 * [string length [lindex $strings $i]]]
|
2004-06-28 17:09:11 +04:00
|
|
|
}
|
2004-11-15 00:56:29 +03:00
|
|
|
do_test $test.4 {
|
|
|
|
set bytes [list]
|
|
|
|
set lens [list]
|
|
|
|
foreach i $idxlist {
|
|
|
|
lappend bytes [sqlite3_column_bytes16 $STMT $i]
|
|
|
|
}
|
|
|
|
set bytes
|
|
|
|
} $lens
|
|
|
|
}
|
2004-06-28 17:09:11 +04:00
|
|
|
|
|
|
|
# Blob
|
|
|
|
do_test $test.5 {
|
|
|
|
set utf8 [list]
|
|
|
|
foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}
|
|
|
|
set utf8
|
|
|
|
} $strings
|
|
|
|
|
|
|
|
# UTF-8
|
|
|
|
do_test $test.6 {
|
2004-05-26 14:11:05 +04:00
|
|
|
set utf8 [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
|
2004-05-26 14:11:05 +04:00
|
|
|
set utf8
|
2004-05-27 05:49:51 +04:00
|
|
|
} $strings
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:04:07 +04:00
|
|
|
# Floats
|
2004-06-28 17:09:11 +04:00
|
|
|
do_test $test.7 {
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8 [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8
|
2004-05-27 05:49:51 +04:00
|
|
|
} $doubles
|
2004-05-27 05:04:07 +04:00
|
|
|
|
|
|
|
# UTF-16
|
2004-11-14 07:04:17 +03:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test $test.8 {
|
|
|
|
set utf8 [list]
|
|
|
|
foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
|
|
|
|
set utf8
|
|
|
|
} $strings
|
|
|
|
}
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:04:07 +04:00
|
|
|
# Integers
|
2004-06-28 17:09:11 +04:00
|
|
|
do_test $test.9 {
|
2004-05-27 05:04:07 +04:00
|
|
|
set ints [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
|
2004-05-27 05:04:07 +04:00
|
|
|
set ints
|
2004-05-27 05:49:51 +04:00
|
|
|
} $ints
|
2004-05-27 05:04:07 +04:00
|
|
|
|
|
|
|
# Floats
|
2004-06-28 17:09:11 +04:00
|
|
|
do_test $test.10 {
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8 [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8
|
2004-05-27 05:49:51 +04:00
|
|
|
} $doubles
|
2004-05-27 05:04:07 +04:00
|
|
|
|
|
|
|
# UTF-8
|
2004-06-28 17:09:11 +04:00
|
|
|
do_test $test.11 {
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8 [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
|
2004-05-27 05:04:07 +04:00
|
|
|
set utf8
|
2004-05-27 05:49:51 +04:00
|
|
|
} $strings
|
2004-05-27 05:04:07 +04:00
|
|
|
|
|
|
|
# Types
|
2004-06-28 17:09:11 +04:00
|
|
|
do_test $test.12 {
|
2004-05-26 14:11:05 +04:00
|
|
|
set types [list]
|
2004-05-27 05:49:51 +04:00
|
|
|
foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
|
2004-05-26 14:11:05 +04:00
|
|
|
set types
|
2004-05-27 05:49:51 +04:00
|
|
|
} $types
|
|
|
|
|
2004-06-28 17:09:11 +04:00
|
|
|
# Test that an out of range request returns the equivalent of NULL
|
|
|
|
do_test $test.13 {
|
|
|
|
sqlite3_column_int $STMT -1
|
|
|
|
} {0}
|
|
|
|
do_test $test.13 {
|
|
|
|
sqlite3_column_text $STMT -1
|
|
|
|
} {}
|
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
}
|
|
|
|
|
2006-01-24 00:37:32 +03:00
|
|
|
ifcapable !floatingpoint {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
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);
|
2004-05-27 13:28:41 +04:00
|
|
|
INSERT INTO t1 VALUES(1.2, 1.3, 1.4);
|
2004-05-27 05:49:51 +04:00
|
|
|
}
|
|
|
|
set sql "SELECT * FROM t1"
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
sqlite3_column_count $STMT
|
|
|
|
} 3
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-28 17:13:02 +04:00
|
|
|
check_header $STMT capi3-5.1 {a b c} {VARINT BLOB VARCHAR(16)}
|
2006-02-10 05:27:42 +03:00
|
|
|
check_origin_header $STMT capi3-5.1 {main main main} {t1 t1 t1} {a b c}
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test capi3-5.2 {
|
2004-05-26 14:11:05 +04:00
|
|
|
sqlite3_step $STMT
|
|
|
|
} SQLITE_ROW
|
|
|
|
|
2004-05-28 17:13:02 +04:00
|
|
|
check_header $STMT capi3-5.3 {a b c} {VARINT BLOB VARCHAR(16)}
|
2006-02-10 05:27:42 +03:00
|
|
|
check_origin_header $STMT capi3-5.3 {main main main} {t1 t1 t1} {a b c}
|
2004-05-27 14:30:52 +04:00
|
|
|
check_data $STMT capi3-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test capi3-5.5 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} SQLITE_ROW
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-28 17:13:02 +04:00
|
|
|
check_header $STMT capi3-5.6 {a b c} {VARINT BLOB VARCHAR(16)}
|
2006-02-10 05:27:42 +03:00
|
|
|
check_origin_header $STMT capi3-5.6 {main main main} {t1 t1 t1} {a b c}
|
2004-05-27 14:30:52 +04:00
|
|
|
check_data $STMT capi3-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2004-05-27 05:49:51 +04:00
|
|
|
do_test capi3-5.8 {
|
2004-05-26 14:11:05 +04:00
|
|
|
sqlite3_step $STMT
|
2004-05-27 13:28:41 +04:00
|
|
|
} SQLITE_ROW
|
|
|
|
|
2004-05-28 17:13:02 +04:00
|
|
|
check_header $STMT capi3-5.9 {a b c} {VARINT BLOB VARCHAR(16)}
|
2006-02-10 05:27:42 +03:00
|
|
|
check_origin_header $STMT capi3-5.9 {main main main} {t1 t1 t1} {a b c}
|
2004-05-27 14:30:52 +04:00
|
|
|
check_data $STMT capi3-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}
|
2004-05-27 13:28:41 +04:00
|
|
|
|
|
|
|
do_test capi3-5.11 {
|
|
|
|
sqlite3_step $STMT
|
2004-05-26 14:11:05 +04:00
|
|
|
} SQLITE_DONE
|
|
|
|
|
2004-05-27 13:28:41 +04:00
|
|
|
do_test capi3-5.12 {
|
2004-05-26 14:11:05 +04:00
|
|
|
sqlite3_finalize $STMT
|
2004-05-27 05:49:51 +04:00
|
|
|
} SQLITE_OK
|
2004-05-26 14:11:05 +04:00
|
|
|
|
2006-04-07 17:50:37 +04:00
|
|
|
do_test capi3-5.20 {
|
|
|
|
set sql "SELECT a, sum(b), max(c) FROM t1 GROUP BY a"
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
sqlite3_column_count $STMT
|
|
|
|
} 3
|
|
|
|
|
|
|
|
check_header $STMT capi3-5.21 {a sum(b) max(c)} {VARINT {} {}}
|
|
|
|
check_origin_header $STMT capi3-5.22 {main {} {}} {t1 {} {}} {a {} {}}
|
|
|
|
do_test capi3-5.23 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} SQLITE_OK
|
|
|
|
|
2007-06-21 19:25:05 +04:00
|
|
|
do_test capi3-5.30 {
|
|
|
|
set sql "SELECT a AS x, sum(b) AS y, max(c) AS z FROM t1 AS m GROUP BY x"
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
sqlite3_column_count $STMT
|
|
|
|
} 3
|
|
|
|
|
|
|
|
check_header $STMT capi3-5.31 {x y z} {VARINT {} {}}
|
|
|
|
check_origin_header $STMT capi3-5.32 {main {} {}} {t1 {} {}} {a {} {}}
|
|
|
|
do_test capi3-5.33 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} SQLITE_OK
|
|
|
|
|
2006-04-07 17:50:37 +04:00
|
|
|
|
2004-06-30 06:35:51 +04:00
|
|
|
set ::ENC [execsql {pragma encoding}]
|
2004-05-21 14:08:53 +04:00
|
|
|
db close
|
|
|
|
|
2004-06-19 07:33:57 +04:00
|
|
|
do_test capi3-6.0 {
|
2006-01-03 03:33:50 +03:00
|
|
|
sqlite3 db test.db
|
|
|
|
set DB [sqlite3_connection_pointer db]
|
2010-06-22 17:46:43 +04:00
|
|
|
if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }
|
2004-06-19 07:33:57 +04:00
|
|
|
set sql {SELECT a FROM t1 order by rowid}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
expr 0
|
|
|
|
} {0}
|
|
|
|
do_test capi3-6.1 {
|
2006-01-10 02:40:25 +03:00
|
|
|
db cache flush
|
2004-06-19 07:33:57 +04:00
|
|
|
sqlite3_close $DB
|
|
|
|
} {SQLITE_BUSY}
|
|
|
|
do_test capi3-6.2 {
|
|
|
|
sqlite3_step $STMT
|
2011-03-19 00:55:46 +03:00
|
|
|
} {SQLITE_ERROR}
|
|
|
|
#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
|
2004-06-19 07:33:57 +04:00
|
|
|
do_test capi3-6.3 {
|
|
|
|
sqlite3_finalize $STMT
|
2011-03-19 00:55:46 +03:00
|
|
|
} {SQLITE_SCHEMA}
|
2007-01-04 02:37:28 +03:00
|
|
|
do_test capi3-6.4-misuse {
|
2006-01-10 02:40:25 +03:00
|
|
|
db cache flush
|
2004-06-19 07:33:57 +04:00
|
|
|
sqlite3_close $DB
|
|
|
|
} {SQLITE_OK}
|
2006-01-03 03:33:50 +03:00
|
|
|
db close
|
2004-06-19 07:33:57 +04:00
|
|
|
|
2008-03-19 03:21:30 +03:00
|
|
|
# This procedure sets the value of the file-format in file 'test.db'
|
|
|
|
# to $newval. Also, the schema cookie is incremented.
|
|
|
|
#
|
|
|
|
proc set_file_format {newval} {
|
|
|
|
hexio_write test.db 44 [hexio_render_int32 $newval]
|
|
|
|
set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
|
|
|
|
incr schemacookie
|
|
|
|
hexio_write test.db 40 [hexio_render_int32 $schemacookie]
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
|
|
|
# This procedure returns the value of the file-format in file 'test.db'.
|
|
|
|
#
|
|
|
|
proc get_file_format {{fname test.db}} {
|
|
|
|
return [hexio_get_int [hexio_read $fname 44 4]]
|
|
|
|
}
|
|
|
|
|
2004-07-22 19:02:25 +04:00
|
|
|
if {![sqlite3 -has-codec]} {
|
|
|
|
# Test what happens when the library encounters a newer file format.
|
|
|
|
do_test capi3-7.1 {
|
2008-03-19 03:21:30 +03:00
|
|
|
set_file_format 5
|
2004-07-22 19:02:25 +04:00
|
|
|
} {}
|
|
|
|
do_test capi3-7.2 {
|
2010-07-08 13:44:42 +04:00
|
|
|
catch { sqlite3 db test.db }
|
2004-07-22 19:02:25 +04:00
|
|
|
catchsql {
|
|
|
|
SELECT * FROM sqlite_master;
|
|
|
|
}
|
|
|
|
} {1 {unsupported file format}}
|
2004-06-29 17:18:23 +04:00
|
|
|
db close
|
2004-07-22 19:02:25 +04:00
|
|
|
}
|
2004-06-29 17:18:23 +04:00
|
|
|
|
2004-07-22 19:02:25 +04:00
|
|
|
if {![sqlite3 -has-codec]} {
|
|
|
|
# Now test that the library correctly handles bogus entries in the
|
|
|
|
# sqlite_master table (schema corruption).
|
|
|
|
do_test capi3-8.1 {
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test.db test.db-journal
|
2004-07-22 19:02:25 +04:00
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t1(a);
|
|
|
|
}
|
|
|
|
db close
|
|
|
|
} {}
|
|
|
|
do_test capi3-8.2 {
|
2008-03-19 03:21:30 +03:00
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
PRAGMA writable_schema=ON;
|
|
|
|
INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);
|
|
|
|
}
|
|
|
|
db close
|
2004-07-22 19:02:25 +04:00
|
|
|
} {}
|
|
|
|
do_test capi3-8.3 {
|
2010-07-08 13:44:42 +04:00
|
|
|
catch { sqlite3 db test.db }
|
2004-07-22 19:02:25 +04:00
|
|
|
catchsql {
|
|
|
|
SELECT * FROM sqlite_master;
|
|
|
|
}
|
2008-03-19 16:03:33 +03:00
|
|
|
} {1 {malformed database schema (?)}}
|
2004-07-22 19:02:25 +04:00
|
|
|
do_test capi3-8.4 {
|
|
|
|
# Build a 5-field row record. The first field is a string 'table', and
|
2008-03-19 03:21:30 +03:00
|
|
|
# subsequent fields are all NULL.
|
|
|
|
db close
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test.db test.db-journal
|
2008-03-19 03:21:30 +03:00
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t1(a);
|
|
|
|
PRAGMA writable_schema=ON;
|
|
|
|
INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
|
2004-07-22 19:02:25 +04:00
|
|
|
}
|
2008-03-19 03:21:30 +03:00
|
|
|
db close
|
2004-09-02 18:57:08 +04:00
|
|
|
} {};
|
2004-07-22 19:02:25 +04:00
|
|
|
do_test capi3-8.5 {
|
2010-07-08 13:44:42 +04:00
|
|
|
catch { sqlite3 db test.db }
|
2004-07-22 19:02:25 +04:00
|
|
|
catchsql {
|
|
|
|
SELECT * FROM sqlite_master;
|
|
|
|
}
|
2008-03-19 16:03:33 +03:00
|
|
|
} {1 {malformed database schema (?)}}
|
2004-07-22 19:02:25 +04:00
|
|
|
db close
|
|
|
|
}
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test.db
|
|
|
|
forcedelete test.db-journal
|
2004-07-22 19:02:25 +04:00
|
|
|
|
2004-06-29 17:18:23 +04:00
|
|
|
|
|
|
|
# Test the english language string equivalents for sqlite error codes
|
|
|
|
set code2english [list \
|
|
|
|
SQLITE_OK {not an error} \
|
|
|
|
SQLITE_ERROR {SQL logic error or missing database} \
|
|
|
|
SQLITE_PERM {access permission denied} \
|
|
|
|
SQLITE_ABORT {callback requested query abort} \
|
|
|
|
SQLITE_BUSY {database is locked} \
|
|
|
|
SQLITE_LOCKED {database table is locked} \
|
|
|
|
SQLITE_NOMEM {out of memory} \
|
|
|
|
SQLITE_READONLY {attempt to write a readonly database} \
|
|
|
|
SQLITE_INTERRUPT {interrupted} \
|
|
|
|
SQLITE_IOERR {disk I/O error} \
|
|
|
|
SQLITE_CORRUPT {database disk image is malformed} \
|
2005-08-11 06:10:18 +04:00
|
|
|
SQLITE_FULL {database or disk is full} \
|
2004-06-29 17:18:23 +04:00
|
|
|
SQLITE_CANTOPEN {unable to open database file} \
|
|
|
|
SQLITE_EMPTY {table contains no data} \
|
|
|
|
SQLITE_SCHEMA {database schema has changed} \
|
|
|
|
SQLITE_CONSTRAINT {constraint failed} \
|
|
|
|
SQLITE_MISMATCH {datatype mismatch} \
|
|
|
|
SQLITE_MISUSE {library routine called out of sequence} \
|
2008-05-05 20:56:34 +04:00
|
|
|
SQLITE_NOLFS {large file support is disabled} \
|
2004-06-29 17:18:23 +04:00
|
|
|
SQLITE_AUTH {authorization denied} \
|
|
|
|
SQLITE_FORMAT {auxiliary database format error} \
|
2004-11-20 23:18:55 +03:00
|
|
|
SQLITE_RANGE {bind or column index out of range} \
|
2004-06-29 17:18:23 +04:00
|
|
|
SQLITE_NOTADB {file is encrypted or is not a database} \
|
|
|
|
unknownerror {unknown error} \
|
|
|
|
]
|
|
|
|
|
|
|
|
set test_number 1
|
|
|
|
foreach {code english} $code2english {
|
|
|
|
do_test capi3-9.$test_number "sqlite3_test_errstr $code" $english
|
|
|
|
incr test_number
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test the error message when a "real" out of memory occurs.
|
2007-08-29 23:15:08 +04:00
|
|
|
ifcapable memdebug {
|
2007-08-25 17:37:48 +04:00
|
|
|
do_test capi3-10-1 {
|
|
|
|
sqlite3 db test.db
|
|
|
|
set DB [sqlite3_connection_pointer db]
|
2007-08-29 23:15:08 +04:00
|
|
|
sqlite3_memdebug_fail 1
|
2007-08-25 17:37:48 +04:00
|
|
|
catchsql {
|
|
|
|
select * from sqlite_master;
|
|
|
|
}
|
|
|
|
} {1 {out of memory}}
|
|
|
|
do_test capi3-10-2 {
|
|
|
|
sqlite3_errmsg $::DB
|
2004-11-14 07:04:17 +03:00
|
|
|
} {out of memory}
|
2007-08-25 17:37:48 +04:00
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test capi3-10-3 {
|
|
|
|
utf8 [sqlite3_errmsg16 $::DB]
|
|
|
|
} {out of memory}
|
|
|
|
}
|
|
|
|
db close
|
2007-08-29 16:31:25 +04:00
|
|
|
sqlite3_memdebug_fail -1
|
2008-06-23 21:56:47 +04:00
|
|
|
do_test capi3-10-4 {
|
|
|
|
sqlite3 db test.db
|
|
|
|
set DB [sqlite3_connection_pointer db]
|
|
|
|
sqlite3_memdebug_fail 1
|
|
|
|
catchsql {
|
|
|
|
select * from sqlite_master where rowid>5;
|
|
|
|
}
|
|
|
|
} {1 {out of memory}}
|
|
|
|
do_test capi3-10-5 {
|
|
|
|
sqlite3_errmsg $::DB
|
|
|
|
} {out of memory}
|
|
|
|
ifcapable {utf16} {
|
|
|
|
do_test capi3-10-6 {
|
|
|
|
utf8 [sqlite3_errmsg16 $::DB]
|
|
|
|
} {out of memory}
|
|
|
|
}
|
|
|
|
db close
|
|
|
|
sqlite3_memdebug_fail -1
|
2004-06-29 18:03:58 +04:00
|
|
|
}
|
2004-06-29 17:18:23 +04:00
|
|
|
|
2004-06-30 10:30:25 +04:00
|
|
|
# The following tests - capi3-11.* - test that a COMMIT or ROLLBACK
|
|
|
|
# statement issued while there are still outstanding VMs that are part of
|
|
|
|
# the transaction fails.
|
2006-01-03 03:33:50 +03:00
|
|
|
sqlite3 db test.db
|
|
|
|
set DB [sqlite3_connection_pointer db]
|
2004-06-30 10:30:25 +04:00
|
|
|
sqlite_register_test_function $DB func
|
|
|
|
do_test capi3-11.1 {
|
|
|
|
execsql {
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE t1(a, b);
|
|
|
|
INSERT INTO t1 VALUES(1, 'int');
|
|
|
|
INSERT INTO t1 VALUES(2, 'notatype');
|
|
|
|
}
|
|
|
|
} {}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.1.1 {
|
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 0
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.2 {
|
|
|
|
set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
2008-11-05 19:37:34 +03:00
|
|
|
|
|
|
|
# As of 3.6.5 a COMMIT is OK during while a query is still running -
|
|
|
|
# as long as it is a read-only query and not an incremental BLOB write.
|
|
|
|
#
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-11.3.1 {
|
2004-06-30 10:30:25 +04:00
|
|
|
catchsql {
|
|
|
|
COMMIT;
|
|
|
|
}
|
2008-11-05 19:37:34 +03:00
|
|
|
} {0 {}}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-11.3.2 {
|
|
|
|
sqlite3_extended_errcode $DB
|
2008-11-05 19:37:34 +03:00
|
|
|
} {SQLITE_OK}
|
2008-10-30 18:03:15 +03:00
|
|
|
do_test capi3-11.3.3 {
|
2005-05-26 20:23:34 +04:00
|
|
|
sqlite3_get_autocommit $DB
|
2008-11-05 19:37:34 +03:00
|
|
|
} 1
|
|
|
|
do_test capi3-11.3.4 {
|
|
|
|
db eval {PRAGMA lock_status}
|
|
|
|
} {main shared temp closed}
|
|
|
|
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.4 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ERROR}
|
|
|
|
do_test capi3-11.5 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_ERROR}
|
|
|
|
do_test capi3-11.6 {
|
|
|
|
catchsql {
|
|
|
|
SELECT * FROM t1;
|
|
|
|
}
|
|
|
|
} {0 {1 int 2 notatype}}
|
|
|
|
do_test capi3-11.7 {
|
2005-05-26 20:23:34 +04:00
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 1
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.8 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t2(a);
|
|
|
|
INSERT INTO t2 VALUES(1);
|
|
|
|
INSERT INTO t2 VALUES(2);
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 VALUES(3);
|
|
|
|
}
|
|
|
|
} {}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.8.1 {
|
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 0
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.9 {
|
|
|
|
set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.9.1 {
|
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 0
|
|
|
|
do_test capi3-11.9.2 {
|
2004-06-30 10:30:25 +04:00
|
|
|
catchsql {
|
|
|
|
ROLLBACK;
|
|
|
|
}
|
2012-02-13 20:43:16 +04:00
|
|
|
} {0 {}}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.9.3 {
|
|
|
|
sqlite3_get_autocommit $DB
|
2012-02-13 20:43:16 +04:00
|
|
|
} 1
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.10 {
|
|
|
|
sqlite3_step $STMT
|
2012-02-13 20:43:16 +04:00
|
|
|
} {SQLITE_ERROR}
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.11 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
|
|
|
do_test capi3-11.12 {
|
|
|
|
sqlite3_step $STMT
|
2012-02-13 20:43:16 +04:00
|
|
|
sqlite3_step $STMT
|
2004-06-30 10:30:25 +04:00
|
|
|
} {SQLITE_DONE}
|
|
|
|
do_test capi3-11.13 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_OK}
|
|
|
|
do_test capi3-11.14 {
|
|
|
|
execsql {
|
|
|
|
SELECT a FROM t2;
|
|
|
|
}
|
2012-02-13 20:43:16 +04:00
|
|
|
} {1 2}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.14.1 {
|
|
|
|
sqlite3_get_autocommit $DB
|
2012-02-13 20:43:16 +04:00
|
|
|
} 1
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.15 {
|
|
|
|
catchsql {
|
|
|
|
ROLLBACK;
|
|
|
|
}
|
2012-02-13 20:43:16 +04:00
|
|
|
} {1 {cannot rollback - no transaction is active}}
|
2005-05-26 20:23:34 +04:00
|
|
|
do_test capi3-11.15.1 {
|
|
|
|
sqlite3_get_autocommit $DB
|
|
|
|
} 1
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.16 {
|
|
|
|
execsql {
|
|
|
|
SELECT a FROM t2;
|
|
|
|
}
|
|
|
|
} {1 2}
|
|
|
|
|
|
|
|
# Sanity check on the definition of 'outstanding VM'. This means any VM
|
|
|
|
# that has had sqlite3_step() called more recently than sqlite3_finalize() or
|
|
|
|
# sqlite3_reset(). So a VM that has just been prepared or reset does not
|
|
|
|
# count as an active VM.
|
|
|
|
do_test capi3-11.17 {
|
|
|
|
execsql {
|
|
|
|
BEGIN;
|
|
|
|
}
|
|
|
|
} {}
|
|
|
|
do_test capi3-11.18 {
|
|
|
|
set STMT [sqlite3_prepare $DB "SELECT a FROM t1" -1 TAIL]
|
|
|
|
catchsql {
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
} {0 {}}
|
|
|
|
do_test capi3-11.19 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
|
|
|
do_test capi3-11.20 {
|
|
|
|
catchsql {
|
|
|
|
BEGIN;
|
|
|
|
COMMIT;
|
|
|
|
}
|
2008-11-05 19:37:34 +03:00
|
|
|
} {0 {}}
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.20 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
catchsql {
|
|
|
|
COMMIT;
|
|
|
|
}
|
2008-11-05 19:37:34 +03:00
|
|
|
} {1 {cannot commit - no transaction is active}}
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-11.21 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_OK}
|
2004-06-29 17:18:23 +04:00
|
|
|
|
2007-12-14 00:54:09 +03:00
|
|
|
# The following tests - capi3-12.* - check that its Ok to start a
|
|
|
|
# transaction while other VMs are active, and that its Ok to execute
|
2006-08-16 20:42:48 +04:00
|
|
|
# atomic updates in the same situation
|
|
|
|
#
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-12.1 {
|
|
|
|
set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
|
|
|
do_test capi3-12.2 {
|
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 VALUES(3, NULL);
|
|
|
|
}
|
|
|
|
} {0 {}}
|
|
|
|
do_test capi3-12.3 {
|
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 VALUES(4);
|
|
|
|
}
|
2006-08-16 20:42:48 +04:00
|
|
|
} {0 {}}
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-12.4 {
|
|
|
|
catchsql {
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES(4, NULL);
|
|
|
|
}
|
|
|
|
} {0 {}}
|
|
|
|
do_test capi3-12.5 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
2006-08-16 20:42:48 +04:00
|
|
|
do_test capi3-12.5.1 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ROW}
|
2004-06-30 10:30:25 +04:00
|
|
|
do_test capi3-12.6 {
|
|
|
|
sqlite3_step $STMT
|
2004-11-16 18:50:19 +03:00
|
|
|
} {SQLITE_DONE}
|
2004-11-22 13:02:21 +03:00
|
|
|
do_test capi3-12.7 {
|
2004-06-30 10:30:25 +04:00
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_OK}
|
2004-11-22 13:02:21 +03:00
|
|
|
do_test capi3-12.8 {
|
2004-06-30 10:30:25 +04:00
|
|
|
execsql {
|
|
|
|
COMMIT;
|
|
|
|
SELECT a FROM t1;
|
|
|
|
}
|
|
|
|
} {1 2 3 4}
|
2004-06-29 17:18:23 +04:00
|
|
|
|
2005-01-20 04:14:23 +03:00
|
|
|
# Test cases capi3-13.* test the sqlite3_clear_bindings() and
|
|
|
|
# sqlite3_sleep APIs.
|
|
|
|
#
|
|
|
|
if {[llength [info commands sqlite3_clear_bindings]]>0} {
|
|
|
|
do_test capi3-13.1 {
|
|
|
|
execsql {
|
|
|
|
DELETE FROM t1;
|
|
|
|
}
|
|
|
|
set STMT [sqlite3_prepare $DB "INSERT INTO t1 VALUES(?, ?)" -1 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_DONE}
|
|
|
|
do_test capi3-13.2 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
sqlite3_bind_text $STMT 1 hello 5
|
|
|
|
sqlite3_bind_text $STMT 2 world 5
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_DONE}
|
|
|
|
do_test capi3-13.3 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
sqlite3_clear_bindings $STMT
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_DONE}
|
|
|
|
do_test capi3-13-4 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
execsql {
|
|
|
|
SELECT * FROM t1;
|
|
|
|
}
|
|
|
|
} {{} {} hello world {} {}}
|
|
|
|
}
|
|
|
|
if {[llength [info commands sqlite3_sleep]]>0} {
|
|
|
|
do_test capi3-13-5 {
|
|
|
|
set ms [sqlite3_sleep 80]
|
|
|
|
expr {$ms==80 || $ms==1000}
|
|
|
|
} {1}
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:54:55 +04:00
|
|
|
# Ticket #1219: Make sure binding APIs can handle a NULL pointer.
|
|
|
|
#
|
2007-01-04 02:37:28 +03:00
|
|
|
do_test capi3-14.1-misuse {
|
2005-06-06 21:54:55 +04:00
|
|
|
set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
|
|
|
|
lappend rc $msg
|
|
|
|
} {1 SQLITE_MISUSE}
|
|
|
|
|
2006-01-31 01:35:43 +03:00
|
|
|
# Ticket #1650: Honor the nBytes parameter to sqlite3_prepare.
|
|
|
|
#
|
|
|
|
do_test capi3-15.1 {
|
|
|
|
set sql {SELECT * FROM t2}
|
|
|
|
set nbytes [string length $sql]
|
|
|
|
append sql { WHERE a==1}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql $nbytes TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
sqlite3_column_int $STMT 0
|
|
|
|
} {1}
|
|
|
|
do_test capi3-15.2 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
sqlite3_column_int $STMT 0
|
|
|
|
} {2}
|
|
|
|
do_test capi3-15.3 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_OK}
|
2007-10-23 22:55:48 +04:00
|
|
|
do_test capi3-15.4 {
|
|
|
|
# 123456789 1234567
|
|
|
|
set sql {SELECT 1234567890}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql 8 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
set v1 [sqlite3_column_int $STMT 0]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set v1
|
|
|
|
} {1}
|
|
|
|
do_test capi3-15.5 {
|
|
|
|
# 123456789 1234567
|
|
|
|
set sql {SELECT 1234567890}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql 9 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
set v1 [sqlite3_column_int $STMT 0]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set v1
|
|
|
|
} {12}
|
|
|
|
do_test capi3-15.6 {
|
|
|
|
# 123456789 1234567
|
|
|
|
set sql {SELECT 1234567890}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql 12 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
set v1 [sqlite3_column_int $STMT 0]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set v1
|
|
|
|
} {12345}
|
|
|
|
do_test capi3-15.7 {
|
|
|
|
# 123456789 1234567
|
|
|
|
set sql {SELECT 12.34567890}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql 12 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
set v1 [sqlite3_column_double $STMT 0]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set v1
|
|
|
|
} {12.34}
|
|
|
|
do_test capi3-15.8 {
|
|
|
|
# 123456789 1234567
|
|
|
|
set sql {SELECT 12.34567890}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql 14 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
set v1 [sqlite3_column_double $STMT 0]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
set v1
|
|
|
|
} {12.3456}
|
2005-06-06 21:54:55 +04:00
|
|
|
|
2006-02-18 19:36:45 +03:00
|
|
|
# Make sure code is always generated even if an IF EXISTS or
|
|
|
|
# IF NOT EXISTS clause is present that the table does not or
|
|
|
|
# does exists. That way we will always have a prepared statement
|
|
|
|
# to expire when the schema changes.
|
|
|
|
#
|
|
|
|
do_test capi3-16.1 {
|
|
|
|
set sql {DROP TABLE IF EXISTS t3}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
expr {$STMT!=""}
|
|
|
|
} {1}
|
|
|
|
do_test capi3-16.2 {
|
|
|
|
set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}
|
|
|
|
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
expr {$STMT!=""}
|
|
|
|
} {1}
|
|
|
|
|
|
|
|
# But still we do not generate code if there is no SQL
|
|
|
|
#
|
|
|
|
do_test capi3-16.3 {
|
|
|
|
set STMT [sqlite3_prepare $DB {} -1 TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
expr {$STMT==""}
|
|
|
|
} {1}
|
|
|
|
do_test capi3-16.4 {
|
|
|
|
set STMT [sqlite3_prepare $DB {;} -1 TAIL]
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
expr {$STMT==""}
|
|
|
|
} {1}
|
|
|
|
|
2007-06-19 14:58:24 +04:00
|
|
|
# Ticket #2426: Misuse of sqlite3_column_* by calling it after
|
|
|
|
# a sqlite3_reset should be harmless.
|
|
|
|
#
|
|
|
|
do_test capi3-17.1 {
|
|
|
|
set STMT [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
|
|
|
|
sqlite3_step $STMT
|
|
|
|
sqlite3_column_int $STMT 0
|
|
|
|
} {1}
|
|
|
|
do_test capi3-17.2 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
sqlite3_column_int $STMT 0
|
|
|
|
} {0}
|
|
|
|
do_test capi3-17.3 {
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
} {SQLITE_OK}
|
2006-02-18 19:36:45 +03:00
|
|
|
|
2008-01-22 04:48:05 +03:00
|
|
|
# Verify that sqlite3_step() fails with an SQLITE_SCHEMA error
|
|
|
|
# when the statement is prepared with sqlite3_prepare() (not
|
|
|
|
# sqlite3_prepare_v2()) and the schema has changed.
|
|
|
|
#
|
|
|
|
do_test capi3-18.1 {
|
|
|
|
set STMT [sqlite3_prepare db {SELECT * FROM t2} -1 TAIL]
|
|
|
|
sqlite3 db2 test.db
|
|
|
|
db2 eval {CREATE TABLE t3(x)}
|
|
|
|
db2 close
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ERROR}
|
|
|
|
do_test capi3-18.2 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
sqlite3_errcode db
|
|
|
|
} {SQLITE_SCHEMA}
|
|
|
|
do_test capi3-18.3 {
|
|
|
|
sqlite3_errmsg db
|
|
|
|
} {database schema has changed}
|
|
|
|
# The error persist on retry when sqlite3_prepare() has been used.
|
|
|
|
do_test capi3-18.4 {
|
|
|
|
sqlite3_step $STMT
|
|
|
|
} {SQLITE_ERROR}
|
|
|
|
do_test capi3-18.5 {
|
|
|
|
sqlite3_reset $STMT
|
|
|
|
sqlite3_errcode db
|
|
|
|
} {SQLITE_SCHEMA}
|
|
|
|
do_test capi3-18.6 {
|
|
|
|
sqlite3_errmsg db
|
|
|
|
} {database schema has changed}
|
|
|
|
sqlite3_finalize $STMT
|
|
|
|
|
2008-05-23 18:49:49 +04:00
|
|
|
# Ticket #3134. Prepare a statement with an nBytes parameter of 0.
|
|
|
|
# Make sure this works correctly and does not reference memory out of
|
|
|
|
# range.
|
|
|
|
#
|
|
|
|
do_test capi3-19.1 {
|
|
|
|
sqlite3_prepare_tkt3134 db
|
|
|
|
} {}
|
2008-01-22 04:48:05 +03:00
|
|
|
|
2008-07-07 17:31:58 +04:00
|
|
|
# Tests of the interface when no VFS is registered.
|
|
|
|
#
|
2008-07-12 19:55:54 +04:00
|
|
|
if {![info exists tester_do_binarylog]} {
|
|
|
|
db close
|
|
|
|
vfs_unregister_all
|
|
|
|
do_test capi3-20.1 {
|
|
|
|
sqlite3_sleep 100
|
|
|
|
} {0}
|
|
|
|
vfs_reregister_all
|
|
|
|
}
|
2008-07-07 17:31:58 +04:00
|
|
|
|
2004-06-30 10:30:25 +04:00
|
|
|
finish_test
|