Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -10,11 +10,11 @@ ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.77 2004/05/25 23:35:19 danielk1977 Exp $ +** @(#) $Id: sqlite.h.in,v 1.78 2004/05/26 00:07:25 danielk1977 Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ #include /* Needed for the definition of va_list */ @@ -583,58 +583,10 @@ const char **pzTail, /* OUT: uncompiled tail of zSql */ sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */ char **pzErrmsg /* OUT: Error message. */ ); -/* -** After an SQL statement has been compiled, it is handed to this routine -** to be executed. This routine executes the statement as far as it can -** go then returns. The return value will be one of SQLITE_DONE, -** SQLITE_ERROR, SQLITE_BUSY, SQLITE_ROW, or SQLITE_MISUSE. -** -** SQLITE_DONE means that the execute of the SQL statement is complete -** an no errors have occurred. sqlite3_step() should not be called again -** for the same virtual machine. *pN is set to the number of columns in -** the result set and *pazColName is set to an array of strings that -** describe the column names and datatypes. The name of the i-th column -** is (*pazColName)[i] and the datatype of the i-th column is -** (*pazColName)[i+*pN]. *pazValue is set to NULL. -** -** SQLITE_ERROR means that the virtual machine encountered a run-time -** error. sqlite3_step() should not be called again for the same -** virtual machine. *pN is set to 0 and *pazColName and *pazValue are set -** to NULL. Use sqlite3_finalize() to obtain the specific error code -** and the error message text for the error. -** -** SQLITE_BUSY means that an attempt to open the database failed because -** another thread or process is holding a lock. The calling routine -** can try again to open the database by calling sqlite3_step() again. -** The return code will only be SQLITE_BUSY if no busy handler is registered -** using the sqlite3_busy_handler() or sqlite3_busy_timeout() routines. If -** a busy handler callback has been registered but returns 0, then this -** routine will return SQLITE_ERROR and sqltie_finalize() will return -** SQLITE_BUSY when it is called. -** -** SQLITE_ROW means that a single row of the result is now available. -** The data is contained in *pazValue. The value of the i-th column is -** (*azValue)[i]. *pN and *pazColName are set as described in SQLITE_DONE. -** Invoke sqlite3_step() again to advance to the next row. -** -** SQLITE_MISUSE is returned if sqlite3_step() is called incorrectly. -** For example, if you call sqlite3_step() after the virtual machine -** has halted (after a prior call to sqlite3_step() has returned SQLITE_DONE) -** or if you call sqlite3_step() with an incorrectly initialized virtual -** machine or a virtual machine that has been deleted or that is associated -** with an sqlite structure that has been closed. -*/ -int sqlite3_step( - sqlite_vm *pVm, /* The virtual machine to execute */ - int *pN, /* OUT: Number of columns in result */ - const char ***pazValue, /* OUT: Column data */ - const char ***pazColName /* OUT: Column names and datatypes */ -); - /* ** This routine is called to delete a virtual machine after it has finished ** executing. The return value is the result code. SQLITE_OK is returned ** if the statement executed successfully and some other value is returned if ** there was any kind of error. If an error occurred and pzErrMsg is not @@ -1121,11 +1073,11 @@ ** Perhaps it was called on a virtual machine that had already been ** finalized or on one that had previously returned SQLITE_ERROR or ** SQLITE_DONE. Or it could be the case the the same database connection ** is being used simulataneously by two or more threads. */ -int sqlite3_step_new(sqlite3_stmt*); +int sqlite3_step(sqlite3_stmt*); /* ** The sqlite3_finalize() function is called to delete a compiled ** SQL statement obtained by a previous call to sqlite3_prepare() Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.52 2004/05/25 23:35:19 danielk1977 Exp $ +** $Id: test1.c,v 1.53 2004/05/26 00:07:26 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -756,72 +756,10 @@ return TCL_ERROR; } return TCL_OK; } -/* -** Usage: sqlite3_step VM ?NVAR? ?VALUEVAR? ?COLNAMEVAR? -** -** Step a virtual machine. Return a the result code as a string. -** Column results are written into three variables. -*/ -#if 0 -static int test_step( - void *NotUsed, - Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ - int argc, /* Number of arguments */ - char **argv /* Text of each argument */ -){ - sqlite_vm *vm; - int rc, i; - const char **azValue = 0; - const char **azColName = 0; - int N = 0; - char *zRc; - char zBuf[50]; - if( argc<2 || argc>5 ){ - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " VM NVAR VALUEVAR COLNAMEVAR", 0); - return TCL_ERROR; - } - if( getVmPointer(interp, argv[1], &vm) ) return TCL_ERROR; - rc = sqlite3_step(vm, argc>=3?&N:0, argc>=4?&azValue:0, argc==5?&azColName:0); - if( argc>=3 ){ - sprintf(zBuf, "%d", N); - Tcl_SetVar(interp, argv[2], zBuf, 0); - } - if( argc>=4 ){ - Tcl_SetVar(interp, argv[3], "", 0); - if( azValue ){ - for(i=0; i #include "vdbeInt.h" @@ -490,94 +490,15 @@ } /* pStack->flags |= MEM_Real; */ pStack->flags = MEM_Real; } -/* -** Advance the virtual machine to the next output row. -** -** The return vale will be either SQLITE_BUSY, SQLITE_DONE, -** SQLITE_ROW, SQLITE_ERROR, or SQLITE_MISUSE. -** -** SQLITE_BUSY means that the virtual machine attempted to open -** a locked database and there is no busy callback registered. -** Call sqlite3_step() again to retry the open. *pN is set to 0 -** and *pazColName and *pazValue are both set to NULL. -** -** SQLITE_DONE means that the virtual machine has finished -** executing. sqlite3_step() should not be called again on this -** virtual machine. *pN and *pazColName are set appropriately -** but *pazValue is set to NULL. -** -** SQLITE_ROW means that the virtual machine has generated another -** row of the result set. *pN is set to the number of columns in -** the row. *pazColName is set to the names of the columns followed -** by the column datatypes. *pazValue is set to the values of each -** column in the row. The value of the i-th column is (*pazValue)[i]. -** The name of the i-th column is (*pazColName)[i] and the datatype -** of the i-th column is (*pazColName)[i+*pN]. -** -** SQLITE_ERROR means that a run-time error (such as a constraint -** violation) has occurred. The details of the error will be returned -** by the next call to sqlite3_finalize(). sqlite3_step() should not -** be called again on the VM. -** -** SQLITE_MISUSE means that the this routine was called inappropriately. -** Perhaps it was called on a virtual machine that had already been -** finalized or on one that had previously returned SQLITE_ERROR or -** SQLITE_DONE. Or it could be the case the the same database connection -** is being used simulataneously by two or more threads. -*/ -#if 0 -int sqlite3_step( - sqlite_vm *pVm, /* The virtual machine to execute */ - int *pN, /* OUT: Number of columns in result */ - const char ***pazValue, /* OUT: Column data */ - const char ***pazColName /* OUT: Column names and datatypes */ -){ - sqlite3_stmt *pStmt = (sqlite3_stmt*)pVm; - int rc; - - rc = sqlite3_step_new(pStmt); - - if( pazValue ) *pazValue = 0; - if( pazColName ) *pazColName = 0; - if( pN ) *pN = 0; - - if( rc==SQLITE_DONE || rc==SQLITE_ROW ){ - int i; - int cols = sqlite3_column_count(pStmt) * (pazColName?1:0); - int vals = sqlite3_data_count(pStmt) * (pazValue?1:0); - - /* Temporary memory leak */ - if( cols ) *pazColName = sqliteMalloc(sizeof(char *)*cols * 2); - if( pN ) *pN = cols; - - for(i=0; imagic!=VDBE_MAGIC_RUN ){ Index: test/bind.test ================================================================== --- test/bind.test +++ test/bind.test @@ -9,15 +9,32 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # -# $Id: bind.test,v 1.7 2004/05/24 12:55:55 danielk1977 Exp $ +# $Id: bind.test,v 1.8 2004/05/26 00:07:25 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl + +proc sqlite_step {stmt N VALS COLS} { + upvar VALS vals + upvar COLS cols + set vals [list] + set cols [list] + + 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_data_count $stmt]} {incr i} { + lappend vals [sqlite3_column_data $stmt $i] + } + + return $rc +} do_test bind-1.1 { db close set DB [sqlite db test.db] execsql {CREATE TABLE t1(a,b,c)}