]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Negative N values in sqlite3_get_auxdata() and sqlite3_set_auxdata() can be
authordrh <drh@noemail.net>
Thu, 11 May 2017 15:20:18 +0000 (15:20 +0000)
committerdrh <drh@noemail.net>
Thu, 11 May 2017 15:20:18 +0000 (15:20 +0000)
used to access an auxiliary data cache over all functions in a single prepared
statement.

FossilOrigin-Name: ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae

manifest
manifest.uuid
src/sqlite.h.in
src/vdbeapi.c
src/vdbeaux.c

index de491ca0b8ac925dd4bc25e7f4855f5cbc8136a7..1276b9e33445d6bb54b5d834b01e47b5ea43a6f5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C New\srequirements\smarks\sand\sdocumentation\sfor\sthe\sauthorizer.
-D 2017-05-11T13:43:57.931
+C Negative\sN\svalues\sin\ssqlite3_get_auxdata()\sand\ssqlite3_set_auxdata()\scan\sbe\nused\sto\saccess\san\sauxiliary\sdata\scache\sover\sall\sfunctions\sin\sa\ssingle\sprepared\s\nstatement.
+D 2017-05-11T15:20:18.112
 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6
@@ -404,7 +404,7 @@ F src/resolve.c 3e518b962d932a997fae373366880fc028c75706
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
 F src/select.c d74b1cde1d9ca6d08bec50b60a5be19440273646bc8ae16648d748c38161d5b7
 F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794
-F src/sqlite.h.in f70c07c37d5ad7fc2dbe6f6be57253ed77b7aecf9adfe01a8490e26f7bdd8d3f
+F src/sqlite.h.in 8dd468837a4f6d76713e3a4cc65bea48095009038593d41040ab46c1b351197f
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
 F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a5108b
@@ -472,8 +472,8 @@ F src/vacuum.c 1fe4555cd8c9b263afb85b5b4ee3a4a4181ad569
 F src/vdbe.c 9bac2bc2313ed682e6f48ccff6644d3263341885bfcbb3cdea7b720c722be2d5
 F src/vdbe.h f7d1456e28875c2dcb964056589b5b7149ab7edf39edeca801596a39bb3d3848
 F src/vdbeInt.h 1ecdacc1322fdd3241ec30c32a480e328a6f864e532dc53fae8e0ab68121aebf
-F src/vdbeapi.c 736dce6a84d67ff7d8ebc5667048c5938fb2e5b2c6eff4a770e177a3f2797cb0
-F src/vdbeaux.c 436a903111fcc184bae36f9016100da0d294da294d526bf4702328da1ddcde4b
+F src/vdbeapi.c dc904b3c5e459727993c2421e653e29d63223846d129fae98adc782b0a996481
+F src/vdbeaux.c 01dcf59b2a96bd3cc9db8c0d7f266518d113587459a2b3316279c4f9c90f28a9
 F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9
 F src/vdbemem.c 2c70f8f5de6c71fb99a22c5b83be9fab5c47cdd8e279fa44a8c00cfed06d7e89
 F src/vdbesort.c e72fe02a2121386ba767ede8942e9450878b8fc873abf3d1b6824485f092570c
@@ -1579,7 +1579,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2
-R 0c6451e367b2cefc9e69fa0621b4d931
+P 3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb
+R dd46ebd5214a15a152d68d903a52e3e5
+T *branch * auxdata-cache
+T *sym-auxdata-cache *
+T -sym-trunk *
 U drh
-Z 18c2f8082a296f2f15ab41c2498f7cb3
+Z 41e6a797cec545b1cb4bc140fa542902
index 4e27390c060afca32da75bc46c40b8659255bd40..5ff8b63dbfdc0cca90fea44fc26afe144e8d686f 100644 (file)
@@ -1 +1 @@
-3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb
\ No newline at end of file
+ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae
\ No newline at end of file
index eb108138b5ff05f2b427de649718f84e713cbd7f..d836e970589799e0b90c7c9a368c504c1d9b65ed 100644 (file)
@@ -4763,10 +4763,11 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 ** the compiled regular expression can be reused on multiple
 ** invocations of the same function.
 **
-** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
-** associated by the sqlite3_set_auxdata() function with the Nth argument
-** value to the application-defined function. ^If there is no metadata
-** associated with the function argument, this sqlite3_get_auxdata() interface
+** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
+** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
+** value to the application-defined function.  ^N is zero for the left-most
+** function argument.  ^If there is no metadata
+** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
 ** returns a NULL pointer.
 **
 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
@@ -4797,6 +4798,10 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 ** function parameters that are compile-time constants, including literal
 ** values and [parameters] and expressions composed from the same.)^
 **
+** The value of the N parameter to these interfaces should be non-negative.
+** Future enhancements may make use of negative N values to define new
+** kinds of function caching behavior.
+**
 ** These routines must be called from the same thread in which
 ** the SQL function is running.
 */
index 214710e8f3834dd5a16ff90765aeec8309dabc29..bdc5f0320d8f723360b8985699750b1fb8fc5f00 100644 (file)
@@ -804,6 +804,12 @@ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
 /*
 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
 ** the user-function defined by pCtx.
+**
+** The left-most argument is 0.
+**
+** Undocumented behavior:  If iArg is negative then access a cache of
+** auxiliary data pointers that is available to all functions within a
+** single prepared statement.  The iArg values must match.
 */
 void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
   AuxData *pAuxData;
@@ -815,7 +821,7 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
   assert( pCtx->pVdbe!=0 );
 #endif
   for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
-    if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ){
+    if(  pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
       return pAuxData->pAux;
     }
   }
@@ -826,6 +832,12 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
 ** Set the auxiliary data pointer and delete function, for the iArg'th
 ** argument to the user-function defined by pCtx. Any previous value is
 ** deleted by calling the delete function specified when it was set.
+**
+** The left-most argument is 0.
+**
+** Undocumented behavior:  If iArg is negative then make the data available
+** to all functions within the current prepared statement using iArg as an
+** access code.
 */
 void sqlite3_set_auxdata(
   sqlite3_context *pCtx, 
@@ -837,7 +849,6 @@ void sqlite3_set_auxdata(
   Vdbe *pVdbe = pCtx->pVdbe;
 
   assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
-  if( iArg<0 ) goto failed;
 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
   if( pVdbe==0 ) goto failed;
 #else
@@ -845,7 +856,9 @@ void sqlite3_set_auxdata(
 #endif
 
   for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
-    if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ) break;
+    if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
+      break;
+    }
   }
   if( pAuxData==0 ){
     pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
index 7d0e7678973fcbbb514bf4a79b789684effc9caf..c1b91a6d2ccd1f6b415b8acabdc18221dd81109b 100644 (file)
@@ -2968,7 +2968,8 @@ void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){
   while( *pp ){
     AuxData *pAux = *pp;
     if( (iOp<0)
-     || (pAux->iAuxOp==iOp 
+     || (pAux->iAuxOp==iOp
+          && pAux->iAuxArg>=0
           && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))
     ){
       testcase( pAux->iAuxArg==31 );