diff --git a/manifest b/manifest index 2b00436646..85871908ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\smakefile\starget\s"fastfuzztest"\sruns\sthe\ssame\stests\sas\s"fuzztest"\sbut\nwith\sa\s100M\smemory\ssize\slimit.\s\sThis\smore\sthan\sdoubles\sthe\sspeed.\s\sThe\noriginal\sunlimited\s"fuzztest"\sis\sstill\srun\son\sa\s"fulltest". -D 2015-07-24T17:26:13.576 +C Add\sthe\ssqlite3_bind_zeroblob64()\sAPI. +D 2015-07-24T17:36:34.275 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4de3ef40c8b3b75c0c55ff4242a43c8ce1ad90ee F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -291,7 +291,7 @@ F src/insert.c b5f8b35a1b7924020e48cade5b2b5017bca7906b F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 92bafa308607dd985ca389a788cd9e0a2b608712 -F src/loadext.c 78ff69f010ba4db1cc7a2bfdd9cdcacd63ade888 +F src/loadext.c dfcee8c7c032cd0fd55af3e0fc1fcfb01e426df2 F src/main.c 0a60b7ca8252c3a6f95438fa4ce8fe5b275c69f2 F src/malloc.c 19461e159bccf0e2cf06a50e867963d0a7b124a8 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -329,15 +329,15 @@ F src/resolve.c 2d47554370de8de6dd5be060cef9559eec315005 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 57ef3d98c4400b93eea318813be41b2af2da2217 F src/shell.c 8af3cced094aebb5f57a8ad739b9dafc7867eed7 -F src/sqlite.h.in f589633da2c6b55bb9eef525eb8ab918693a95a2 +F src/sqlite.h.in f623dd30a4fb7df2fb44a2a85e27813d25e486c2 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad -F src/sqlite3ext.h 3d12a31e2346ce8c00c189bc5816d056d4f36c5f +F src/sqlite3ext.h a0b948ebc89bac13941254641326a6aa248c2cc4 F src/sqliteInt.h c67d0a1368484dd156e7d13caa62862adc2ebefa F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 -F src/test1.c 375d7bd56d9f806095deb91a3dafe61bd0e367c8 +F src/test1.c ab312f4160fdd9c82e65e8b123e35ef17e879c07 F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -393,7 +393,7 @@ F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c 86be40a4568f5385048ea6623adfd11ddb7bf710 F src/vdbe.h 7a75045d879118b9d3af7e8b3c108f2f27c51473 F src/vdbeInt.h 8b54e01ad0463590e7cffabce0bc36da9ee4f816 -F src/vdbeapi.c f91ac25af031b48c3b5c7e1ce667f07f88dfea5b +F src/vdbeapi.c adabbd66eb2e3a10f3998485ee0be7e326d06ee4 F src/vdbeaux.c 787f5f9d58f4c6f39294ed06909ba602d1a402e6 F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c ae38a0d35ae71cf604381a887c170466ba518090 @@ -1307,7 +1307,7 @@ F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 61256715b686359df48ca1742db50cc7e3e7b862 F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda -F test/zeroblob.test de0bf437a28a0b46f25bf735a0b83f74d46256ed +F test/zeroblob.test c54bc7a95df5fb2d463e00822e1377384954c161 F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/build-all-msvc.bat 9058bd90a3c078a3d8c17d40e853aaa0f47885f4 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 @@ -1365,7 +1365,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f8991e6f726485301c80d2dbb05e7d5c0d283b5d -R 5b7cdbc8a797f7286663b9eb72acbd15 -U drh -Z 4fdeea847ec9dd14145b4857e3d98a62 +P cfeb1b1c294c58222549d06819e9df2e300388fd +R be55ecd95e11079a1d74a40086198667 +U dan +Z 9412dcdb73ce7aff94945d2816a795b2 diff --git a/manifest.uuid b/manifest.uuid index a55fee3566..1811824ac8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cfeb1b1c294c58222549d06819e9df2e300388fd \ No newline at end of file +1997ee548b2e569a39e73319b661c1a78dfe5dae \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index b519c4054f..1d398c54ce 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -406,7 +406,8 @@ static const sqlite3_api_routines sqlite3Apis = { /* Version 3.8.11 and later */ (sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup, sqlite3_value_free, - sqlite3_result_zeroblob64 + sqlite3_result_zeroblob64, + sqlite3_bind_zeroblob64 }; /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 909d568692..4489c37ea4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3562,6 +3562,7 @@ int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, void(*)(void*), unsigned char encoding); int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); +int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); /* ** CAPI3REF: Number Of SQL Parameters diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 10fb40a2a8..48a5bf744b 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -271,6 +271,7 @@ struct sqlite3_api_routines { sqlite3_value *(*value_dup)(const sqlite3_value*); void (*value_free)(sqlite3_value*); int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64); + int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64); }; /* @@ -505,6 +506,7 @@ struct sqlite3_api_routines { #define sqlite3_value_dup sqlite3_api->value_dup #define sqlite3_value_free sqlite3_api->value_free #define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64 +#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64 #endif /* SQLITE_CORE */ #ifndef SQLITE_CORE diff --git a/src/test1.c b/src/test1.c index 15fd8c7f7d..ceccf10db8 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3008,6 +3008,43 @@ static int test_bind_zeroblob( return TCL_OK; } +/* +** Usage: sqlite3_bind_zeroblob64 STMT IDX N +** +** Test the sqlite3_bind_zeroblob64 interface. STMT is a prepared statement. +** IDX is the index of a wildcard in the prepared statement. This command +** binds a N-byte zero-filled BLOB to the wildcard. +*/ +static int test_bind_zeroblob64( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + int idx; + i64 n; + int rc; + + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "STMT IDX N"); + return TCL_ERROR; + } + + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; + if( Tcl_GetWideIntFromObj(interp, objv[3], &n) ) return TCL_ERROR; + + rc = sqlite3_bind_zeroblob64(pStmt, idx, n); + if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); + return TCL_ERROR; + } + + return TCL_OK; +} + /* ** Usage: sqlite3_bind_int STMT N VALUE ** @@ -6796,6 +6833,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, { "sqlite3_bind_int", test_bind_int, 0 }, { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, + { "sqlite3_bind_zeroblob64", test_bind_zeroblob64, 0 }, { "sqlite3_bind_int64", test_bind_int64, 0 }, { "sqlite3_bind_double", test_bind_double, 0 }, { "sqlite3_bind_null", test_bind_null ,0 }, diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 92d33486ba..ebd5ef29a2 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1415,6 +1415,20 @@ int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ } return rc; } +int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ + int rc; + Vdbe *p = (Vdbe *)pStmt; + sqlite3_mutex_enter(p->db->mutex); + if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ + rc = SQLITE_TOOBIG; + }else{ + assert( (n & 0x7FFFFFFF)==n ); + rc = sqlite3_bind_zeroblob(pStmt, i, n); + } + rc = sqlite3ApiExit(p->db, rc); + sqlite3_mutex_leave(p->db->mutex); + return rc; +} /* ** Return the number of wildcards that can be potentially bound to. diff --git a/test/zeroblob.test b/test/zeroblob.test index ff337ca48d..c45be2b09c 100644 --- a/test/zeroblob.test +++ b/test/zeroblob.test @@ -269,9 +269,9 @@ do_test zeroblob-10.1 { } {1 {string or blob too big}} #------------------------------------------------------------------------- -## Test the zeroblob() function on its own with negative or oversized -## arguments. -## +# Test the zeroblob() function on its own with negative or oversized +# arguments. +# do_execsql_test 11.0 { SELECT length(zeroblob(-1444444444444444)); } {0} @@ -288,5 +288,33 @@ do_catchsql_test 11.4 { SELECT quote(test_zeroblob(-1)); } {0 X''} +#------------------------------------------------------------------------- +# Test the sqlite3_bind_zeroblob64() API. +# +proc bind_and_run {stmt nZero} { + sqlite3_bind_zeroblob64 $stmt 1 $nZero + sqlite3_step $stmt + set ret [sqlite3_column_int $stmt 0] + sqlite3_reset $stmt + set ret +} +set stmt [sqlite3_prepare db "SELECT length(?)" -1 dummy] + +do_test 12.1 { bind_and_run $stmt 40 } 40 +do_test 12.2 { bind_and_run $stmt 0 } 0 +do_test 12.3 { bind_and_run $stmt 1000 } 1000 + +do_test 12.4 { + list [catch { bind_and_run $stmt [expr 1500 * 1024 * 1024] } msg] $msg +} {1 SQLITE_TOOBIG} +do_test 12.5 { + sqlite3_step $stmt + set ret [sqlite3_column_int $stmt 0] + sqlite3_reset $stmt + set ret +} {1000} + +sqlite3_finalize $stmt + test_restore_config_pagecache finish_test