]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add new interfaces sqlite3_result_pointer(), and branch-3.8.6
authordrh <drh@noemail.net>
Fri, 21 Jul 2017 03:23:38 +0000 (03:23 +0000)
committerdrh <drh@noemail.net>
Fri, 21 Jul 2017 03:23:38 +0000 (03:23 +0000)
sqlite3_value_pointer() and use them to transfer the eponymous FTS3 column
pointer to the snippet() and offsets() routines.  This is a cherry-pick
of [f0f492245e95], which is in turn inspired by check-in [72de49f2].

FossilOrigin-Name: a66a5b397b1e1c456df40a5407c4a41d2f116d0dc5dd2e9c99b878d2026c566b

ext/fts3/fts3.c
manifest
manifest.uuid
src/sqlite.h.in
src/vdbeInt.h
src/vdbeapi.c

index 5f7db5067f335ef10081cdfcf154b141391c0fbe..89132ff3c07c679334583c8c66efe7ef4e45fa5d 100644 (file)
@@ -3244,7 +3244,7 @@ static int fts3ColumnMethod(
   }else if( iCol==p->nColumn ){
     /* The extra column whose name is the same as the table.
     ** Return a blob which is a pointer to the cursor.  */
-    sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
+    sqlite3_result_pointer(pCtx, pCsr);
   }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
     sqlite3_result_int64(pCtx, pCsr->iLangid);
   }else{
@@ -3436,16 +3436,13 @@ static int fts3FunctionArg(
   sqlite3_value *pVal,            /* argv[0] passed to function */
   Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */
 ){
-  Fts3Cursor *pRet;
-  if( sqlite3_value_type(pVal)!=SQLITE_BLOB 
-   || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
-  ){
+  Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal);
+  if( pRet==0 ){
     char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
     sqlite3_result_error(pContext, zErr, -1);
     sqlite3_free(zErr);
     return SQLITE_ERROR;
   }
-  memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
   *ppCsr = pRet;
   return SQLITE_OK;
 }
index fb3fd995c4bad2ce885af3ebdac5555e30c7ec44..fce3bfb44284589765d0aa457ce07ab39e6442cd 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Prevent\sa\svirtual\stable\sfrom\sbeing\sdestroyed\swhile\sit\sis\sin\suse.\sAlso:\sreplace\sVdbe.inVtabMethod\swith\ssqlite3.nVDestroy.\s\sSimplify\sthe\sEXPLAIN\soutput\sfor\sP4.pVtab\sto\sonly\sshow\sthe\ssqlite3_vtab\spointer.\sCherrypick\sof\s[cbeb9a1aed8c].
-D 2015-05-21T17:24:32.265
+C Add\snew\sinterfaces\ssqlite3_result_pointer(),\sand\nsqlite3_value_pointer()\sand\suse\sthem\sto\stransfer\sthe\seponymous\sFTS3\scolumn\npointer\sto\sthe\ssnippet()\sand\soffsets()\sroutines.\s\sThis\sis\sa\scherry-pick\nof\s[f0f492245e95],\swhich\sis\sin\sturn\sinspired\sby\scheck-in\s[72de49f2].
+D 2017-07-21T03:23:38.791
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
 F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c 47ca4807aff27d4a2416ccb52bbfb9c7ee6e861b
+F ext/fts3/fts3.c 48fed98ac40671850d8eb20528b0baa836c0c847c43999b32e14f3b0ea5f1015
 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
 F ext/fts3/fts3Int.h 53d4eca1fb23eab00681fb028fb82eb5705c1e21
 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365
@@ -224,7 +224,7 @@ F src/resolve.c 0ea356d32a5e884add23d1b9b4e8736681dd5697
 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be
 F src/select.c 5b44995dad6cddd69f40b46101d2ca91509eaaef
 F src/shell.c 75bb7bd2c80bb44861598f322a417c4bafe98fd7
-F src/sqlite.h.in 1609d8ba66bf9f60511f4b01a6624ba821339256
+F src/sqlite.h.in f62f9a483d43996629b869f3b2406d1aa3e1f80a02acdc4e186eba5ed617358a
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
 F src/sqliteInt.h 9ff3e1126716c36e6c68b3cf8b20f5d34a03127d
@@ -285,8 +285,8 @@ F src/util.c 3076bdd51cdbf60a6e2e57fada745be37133c73e
 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
 F src/vdbe.c 63f8f7b874fd6b6a1a86d63ca119220a2278a967
 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
-F src/vdbeInt.h 20e5edac63158bd340e31b8ca071f0868bf16442
-F src/vdbeapi.c 24e40422382beb774daab11fe9fe9d37e8a04949
+F src/vdbeInt.h 0d54df3825279764ac38715b2da3bb5c63846930369e1bbf913385f0319f869e
+F src/vdbeapi.c feda38a297ee8c96a267114088330f3085eb9e2fb259272324d2eeb67bab1b6f
 F src/vdbeaux.c 3021f190c41e2aacd835e2cae59221d827f5b162
 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac
 F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394
@@ -1187,8 +1187,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 31b13eb52894db75b52b6419bd9ec980b4c3ac43
-Q +cbeb9a1aed8ce3fb569a7717ad03c7c058b68de6
-R ef0792a2d780c2a5f59e3111e51497e1
-U dan
-Z 2e7e26283d4581d959f7c58268e40754
+P b3bb660af9472e2c511d1fe87b5193256f74c0db
+Q +f0f492245e957f5339c5aef02716321e45c18914b9a78387e4158f87fc2d83f9
+R 48e78475965e6318cb646ac2e8cfc445
+U drh
+Z 86d311a58c64bf497ba0f92bac5d92ca
index f80e0ef5b782a61843270d6131e038152bcf3eca..e6bc581269adc20e7cadb7f3c1c6535bc8747d99 100644 (file)
@@ -1 +1 @@
-b3bb660af9472e2c511d1fe87b5193256f74c0db
\ No newline at end of file
+a66a5b397b1e1c456df40a5407c4a41d2f116d0dc5dd2e9c99b878d2026c566b
\ No newline at end of file
index bf2299f62fc0ca8b2ec5aa497c3c225b940baacf..da568f9fc2fd91c4e78bf94b83d6d0988b425e64 100644 (file)
@@ -4190,6 +4190,7 @@ int sqlite3_value_bytes16(sqlite3_value*);
 double sqlite3_value_double(sqlite3_value*);
 int sqlite3_value_int(sqlite3_value*);
 sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
+void *sqlite3_value_pointer(sqlite3_value*);
 const unsigned char *sqlite3_value_text(sqlite3_value*);
 const void *sqlite3_value_text16(sqlite3_value*);
 const void *sqlite3_value_text16le(sqlite3_value*);
@@ -4458,6 +4459,7 @@ void sqlite3_result_error_code(sqlite3_context*, int);
 void sqlite3_result_int(sqlite3_context*, int);
 void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
 void sqlite3_result_null(sqlite3_context*);
+void sqlite3_result_pointer(sqlite3_context*, void*);
 void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
 void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
 void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
index 82df7c0737aaf0b726edae1f7275cc542921c23c..86d44e114bf235a57381d22c1a9a1b9769dcf283 100644 (file)
@@ -167,6 +167,7 @@ struct Mem {
   union {
     i64 i;              /* Integer value used when MEM_Int is set in flags */
     int nZero;          /* Used when bit MEM_Zero is set in flags */
+    void *pPtr;         /* Pointer when flags==MEM_Ptr|MEM_Null */
     FuncDef *pDef;      /* Used only when flags==MEM_Agg */
     RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */
     VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */
@@ -212,6 +213,7 @@ struct Mem {
 ** policy for Mem.z.  The MEM_Term flag tells us whether or not the
 ** string is \000 or \u0000 terminated
 */
+#define MEM_Ptr       0x8000   /* u.pPtr is valid if type==SQLITE_NULL */
 #define MEM_Term      0x0200   /* String rep is nul terminated */
 #define MEM_Dyn       0x0400   /* Need to call Mem.xDel() on Mem.z */
 #define MEM_Static    0x0800   /* Mem.z points to a static string */
@@ -227,7 +229,7 @@ struct Mem {
 ** Clear any existing type flags from a Mem and replace them with f
 */
 #define MemSetTypeFlag(p, f) \
-   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)
+   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero|MEM_Ptr))|f)
 
 /*
 ** Return true if a memory cell is not marked as invalid.  This macro
index 5e5bb813663ab776b6452651718de1eea025423a..ede572cddba6460d010b12971bfe3fa73079a30e 100644 (file)
@@ -156,6 +156,11 @@ int sqlite3_value_int(sqlite3_value *pVal){
 sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
   return sqlite3VdbeIntValue((Mem*)pVal);
 }
+void *sqlite3_value_pointer(sqlite3_value *pVal){
+  Mem *p = (Mem*)pVal;
+  if( (p->flags&(MEM_TypeMask|MEM_Ptr))==(MEM_Null|MEM_Ptr) ) return p->u.pPtr;
+  return 0;
+}
 const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
   return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
 }
@@ -263,6 +268,13 @@ void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
   assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
   sqlite3VdbeMemSetInt64(&pCtx->s, iVal);
 }
+void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
+  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
+  sqlite3VdbeMemSetNull(&pCtx->s);
+  assert( (pCtx->s.flags & (MEM_TypeMask|MEM_Ptr))==MEM_Null );
+  pCtx->s.flags |= MEM_Ptr;
+  pCtx->s.u.pPtr = pPtr;
+}
 void sqlite3_result_null(sqlite3_context *pCtx){
   assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
   sqlite3VdbeMemSetNull(&pCtx->s);