diff --git a/manifest b/manifest index e3ecf03fc3..ad13ee4543 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correctly\s\sstore\slarge\sintegers.\s\sTicket\s#1212.\s(CVS\s2445) -D 2005-04-15T12:04:34 +C Remove\ssome\svestigal\scode.\s\sAdd\sthe\sexperimental\ssqlite3_transfer_bindings()\nAPI.\s(CVS\s2446) +D 2005-04-22T02:38:38 F Makefile.in 5c00d0037104de2a50ac7647a5f12769795957a3 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -34,9 +34,9 @@ F src/btree.c 25770f8cf1fe778757b69cbe0b84c02615c6e1f5 F src/btree.h 41a71ce027db9ddee72cb43df2316bbe3a1d92af F src/build.c 8afb06c791adcde7787f157bbc55aeef27fb27c1 F src/date.c 2134ef4388256e8247405178df8a61bd60dc180a -F src/delete.c bbdd1745a830e8b1b521481401f5ccc2aada5048 +F src/delete.c 75b53db21aa1879d3655bbbc208007db31d58a63 F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d -F src/expr.c bf7253cd2d828ec8bf321321c2598e4b8918d79b +F src/expr.c bef1589dbd9481b88f26d7908fc70bad9576e541 F src/func.c ff0673a25ec6216934e664bf9f480ae8b2c66936 F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 @@ -54,34 +54,34 @@ F src/os_win.c 2bbbe6fbb010763c3fa79d5e951afca9b138c6b5 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/pager.c 95e24c9134a00613ca87b963a84ad62d85d5b979 F src/pager.h 94bb42704ae861036a3bf3bbbe04dd3f0c6a690d -F src/parse.y 1770b8673c652756b2dd5bcec16f0bf741e5e879 +F src/parse.y 3e314b3a96b199b0501ed426f2cee3392ffce806 F src/pragma.c 845c8ab0ab7d09ed2115d3dfc859ba2364b365a7 F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 -F src/select.c a324af36afe5f050a1e070806ad3ededf1d58f50 +F src/select.c 277cf8893db3d822905097b31dfa209198a4febe F src/shell.c 25b3217d7c64e6497225439d261a253a23efff26 -F src/sqlite.h.in 1ece9aafba94b8515b276b3de73cbabe0912d42a -F src/sqliteInt.h 474c20597ee66bb3a666bed0abd76e7be579184a +F src/sqlite.h.in 3675e3ada207e09b9d52a0463561325df4ac26b5 +F src/sqliteInt.h a2d37daf004eb039b740b0e2f99406adb4037cac F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/tclsqlite.c 245b242edfb587e305954698ed93c1bc3daed678 -F src/test1.c 32a158ca4aca2e9b43d911eda4552253df9a207d +F src/test1.c adbf44d01e700895ad1e76cc90834d8dafd79152 F src/test2.c 7f0ef466706ac01414e1136b96e5d8a65cb97545 F src/test3.c 683e1e3819152ffd35da2f201e507228921148d0 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5 F src/tokenize.c 103cbaa932c790f540f8eceb63cd3010e117bdff F src/trigger.c 1a6d0c7c51b70bdc58d5068be72034071eff23ad -F src/update.c ddfd8afaecc6a700c6a5ec8de85b3433eb0e42d2 +F src/update.c 04ea9dd784ccfeaf38a681b3edfe3b1c4edfdda7 F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c F src/util.c 02bc2750336b021b3f10e61538f665c4b0033b5d F src/vacuum.c 5cf598003191bd91c17a64742bad8e46241698a8 F src/vdbe.c d2574042c44baf6b1016c61e8072dec529ac748a F src/vdbe.h 7f586cb6d6b57764e5aac1f87107d6a95ddce24c F src/vdbeInt.h 4afaae2f4adcab54ad2a40dabb2e689fba7b1561 -F src/vdbeapi.c 467caa6e6fb9247528b1c7ab9132ae1b4748e8ac +F src/vdbeapi.c 87f363c9c6a32a403d22dda6d594d3548775a0d5 F src/vdbeaux.c b4d9b9a9d87254a279a88e3f91d0db048071c856 F src/vdbemem.c 4e853ce3151eaf7906150da85a1b3ce1fe5e8da8 -F src/where.c c4b227458e8993decb515ed9a2fe2d4f5f8e3125 +F src/where.c 836906aeb19f2da270ce760ebebc4ac5aa924c8d F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42 F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3 F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6 @@ -99,6 +99,7 @@ F test/autovacuum_ioerr2.test 2f8a3fb31f833fd0ca86ad4ad98913c73e807572 F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 F test/bind.test bf1a99cb5471c8ec9958f7af0c8608d824535558 +F test/bindxfer.test 856830e9e5552b9882c9d5c6647f90e25bdae4ac F test/blob.test fc41fe95bdc10da51f0dee73ce86e75ce1d6eb9d F test/btree.test 8aa7424aeec844df990273fe36447e5d7e407261 F test/btree2.test dbce930b549d5ac883a7d8905c976209ea241db3 @@ -278,7 +279,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b -P 6cd19ddcba5fbea1be04b44699c911294618e948 -R a7a67bb0e6e2a718d4c8bea2017ab2d0 +P 00e20690bb8cc6522c9c48f36f0c3336ae007827 +R 6a430a8ca8d157615203d0413b70c426 U drh -Z cea3468783cfb264aa646a98028d300b +Z 51d7570a6b49b81dfa3ff13333279222 diff --git a/manifest.uuid b/manifest.uuid index b98c2ee228..5a0f9aa926 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00e20690bb8cc6522c9c48f36f0c3336ae007827 \ No newline at end of file +88b39436f00d645cdb6333a7413c698c42227d3f \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index b86fc0a2a1..308509e439 100644 --- a/src/delete.c +++ b/src/delete.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** in order to generate code for DELETE FROM statements. ** -** $Id: delete.c,v 1.103 2005/04/08 16:07:48 kwel Exp $ +** $Id: delete.c,v 1.104 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" @@ -230,7 +230,7 @@ void sqlite3DeleteFrom( /* Begin the database scan */ - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0); + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0); if( pWInfo==0 ) goto delete_from_cleanup; /* Remember the rowid of every item to be deleted. diff --git a/src/expr.c b/src/expr.c index 2971c02a9c..79c7b59e2a 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.197 2005/03/21 03:53:38 danielk1977 Exp $ +** $Id: expr.c,v 1.198 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" #include @@ -529,7 +529,6 @@ Select *sqlite3SelectDup(Select *p){ pNew->iLimit = -1; pNew->iOffset = -1; pNew->ppOpenTemp = 0; - pNew->pFetch = 0; pNew->isResolved = p->isResolved; pNew->isAgg = p->isAgg; return pNew; diff --git a/src/parse.y b/src/parse.y index e60fe1a43e..2b8d052d10 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.170 2005/03/29 03:10:59 danielk1977 Exp $ +** @(#) $Id: parse.y,v 1.171 2005/04/22 02:38:38 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -543,14 +543,14 @@ cmd ::= DELETE FROM fullname(X) where_opt(Y). {sqlite3DeleteFrom(pParse,X,Y);} where_opt(A) ::= . {A = 0;} where_opt(A) ::= WHERE expr(X). {A = X;} -%type setlist {ExprList*} -%destructor setlist {sqlite3ExprListDelete($$);} - ////////////////////////// The UPDATE command //////////////////////////////// // cmd ::= UPDATE orconf(R) fullname(X) SET setlist(Y) where_opt(Z). {sqlite3Update(pParse,X,Y,Z,R);} +%type setlist {ExprList*} +%destructor setlist {sqlite3ExprListDelete($$);} + setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y). {A = sqlite3ExprListAppend(Z,Y,&X);} setlist(A) ::= nm(X) EQ expr(Y). {A = sqlite3ExprListAppend(0,Y,&X);} diff --git a/src/select.c b/src/select.c index aa2d296e2e..ee15c72168 100644 --- a/src/select.c +++ b/src/select.c @@ -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.243 2005/03/28 03:39:56 drh Exp $ +** $Id: select.c,v 1.244 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" @@ -2760,7 +2760,7 @@ int sqlite3Select( /* Begin the database scan */ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, - pGroupBy ? 0 : &pOrderBy, p->pFetch); + pGroupBy ? 0 : &pOrderBy); if( pWInfo==0 ) goto select_end; /* Use the standard inner loop if we are not dealing with diff --git a/src/sqlite.h.in b/src/sqlite.h.in index fc4dfd6822..5e494e028c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.132 2005/03/31 22:26:20 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.133 2005/04/22 02:38:38 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -1208,6 +1208,17 @@ int sqlite3_sleep(int); */ int sqlite3_expired(sqlite3_stmt*); +/* +** Move all bindings from the first prepared statement over to the second. +** This routine is useful, for example, if the first prepared statement +** fails with an SQLITE_SCHEMA error. The same SQL can be prepared into +** the second prepared statement then all of the bindings transfered over +** to the second statement before the first statement is finalized. +** +******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** +*/ +int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); + /* ** If the following global variable is made to point to a ** string which is the name of a directory, then all temporary files diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 2cd0e95950..8a30b7f360 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.375 2005/03/29 03:10:59 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.376 2005/04/22 02:38:38 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -317,7 +317,6 @@ extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */ typedef struct Column Column; typedef struct Table Table; typedef struct Index Index; -typedef struct Instruction Instruction; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct Parse Parse; @@ -339,7 +338,6 @@ typedef struct KeyClass KeyClass; typedef struct CollSeq CollSeq; typedef struct KeyInfo KeyInfo; typedef struct NameContext NameContext; -typedef struct Fetch Fetch; /* ** Each database file to be accessed by the system is an instance @@ -1049,7 +1047,6 @@ struct Select { Expr *pOffset; /* OFFSET expression. NULL means not used. */ int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */ IdList **ppOpenTemp; /* OP_OpenTemp addresses used by multi-selects */ - Fetch *pFetch; /* If this stmt is part of a FETCH command */ u8 isResolved; /* True once sqlite3SelectResolve() has run. */ u8 isAgg; /* True if this is an aggregate query */ }; @@ -1419,7 +1416,7 @@ void sqlite3OpenTableForReading(Vdbe*, int iCur, Table*); void sqlite3OpenTable(Vdbe*, int iCur, Table*, int); void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); -WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, Fetch*); +WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**); void sqlite3WhereEnd(WhereInfo*); void sqlite3ExprCode(Parse*, Expr*); void sqlite3ExprCodeAndCache(Parse*, Expr*); diff --git a/src/test1.c b/src/test1.c index 2acfe7530f..0a774a9227 100644 --- a/src/test1.c +++ b/src/test1.c @@ -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.136 2005/03/29 03:11:00 danielk1977 Exp $ +** $Id: test1.c,v 1.137 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -971,6 +971,30 @@ static int test_expired( return TCL_OK; } +/* +** Usage: sqlite3_transfer_bindings FROMSTMT TOSTMT +** +** Transfer all bindings from FROMSTMT over to TOSTMT +*/ +static int test_transfer_bind( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt1, *pStmt2; + if( objc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " FROM-STMT TO-STMT", 0); + return TCL_ERROR; + } + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt1)) return TCL_ERROR; + if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt2)) return TCL_ERROR; + Tcl_SetObjResult(interp, + Tcl_NewIntObj(sqlite3_transfer_bindings(pStmt1,pStmt2))); + return TCL_OK; +} + /* ** Usage: sqlite3_changes DB ** @@ -2961,6 +2985,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_finalize", test_finalize ,0 }, { "sqlite3_reset", test_reset ,0 }, { "sqlite3_expired", test_expired ,0 }, + { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, diff --git a/src/update.c b/src/update.c index 489fe3ff30..b70f6393f4 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.106 2005/04/08 16:08:36 kwel Exp $ +** $Id: update.c,v 1.107 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" @@ -267,7 +267,7 @@ void sqlite3Update( /* Begin the database scan */ - pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0); + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0); if( pWInfo==0 ) goto update_cleanup; /* Remember the index of every item to be updated. diff --git a/src/vdbeapi.c b/src/vdbeapi.c index ca1612875a..247c1e0d0f 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -622,3 +622,26 @@ int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){ } return 0; } + +/* EXPERIMENTAL +** +** Transfer all bindings from the first statement over to the second. +** If the two statements contain a different number of bindings, then +** an SQLITE_ERROR is returned. +*/ +int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){ + Vdbe *pFrom = (Vdbe*)pFromStmt; + Vdbe *pTo = (Vdbe*)pToStmt; + int i, rc = SQLITE_OK; + if( (pFrom->magic!=VDBE_MAGIC_RUN && pFrom->magic!=VDBE_MAGIC_HALT) + || (pTo->magic!=VDBE_MAGIC_RUN && pTo->magic!=VDBE_MAGIC_HALT) ){ + return SQLITE_MISUSE; + } + if( pFrom->nVar!=pTo->nVar ){ + return SQLITE_ERROR; + } + for(i=0; rc==SQLITE_OK && inVar; i++){ + rc = sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]); + } + return rc; +} diff --git a/src/where.c b/src/where.c index 587d2c7f13..48ad161a7c 100644 --- a/src/where.c +++ b/src/where.c @@ -16,7 +16,7 @@ ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.136 2005/03/16 12:15:21 danielk1977 Exp $ +** $Id: where.c,v 1.137 2005/04/22 02:38:38 drh Exp $ */ #include "sqliteInt.h" @@ -599,8 +599,7 @@ WhereInfo *sqlite3WhereBegin( Parse *pParse, /* The parser context */ SrcList *pTabList, /* A list of all tables to be scanned */ Expr *pWhere, /* The WHERE clause */ - ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */ - Fetch *pFetch /* Initial location of cursors. NULL otherwise */ + ExprList **ppOrderBy /* An ORDER BY clause, or NULL */ ){ int i; /* Loop counter */ WhereInfo *pWInfo; /* Will become the return value of this function */ diff --git a/test/bindxfer.test b/test/bindxfer.test new file mode 100644 index 0000000000..0d0bea0de0 --- /dev/null +++ b/test/bindxfer.test @@ -0,0 +1,74 @@ +# 2005 April 21 +# +# 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 sqlite_transfer_bindings() API. +# +# $Id: bindxfer.test,v 1.1 2005/04/22 02:38:39 drh Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +proc sqlite_step {stmt VALS COLS} { + upvar #0 $VALS vals + upvar #0 $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_text $stmt $i] + } + + return $rc +} + +do_test bindxfer-1.1 { + db close + set DB [sqlite3 db test.db] + execsql {CREATE TABLE t1(a,b,c);} + set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL] + set TAIL +} {} +do_test bindxfer-1.2 { + sqlite3_bind_parameter_count $VM1 +} 3 +do_test bindxfer-1.3 { + set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL] + set TAIL +} {} +do_test bindxfer-1.4 { + sqlite3_bind_parameter_count $VM2 +} 3 +do_test bindxfer-1.5 { + sqlite_bind $VM1 1 one normal + set sqlite_static_bind_value two + sqlite_bind $VM1 2 {} static + sqlite_bind $VM1 3 {} null + sqlite3_transfer_bindings $VM1 $VM2 + sqlite_step $VM1 VALUES COLNAMES +} SQLITE_ROW +do_test bindxfer-1.6 { + set VALUES +} {{} {} {}} +do_test bindxfer-1.7 { + sqlite_step $VM2 VALUES COLNAMES +} SQLITE_ROW +do_test bindxfer-1.8 { + set VALUES +} {one two {}} +catch {sqlite3_finalize $VM1} +catch {sqlite3_finalize $VM2} + +finish_test