Fossil SCM
Update the built-in SQLite to the 3rd 3.20.0 release candidate.
Commit
8ffba76b7342556ee76774af3d98209729ca034a93f6c00fd168a60fabeafb95
Parent
8b9ce19e38d5b7d…
2 files changed
+109
-80
+19
-16
+109
-80
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1150,11 +1150,11 @@ | ||
| 1150 | 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | 1152 | */ |
| 1153 | 1153 | #define SQLITE_VERSION "3.20.0" |
| 1154 | 1154 | #define SQLITE_VERSION_NUMBER 3020000 |
| 1155 | -#define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51" | |
| 1155 | +#define SQLITE_SOURCE_ID "2017-07-28 00:45:38 d891a2a00a34b6726624c66273f0f3388da9de6a771771c94b6e8a970dd9cdb9" | |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | 1160 | ** |
| @@ -4910,18 +4910,18 @@ | ||
| 4910 | 4910 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 4911 | 4911 | ** content is later written using |
| 4912 | 4912 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 4913 | 4913 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 4914 | 4914 | ** |
| 4915 | -** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in | |
| 4915 | +** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in | |
| 4916 | 4916 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 4917 | -** associated with the pointer P of type T. | |
| 4918 | -** ^The sqlite3_bind_pointer() routine can be used to pass | |
| 4919 | -** host-language pointers into [application-defined SQL functions]. | |
| 4920 | -** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears | |
| 4921 | -** to be an ordinary SQL NULL value to everything other than | |
| 4922 | -** [sqlite3_value_pointer()]. The T parameter should be a static string. | |
| 4917 | +** associated with the pointer P of type T. ^D is either a NULL pointer or | |
| 4918 | +** a pointer to a destructor function for P. ^SQLite will invoke the | |
| 4919 | +** destructor D with a single argument of P when it is finished using | |
| 4920 | +** P. The T parameter should be a static string, preferably a string | |
| 4921 | +** literal. The sqlite3_bind_pointer() routine is part of the | |
| 4922 | +** [pointer passing interface] added for SQLite 3.20.0. | |
| 4923 | 4923 | ** |
| 4924 | 4924 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 4925 | 4925 | ** for the [prepared statement] or with a prepared statement for which |
| 4926 | 4926 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 4927 | 4927 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -4952,11 +4952,11 @@ | ||
| 4952 | 4952 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 4953 | 4953 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 4954 | 4954 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 4955 | 4955 | void(*)(void*), unsigned char encoding); |
| 4956 | 4956 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 4957 | -SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*); | |
| 4957 | +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); | |
| 4958 | 4958 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 4959 | 4959 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 4960 | 4960 | |
| 4961 | 4961 | /* |
| 4962 | 4962 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -5785,14 +5785,15 @@ | ||
| 5785 | 5785 | ** in the native byte-order of the host machine. ^The |
| 5786 | 5786 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 5787 | 5787 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 5788 | 5788 | ** |
| 5789 | 5789 | ** ^If [sqlite3_value] object V was initialized |
| 5790 | -** using [sqlite3_bind_pointer(S,I,P,X)] or [sqlite3_result_pointer(C,P,X)] | |
| 5790 | +** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] | |
| 5791 | 5791 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 5792 | 5792 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 5793 | -** sqlite3_value_pointer(V,Y) returns a NULL. | |
| 5793 | +** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() | |
| 5794 | +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. | |
| 5794 | 5795 | ** |
| 5795 | 5796 | ** ^(The sqlite3_value_type(V) interface returns the |
| 5796 | 5797 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 5797 | 5798 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 5798 | 5799 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -6123,18 +6124,20 @@ | ||
| 6123 | 6124 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 6124 | 6125 | ** ^A [protected sqlite3_value] object may always be used where an |
| 6125 | 6126 | ** [unprotected sqlite3_value] object is required, so either |
| 6126 | 6127 | ** kind of [sqlite3_value] object can be used with this interface. |
| 6127 | 6128 | ** |
| 6128 | -** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an | |
| 6129 | +** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an | |
| 6129 | 6130 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 6130 | 6131 | ** also associates the host-language pointer P or type T with that |
| 6131 | 6132 | ** NULL value such that the pointer can be retrieved within an |
| 6132 | 6133 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 6133 | -** The T parameter should be a static string. | |
| 6134 | -** This mechanism can be used to pass non-SQL values between | |
| 6135 | -** application-defined functions. | |
| 6134 | +** ^If the D parameter is not NULL, then it is a pointer to a destructor | |
| 6135 | +** for the P parameter. ^SQLite invokes D with P as its only argument | |
| 6136 | +** when SQLite is finished with P. The T parameter should be a static | |
| 6137 | +** string and preferably a string literal. The sqlite3_result_pointer() | |
| 6138 | +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. | |
| 6136 | 6139 | ** |
| 6137 | 6140 | ** If these routines are called from within the different thread |
| 6138 | 6141 | ** than the one containing the application-defined function that received |
| 6139 | 6142 | ** the [sqlite3_context] pointer, the results are undefined. |
| 6140 | 6143 | */ |
| @@ -6155,11 +6158,11 @@ | ||
| 6155 | 6158 | void(*)(void*), unsigned char encoding); |
| 6156 | 6159 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6157 | 6160 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6158 | 6161 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6159 | 6162 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 6160 | -SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*); | |
| 6163 | +SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); | |
| 6161 | 6164 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 6162 | 6165 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 6163 | 6166 | |
| 6164 | 6167 | |
| 6165 | 6168 | /* |
| @@ -15397,11 +15400,11 @@ | ||
| 15397 | 15400 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 15398 | 15401 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ |
| 15399 | 15402 | 0, 0, xFunc, 0, #zName, {0} } |
| 15400 | 15403 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ |
| 15401 | 15404 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| 15402 | - (void*)xFunc, 0, xFunc, 0, #zName, {0} } | |
| 15405 | + (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} } | |
| 15403 | 15406 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 15404 | 15407 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 15405 | 15408 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15406 | 15409 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 15407 | 15410 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| @@ -18645,12 +18648,12 @@ | ||
| 18645 | 18648 | */ |
| 18646 | 18649 | struct sqlite3_value { |
| 18647 | 18650 | union MemValue { |
| 18648 | 18651 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18649 | 18652 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18650 | - int nZero; /* Used when bit MEM_Zero is set in flags */ | |
| 18651 | - void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */ | |
| 18653 | + int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */ | |
| 18654 | + const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */ | |
| 18652 | 18655 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| 18653 | 18656 | RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ |
| 18654 | 18657 | VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ |
| 18655 | 18658 | } u; |
| 18656 | 18659 | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ |
| @@ -18678,37 +18681,38 @@ | ||
| 18678 | 18681 | |
| 18679 | 18682 | /* One or more of the following flags are set to indicate the validOK |
| 18680 | 18683 | ** representations of the value stored in the Mem struct. |
| 18681 | 18684 | ** |
| 18682 | 18685 | ** If the MEM_Null flag is set, then the value is an SQL NULL value. |
| 18683 | -** No other flags may be set in this case. | |
| 18686 | +** For a pointer type created using sqlite3_bind_pointer() or | |
| 18687 | +** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set. | |
| 18684 | 18688 | ** |
| 18685 | 18689 | ** If the MEM_Str flag is set then Mem.z points at a string representation. |
| 18686 | 18690 | ** Usually this is encoded in the same unicode encoding as the main |
| 18687 | 18691 | ** database (see below for exceptions). If the MEM_Term flag is also |
| 18688 | 18692 | ** set, then the string is nul terminated. The MEM_Int and MEM_Real |
| 18689 | 18693 | ** flags may coexist with the MEM_Str flag. |
| 18690 | 18694 | */ |
| 18691 | -#define MEM_Null 0x0001 /* Value is NULL */ | |
| 18695 | +#define MEM_Null 0x0001 /* Value is NULL (or a pointer) */ | |
| 18692 | 18696 | #define MEM_Str 0x0002 /* Value is a string */ |
| 18693 | 18697 | #define MEM_Int 0x0004 /* Value is an integer */ |
| 18694 | 18698 | #define MEM_Real 0x0008 /* Value is a real number */ |
| 18695 | 18699 | #define MEM_Blob 0x0010 /* Value is a BLOB */ |
| 18696 | 18700 | #define MEM_AffMask 0x001f /* Mask of affinity bits */ |
| 18697 | 18701 | #define MEM_RowSet 0x0020 /* Value is a RowSet object */ |
| 18698 | 18702 | #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ |
| 18699 | 18703 | #define MEM_Undefined 0x0080 /* Value is undefined */ |
| 18700 | 18704 | #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */ |
| 18701 | -#define MEM_TypeMask 0x81ff /* Mask of type bits */ | |
| 18705 | +#define MEM_TypeMask 0xc1ff /* Mask of type bits */ | |
| 18702 | 18706 | |
| 18703 | 18707 | |
| 18704 | 18708 | /* Whenever Mem contains a valid string or blob representation, one of |
| 18705 | 18709 | ** the following flags must be set to determine the memory management |
| 18706 | 18710 | ** policy for Mem.z. The MEM_Term flag tells us whether or not the |
| 18707 | 18711 | ** string is \000 or \u0000 terminated |
| 18708 | 18712 | */ |
| 18709 | -#define MEM_Term 0x0200 /* String rep is nul terminated */ | |
| 18713 | +#define MEM_Term 0x0200 /* String in Mem.z is zero terminated */ | |
| 18710 | 18714 | #define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */ |
| 18711 | 18715 | #define MEM_Static 0x0800 /* Mem.z points to a static string */ |
| 18712 | 18716 | #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ |
| 18713 | 18717 | #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ |
| 18714 | 18718 | #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ |
| @@ -18932,11 +18936,11 @@ | ||
| 18932 | 18936 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 18933 | 18937 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 18934 | 18938 | #else |
| 18935 | 18939 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 18936 | 18940 | #endif |
| 18937 | -SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*); | |
| 18941 | +SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); | |
| 18938 | 18942 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 18939 | 18943 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 18940 | 18944 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 18941 | 18945 | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); |
| 18942 | 18946 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -70268,11 +70272,11 @@ | ||
| 70268 | 70272 | ** This routine is intended for use inside of assert() statements, like |
| 70269 | 70273 | ** this: assert( sqlite3VdbeCheckMemInvariants(pMem) ); |
| 70270 | 70274 | */ |
| 70271 | 70275 | SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){ |
| 70272 | 70276 | /* If MEM_Dyn is set then Mem.xDel!=0. |
| 70273 | - ** Mem.xDel is might not be initialized if MEM_Dyn is clear. | |
| 70277 | + ** Mem.xDel might not be initialized if MEM_Dyn is clear. | |
| 70274 | 70278 | */ |
| 70275 | 70279 | assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 ); |
| 70276 | 70280 | |
| 70277 | 70281 | /* MEM_Dyn may only be set if Mem.szMalloc==0. In this way we |
| 70278 | 70282 | ** ensure that if Mem.szMalloc>0 then it is safe to do |
| @@ -70281,13 +70285,38 @@ | ||
| 70281 | 70285 | assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 ); |
| 70282 | 70286 | |
| 70283 | 70287 | /* Cannot be both MEM_Int and MEM_Real at the same time */ |
| 70284 | 70288 | assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); |
| 70285 | 70289 | |
| 70286 | - /* Cannot be both MEM_Null and some other type */ | |
| 70287 | - assert( (p->flags & MEM_Null)==0 || | |
| 70288 | - (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); | |
| 70290 | + if( p->flags & MEM_Null ){ | |
| 70291 | + /* Cannot be both MEM_Null and some other type */ | |
| 70292 | + assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob | |
| 70293 | + |MEM_RowSet|MEM_Frame|MEM_Agg|MEM_Zero))==0 ); | |
| 70294 | + | |
| 70295 | + /* If MEM_Null is set, then either the value is a pure NULL (the usual | |
| 70296 | + ** case) or it is a pointer set using sqlite3_bind_pointer() or | |
| 70297 | + ** sqlite3_result_pointer(). If a pointer, then MEM_Term must also be | |
| 70298 | + ** set. | |
| 70299 | + */ | |
| 70300 | + if( (p->flags & (MEM_Term|MEM_Subtype))==(MEM_Term|MEM_Subtype) ){ | |
| 70301 | + /* This is a pointer type. There may be a flag to indicate what to | |
| 70302 | + ** do with the pointer. */ | |
| 70303 | + assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) + | |
| 70304 | + ((p->flags&MEM_Ephem)!=0 ? 1 : 0) + | |
| 70305 | + ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 ); | |
| 70306 | + | |
| 70307 | + /* No other bits set */ | |
| 70308 | + assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype | |
| 70309 | + |MEM_Dyn|MEM_Ephem|MEM_Static))==0 ); | |
| 70310 | + }else{ | |
| 70311 | + /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn, | |
| 70312 | + ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */ | |
| 70313 | + } | |
| 70314 | + }else{ | |
| 70315 | + /* The MEM_Cleared bit is only allowed on NULLs */ | |
| 70316 | + assert( (p->flags & MEM_Cleared)==0 ); | |
| 70317 | + } | |
| 70289 | 70318 | |
| 70290 | 70319 | /* The szMalloc field holds the correct memory allocation size */ |
| 70291 | 70320 | assert( p->szMalloc==0 |
| 70292 | 70321 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 70293 | 70322 | |
| @@ -70946,22 +70975,29 @@ | ||
| 70946 | 70975 | pMem->u.i = val; |
| 70947 | 70976 | pMem->flags = MEM_Int; |
| 70948 | 70977 | } |
| 70949 | 70978 | } |
| 70950 | 70979 | |
| 70980 | +/* A no-op destructor */ | |
| 70981 | +static void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); } | |
| 70982 | + | |
| 70951 | 70983 | /* |
| 70952 | 70984 | ** Set the value stored in *pMem should already be a NULL. |
| 70953 | 70985 | ** Also store a pointer to go with it. |
| 70954 | 70986 | */ |
| 70955 | -SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr, const char *zPType){ | |
| 70987 | +SQLITE_PRIVATE void sqlite3VdbeMemSetPointer( | |
| 70988 | + Mem *pMem, | |
| 70989 | + void *pPtr, | |
| 70990 | + const char *zPType, | |
| 70991 | + void (*xDestructor)(void*) | |
| 70992 | +){ | |
| 70956 | 70993 | assert( pMem->flags==MEM_Null ); |
| 70957 | - if( zPType ){ | |
| 70958 | - pMem->flags = MEM_Null|MEM_Subtype|MEM_Term|MEM_Static; | |
| 70959 | - pMem->u.pPtr = pPtr; | |
| 70960 | - pMem->eSubtype = 'p'; | |
| 70961 | - pMem->z = (char*)zPType; | |
| 70962 | - } | |
| 70994 | + pMem->u.zPType = zPType ? zPType : ""; | |
| 70995 | + pMem->z = pPtr; | |
| 70996 | + pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term; | |
| 70997 | + pMem->eSubtype = 'p'; | |
| 70998 | + pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor; | |
| 70963 | 70999 | } |
| 70964 | 71000 | |
| 70965 | 71001 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 70966 | 71002 | /* |
| 70967 | 71003 | ** Delete any previous value and set the value stored in *pMem to val, |
| @@ -76564,10 +76600,13 @@ | ||
| 76564 | 76600 | ** throw an error if it is given inputs that would make it non-deterministic. |
| 76565 | 76601 | ** This routine is invoked by date/time functions that use non-deterministic |
| 76566 | 76602 | ** features such as 'now'. |
| 76567 | 76603 | */ |
| 76568 | 76604 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){ |
| 76605 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 | |
| 76606 | + if( pCtx->pVdbe==0 ) return 1; | |
| 76607 | +#endif | |
| 76569 | 76608 | if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){ |
| 76570 | 76609 | sqlite3_result_error(pCtx, |
| 76571 | 76610 | "non-deterministic function in index expression or CHECK constraint", |
| 76572 | 76611 | -1); |
| 76573 | 76612 | return 0; |
| @@ -76884,16 +76923,17 @@ | ||
| 76884 | 76923 | Mem *pMem = (Mem*)pVal; |
| 76885 | 76924 | return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0); |
| 76886 | 76925 | } |
| 76887 | 76926 | SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){ |
| 76888 | 76927 | Mem *p = (Mem*)pVal; |
| 76889 | - if( p->flags==(MEM_Null|MEM_Subtype|MEM_Term|MEM_Static) | |
| 76928 | + if( (p->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) == | |
| 76929 | + (MEM_Null|MEM_Term|MEM_Subtype) | |
| 76890 | 76930 | && zPType!=0 |
| 76891 | 76931 | && p->eSubtype=='p' |
| 76892 | - && strcmp(p->z, zPType)==0 | |
| 76932 | + && strcmp(p->u.zPType, zPType)==0 | |
| 76893 | 76933 | ){ |
| 76894 | - return p->u.pPtr; | |
| 76934 | + return (void*)p->z; | |
| 76895 | 76935 | }else{ |
| 76896 | 76936 | return 0; |
| 76897 | 76937 | } |
| 76898 | 76938 | } |
| 76899 | 76939 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ |
| @@ -77072,15 +77112,20 @@ | ||
| 77072 | 77112 | } |
| 77073 | 77113 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 77074 | 77114 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 77075 | 77115 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 77076 | 77116 | } |
| 77077 | -SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr, const char *zPT){ | |
| 77117 | +SQLITE_API void sqlite3_result_pointer( | |
| 77118 | + sqlite3_context *pCtx, | |
| 77119 | + void *pPtr, | |
| 77120 | + const char *zPType, | |
| 77121 | + void (*xDestructor)(void*) | |
| 77122 | +){ | |
| 77078 | 77123 | Mem *pOut = pCtx->pOut; |
| 77079 | 77124 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77080 | 77125 | sqlite3VdbeMemSetNull(pOut); |
| 77081 | - sqlite3VdbeMemSetPointer(pOut, pPtr, zPT); | |
| 77126 | + sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); | |
| 77082 | 77127 | } |
| 77083 | 77128 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 77084 | 77129 | Mem *pOut = pCtx->pOut; |
| 77085 | 77130 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77086 | 77131 | pOut->eSubtype = eSubtype & 0xff; |
| @@ -78081,17 +78126,25 @@ | ||
| 78081 | 78126 | if( rc==SQLITE_OK ){ |
| 78082 | 78127 | sqlite3_mutex_leave(p->db->mutex); |
| 78083 | 78128 | } |
| 78084 | 78129 | return rc; |
| 78085 | 78130 | } |
| 78086 | -SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,const char *zT){ | |
| 78131 | +SQLITE_API int sqlite3_bind_pointer( | |
| 78132 | + sqlite3_stmt *pStmt, | |
| 78133 | + int i, | |
| 78134 | + void *pPtr, | |
| 78135 | + const char *zPTtype, | |
| 78136 | + void (*xDestructor)(void*) | |
| 78137 | +){ | |
| 78087 | 78138 | int rc; |
| 78088 | 78139 | Vdbe *p = (Vdbe*)pStmt; |
| 78089 | 78140 | rc = vdbeUnbind(p, i); |
| 78090 | 78141 | if( rc==SQLITE_OK ){ |
| 78091 | - sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT); | |
| 78142 | + sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zPTtype, xDestructor); | |
| 78092 | 78143 | sqlite3_mutex_leave(p->db->mutex); |
| 78144 | + }else if( xDestructor ){ | |
| 78145 | + xDestructor(pPtr); | |
| 78093 | 78146 | } |
| 78094 | 78147 | return rc; |
| 78095 | 78148 | } |
| 78096 | 78149 | SQLITE_API int sqlite3_bind_text( |
| 78097 | 78150 | sqlite3_stmt *pStmt, |
| @@ -112259,12 +112312,12 @@ | ||
| 112259 | 112312 | /* Version 3.20.0 and later */ |
| 112260 | 112313 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, |
| 112261 | 112314 | sqlite3_stmt**,const char**); |
| 112262 | 112315 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, |
| 112263 | 112316 | sqlite3_stmt**,const void**); |
| 112264 | - int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*); | |
| 112265 | - void (*result_pointer)(sqlite3_context*,void*,const char*); | |
| 112317 | + int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); | |
| 112318 | + void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); | |
| 112266 | 112319 | void *(*value_pointer)(sqlite3_value*,const char*); |
| 112267 | 112320 | }; |
| 112268 | 112321 | |
| 112269 | 112322 | /* |
| 112270 | 112323 | ** This is the function signature used for all extension entry points. It |
| @@ -150347,11 +150400,11 @@ | ||
| 150347 | 150400 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 150348 | 150401 | |
| 150349 | 150402 | switch( iCol-p->nColumn ){ |
| 150350 | 150403 | case 0: |
| 150351 | 150404 | /* The special 'table-name' column */ |
| 150352 | - sqlite3_result_pointer(pCtx, pCsr, "fts3cursor"); | |
| 150405 | + sqlite3_result_pointer(pCtx, pCsr, "fts3cursor", 0); | |
| 150353 | 150406 | break; |
| 150354 | 150407 | |
| 150355 | 150408 | case 1: |
| 150356 | 150409 | /* The docid column */ |
| 150357 | 150410 | sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| @@ -165581,26 +165634,18 @@ | ||
| 165581 | 165634 | int (*xQueryFunc)(sqlite3_rtree_query_info*); |
| 165582 | 165635 | void (*xDestructor)(void*); |
| 165583 | 165636 | void *pContext; |
| 165584 | 165637 | }; |
| 165585 | 165638 | |
| 165586 | - | |
| 165587 | -/* | |
| 165588 | -** Value for the first field of every RtreeMatchArg object. The MATCH | |
| 165589 | -** operator tests that the first field of a blob operand matches this | |
| 165590 | -** value to avoid operating on invalid blobs (which could cause a segfault). | |
| 165591 | -*/ | |
| 165592 | -#define RTREE_GEOMETRY_MAGIC 0x891245AB | |
| 165593 | - | |
| 165594 | 165639 | /* |
| 165595 | 165640 | ** An instance of this structure (in the form of a BLOB) is returned by |
| 165596 | 165641 | ** the SQL functions that sqlite3_rtree_geometry_callback() and |
| 165597 | 165642 | ** sqlite3_rtree_query_callback() create, and is read as the right-hand |
| 165598 | 165643 | ** operand to the MATCH operator of an R-Tree. |
| 165599 | 165644 | */ |
| 165600 | 165645 | struct RtreeMatchArg { |
| 165601 | - u32 magic; /* Always RTREE_GEOMETRY_MAGIC */ | |
| 165646 | + u32 iSize; /* Size of this object */ | |
| 165602 | 165647 | RtreeGeomCallback cb; /* Info about the callback functions */ |
| 165603 | 165648 | int nParam; /* Number of parameters to the SQL function */ |
| 165604 | 165649 | sqlite3_value **apSqlParam; /* Original SQL parameter values */ |
| 165605 | 165650 | RtreeDValue aParam[1]; /* Values for parameters to the SQL function */ |
| 165606 | 165651 | }; |
| @@ -166891,37 +166936,21 @@ | ||
| 166891 | 166936 | ** as the second argument for a MATCH constraint. The value passed as the |
| 166892 | 166937 | ** first argument to this function is the right-hand operand to the MATCH |
| 166893 | 166938 | ** operator. |
| 166894 | 166939 | */ |
| 166895 | 166940 | static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){ |
| 166896 | - RtreeMatchArg *pBlob; /* BLOB returned by geometry function */ | |
| 166941 | + RtreeMatchArg *pBlob, *pSrc; /* BLOB returned by geometry function */ | |
| 166897 | 166942 | sqlite3_rtree_query_info *pInfo; /* Callback information */ |
| 166898 | - int nBlob; /* Size of the geometry function blob */ | |
| 166899 | - int nExpected; /* Expected size of the BLOB */ | |
| 166900 | - | |
| 166901 | - /* Check that value is actually a blob. */ | |
| 166902 | - if( sqlite3_value_type(pValue)!=SQLITE_BLOB ) return SQLITE_ERROR; | |
| 166903 | - | |
| 166904 | - /* Check that the blob is roughly the right size. */ | |
| 166905 | - nBlob = sqlite3_value_bytes(pValue); | |
| 166906 | - if( nBlob<(int)sizeof(RtreeMatchArg) ){ | |
| 166907 | - return SQLITE_ERROR; | |
| 166908 | - } | |
| 166909 | - | |
| 166910 | - pInfo = (sqlite3_rtree_query_info*)sqlite3_malloc( sizeof(*pInfo)+nBlob ); | |
| 166943 | + | |
| 166944 | + pSrc = sqlite3_value_pointer(pValue, "RtreeMatchArg"); | |
| 166945 | + if( pSrc==0 ) return SQLITE_ERROR; | |
| 166946 | + pInfo = (sqlite3_rtree_query_info*) | |
| 166947 | + sqlite3_malloc64( sizeof(*pInfo)+pSrc->iSize ); | |
| 166911 | 166948 | if( !pInfo ) return SQLITE_NOMEM; |
| 166912 | 166949 | memset(pInfo, 0, sizeof(*pInfo)); |
| 166913 | 166950 | pBlob = (RtreeMatchArg*)&pInfo[1]; |
| 166914 | - | |
| 166915 | - memcpy(pBlob, sqlite3_value_blob(pValue), nBlob); | |
| 166916 | - nExpected = (int)(sizeof(RtreeMatchArg) + | |
| 166917 | - pBlob->nParam*sizeof(sqlite3_value*) + | |
| 166918 | - (pBlob->nParam-1)*sizeof(RtreeDValue)); | |
| 166919 | - if( pBlob->magic!=RTREE_GEOMETRY_MAGIC || nBlob!=nExpected ){ | |
| 166920 | - sqlite3_free(pInfo); | |
| 166921 | - return SQLITE_ERROR; | |
| 166922 | - } | |
| 166951 | + memcpy(pBlob, pSrc, pSrc->iSize); | |
| 166923 | 166952 | pInfo->pContext = pBlob->cb.pContext; |
| 166924 | 166953 | pInfo->nParam = pBlob->nParam; |
| 166925 | 166954 | pInfo->aParam = pBlob->aParam; |
| 166926 | 166955 | pInfo->apSqlParam = pBlob->apSqlParam; |
| 166927 | 166956 | |
| @@ -168955,11 +168984,11 @@ | ||
| 168955 | 168984 | pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob); |
| 168956 | 168985 | if( !pBlob ){ |
| 168957 | 168986 | sqlite3_result_error_nomem(ctx); |
| 168958 | 168987 | }else{ |
| 168959 | 168988 | int i; |
| 168960 | - pBlob->magic = RTREE_GEOMETRY_MAGIC; | |
| 168989 | + pBlob->iSize = nBlob; | |
| 168961 | 168990 | pBlob->cb = pGeomCtx[0]; |
| 168962 | 168991 | pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg]; |
| 168963 | 168992 | pBlob->nParam = nArg; |
| 168964 | 168993 | for(i=0; i<nArg; i++){ |
| 168965 | 168994 | pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]); |
| @@ -168972,11 +169001,11 @@ | ||
| 168972 | 169001 | } |
| 168973 | 169002 | if( memErr ){ |
| 168974 | 169003 | sqlite3_result_error_nomem(ctx); |
| 168975 | 169004 | rtreeMatchArgFree(pBlob); |
| 168976 | 169005 | }else{ |
| 168977 | - sqlite3_result_blob(ctx, pBlob, nBlob, rtreeMatchArgFree); | |
| 169006 | + sqlite3_result_pointer(ctx, pBlob, "RtreeMatchArg", rtreeMatchArgFree); | |
| 168978 | 169007 | } |
| 168979 | 169008 | } |
| 168980 | 169009 | } |
| 168981 | 169010 | |
| 168982 | 169011 | /* |
| @@ -200285,11 +200314,11 @@ | ||
| 200285 | 200314 | int nArg, /* Number of args */ |
| 200286 | 200315 | sqlite3_value **apUnused /* Function arguments */ |
| 200287 | 200316 | ){ |
| 200288 | 200317 | assert( nArg==0 ); |
| 200289 | 200318 | UNUSED_PARAM2(nArg, apUnused); |
| 200290 | - sqlite3_result_text(pCtx, "fts5: 2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51", -1, SQLITE_TRANSIENT); | |
| 200319 | + sqlite3_result_text(pCtx, "fts5: 2017-07-27 18:43:13 2dfcd9a8ecdf0ddd8e044d820639830c6171141c588cf0224255af85c64cf79c", -1, SQLITE_TRANSIENT); | |
| 200291 | 200320 | } |
| 200292 | 200321 | |
| 200293 | 200322 | static int fts5Init(sqlite3 *db){ |
| 200294 | 200323 | static const sqlite3_module fts5Mod = { |
| 200295 | 200324 | /* iVersion */ 2, |
| 200296 | 200325 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1150,11 +1150,11 @@ | |
| 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | */ |
| 1153 | #define SQLITE_VERSION "3.20.0" |
| 1154 | #define SQLITE_VERSION_NUMBER 3020000 |
| 1155 | #define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51" |
| 1156 | |
| 1157 | /* |
| 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | ** |
| @@ -4910,18 +4910,18 @@ | |
| 4910 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 4911 | ** content is later written using |
| 4912 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 4913 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 4914 | ** |
| 4915 | ** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in |
| 4916 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 4917 | ** associated with the pointer P of type T. |
| 4918 | ** ^The sqlite3_bind_pointer() routine can be used to pass |
| 4919 | ** host-language pointers into [application-defined SQL functions]. |
| 4920 | ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears |
| 4921 | ** to be an ordinary SQL NULL value to everything other than |
| 4922 | ** [sqlite3_value_pointer()]. The T parameter should be a static string. |
| 4923 | ** |
| 4924 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 4925 | ** for the [prepared statement] or with a prepared statement for which |
| 4926 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 4927 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -4952,11 +4952,11 @@ | |
| 4952 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 4953 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 4954 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 4955 | void(*)(void*), unsigned char encoding); |
| 4956 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 4957 | SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*); |
| 4958 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 4959 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 4960 | |
| 4961 | /* |
| 4962 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -5785,14 +5785,15 @@ | |
| 5785 | ** in the native byte-order of the host machine. ^The |
| 5786 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 5787 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 5788 | ** |
| 5789 | ** ^If [sqlite3_value] object V was initialized |
| 5790 | ** using [sqlite3_bind_pointer(S,I,P,X)] or [sqlite3_result_pointer(C,P,X)] |
| 5791 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 5792 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 5793 | ** sqlite3_value_pointer(V,Y) returns a NULL. |
| 5794 | ** |
| 5795 | ** ^(The sqlite3_value_type(V) interface returns the |
| 5796 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 5797 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 5798 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -6123,18 +6124,20 @@ | |
| 6123 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 6124 | ** ^A [protected sqlite3_value] object may always be used where an |
| 6125 | ** [unprotected sqlite3_value] object is required, so either |
| 6126 | ** kind of [sqlite3_value] object can be used with this interface. |
| 6127 | ** |
| 6128 | ** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an |
| 6129 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 6130 | ** also associates the host-language pointer P or type T with that |
| 6131 | ** NULL value such that the pointer can be retrieved within an |
| 6132 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 6133 | ** The T parameter should be a static string. |
| 6134 | ** This mechanism can be used to pass non-SQL values between |
| 6135 | ** application-defined functions. |
| 6136 | ** |
| 6137 | ** If these routines are called from within the different thread |
| 6138 | ** than the one containing the application-defined function that received |
| 6139 | ** the [sqlite3_context] pointer, the results are undefined. |
| 6140 | */ |
| @@ -6155,11 +6158,11 @@ | |
| 6155 | void(*)(void*), unsigned char encoding); |
| 6156 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6157 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6158 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6159 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 6160 | SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*); |
| 6161 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 6162 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 6163 | |
| 6164 | |
| 6165 | /* |
| @@ -15397,11 +15400,11 @@ | |
| 15397 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 15398 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ |
| 15399 | 0, 0, xFunc, 0, #zName, {0} } |
| 15400 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ |
| 15401 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| 15402 | (void*)xFunc, 0, xFunc, 0, #zName, {0} } |
| 15403 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 15404 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 15405 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15406 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 15407 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| @@ -18645,12 +18648,12 @@ | |
| 18645 | */ |
| 18646 | struct sqlite3_value { |
| 18647 | union MemValue { |
| 18648 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18649 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18650 | int nZero; /* Used when bit MEM_Zero is set in flags */ |
| 18651 | void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */ |
| 18652 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| 18653 | RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ |
| 18654 | VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ |
| 18655 | } u; |
| 18656 | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ |
| @@ -18678,37 +18681,38 @@ | |
| 18678 | |
| 18679 | /* One or more of the following flags are set to indicate the validOK |
| 18680 | ** representations of the value stored in the Mem struct. |
| 18681 | ** |
| 18682 | ** If the MEM_Null flag is set, then the value is an SQL NULL value. |
| 18683 | ** No other flags may be set in this case. |
| 18684 | ** |
| 18685 | ** If the MEM_Str flag is set then Mem.z points at a string representation. |
| 18686 | ** Usually this is encoded in the same unicode encoding as the main |
| 18687 | ** database (see below for exceptions). If the MEM_Term flag is also |
| 18688 | ** set, then the string is nul terminated. The MEM_Int and MEM_Real |
| 18689 | ** flags may coexist with the MEM_Str flag. |
| 18690 | */ |
| 18691 | #define MEM_Null 0x0001 /* Value is NULL */ |
| 18692 | #define MEM_Str 0x0002 /* Value is a string */ |
| 18693 | #define MEM_Int 0x0004 /* Value is an integer */ |
| 18694 | #define MEM_Real 0x0008 /* Value is a real number */ |
| 18695 | #define MEM_Blob 0x0010 /* Value is a BLOB */ |
| 18696 | #define MEM_AffMask 0x001f /* Mask of affinity bits */ |
| 18697 | #define MEM_RowSet 0x0020 /* Value is a RowSet object */ |
| 18698 | #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ |
| 18699 | #define MEM_Undefined 0x0080 /* Value is undefined */ |
| 18700 | #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */ |
| 18701 | #define MEM_TypeMask 0x81ff /* Mask of type bits */ |
| 18702 | |
| 18703 | |
| 18704 | /* Whenever Mem contains a valid string or blob representation, one of |
| 18705 | ** the following flags must be set to determine the memory management |
| 18706 | ** policy for Mem.z. The MEM_Term flag tells us whether or not the |
| 18707 | ** string is \000 or \u0000 terminated |
| 18708 | */ |
| 18709 | #define MEM_Term 0x0200 /* String rep is nul terminated */ |
| 18710 | #define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */ |
| 18711 | #define MEM_Static 0x0800 /* Mem.z points to a static string */ |
| 18712 | #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ |
| 18713 | #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ |
| 18714 | #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ |
| @@ -18932,11 +18936,11 @@ | |
| 18932 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 18933 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 18934 | #else |
| 18935 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 18936 | #endif |
| 18937 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*); |
| 18938 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 18939 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 18940 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 18941 | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); |
| 18942 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -70268,11 +70272,11 @@ | |
| 70268 | ** This routine is intended for use inside of assert() statements, like |
| 70269 | ** this: assert( sqlite3VdbeCheckMemInvariants(pMem) ); |
| 70270 | */ |
| 70271 | SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){ |
| 70272 | /* If MEM_Dyn is set then Mem.xDel!=0. |
| 70273 | ** Mem.xDel is might not be initialized if MEM_Dyn is clear. |
| 70274 | */ |
| 70275 | assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 ); |
| 70276 | |
| 70277 | /* MEM_Dyn may only be set if Mem.szMalloc==0. In this way we |
| 70278 | ** ensure that if Mem.szMalloc>0 then it is safe to do |
| @@ -70281,13 +70285,38 @@ | |
| 70281 | assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 ); |
| 70282 | |
| 70283 | /* Cannot be both MEM_Int and MEM_Real at the same time */ |
| 70284 | assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); |
| 70285 | |
| 70286 | /* Cannot be both MEM_Null and some other type */ |
| 70287 | assert( (p->flags & MEM_Null)==0 || |
| 70288 | (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); |
| 70289 | |
| 70290 | /* The szMalloc field holds the correct memory allocation size */ |
| 70291 | assert( p->szMalloc==0 |
| 70292 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 70293 | |
| @@ -70946,22 +70975,29 @@ | |
| 70946 | pMem->u.i = val; |
| 70947 | pMem->flags = MEM_Int; |
| 70948 | } |
| 70949 | } |
| 70950 | |
| 70951 | /* |
| 70952 | ** Set the value stored in *pMem should already be a NULL. |
| 70953 | ** Also store a pointer to go with it. |
| 70954 | */ |
| 70955 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr, const char *zPType){ |
| 70956 | assert( pMem->flags==MEM_Null ); |
| 70957 | if( zPType ){ |
| 70958 | pMem->flags = MEM_Null|MEM_Subtype|MEM_Term|MEM_Static; |
| 70959 | pMem->u.pPtr = pPtr; |
| 70960 | pMem->eSubtype = 'p'; |
| 70961 | pMem->z = (char*)zPType; |
| 70962 | } |
| 70963 | } |
| 70964 | |
| 70965 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 70966 | /* |
| 70967 | ** Delete any previous value and set the value stored in *pMem to val, |
| @@ -76564,10 +76600,13 @@ | |
| 76564 | ** throw an error if it is given inputs that would make it non-deterministic. |
| 76565 | ** This routine is invoked by date/time functions that use non-deterministic |
| 76566 | ** features such as 'now'. |
| 76567 | */ |
| 76568 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){ |
| 76569 | if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){ |
| 76570 | sqlite3_result_error(pCtx, |
| 76571 | "non-deterministic function in index expression or CHECK constraint", |
| 76572 | -1); |
| 76573 | return 0; |
| @@ -76884,16 +76923,17 @@ | |
| 76884 | Mem *pMem = (Mem*)pVal; |
| 76885 | return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0); |
| 76886 | } |
| 76887 | SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){ |
| 76888 | Mem *p = (Mem*)pVal; |
| 76889 | if( p->flags==(MEM_Null|MEM_Subtype|MEM_Term|MEM_Static) |
| 76890 | && zPType!=0 |
| 76891 | && p->eSubtype=='p' |
| 76892 | && strcmp(p->z, zPType)==0 |
| 76893 | ){ |
| 76894 | return p->u.pPtr; |
| 76895 | }else{ |
| 76896 | return 0; |
| 76897 | } |
| 76898 | } |
| 76899 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ |
| @@ -77072,15 +77112,20 @@ | |
| 77072 | } |
| 77073 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 77074 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 77075 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 77076 | } |
| 77077 | SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr, const char *zPT){ |
| 77078 | Mem *pOut = pCtx->pOut; |
| 77079 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77080 | sqlite3VdbeMemSetNull(pOut); |
| 77081 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPT); |
| 77082 | } |
| 77083 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 77084 | Mem *pOut = pCtx->pOut; |
| 77085 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77086 | pOut->eSubtype = eSubtype & 0xff; |
| @@ -78081,17 +78126,25 @@ | |
| 78081 | if( rc==SQLITE_OK ){ |
| 78082 | sqlite3_mutex_leave(p->db->mutex); |
| 78083 | } |
| 78084 | return rc; |
| 78085 | } |
| 78086 | SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,const char *zT){ |
| 78087 | int rc; |
| 78088 | Vdbe *p = (Vdbe*)pStmt; |
| 78089 | rc = vdbeUnbind(p, i); |
| 78090 | if( rc==SQLITE_OK ){ |
| 78091 | sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT); |
| 78092 | sqlite3_mutex_leave(p->db->mutex); |
| 78093 | } |
| 78094 | return rc; |
| 78095 | } |
| 78096 | SQLITE_API int sqlite3_bind_text( |
| 78097 | sqlite3_stmt *pStmt, |
| @@ -112259,12 +112312,12 @@ | |
| 112259 | /* Version 3.20.0 and later */ |
| 112260 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, |
| 112261 | sqlite3_stmt**,const char**); |
| 112262 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, |
| 112263 | sqlite3_stmt**,const void**); |
| 112264 | int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*); |
| 112265 | void (*result_pointer)(sqlite3_context*,void*,const char*); |
| 112266 | void *(*value_pointer)(sqlite3_value*,const char*); |
| 112267 | }; |
| 112268 | |
| 112269 | /* |
| 112270 | ** This is the function signature used for all extension entry points. It |
| @@ -150347,11 +150400,11 @@ | |
| 150347 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 150348 | |
| 150349 | switch( iCol-p->nColumn ){ |
| 150350 | case 0: |
| 150351 | /* The special 'table-name' column */ |
| 150352 | sqlite3_result_pointer(pCtx, pCsr, "fts3cursor"); |
| 150353 | break; |
| 150354 | |
| 150355 | case 1: |
| 150356 | /* The docid column */ |
| 150357 | sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| @@ -165581,26 +165634,18 @@ | |
| 165581 | int (*xQueryFunc)(sqlite3_rtree_query_info*); |
| 165582 | void (*xDestructor)(void*); |
| 165583 | void *pContext; |
| 165584 | }; |
| 165585 | |
| 165586 | |
| 165587 | /* |
| 165588 | ** Value for the first field of every RtreeMatchArg object. The MATCH |
| 165589 | ** operator tests that the first field of a blob operand matches this |
| 165590 | ** value to avoid operating on invalid blobs (which could cause a segfault). |
| 165591 | */ |
| 165592 | #define RTREE_GEOMETRY_MAGIC 0x891245AB |
| 165593 | |
| 165594 | /* |
| 165595 | ** An instance of this structure (in the form of a BLOB) is returned by |
| 165596 | ** the SQL functions that sqlite3_rtree_geometry_callback() and |
| 165597 | ** sqlite3_rtree_query_callback() create, and is read as the right-hand |
| 165598 | ** operand to the MATCH operator of an R-Tree. |
| 165599 | */ |
| 165600 | struct RtreeMatchArg { |
| 165601 | u32 magic; /* Always RTREE_GEOMETRY_MAGIC */ |
| 165602 | RtreeGeomCallback cb; /* Info about the callback functions */ |
| 165603 | int nParam; /* Number of parameters to the SQL function */ |
| 165604 | sqlite3_value **apSqlParam; /* Original SQL parameter values */ |
| 165605 | RtreeDValue aParam[1]; /* Values for parameters to the SQL function */ |
| 165606 | }; |
| @@ -166891,37 +166936,21 @@ | |
| 166891 | ** as the second argument for a MATCH constraint. The value passed as the |
| 166892 | ** first argument to this function is the right-hand operand to the MATCH |
| 166893 | ** operator. |
| 166894 | */ |
| 166895 | static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){ |
| 166896 | RtreeMatchArg *pBlob; /* BLOB returned by geometry function */ |
| 166897 | sqlite3_rtree_query_info *pInfo; /* Callback information */ |
| 166898 | int nBlob; /* Size of the geometry function blob */ |
| 166899 | int nExpected; /* Expected size of the BLOB */ |
| 166900 | |
| 166901 | /* Check that value is actually a blob. */ |
| 166902 | if( sqlite3_value_type(pValue)!=SQLITE_BLOB ) return SQLITE_ERROR; |
| 166903 | |
| 166904 | /* Check that the blob is roughly the right size. */ |
| 166905 | nBlob = sqlite3_value_bytes(pValue); |
| 166906 | if( nBlob<(int)sizeof(RtreeMatchArg) ){ |
| 166907 | return SQLITE_ERROR; |
| 166908 | } |
| 166909 | |
| 166910 | pInfo = (sqlite3_rtree_query_info*)sqlite3_malloc( sizeof(*pInfo)+nBlob ); |
| 166911 | if( !pInfo ) return SQLITE_NOMEM; |
| 166912 | memset(pInfo, 0, sizeof(*pInfo)); |
| 166913 | pBlob = (RtreeMatchArg*)&pInfo[1]; |
| 166914 | |
| 166915 | memcpy(pBlob, sqlite3_value_blob(pValue), nBlob); |
| 166916 | nExpected = (int)(sizeof(RtreeMatchArg) + |
| 166917 | pBlob->nParam*sizeof(sqlite3_value*) + |
| 166918 | (pBlob->nParam-1)*sizeof(RtreeDValue)); |
| 166919 | if( pBlob->magic!=RTREE_GEOMETRY_MAGIC || nBlob!=nExpected ){ |
| 166920 | sqlite3_free(pInfo); |
| 166921 | return SQLITE_ERROR; |
| 166922 | } |
| 166923 | pInfo->pContext = pBlob->cb.pContext; |
| 166924 | pInfo->nParam = pBlob->nParam; |
| 166925 | pInfo->aParam = pBlob->aParam; |
| 166926 | pInfo->apSqlParam = pBlob->apSqlParam; |
| 166927 | |
| @@ -168955,11 +168984,11 @@ | |
| 168955 | pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob); |
| 168956 | if( !pBlob ){ |
| 168957 | sqlite3_result_error_nomem(ctx); |
| 168958 | }else{ |
| 168959 | int i; |
| 168960 | pBlob->magic = RTREE_GEOMETRY_MAGIC; |
| 168961 | pBlob->cb = pGeomCtx[0]; |
| 168962 | pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg]; |
| 168963 | pBlob->nParam = nArg; |
| 168964 | for(i=0; i<nArg; i++){ |
| 168965 | pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]); |
| @@ -168972,11 +169001,11 @@ | |
| 168972 | } |
| 168973 | if( memErr ){ |
| 168974 | sqlite3_result_error_nomem(ctx); |
| 168975 | rtreeMatchArgFree(pBlob); |
| 168976 | }else{ |
| 168977 | sqlite3_result_blob(ctx, pBlob, nBlob, rtreeMatchArgFree); |
| 168978 | } |
| 168979 | } |
| 168980 | } |
| 168981 | |
| 168982 | /* |
| @@ -200285,11 +200314,11 @@ | |
| 200285 | int nArg, /* Number of args */ |
| 200286 | sqlite3_value **apUnused /* Function arguments */ |
| 200287 | ){ |
| 200288 | assert( nArg==0 ); |
| 200289 | UNUSED_PARAM2(nArg, apUnused); |
| 200290 | sqlite3_result_text(pCtx, "fts5: 2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51", -1, SQLITE_TRANSIENT); |
| 200291 | } |
| 200292 | |
| 200293 | static int fts5Init(sqlite3 *db){ |
| 200294 | static const sqlite3_module fts5Mod = { |
| 200295 | /* iVersion */ 2, |
| 200296 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1150,11 +1150,11 @@ | |
| 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | */ |
| 1153 | #define SQLITE_VERSION "3.20.0" |
| 1154 | #define SQLITE_VERSION_NUMBER 3020000 |
| 1155 | #define SQLITE_SOURCE_ID "2017-07-28 00:45:38 d891a2a00a34b6726624c66273f0f3388da9de6a771771c94b6e8a970dd9cdb9" |
| 1156 | |
| 1157 | /* |
| 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | ** |
| @@ -4910,18 +4910,18 @@ | |
| 4910 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 4911 | ** content is later written using |
| 4912 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 4913 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 4914 | ** |
| 4915 | ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in |
| 4916 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 4917 | ** associated with the pointer P of type T. ^D is either a NULL pointer or |
| 4918 | ** a pointer to a destructor function for P. ^SQLite will invoke the |
| 4919 | ** destructor D with a single argument of P when it is finished using |
| 4920 | ** P. The T parameter should be a static string, preferably a string |
| 4921 | ** literal. The sqlite3_bind_pointer() routine is part of the |
| 4922 | ** [pointer passing interface] added for SQLite 3.20.0. |
| 4923 | ** |
| 4924 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 4925 | ** for the [prepared statement] or with a prepared statement for which |
| 4926 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 4927 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -4952,11 +4952,11 @@ | |
| 4952 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 4953 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 4954 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 4955 | void(*)(void*), unsigned char encoding); |
| 4956 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 4957 | SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); |
| 4958 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 4959 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 4960 | |
| 4961 | /* |
| 4962 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -5785,14 +5785,15 @@ | |
| 5785 | ** in the native byte-order of the host machine. ^The |
| 5786 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 5787 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 5788 | ** |
| 5789 | ** ^If [sqlite3_value] object V was initialized |
| 5790 | ** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] |
| 5791 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 5792 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 5793 | ** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() |
| 5794 | ** routine is part of the [pointer passing interface] added for SQLite 3.20.0. |
| 5795 | ** |
| 5796 | ** ^(The sqlite3_value_type(V) interface returns the |
| 5797 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 5798 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 5799 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -6123,18 +6124,20 @@ | |
| 6124 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 6125 | ** ^A [protected sqlite3_value] object may always be used where an |
| 6126 | ** [unprotected sqlite3_value] object is required, so either |
| 6127 | ** kind of [sqlite3_value] object can be used with this interface. |
| 6128 | ** |
| 6129 | ** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an |
| 6130 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 6131 | ** also associates the host-language pointer P or type T with that |
| 6132 | ** NULL value such that the pointer can be retrieved within an |
| 6133 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 6134 | ** ^If the D parameter is not NULL, then it is a pointer to a destructor |
| 6135 | ** for the P parameter. ^SQLite invokes D with P as its only argument |
| 6136 | ** when SQLite is finished with P. The T parameter should be a static |
| 6137 | ** string and preferably a string literal. The sqlite3_result_pointer() |
| 6138 | ** routine is part of the [pointer passing interface] added for SQLite 3.20.0. |
| 6139 | ** |
| 6140 | ** If these routines are called from within the different thread |
| 6141 | ** than the one containing the application-defined function that received |
| 6142 | ** the [sqlite3_context] pointer, the results are undefined. |
| 6143 | */ |
| @@ -6155,11 +6158,11 @@ | |
| 6158 | void(*)(void*), unsigned char encoding); |
| 6159 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6160 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6161 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6162 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 6163 | SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); |
| 6164 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 6165 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 6166 | |
| 6167 | |
| 6168 | /* |
| @@ -15397,11 +15400,11 @@ | |
| 15400 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 15401 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ |
| 15402 | 0, 0, xFunc, 0, #zName, {0} } |
| 15403 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ |
| 15404 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ |
| 15405 | (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} } |
| 15406 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 15407 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 15408 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15409 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 15410 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| @@ -18645,12 +18648,12 @@ | |
| 18648 | */ |
| 18649 | struct sqlite3_value { |
| 18650 | union MemValue { |
| 18651 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18652 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18653 | int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */ |
| 18654 | const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */ |
| 18655 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| 18656 | RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ |
| 18657 | VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ |
| 18658 | } u; |
| 18659 | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ |
| @@ -18678,37 +18681,38 @@ | |
| 18681 | |
| 18682 | /* One or more of the following flags are set to indicate the validOK |
| 18683 | ** representations of the value stored in the Mem struct. |
| 18684 | ** |
| 18685 | ** If the MEM_Null flag is set, then the value is an SQL NULL value. |
| 18686 | ** For a pointer type created using sqlite3_bind_pointer() or |
| 18687 | ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set. |
| 18688 | ** |
| 18689 | ** If the MEM_Str flag is set then Mem.z points at a string representation. |
| 18690 | ** Usually this is encoded in the same unicode encoding as the main |
| 18691 | ** database (see below for exceptions). If the MEM_Term flag is also |
| 18692 | ** set, then the string is nul terminated. The MEM_Int and MEM_Real |
| 18693 | ** flags may coexist with the MEM_Str flag. |
| 18694 | */ |
| 18695 | #define MEM_Null 0x0001 /* Value is NULL (or a pointer) */ |
| 18696 | #define MEM_Str 0x0002 /* Value is a string */ |
| 18697 | #define MEM_Int 0x0004 /* Value is an integer */ |
| 18698 | #define MEM_Real 0x0008 /* Value is a real number */ |
| 18699 | #define MEM_Blob 0x0010 /* Value is a BLOB */ |
| 18700 | #define MEM_AffMask 0x001f /* Mask of affinity bits */ |
| 18701 | #define MEM_RowSet 0x0020 /* Value is a RowSet object */ |
| 18702 | #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ |
| 18703 | #define MEM_Undefined 0x0080 /* Value is undefined */ |
| 18704 | #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */ |
| 18705 | #define MEM_TypeMask 0xc1ff /* Mask of type bits */ |
| 18706 | |
| 18707 | |
| 18708 | /* Whenever Mem contains a valid string or blob representation, one of |
| 18709 | ** the following flags must be set to determine the memory management |
| 18710 | ** policy for Mem.z. The MEM_Term flag tells us whether or not the |
| 18711 | ** string is \000 or \u0000 terminated |
| 18712 | */ |
| 18713 | #define MEM_Term 0x0200 /* String in Mem.z is zero terminated */ |
| 18714 | #define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */ |
| 18715 | #define MEM_Static 0x0800 /* Mem.z points to a static string */ |
| 18716 | #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ |
| 18717 | #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ |
| 18718 | #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ |
| @@ -18932,11 +18936,11 @@ | |
| 18936 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 18937 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 18938 | #else |
| 18939 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 18940 | #endif |
| 18941 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); |
| 18942 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 18943 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 18944 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 18945 | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); |
| 18946 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -70268,11 +70272,11 @@ | |
| 70272 | ** This routine is intended for use inside of assert() statements, like |
| 70273 | ** this: assert( sqlite3VdbeCheckMemInvariants(pMem) ); |
| 70274 | */ |
| 70275 | SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){ |
| 70276 | /* If MEM_Dyn is set then Mem.xDel!=0. |
| 70277 | ** Mem.xDel might not be initialized if MEM_Dyn is clear. |
| 70278 | */ |
| 70279 | assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 ); |
| 70280 | |
| 70281 | /* MEM_Dyn may only be set if Mem.szMalloc==0. In this way we |
| 70282 | ** ensure that if Mem.szMalloc>0 then it is safe to do |
| @@ -70281,13 +70285,38 @@ | |
| 70285 | assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 ); |
| 70286 | |
| 70287 | /* Cannot be both MEM_Int and MEM_Real at the same time */ |
| 70288 | assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); |
| 70289 | |
| 70290 | if( p->flags & MEM_Null ){ |
| 70291 | /* Cannot be both MEM_Null and some other type */ |
| 70292 | assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob |
| 70293 | |MEM_RowSet|MEM_Frame|MEM_Agg|MEM_Zero))==0 ); |
| 70294 | |
| 70295 | /* If MEM_Null is set, then either the value is a pure NULL (the usual |
| 70296 | ** case) or it is a pointer set using sqlite3_bind_pointer() or |
| 70297 | ** sqlite3_result_pointer(). If a pointer, then MEM_Term must also be |
| 70298 | ** set. |
| 70299 | */ |
| 70300 | if( (p->flags & (MEM_Term|MEM_Subtype))==(MEM_Term|MEM_Subtype) ){ |
| 70301 | /* This is a pointer type. There may be a flag to indicate what to |
| 70302 | ** do with the pointer. */ |
| 70303 | assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) + |
| 70304 | ((p->flags&MEM_Ephem)!=0 ? 1 : 0) + |
| 70305 | ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 ); |
| 70306 | |
| 70307 | /* No other bits set */ |
| 70308 | assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype |
| 70309 | |MEM_Dyn|MEM_Ephem|MEM_Static))==0 ); |
| 70310 | }else{ |
| 70311 | /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn, |
| 70312 | ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */ |
| 70313 | } |
| 70314 | }else{ |
| 70315 | /* The MEM_Cleared bit is only allowed on NULLs */ |
| 70316 | assert( (p->flags & MEM_Cleared)==0 ); |
| 70317 | } |
| 70318 | |
| 70319 | /* The szMalloc field holds the correct memory allocation size */ |
| 70320 | assert( p->szMalloc==0 |
| 70321 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 70322 | |
| @@ -70946,22 +70975,29 @@ | |
| 70975 | pMem->u.i = val; |
| 70976 | pMem->flags = MEM_Int; |
| 70977 | } |
| 70978 | } |
| 70979 | |
| 70980 | /* A no-op destructor */ |
| 70981 | static void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); } |
| 70982 | |
| 70983 | /* |
| 70984 | ** Set the value stored in *pMem should already be a NULL. |
| 70985 | ** Also store a pointer to go with it. |
| 70986 | */ |
| 70987 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer( |
| 70988 | Mem *pMem, |
| 70989 | void *pPtr, |
| 70990 | const char *zPType, |
| 70991 | void (*xDestructor)(void*) |
| 70992 | ){ |
| 70993 | assert( pMem->flags==MEM_Null ); |
| 70994 | pMem->u.zPType = zPType ? zPType : ""; |
| 70995 | pMem->z = pPtr; |
| 70996 | pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term; |
| 70997 | pMem->eSubtype = 'p'; |
| 70998 | pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor; |
| 70999 | } |
| 71000 | |
| 71001 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 71002 | /* |
| 71003 | ** Delete any previous value and set the value stored in *pMem to val, |
| @@ -76564,10 +76600,13 @@ | |
| 76600 | ** throw an error if it is given inputs that would make it non-deterministic. |
| 76601 | ** This routine is invoked by date/time functions that use non-deterministic |
| 76602 | ** features such as 'now'. |
| 76603 | */ |
| 76604 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){ |
| 76605 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 76606 | if( pCtx->pVdbe==0 ) return 1; |
| 76607 | #endif |
| 76608 | if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){ |
| 76609 | sqlite3_result_error(pCtx, |
| 76610 | "non-deterministic function in index expression or CHECK constraint", |
| 76611 | -1); |
| 76612 | return 0; |
| @@ -76884,16 +76923,17 @@ | |
| 76923 | Mem *pMem = (Mem*)pVal; |
| 76924 | return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0); |
| 76925 | } |
| 76926 | SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){ |
| 76927 | Mem *p = (Mem*)pVal; |
| 76928 | if( (p->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) == |
| 76929 | (MEM_Null|MEM_Term|MEM_Subtype) |
| 76930 | && zPType!=0 |
| 76931 | && p->eSubtype=='p' |
| 76932 | && strcmp(p->u.zPType, zPType)==0 |
| 76933 | ){ |
| 76934 | return (void*)p->z; |
| 76935 | }else{ |
| 76936 | return 0; |
| 76937 | } |
| 76938 | } |
| 76939 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ |
| @@ -77072,15 +77112,20 @@ | |
| 77112 | } |
| 77113 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 77114 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 77115 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 77116 | } |
| 77117 | SQLITE_API void sqlite3_result_pointer( |
| 77118 | sqlite3_context *pCtx, |
| 77119 | void *pPtr, |
| 77120 | const char *zPType, |
| 77121 | void (*xDestructor)(void*) |
| 77122 | ){ |
| 77123 | Mem *pOut = pCtx->pOut; |
| 77124 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77125 | sqlite3VdbeMemSetNull(pOut); |
| 77126 | sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); |
| 77127 | } |
| 77128 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 77129 | Mem *pOut = pCtx->pOut; |
| 77130 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77131 | pOut->eSubtype = eSubtype & 0xff; |
| @@ -78081,17 +78126,25 @@ | |
| 78126 | if( rc==SQLITE_OK ){ |
| 78127 | sqlite3_mutex_leave(p->db->mutex); |
| 78128 | } |
| 78129 | return rc; |
| 78130 | } |
| 78131 | SQLITE_API int sqlite3_bind_pointer( |
| 78132 | sqlite3_stmt *pStmt, |
| 78133 | int i, |
| 78134 | void *pPtr, |
| 78135 | const char *zPTtype, |
| 78136 | void (*xDestructor)(void*) |
| 78137 | ){ |
| 78138 | int rc; |
| 78139 | Vdbe *p = (Vdbe*)pStmt; |
| 78140 | rc = vdbeUnbind(p, i); |
| 78141 | if( rc==SQLITE_OK ){ |
| 78142 | sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zPTtype, xDestructor); |
| 78143 | sqlite3_mutex_leave(p->db->mutex); |
| 78144 | }else if( xDestructor ){ |
| 78145 | xDestructor(pPtr); |
| 78146 | } |
| 78147 | return rc; |
| 78148 | } |
| 78149 | SQLITE_API int sqlite3_bind_text( |
| 78150 | sqlite3_stmt *pStmt, |
| @@ -112259,12 +112312,12 @@ | |
| 112312 | /* Version 3.20.0 and later */ |
| 112313 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, |
| 112314 | sqlite3_stmt**,const char**); |
| 112315 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, |
| 112316 | sqlite3_stmt**,const void**); |
| 112317 | int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); |
| 112318 | void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); |
| 112319 | void *(*value_pointer)(sqlite3_value*,const char*); |
| 112320 | }; |
| 112321 | |
| 112322 | /* |
| 112323 | ** This is the function signature used for all extension entry points. It |
| @@ -150347,11 +150400,11 @@ | |
| 150400 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 150401 | |
| 150402 | switch( iCol-p->nColumn ){ |
| 150403 | case 0: |
| 150404 | /* The special 'table-name' column */ |
| 150405 | sqlite3_result_pointer(pCtx, pCsr, "fts3cursor", 0); |
| 150406 | break; |
| 150407 | |
| 150408 | case 1: |
| 150409 | /* The docid column */ |
| 150410 | sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| @@ -165581,26 +165634,18 @@ | |
| 165634 | int (*xQueryFunc)(sqlite3_rtree_query_info*); |
| 165635 | void (*xDestructor)(void*); |
| 165636 | void *pContext; |
| 165637 | }; |
| 165638 | |
| 165639 | /* |
| 165640 | ** An instance of this structure (in the form of a BLOB) is returned by |
| 165641 | ** the SQL functions that sqlite3_rtree_geometry_callback() and |
| 165642 | ** sqlite3_rtree_query_callback() create, and is read as the right-hand |
| 165643 | ** operand to the MATCH operator of an R-Tree. |
| 165644 | */ |
| 165645 | struct RtreeMatchArg { |
| 165646 | u32 iSize; /* Size of this object */ |
| 165647 | RtreeGeomCallback cb; /* Info about the callback functions */ |
| 165648 | int nParam; /* Number of parameters to the SQL function */ |
| 165649 | sqlite3_value **apSqlParam; /* Original SQL parameter values */ |
| 165650 | RtreeDValue aParam[1]; /* Values for parameters to the SQL function */ |
| 165651 | }; |
| @@ -166891,37 +166936,21 @@ | |
| 166936 | ** as the second argument for a MATCH constraint. The value passed as the |
| 166937 | ** first argument to this function is the right-hand operand to the MATCH |
| 166938 | ** operator. |
| 166939 | */ |
| 166940 | static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){ |
| 166941 | RtreeMatchArg *pBlob, *pSrc; /* BLOB returned by geometry function */ |
| 166942 | sqlite3_rtree_query_info *pInfo; /* Callback information */ |
| 166943 | |
| 166944 | pSrc = sqlite3_value_pointer(pValue, "RtreeMatchArg"); |
| 166945 | if( pSrc==0 ) return SQLITE_ERROR; |
| 166946 | pInfo = (sqlite3_rtree_query_info*) |
| 166947 | sqlite3_malloc64( sizeof(*pInfo)+pSrc->iSize ); |
| 166948 | if( !pInfo ) return SQLITE_NOMEM; |
| 166949 | memset(pInfo, 0, sizeof(*pInfo)); |
| 166950 | pBlob = (RtreeMatchArg*)&pInfo[1]; |
| 166951 | memcpy(pBlob, pSrc, pSrc->iSize); |
| 166952 | pInfo->pContext = pBlob->cb.pContext; |
| 166953 | pInfo->nParam = pBlob->nParam; |
| 166954 | pInfo->aParam = pBlob->aParam; |
| 166955 | pInfo->apSqlParam = pBlob->apSqlParam; |
| 166956 | |
| @@ -168955,11 +168984,11 @@ | |
| 168984 | pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob); |
| 168985 | if( !pBlob ){ |
| 168986 | sqlite3_result_error_nomem(ctx); |
| 168987 | }else{ |
| 168988 | int i; |
| 168989 | pBlob->iSize = nBlob; |
| 168990 | pBlob->cb = pGeomCtx[0]; |
| 168991 | pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg]; |
| 168992 | pBlob->nParam = nArg; |
| 168993 | for(i=0; i<nArg; i++){ |
| 168994 | pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]); |
| @@ -168972,11 +169001,11 @@ | |
| 169001 | } |
| 169002 | if( memErr ){ |
| 169003 | sqlite3_result_error_nomem(ctx); |
| 169004 | rtreeMatchArgFree(pBlob); |
| 169005 | }else{ |
| 169006 | sqlite3_result_pointer(ctx, pBlob, "RtreeMatchArg", rtreeMatchArgFree); |
| 169007 | } |
| 169008 | } |
| 169009 | } |
| 169010 | |
| 169011 | /* |
| @@ -200285,11 +200314,11 @@ | |
| 200314 | int nArg, /* Number of args */ |
| 200315 | sqlite3_value **apUnused /* Function arguments */ |
| 200316 | ){ |
| 200317 | assert( nArg==0 ); |
| 200318 | UNUSED_PARAM2(nArg, apUnused); |
| 200319 | sqlite3_result_text(pCtx, "fts5: 2017-07-27 18:43:13 2dfcd9a8ecdf0ddd8e044d820639830c6171141c588cf0224255af85c64cf79c", -1, SQLITE_TRANSIENT); |
| 200320 | } |
| 200321 | |
| 200322 | static int fts5Init(sqlite3 *db){ |
| 200323 | static const sqlite3_module fts5Mod = { |
| 200324 | /* iVersion */ 2, |
| 200325 |
+19
-16
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -121,11 +121,11 @@ | ||
| 121 | 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | 123 | */ |
| 124 | 124 | #define SQLITE_VERSION "3.20.0" |
| 125 | 125 | #define SQLITE_VERSION_NUMBER 3020000 |
| 126 | -#define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51" | |
| 126 | +#define SQLITE_SOURCE_ID "2017-07-28 00:45:38 d891a2a00a34b6726624c66273f0f3388da9de6a771771c94b6e8a970dd9cdb9" | |
| 127 | 127 | |
| 128 | 128 | /* |
| 129 | 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | 130 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 131 | 131 | ** |
| @@ -3881,18 +3881,18 @@ | ||
| 3881 | 3881 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 3882 | 3882 | ** content is later written using |
| 3883 | 3883 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 3884 | 3884 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 3885 | 3885 | ** |
| 3886 | -** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in | |
| 3886 | +** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in | |
| 3887 | 3887 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 3888 | -** associated with the pointer P of type T. | |
| 3889 | -** ^The sqlite3_bind_pointer() routine can be used to pass | |
| 3890 | -** host-language pointers into [application-defined SQL functions]. | |
| 3891 | -** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears | |
| 3892 | -** to be an ordinary SQL NULL value to everything other than | |
| 3893 | -** [sqlite3_value_pointer()]. The T parameter should be a static string. | |
| 3888 | +** associated with the pointer P of type T. ^D is either a NULL pointer or | |
| 3889 | +** a pointer to a destructor function for P. ^SQLite will invoke the | |
| 3890 | +** destructor D with a single argument of P when it is finished using | |
| 3891 | +** P. The T parameter should be a static string, preferably a string | |
| 3892 | +** literal. The sqlite3_bind_pointer() routine is part of the | |
| 3893 | +** [pointer passing interface] added for SQLite 3.20.0. | |
| 3894 | 3894 | ** |
| 3895 | 3895 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 3896 | 3896 | ** for the [prepared statement] or with a prepared statement for which |
| 3897 | 3897 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 3898 | 3898 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -3923,11 +3923,11 @@ | ||
| 3923 | 3923 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 3924 | 3924 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3925 | 3925 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 3926 | 3926 | void(*)(void*), unsigned char encoding); |
| 3927 | 3927 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3928 | -SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*); | |
| 3928 | +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); | |
| 3929 | 3929 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3930 | 3930 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 3931 | 3931 | |
| 3932 | 3932 | /* |
| 3933 | 3933 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -4756,14 +4756,15 @@ | ||
| 4756 | 4756 | ** in the native byte-order of the host machine. ^The |
| 4757 | 4757 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 4758 | 4758 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 4759 | 4759 | ** |
| 4760 | 4760 | ** ^If [sqlite3_value] object V was initialized |
| 4761 | -** using [sqlite3_bind_pointer(S,I,P,X)] or [sqlite3_result_pointer(C,P,X)] | |
| 4761 | +** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] | |
| 4762 | 4762 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 4763 | 4763 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 4764 | -** sqlite3_value_pointer(V,Y) returns a NULL. | |
| 4764 | +** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() | |
| 4765 | +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. | |
| 4765 | 4766 | ** |
| 4766 | 4767 | ** ^(The sqlite3_value_type(V) interface returns the |
| 4767 | 4768 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 4768 | 4769 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 4769 | 4770 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -5094,18 +5095,20 @@ | ||
| 5094 | 5095 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 5095 | 5096 | ** ^A [protected sqlite3_value] object may always be used where an |
| 5096 | 5097 | ** [unprotected sqlite3_value] object is required, so either |
| 5097 | 5098 | ** kind of [sqlite3_value] object can be used with this interface. |
| 5098 | 5099 | ** |
| 5099 | -** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an | |
| 5100 | +** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an | |
| 5100 | 5101 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 5101 | 5102 | ** also associates the host-language pointer P or type T with that |
| 5102 | 5103 | ** NULL value such that the pointer can be retrieved within an |
| 5103 | 5104 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 5104 | -** The T parameter should be a static string. | |
| 5105 | -** This mechanism can be used to pass non-SQL values between | |
| 5106 | -** application-defined functions. | |
| 5105 | +** ^If the D parameter is not NULL, then it is a pointer to a destructor | |
| 5106 | +** for the P parameter. ^SQLite invokes D with P as its only argument | |
| 5107 | +** when SQLite is finished with P. The T parameter should be a static | |
| 5108 | +** string and preferably a string literal. The sqlite3_result_pointer() | |
| 5109 | +** routine is part of the [pointer passing interface] added for SQLite 3.20.0. | |
| 5107 | 5110 | ** |
| 5108 | 5111 | ** If these routines are called from within the different thread |
| 5109 | 5112 | ** than the one containing the application-defined function that received |
| 5110 | 5113 | ** the [sqlite3_context] pointer, the results are undefined. |
| 5111 | 5114 | */ |
| @@ -5126,11 +5129,11 @@ | ||
| 5126 | 5129 | void(*)(void*), unsigned char encoding); |
| 5127 | 5130 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 5128 | 5131 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5129 | 5132 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5130 | 5133 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 5131 | -SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*); | |
| 5134 | +SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); | |
| 5132 | 5135 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 5133 | 5136 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 5134 | 5137 | |
| 5135 | 5138 | |
| 5136 | 5139 | /* |
| 5137 | 5140 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -121,11 +121,11 @@ | |
| 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | */ |
| 124 | #define SQLITE_VERSION "3.20.0" |
| 125 | #define SQLITE_VERSION_NUMBER 3020000 |
| 126 | #define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51" |
| 127 | |
| 128 | /* |
| 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 131 | ** |
| @@ -3881,18 +3881,18 @@ | |
| 3881 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 3882 | ** content is later written using |
| 3883 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 3884 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 3885 | ** |
| 3886 | ** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in |
| 3887 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 3888 | ** associated with the pointer P of type T. |
| 3889 | ** ^The sqlite3_bind_pointer() routine can be used to pass |
| 3890 | ** host-language pointers into [application-defined SQL functions]. |
| 3891 | ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears |
| 3892 | ** to be an ordinary SQL NULL value to everything other than |
| 3893 | ** [sqlite3_value_pointer()]. The T parameter should be a static string. |
| 3894 | ** |
| 3895 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 3896 | ** for the [prepared statement] or with a prepared statement for which |
| 3897 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 3898 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -3923,11 +3923,11 @@ | |
| 3923 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 3924 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3925 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 3926 | void(*)(void*), unsigned char encoding); |
| 3927 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3928 | SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*); |
| 3929 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3930 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 3931 | |
| 3932 | /* |
| 3933 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -4756,14 +4756,15 @@ | |
| 4756 | ** in the native byte-order of the host machine. ^The |
| 4757 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 4758 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 4759 | ** |
| 4760 | ** ^If [sqlite3_value] object V was initialized |
| 4761 | ** using [sqlite3_bind_pointer(S,I,P,X)] or [sqlite3_result_pointer(C,P,X)] |
| 4762 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 4763 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 4764 | ** sqlite3_value_pointer(V,Y) returns a NULL. |
| 4765 | ** |
| 4766 | ** ^(The sqlite3_value_type(V) interface returns the |
| 4767 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 4768 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 4769 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -5094,18 +5095,20 @@ | |
| 5094 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 5095 | ** ^A [protected sqlite3_value] object may always be used where an |
| 5096 | ** [unprotected sqlite3_value] object is required, so either |
| 5097 | ** kind of [sqlite3_value] object can be used with this interface. |
| 5098 | ** |
| 5099 | ** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an |
| 5100 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 5101 | ** also associates the host-language pointer P or type T with that |
| 5102 | ** NULL value such that the pointer can be retrieved within an |
| 5103 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 5104 | ** The T parameter should be a static string. |
| 5105 | ** This mechanism can be used to pass non-SQL values between |
| 5106 | ** application-defined functions. |
| 5107 | ** |
| 5108 | ** If these routines are called from within the different thread |
| 5109 | ** than the one containing the application-defined function that received |
| 5110 | ** the [sqlite3_context] pointer, the results are undefined. |
| 5111 | */ |
| @@ -5126,11 +5129,11 @@ | |
| 5126 | void(*)(void*), unsigned char encoding); |
| 5127 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 5128 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5129 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5130 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 5131 | SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*); |
| 5132 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 5133 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 5134 | |
| 5135 | |
| 5136 | /* |
| 5137 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -121,11 +121,11 @@ | |
| 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | */ |
| 124 | #define SQLITE_VERSION "3.20.0" |
| 125 | #define SQLITE_VERSION_NUMBER 3020000 |
| 126 | #define SQLITE_SOURCE_ID "2017-07-28 00:45:38 d891a2a00a34b6726624c66273f0f3388da9de6a771771c94b6e8a970dd9cdb9" |
| 127 | |
| 128 | /* |
| 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 131 | ** |
| @@ -3881,18 +3881,18 @@ | |
| 3881 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 3882 | ** content is later written using |
| 3883 | ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| 3884 | ** ^A negative value for the zeroblob results in a zero-length BLOB. |
| 3885 | ** |
| 3886 | ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in |
| 3887 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 3888 | ** associated with the pointer P of type T. ^D is either a NULL pointer or |
| 3889 | ** a pointer to a destructor function for P. ^SQLite will invoke the |
| 3890 | ** destructor D with a single argument of P when it is finished using |
| 3891 | ** P. The T parameter should be a static string, preferably a string |
| 3892 | ** literal. The sqlite3_bind_pointer() routine is part of the |
| 3893 | ** [pointer passing interface] added for SQLite 3.20.0. |
| 3894 | ** |
| 3895 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 3896 | ** for the [prepared statement] or with a prepared statement for which |
| 3897 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 3898 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| @@ -3923,11 +3923,11 @@ | |
| 3923 | SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 3924 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3925 | SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 3926 | void(*)(void*), unsigned char encoding); |
| 3927 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3928 | SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); |
| 3929 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3930 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); |
| 3931 | |
| 3932 | /* |
| 3933 | ** CAPI3REF: Number Of SQL Parameters |
| @@ -4756,14 +4756,15 @@ | |
| 4756 | ** in the native byte-order of the host machine. ^The |
| 4757 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 4758 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 4759 | ** |
| 4760 | ** ^If [sqlite3_value] object V was initialized |
| 4761 | ** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] |
| 4762 | ** and if X and Y are strings that compare equal according to strcmp(X,Y), |
| 4763 | ** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, |
| 4764 | ** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() |
| 4765 | ** routine is part of the [pointer passing interface] added for SQLite 3.20.0. |
| 4766 | ** |
| 4767 | ** ^(The sqlite3_value_type(V) interface returns the |
| 4768 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 4769 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 4770 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| @@ -5094,18 +5095,20 @@ | |
| 5095 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 5096 | ** ^A [protected sqlite3_value] object may always be used where an |
| 5097 | ** [unprotected sqlite3_value] object is required, so either |
| 5098 | ** kind of [sqlite3_value] object can be used with this interface. |
| 5099 | ** |
| 5100 | ** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an |
| 5101 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 5102 | ** also associates the host-language pointer P or type T with that |
| 5103 | ** NULL value such that the pointer can be retrieved within an |
| 5104 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 5105 | ** ^If the D parameter is not NULL, then it is a pointer to a destructor |
| 5106 | ** for the P parameter. ^SQLite invokes D with P as its only argument |
| 5107 | ** when SQLite is finished with P. The T parameter should be a static |
| 5108 | ** string and preferably a string literal. The sqlite3_result_pointer() |
| 5109 | ** routine is part of the [pointer passing interface] added for SQLite 3.20.0. |
| 5110 | ** |
| 5111 | ** If these routines are called from within the different thread |
| 5112 | ** than the one containing the application-defined function that received |
| 5113 | ** the [sqlite3_context] pointer, the results are undefined. |
| 5114 | */ |
| @@ -5126,11 +5129,11 @@ | |
| 5129 | void(*)(void*), unsigned char encoding); |
| 5130 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 5131 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5132 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 5133 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 5134 | SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); |
| 5135 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 5136 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 5137 | |
| 5138 | |
| 5139 | /* |
| 5140 |