(1) Vdbe makes a copy of column types. (2) Don't invalidate other cursors

when a statement or transaction is rolled back. (3) Update capi2.test for
the new API. (CVS 1597)

FossilOrigin-Name: 4f5e2530829ef91753b083b5f2a1d7332e311cb6
This commit is contained in:
danielk1977 2004-06-15 02:44:18 +00:00
parent 0c6cc4ed19
commit fbcd585fe6
8 changed files with 330 additions and 136 deletions

View File

@ -1,5 +1,5 @@
C Update\scomments\sin\sbtree.c.\s\sNo\schanges\sto\scode.\s(CVS\s1596)
D 2004-06-15T02:13:27
C (1)\sVdbe\smakes\sa\scopy\sof\scolumn\stypes.\s(2)\sDon't\sinvalidate\sother\scursors\nwhen\sa\sstatement\sor\stransaction\sis\srolled\sback.\s(3)\sUpdate\scapi2.test\sfor\nthe\snew\sAPI.\s(CVS\s1597)
D 2004-06-15T02:44:19
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -26,7 +26,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8
F src/auth.c 204e1e9c45e64315589bc8b62cba5d9de29b6a3c
F src/btree.c 9e60ffbc24d92889d1e799cd16b15c9fbbfc5021
F src/btree.c 3c59f64c92d5e9e87ebbd1450329697202031d33
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
F src/build.c 916a84fa5f8bfd44dbe14c3d7c923dd07ee7373f
F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
@ -54,13 +54,13 @@ F src/parse.y 097438674976355a10cf177bd97326c548820b86
F src/pragma.c e288bd122d3ca41ec2032475abde1ff5fa3095f4
F src/printf.c 63b15f1ea9fe3daa066bb7430fd20d4a2d717dc8
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 164d1a68b3cc3c6a53ca9632a47ccbf9fde267b8
F src/select.c 7036757825668f28e446fea3fc97775f16667f35
F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469
F src/sqlite.h.in 36c253844656186ca53e1999efa6ef7b44f88779
F src/sqliteInt.h 924f0bcb493722c90cec7b19a240a37a4f01bbe7
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c 6f88be282a3617c6739c043fd13571b5f2fe9922
F src/test1.c e7588e3e55f7595c76874a4b9c6365e891ac69d1
F src/test1.c 49c69d360ce09f8ecf56ec5e55fba625703d8b21
F src/test2.c 05f810c90cf6262d5f352860e87d41a3f34207f9
F src/test3.c beafd0ccf7b9ae784744be1b1e66ffe8f64c25da
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
@ -93,7 +93,7 @@ F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293
F test/capi2.test 8fb64e8ab7f78b8254cd4d04bb96822167f731b2
F test/capi2.test b161d9d80899192d3e5e809cf3db98248b5bdc04
F test/capi3.test b6fe8a66d2ffe28d4faaaec154a143131e8ff631
F test/collate1.test 2ee4fa3a47a652ccf56c5ddf65dcc44d9bad82ef
F test/collate2.test c1a3b41f761b28853c5696037f92de928f93233b
@ -140,7 +140,7 @@ F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce
F test/pragma.test 1b6792d4af550ca4973096d77fc278dd6c32c4dd
F test/printf.test 31ac25b4f85fbc7fb507be34c6c0731adbefcf80
F test/progress.test 7542a6ac7894a1b7730c1f9a27f3f8b9388a4d25 x
F test/quick.test 2d13fadfeca9b14d92813883b77f26dc9955cf2c
F test/quick.test a519fa2a7bf0bd1b91fc642b83d765d0dc197a9f
F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d
F test/rowid.test 863e6e75878cccf03d166fe52023f20e09508683
F test/select1.test 2f161f9cdf9fb577336bc8c930edade538567123
@ -155,7 +155,7 @@ F test/table.test bbae9f267e947963f8951e72516667ab16c5810c
F test/tableapi.test 8651d6d1b043217aa851632b515ab68f185fb430
F test/tclsqlite.test 2ff5abfd1e133cddcfc61ad5850e3b93f4a7ff40
F test/temptable.test 3109726251fb4961010eb4d47e5c4df2af6b958d
F test/tester.tcl fc10520db0d3ce4ef6a8b5ab91bd102fc3f4280a
F test/tester.tcl a3f5b6de9fa92b13aad2d3cac972b77638ce6e26
F test/thread1.test fba29da98397c7f657008cf164b9212c1ad33f37
F test/threadtest1.c f5c7d628d5b23a1418816351b3cd8fe06e146250
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
@ -223,7 +223,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 5a814202777f381caf5337b37e11c9ab8b8f554a
R b05c49849b20b6bbd0391b8efa373046
U drh
Z ad351ed4b4238509d8c979104170ecf8
P 1c6a0706359c21e3b04e9097837a297d1d7714c3
R bc3395ed5c26800ea674afecaa20429f
U danielk1977
Z 85a63d429d1d5d2f9e9b5bd0015dc827

View File

@ -1 +1 @@
1c6a0706359c21e3b04e9097837a297d1d7714c3
4f5e2530829ef91753b083b5f2a1d7332e311cb6

View File

@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.168 2004/06/15 02:13:27 drh Exp $
** $Id: btree.c,v 1.169 2004/06/15 02:44:19 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@ -1283,6 +1283,23 @@ int sqlite3BtreeCommit(Btree *pBt){
return rc;
}
#ifndef NDEBUG
/*
** Return the number of write-cursors open on this handle. This is for use
** in assert() expressions, so it is only compiled if NDEBUG is not
** defined.
*/
static int countWriteCursors(Btree *pBt){
BtCursor *pCur;
int r = 0;
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
if( pCur->wrFlag ) r++;
}
return r;
}
#endif
#if 0
/*
** Invalidate all cursors
*/
@ -1299,6 +1316,7 @@ static void invalidateCursors(Btree *pBt){
}
}
}
#endif
#ifdef SQLITE_TEST
/*
@ -1338,7 +1356,7 @@ int sqlite3BtreeRollback(Btree *pBt){
if( getPage(pBt, 1, &pPage1)==SQLITE_OK ){
releasePage(pPage1);
}
invalidateCursors(pBt);
assert( countWriteCursors(pBt)==0 );
}
pBt->inTrans = TRANS_NONE;
pBt->inStmt = 0;
@ -1399,7 +1417,7 @@ int sqlite3BtreeRollbackStmt(Btree *pBt){
int rc;
if( pBt->inStmt==0 || pBt->readOnly ) return SQLITE_OK;
rc = sqlite3pager_stmt_rollback(pBt->pPager);
invalidateCursors(pBt);
assert( countWriteCursors(pBt)==0 );
pBt->inStmt = 0;
return rc;
}

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.189 2004/06/12 09:25:18 danielk1977 Exp $
** $Id: select.c,v 1.190 2004/06/15 02:44:19 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -644,6 +644,7 @@ static const char *columnType(Parse *pParse, SrcList *pTabList, Expr *pExpr){
zType = "INTEGER";
}else{
zType = pTab->aCol[iCol].zType;
if( !zType ) zType = "";
}
}else{
switch( sqlite3ExprType(pExpr) ){
@ -670,7 +671,10 @@ static void generateColumnTypes(
Expr *p = pEList->a[i].pExpr;
const char *zType = columnType(pParse, pTabList, p);
if( p==0 ) continue;
sqlite3VdbeSetColName(v, i+pEList->nExpr, zType, P3_STATIC);
/* The vdbe must make it's own copy of the column-type, in case the
** schema is reset before this virtual machine is deleted.
*/
sqlite3VdbeSetColName(v, i+pEList->nExpr, zType, strlen(zType));
}
}

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.76 2004/06/12 09:25:23 danielk1977 Exp $
** $Id: test1.c,v 1.77 2004/06/15 02:44:19 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@ -773,9 +773,6 @@ static int test_finalize(
rc = sqlite3_finalize(pStmt);
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
if( rc ){
return TCL_ERROR;
}
return TCL_OK;
}
@ -809,10 +806,27 @@ static int test_reset(
}
/*
** Usage: sqlite3_reset VM
** Usage: sqlite3_changes DB
**
** Reset a virtual machine and prepare it to be run again.
** Return the number of changes made to the database by the last SQL
** execution.
*/
static int test_changes(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
sqlite3 *db;
if( objc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetString(objv[0]), " DB", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_changes(db)));
return TCL_OK;
}
/*
** This is the "static_bind_value" that variables are bound to when
@ -1466,7 +1480,7 @@ static int test_step(
if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR;
/* if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; */
Tcl_SetResult(interp, (char *)errorName(rc), 0);
return TCL_OK;
}
@ -1953,7 +1967,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_prepare16", test_prepare16 ,0 },
{ "sqlite3_finalize", test_finalize ,0 },
{ "sqlite3_reset", test_reset ,0 },
{ "sqlite3_step", test_step,0 },
{ "sqlite3_changes", test_changes ,0 },
{ "sqlite3_step", test_step ,0 },
/* sqlite3_column_*() API */
{ "sqlite3_column_count", test_column_count ,0 },

View File

@ -11,12 +11,64 @@
# 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.12 2004/05/21 10:08:55 danielk1977 Exp $
# $Id: capi2.test,v 1.13 2004/06/15 02:44:20 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]
for {set i 0} {$i < [sqlite3_data_count $STMT]} {incr i} {
lappend VALUES [sqlite3_column_text $STMT $i]
}
return $VALUES
}
# Return the column names followed by declaration types for the result set
# of the SQL statement STMT.
#
# i.e. for:
# CREATE TABLE abc(a text, b integer);
# SELECT * FROM abc;
#
# The result is {a b text integer}
proc get_column_names {STMT} {
set VALUES [list]
for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
lappend VALUES [sqlite3_column_name $STMT $i]
}
for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {
lappend VALUES [sqlite3_column_decltype $STMT $i]
}
return $VALUES
}
# Check basic functionality
#
do_test capi2-1.1 {
@ -27,38 +79,41 @@ do_test capi2-1.1 {
set TAIL
} {}
do_test capi2-1.2 {
sqlite_step $VM N VALUES COLNAMES
sqlite3_step $VM
} {SQLITE_ROW}
do_test capi2-1.3 {
set N
sqlite3_data_count $VM
} {2}
do_test capi2-1.4 {
set VALUES
get_row_values $VM
} {t1 1}
do_test capi2-1.5 {
set COLNAMES
get_column_names $VM
} {name rowid text INTEGER}
do_test capi2-1.6 {
set N x
set VALUES y
set COLNAMES z
sqlite_step $VM N VALUES COLNAMES
sqlite3_step $VM
} {SQLITE_DONE}
do_test capi2-1.7 {
list $N $VALUES $COLNAMES
list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
} {2 {} {name rowid text INTEGER}}
do_test capi2-1.8 {
set N x
set VALUES y
set COLNAMES z
sqlite_step $VM N VALUES COLNAMES
sqlite3_step $VM
} {SQLITE_MISUSE}
# Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot
# be interrogated for more information. However in v3, since the column
# count, names and types are determined at compile time, these are still
# accessible after an SQLITE_MISUSE error.
do_test capi2-1.9 {
list $N $VALUES $COLNAMES
} {0 {} {}}
list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
} {2 {} {name rowid text INTEGER}}
do_test capi2-1.10 {
sqlite3_data_count $VM
} {0}
do_test capi2-1.11 {
sqlite3_finalize $VM
} {}
} {SQLITE_OK}
# Check to make sure that the "tail" of a multi-statement SQL script
# is returned by sqlite3_prepare.
@ -76,16 +131,20 @@ do_test capi2-2.1 {
-- A comment at the end
}
do_test capi2-2.2 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
set r [sqlite3_step $VM]
lappend r [sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
do_test capi2-2.3 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
set r [sqlite3_step $VM]
lappend r [sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
do_test capi2-2.4 {
sqlite3_finalize $VM
} {}
} {SQLITE_OK}
do_test capi2-2.5 {
set VM [sqlite3_prepare $DB $SQL -1 SQL]
set SQL
@ -93,12 +152,14 @@ do_test capi2-2.5 {
-- A comment at the end
}
do_test capi2-2.6 {
set r [sqlite_step $VM n val colname]
lappend r $n $val $colname
set r [sqlite3_step $VM]
lappend r [sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
do_test capi2-2.7 {
sqlite3_finalize $VM
} {}
} {SQLITE_OK}
do_test capi2-2.8 {
set VM [sqlite3_prepare $DB $SQL -1 SQL]
list $SQL $VM
@ -143,14 +204,14 @@ do_test capi2-3.6 {
lappend rc $TAIL
} {0 {}}
do_test capi2-3.7 {
set N {}
set VALUE {}
set COLNAME {}
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM] \
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_ROW 1 {{}} {5/0 NUMERIC}}
do_test capi2-3.8 {
sqlite3_finalize $VM
} {}
} {SQLITE_OK}
do_test capi2-3.9 {
execsql {CREATE UNIQUE INDEX i1 ON t1(a)}
set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,2,3)} -1 TAIL]
@ -158,44 +219,56 @@ do_test capi2-3.9 {
} {}
do_test capi2-3.9b {db changes} {0}
do_test capi2-3.10 {
set N {}
set VALUE {}
set COLNAME {}
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM] \
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_DONE 0 {} {}}
do_test capi2-3.10b {db changes} {1}
# Update for v3 - the change has not actually happened until the query is
# finalized. Is this going to cause trouble for anyone? Lee Nelson maybe?
do_test capi2-3.10b {sqlite3_changes $DB} {1}
do_test capi2-3.11 {
sqlite3_finalize $VM
} {}
do_test capi2-3.11b {db changes} {1}
} {SQLITE_OK}
do_test capi2-3.11b {sqlite3_changes $DB} {1}
do_test capi2-3.12 {
list [catch {sqlite3_finalize $VM} msg] [set msg]
} {1 {(21) library routine called out of sequence}}
sqlite3_finalize $VM
} {SQLITE_MISUSE}
do_test capi2-3.13 {
set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,3,4)} -1 TAIL]
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM] \
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_ERROR 0 {} {}}
do_test capi2-3.13b {db changes} {0}
do_test capi2-3.14 {
list [catch {sqlite3_finalize $VM} msg] [set msg]
} {1 {(19) column a is not unique}}
list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
} {SQLITE_CONSTRAINT {column a is not unique}}
do_test capi2-3.15 {
set VM [sqlite3_prepare $DB {CREATE TABLE t2(a NOT NULL, b)} -1 TAIL]
set TAIL
} {}
do_test capi2-3.16 {
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM] \
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_DONE 0 {} {}}
do_test capi2-3.17 {
list [catch {sqlite3_finalize $VM} msg] [set msg]
} {0 {}}
list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
} {SQLITE_OK {not an error}}
do_test capi2-3.18 {
set VM [sqlite3_prepare $DB {INSERT INTO t2 VALUES(NULL,2)} -1 TAIL]
list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM] \
[sqlite3_column_count $VM] \
[get_row_values $VM] \
[get_column_names $VM]
} {SQLITE_ERROR 0 {} {}}
do_test capi2-3.19 {
list [catch {sqlite3_finalize $VM} msg] [set msg]
} {1 {(19) t2.a may not be NULL}}
list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
} {SQLITE_CONSTRAINT {t2.a may not be NULL}}
# Two or more virtual machines exists at the same time.
#
@ -212,32 +285,41 @@ do_test capi2-4.3 {
set TAIL
} {}
do_test capi2-4.4 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM2] \
[sqlite3_column_count $VM2] \
[get_row_values $VM2] \
[get_column_names $VM2]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.5 {
execsql {SELECT * FROM t2 ORDER BY a}
} {2 3}
do_test capi2-4.6 {
list [catch {sqlite3_finalize $VM2} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM2
} {SQLITE_OK}
do_test capi2-4.7 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM3] \
[sqlite3_column_count $VM3] \
[get_row_values $VM3] \
[get_column_names $VM3]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.8 {
execsql {SELECT * FROM t2 ORDER BY a}
} {2 3 3 4}
do_test capi2-4.9 {
list [catch {sqlite3_finalize $VM3} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM3
} {SQLITE_OK}
do_test capi2-4.10 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_DONE 0 {} {}}
do_test capi2-4.11 {
execsql {SELECT * FROM t2 ORDER BY a}
} {1 2 2 3 3 4}
do_test capi2-4.12 {
list [catch {sqlite3_finalize $VM1} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM1
} {SQLITE_OK}
# Interleaved SELECTs
#
@ -245,44 +327,74 @@ do_test capi2-5.1 {
set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
set VM2 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
set VM3 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.2 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM2] \
[sqlite3_column_count $VM2] \
[get_row_values $VM2] \
[get_column_names $VM2]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.3 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.4 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM3] \
[sqlite3_column_count $VM3] \
[get_row_values $VM3] \
[get_column_names $VM3]
} {SQLITE_ROW 2 {2 3} {a b {} {}}}
do_test capi2-5.5 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM3] \
[sqlite3_column_count $VM3] \
[get_row_values $VM3] \
[get_column_names $VM3]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.6 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM3] \
[sqlite3_column_count $VM3] \
[get_row_values $VM3] \
[get_column_names $VM3]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.7 {
list [sqlite_step $VM3 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM3] \
[sqlite3_column_count $VM3] \
[get_row_values $VM3] \
[get_column_names $VM3]
} {SQLITE_DONE 2 {} {a b {} {}}}
do_test capi2-5.8 {
list [catch {sqlite3_finalize $VM3} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM3
} {SQLITE_OK}
do_test capi2-5.9 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.10 {
list [catch {sqlite3_finalize $VM1} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM1
} {SQLITE_OK}
do_test capi2-5.11 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM2] \
[sqlite3_column_count $VM2] \
[get_row_values $VM2] \
[get_column_names $VM2]
} {SQLITE_ROW 2 {3 4} {a b {} {}}}
do_test capi2-5.12 {
list [sqlite_step $VM2 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM2] \
[sqlite3_column_count $VM2] \
[get_row_values $VM2] \
[get_column_names $VM2]
} {SQLITE_ROW 2 {1 2} {a b {} {}}}
do_test capi2-5.11 {
list [catch {sqlite3_finalize $VM2} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM2
} {SQLITE_OK}
# Check for proper SQLITE_BUSY returns.
#
@ -301,76 +413,114 @@ do_test capi2-6.1 {
sqlite db2 test.db
execsql {BEGIN} db2
} {}
do_test capi2-6.2 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
} {SQLITE_BUSY 0 {} {}}
# Update for v3: BEGIN doesn't write-lock the database. It is quite
# difficult to get v3 to write-lock the database, which causes a few
# problems for test scripts.
#
# do_test capi2-6.2 {
# list [sqlite3_step $VM1] \
# [sqlite3_column_count $VM1] \
# [get_row_values $VM1] \
# [get_column_names $VM1]
# } {SQLITE_BUSY 0 {} {}}
do_test capi2-6.3 {
execsql {COMMIT} db2
} {}
do_test capi2-6.4 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 1 {x counter}}
do_test capi2-6.5 {
catchsql {BEGIN} db2
catchsql {INSERT INTO t3 VALUES(10);} db2
} {1 {database is locked}}
do_test capi2-6.6 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 2 {x counter}}
do_test capi2-6.7 {
execsql {SELECT * FROM t2} db2
} {2 3 3 4 1 2}
do_test capi2-6.8 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 3 {x counter}}
do_test capi2-6.9 {
execsql {SELECT * FROM t2}
} {2 3 3 4 1 2}
do_test capi2-6.10 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 4 {x counter}}
do_test capi2-6.11 {
execsql {BEGIN}
} {}
do_test capi2-6.12 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 5 {x counter}}
# execsql {pragma vdbe_trace=on}
do_test capi2-6.13 {
catchsql {UPDATE t3 SET x=x+1}
} {1 {database table is locked}}
do_test capi2-6.14 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 6 {x counter}}
# puts [list [catch {sqlite3_finalize $VM1} msg] [set msg]]; exit
do_test capi2-6.15 {
execsql {SELECT * FROM t1}
} {1 2 3}
do_test capi2-6.16 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 7 {x counter}}
do_test capi2-6.17 {
catchsql {UPDATE t1 SET b=b+1}
} {0 {}}
do_test capi2-6.18 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 8 {x counter}}
do_test capi2-6.19 {
execsql {SELECT * FROM t1}
} {1 3 3}
do_test capi2-6.20 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 9 {x counter}}
do_test capi2-6.21 {
execsql {ROLLBACK; SELECT * FROM t1}
} {1 2 3}
do_test capi2-6.22 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 10 {x counter}}
do_test capi2-6.23 {
execsql {BEGIN TRANSACTION ON CONFLICT ROLLBACK;}
execsql {BEGIN TRANSACTION;}
} {}
do_test capi2-6.24 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 11 {x counter}}
do_test capi2-6.25 {
execsql {
@ -379,7 +529,10 @@ do_test capi2-6.25 {
}
} {1 2 3 2 3 4}
do_test capi2-6.26 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 12 {x counter}}
do_test capi2-6.27 {
catchsql {
@ -388,11 +541,14 @@ do_test capi2-6.27 {
}
} {1 {column a is not unique}}
do_test capi2-6.28 {
list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
list [sqlite3_step $VM1] \
[sqlite3_column_count $VM1] \
[get_row_values $VM1] \
[get_column_names $VM1]
} {SQLITE_ROW 1 13 {x counter}}
do_test capi2-6.99 {
list [catch {sqlite3_finalize $VM1} msg] [set msg]
} {0 {}}
sqlite3_finalize $VM1
} {SQLITE_OK}
catchsql {ROLLBACK}
do_test capi2-7.1 {
@ -415,13 +571,13 @@ do_test capi2-7.4 {
INSERT INTO t1 SELECT a+1,b+1,c+1 FROM t1;
}
} {0 1}
do_test capi2-7.4b {db changes} {1}
do_test capi2-7.4b {sqlite3_changes $DB} {1}
do_test capi2-7.5 {
stepsql $DB {
UPDATE t1 SET a=a+10;
}
} {0 2}
do_test capi2-7.5b {db changes} {2}
do_test capi2-7.5b {sqlite3_changes $DB} {2}
do_test capi2-7.6 {
stepsql $DB {
SELECT * FROM t1;
@ -433,7 +589,7 @@ do_test capi2-7.7 {
}
} {0 2}
do_test capi2-7.8 {
db changes
sqlite3_changes $DB
} {2}
do_test capi2-7.9 {
stepsql $DB {
@ -447,7 +603,7 @@ do_test capi2-7.10 {
}
} {0 4 1 2 3 2 3 4 3 4 5 4 5 6}
do_test capi2-7.11 {
db changes
sqlite3_changes $DB
} {0}
do_test capi2-7.12 {
set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]
@ -459,16 +615,16 @@ do_test capi2-7.12 {
do_test capi2-8.1 {
set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]
sqlite3_finalize $VM1
} {}
} {SQLITE_OK}
# Tickets #384 and #385 - make sure the TAIL argument to sqlite3_prepare
# and all of the return pointers in sqlite_step can be null.
#
do_test capi2-9.1 {
set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 DUMMY]
sqlite_step $VM1
sqlite3_step $VM1
sqlite3_finalize $VM1
} {}
} {SQLITE_OK}
db2 close

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: quick.test,v 1.21 2004/06/14 23:46:48 danielk1977 Exp $
# $Id: quick.test,v 1.22 2004/06/15 02:44:20 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -32,10 +32,6 @@ lappend EXCLUDE ioerr.test ;# seg-faults (?)
lappend EXCLUDE memdb.test ;# fails - malformed database
lappend EXCLUDE version.test ;# This is obsolete.
# Some tests fail in these file as a result of the partial manifest types
# implementation.
lappend EXCLUDE capi2.test
if {[sqlite -has-codec]} {
lappend EXCLUDE \
attach.test \

View File

@ -11,7 +11,7 @@
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.35 2004/05/21 10:08:55 danielk1977 Exp $
# $Id: tester.tcl,v 1.36 2004/06/15 02:44:20 danielk1977 Exp $
# Make sure tclsqlite was compiled correctly. Abort now with an
# error message if not.
@ -202,8 +202,13 @@ proc stepsql {dbptr sql} {
return [list 1 $vm]
}
set sql [string trim $sqltail]
while {[sqlite_step $vm N VAL COL]=="SQLITE_ROW"} {
foreach v $VAL {lappend r $v}
# while {[sqlite_step $vm N VAL COL]=="SQLITE_ROW"} {
# foreach v $VAL {lappend r $v}
# }
while {[sqlite3_step $vm]=="SQLITE_ROW"} {
for {set i 0} {$i<[sqlite3_data_count $vm]} {incr i} {
lappend r [sqlite3_column_text $vm $i]
}
}
if {[catch {sqlite3_finalize $vm} errmsg]} {
return [list 1 $errmsg]