(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:
+21
-3
@@ -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;
|
||||
}
|
||||
|
||||
+6
-2
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-8
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user