/ Check-in [f0f49224]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add new interfaces sqlite3_result_pointer(), and sqlite3_value_pointer() and use them to transfer the eponymous FTS3 column pointer to the snippet() and offsets() routines. This changes is inspired by check-in [72de49f2] but is new implementation, not a cherry-pick.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | branch-3.7.11
Files: files | file ages | folders
SHA3-256: f0f492245e957f5339c5aef02716321e45c18914b9a78387e4158f87fc2d83f9
User & Date: drh 2017-07-21 03:09:35
References
2017-07-21
07:56
Add new interfaces sqlite3_result_pointer(), and 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] via [69906880cee] and is ultimately inspired by check-in [72de49f2]. check-in: 8201f4e1 user: drh tags: branch-3.18
07:45
Add new interfaces sqlite3_result_pointer(), and 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]. check-in: 69906880 user: drh tags: branch-3.9.2
04:08
Add new interfaces sqlite3_result_pointer(), and 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 [f0f49224] which was in turn inspired by [72de49f2]. Leaf check-in: 5a3022e0 user: drh tags: branch-3.8.10
03:23
Add new interfaces sqlite3_result_pointer(), and 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]. Leaf check-in: a66a5b39 user: drh tags: branch-3.8.6
Context
2017-07-21
07:45
Add new interfaces sqlite3_result_pointer(), and 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]. check-in: 69906880 user: drh tags: branch-3.9.2
03:23
Add new interfaces sqlite3_result_pointer(), and 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]. Leaf check-in: a66a5b39 user: drh tags: branch-3.8.6
03:09
Add new interfaces sqlite3_result_pointer(), and sqlite3_value_pointer() and use them to transfer the eponymous FTS3 column pointer to the snippet() and offsets() routines. This changes is inspired by check-in [72de49f2] but is new implementation, not a cherry-pick. Leaf check-in: f0f49224 user: drh tags: branch-3.7.11
2015-05-21
02:24
Silently ignore any attempt to add a prefix index for prefixes zero bytes in size to an fts3/4 table. Or any prefix index size so large that it overflows a 32-bit signed integer. Cherrypick [ad4b19d2ac0889a] check-in: 000197cc user: drh tags: branch-3.7.11
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  3063   3063       /* This call is a request for the "docid" column. Since "docid" is an 
  3064   3064       ** alias for "rowid", use the xRowid() method to obtain the value.
  3065   3065       */
  3066   3066       sqlite3_result_int64(pCtx, pCsr->iPrevId);
  3067   3067     }else if( iCol==p->nColumn ){
  3068   3068       /* The extra column whose name is the same as the table.
  3069   3069       ** Return a blob which is a pointer to the cursor.  */
  3070         -    sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
         3070  +    sqlite3_result_pointer(pCtx, pCsr);
  3071   3071     }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
  3072   3072       sqlite3_result_int64(pCtx, pCsr->iLangid);
  3073   3073     }else{
  3074   3074       /* The requested column is either a user column (one that contains 
  3075   3075       ** indexed data), or the language-id column.  */
  3076   3076       rc = fts3CursorSeek(0, pCsr);
  3077   3077   
................................................................................
  3190   3190   */
  3191   3191   static int fts3FunctionArg(
  3192   3192     sqlite3_context *pContext,      /* SQL function call context */
  3193   3193     const char *zFunc,              /* Function name */
  3194   3194     sqlite3_value *pVal,            /* argv[0] passed to function */
  3195   3195     Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */
  3196   3196   ){
  3197         -  Fts3Cursor *pRet;
  3198         -  if( sqlite3_value_type(pVal)!=SQLITE_BLOB 
  3199         -   || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)
  3200         -  ){
         3197  +  Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal);
         3198  +  if( pRet==0 ){
  3201   3199       char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
  3202   3200       sqlite3_result_error(pContext, zErr, -1);
  3203   3201       sqlite3_free(zErr);
  3204   3202       return SQLITE_ERROR;
  3205   3203     }
  3206         -  memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));
  3207   3204     *ppCsr = pRet;
  3208   3205     return SQLITE_OK;
  3209   3206   }
  3210   3207   
  3211   3208   /*
  3212   3209   ** Implementation of the snippet() function for FTS3
  3213   3210   */

Changes to src/sqlite.h.in.

  3941   3941   */
  3942   3942   const void *sqlite3_value_blob(sqlite3_value*);
  3943   3943   int sqlite3_value_bytes(sqlite3_value*);
  3944   3944   int sqlite3_value_bytes16(sqlite3_value*);
  3945   3945   double sqlite3_value_double(sqlite3_value*);
  3946   3946   int sqlite3_value_int(sqlite3_value*);
  3947   3947   sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
         3948  +void *sqlite3_value_pointer(sqlite3_value*);
  3948   3949   const unsigned char *sqlite3_value_text(sqlite3_value*);
  3949   3950   const void *sqlite3_value_text16(sqlite3_value*);
  3950   3951   const void *sqlite3_value_text16le(sqlite3_value*);
  3951   3952   const void *sqlite3_value_text16be(sqlite3_value*);
  3952   3953   int sqlite3_value_type(sqlite3_value*);
  3953   3954   int sqlite3_value_numeric_type(sqlite3_value*);
  3954   3955   
................................................................................
  4198   4199   void sqlite3_result_error16(sqlite3_context*, const void*, int);
  4199   4200   void sqlite3_result_error_toobig(sqlite3_context*);
  4200   4201   void sqlite3_result_error_nomem(sqlite3_context*);
  4201   4202   void sqlite3_result_error_code(sqlite3_context*, int);
  4202   4203   void sqlite3_result_int(sqlite3_context*, int);
  4203   4204   void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  4204   4205   void sqlite3_result_null(sqlite3_context*);
         4206  +void sqlite3_result_pointer(sqlite3_context*, void*);
  4205   4207   void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  4206   4208   void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  4207   4209   void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  4208   4210   void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  4209   4211   void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  4210   4212   void sqlite3_result_zeroblob(sqlite3_context*, int n);
  4211   4213   

Changes to src/vdbeInt.h.

   147    147   struct Mem {
   148    148     sqlite3 *db;        /* The associated database connection */
   149    149     char *z;            /* String or BLOB value */
   150    150     double r;           /* Real value */
   151    151     union {
   152    152       i64 i;              /* Integer value used when MEM_Int is set in flags */
   153    153       int nZero;          /* Used when bit MEM_Zero is set in flags */
          154  +    void *pPtr;         /* Pointer when flags==MEM_Ptr|MEM_Null */
   154    155       FuncDef *pDef;      /* Used only when flags==MEM_Agg */
   155    156       RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */
   156    157       VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */
   157    158     } u;
   158    159     int n;              /* Number of characters in string value, excluding '\0' */
   159    160     u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
   160    161     u8  type;           /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */
................................................................................
   190    191   #define MEM_TypeMask  0x00ff   /* Mask of type bits */
   191    192   
   192    193   /* Whenever Mem contains a valid string or blob representation, one of
   193    194   ** the following flags must be set to determine the memory management
   194    195   ** policy for Mem.z.  The MEM_Term flag tells us whether or not the
   195    196   ** string is \000 or \u0000 terminated
   196    197   */
          198  +#define MEM_Ptr       0x8000   /* u.pPtr is valid if type==SQLITE_NULL */
   197    199   #define MEM_Term      0x0200   /* String rep is nul terminated */
   198    200   #define MEM_Dyn       0x0400   /* Need to call sqliteFree() on Mem.z */
   199    201   #define MEM_Static    0x0800   /* Mem.z points to a static string */
   200    202   #define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */
   201    203   #define MEM_Agg       0x2000   /* Mem.z points to an agg function context */
   202    204   #define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */
   203    205   #ifdef SQLITE_OMIT_INCRBLOB
................................................................................
   205    207     #define MEM_Zero 0x0000
   206    208   #endif
   207    209   
   208    210   /*
   209    211   ** Clear any existing type flags from a Mem and replace them with f
   210    212   */
   211    213   #define MemSetTypeFlag(p, f) \
   212         -   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)
          214  +   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero|MEM_Ptr))|f)
   213    215   
   214    216   /*
   215    217   ** Return true if a memory cell is not marked as invalid.  This macro
   216    218   ** is for use inside assert() statements only.
   217    219   */
   218    220   #ifdef SQLITE_DEBUG
   219    221   #define memIsValid(M)  ((M)->flags & MEM_Invalid)==0

Changes to src/vdbeapi.c.

   158    158     return sqlite3VdbeRealValue((Mem*)pVal);
   159    159   }
   160    160   int sqlite3_value_int(sqlite3_value *pVal){
   161    161     return (int)sqlite3VdbeIntValue((Mem*)pVal);
   162    162   }
   163    163   sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
   164    164     return sqlite3VdbeIntValue((Mem*)pVal);
          165  +}
          166  +void *sqlite3_value_pointer(sqlite3_value *pVal){
          167  +  Mem *p = (Mem*)pVal;
          168  +  if( (p->flags&(MEM_TypeMask|MEM_Ptr))==(MEM_Null|MEM_Ptr) ) return p->u.pPtr;
          169  +  return 0;
   165    170   }
   166    171   const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
   167    172     return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
   168    173   }
   169    174   #ifndef SQLITE_OMIT_UTF16
   170    175   const void *sqlite3_value_text16(sqlite3_value* pVal){
   171    176     return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
................................................................................
   229    234   void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
   230    235     assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
   231    236     sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);
   232    237   }
   233    238   void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
   234    239     assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
   235    240     sqlite3VdbeMemSetInt64(&pCtx->s, iVal);
          241  +}
          242  +void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
          243  +  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
          244  +  sqlite3VdbeMemSetNull(&pCtx->s);
          245  +  assert( (pCtx->s.flags & (MEM_TypeMask|MEM_Ptr))==MEM_Null );
          246  +  pCtx->s.flags |= MEM_Ptr;
          247  +  pCtx->s.u.pPtr = pPtr;
   236    248   }
   237    249   void sqlite3_result_null(sqlite3_context *pCtx){
   238    250     assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
   239    251     sqlite3VdbeMemSetNull(&pCtx->s);
   240    252   }
   241    253   void sqlite3_result_text(
   242    254     sqlite3_context *pCtx,