]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add new interfaces sqlite3_result_pointer(), and
authordrh <drh@noemail.net>
Fri, 21 Jul 2017 07:45:23 +0000 (07:45 +0000)
committerdrh <drh@noemail.net>
Fri, 21 Jul 2017 07:45:23 +0000 (07:45 +0000)
sqlite3_value_pointer() and use them to transfer the eponymous FTS3 column
pointer to the snippet() and offsets() routines.  This changes is a
cherry-pick of [f0f49224] with version-specific edits.  That check-in was
inspired by check-in [72de49f2].

FossilOrigin-Name: 69906880cee1f246cce494672402e0c7f29bd4ec19c437d26d603870d2bd625d

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

index 748faefec5a2fe91e2bb1d404b5282a00c9404f1..85d8cbc6d5000c06b5060c5b1b5a715d3b447a97 100644 (file)
@@ -3319,7 +3319,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{
@@ -3531,16 +3531,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 b26022c60292ef74b8e656e3fa311f762c8183a7..fab18b3cf44d3ed255f108cf5d8bf4bd0271eb13 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.9.2
-D 2015-11-02T18:31:45.544
+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\schanges\sis\sa\s\ncherry-pick\sof\s[f0f49224]\swith\sversion-specific\sedits.\s\sThat\scheck-in\swas\ninspired\sby\scheck-in\s[72de49f2].
+D 2017-07-21T07:45:23.406
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in f0088ff0d2ac949fce6de7c00f13a99ac5bdb663
 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 e028eb13432f108d2e22cded019fc980700e4e00
+F ext/fts3/fts3.c c936a1563f41025a3e8192735776b2f9c45f5f9821293eb0b885df9cee0f0cee
 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
 F ext/fts3/fts3Int.h c84125c666ee54cef6efce6ff64abb0d0e2f4535
 F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1
@@ -345,7 +345,7 @@ F src/resolve.c 1954a0f01bf65d78d7d559aea3d5c67f33376d91
 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 F src/select.c 0bc9cd2e1cacfdc9cdc9a83884cc100f166e80a4
 F src/shell.c d25df04168d6ba5a4fa05bdbf859df667f9eb621
-F src/sqlite.h.in dc35357824c6bb84a04acd4e99dee3e07299a8c6
+F src/sqlite.h.in 332fccab62c1d932de51ebdfe57ddbce6e04f1c7589b6d088d031840f464009a
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 4b66e3e3435da4b4c8c83696d0349f0c503b3924
 F src/sqliteInt.h e21cc96bc24161df7373f6b24367cf580496889d
@@ -408,8 +408,8 @@ F src/util.c fc612367108b74573c5fd13a85d0a23027f438bd
 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701
 F src/vdbe.c 1e0bf8d6a2308ce916d444ef399921407fd5d972
 F src/vdbe.h 4bc88bd0e06f8046ee6ab7487c0015e85ad949ad
-F src/vdbeInt.h 8b867eac234e28627ffcace3cd4b4b79bbec664b
-F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca
+F src/vdbeInt.h 7209dc7293ef58d7a306db3ee93e63f76ab33e943ea01124b2e645023a2787d4
+F src/vdbeapi.c 4ebb5e6ad10c2ed285d126a6684999cabda6837dbc4e29a754eb9ce3eb451ecb
 F src/vdbeaux.c fd00b489ab3f44f2dca1e4344faf289b7bfcf649
 F src/vdbeblob.c 565fabd302f5fca3bdf3d56cac330483616a39b6
 F src/vdbemem.c 19b3036aa4d676e7103b0fb5efd6327da455f915
@@ -1390,10 +1390,11 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P c0c4b6b39648be9aa9b1e218e6d281ab17812536
-R 56b278dd241b099a55f2d39b092fbea8
-T +bgcolor * #d0c0ff
-T +sym-release *
-T +sym-version-3.9.2 *
+P bda77dda9697c463c3d0704014d51627fceee328
+Q +f0f492245e957f5339c5aef02716321e45c18914b9a78387e4158f87fc2d83f9
+R d9726a99cce883b83c0b86ff1601f729
+T *branch * branch-3.9.2
+T *sym-branch-3.9.2 *
+T -sym-branch-3.9 *
 U drh
-Z ea2f853532ec0d2d6055c0d00a95dc82
+Z 02632e8a008083bfd94c6f55cee630d7
index 2772d49f44bbdb2e5877777c31e0f62e1adf7ae9..ad908c7c7464129c99a3a8df6d3a0b828f0471a4 100644 (file)
@@ -1 +1 @@
-bda77dda9697c463c3d0704014d51627fceee328
\ No newline at end of file
+69906880cee1f246cce494672402e0c7f29bd4ec19c437d26d603870d2bd625d
\ No newline at end of file
index c3b2890f0b3838536bc856757a4723abad981e15..961e6032322ccb2d3eba5f34bdfc31128fc550ff 100644 (file)
@@ -4352,6 +4352,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*);
@@ -4664,6 +4665,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_text64(sqlite3_context*, const char*,sqlite3_uint64,
                            void(*)(void*), unsigned char encoding);
index 7884d955b01f53365f5fccef2d4f880ee880eaf9..afbd74b08040863cca5f8df8dcaaea46f7a8562e 100644 (file)
@@ -169,6 +169,7 @@ struct Mem {
     double r;           /* Real value used when MEM_Real is set in flags */
     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 */
@@ -226,6 +227,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 */
@@ -241,7 +243,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 33c6ba3b287e9a45eb9beaf6d89cda513a029cfd..f5e6cb4b1f95b91e3d0fc5d9333f24471bc53557 100644 (file)
@@ -190,6 +190,11 @@ sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
 unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
   return ((Mem*)pVal)->eSubtype;
 }
+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);
 }
@@ -364,6 +369,13 @@ void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
   assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
   sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
 }
+void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
+  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
+  sqlite3VdbeMemSetNull(pCtx->pOut);
+  assert( (pCtx->pOut->flags & (MEM_TypeMask|MEM_Ptr))==MEM_Null );
+  pCtx->pOut->flags |= MEM_Ptr;
+  pCtx->pOut->u.pPtr = pPtr;
+}
 void sqlite3_result_null(sqlite3_context *pCtx){
   assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
   sqlite3VdbeMemSetNull(pCtx->pOut);