| | @@ -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-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6" |
| 1155 | +#define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51" |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | 1160 | ** |
| | @@ -4672,11 +4672,11 @@ |
| 4672 | 4672 | ); |
| 4673 | 4673 | SQLITE_API int sqlite3_prepare16_v3( |
| 4674 | 4674 | sqlite3 *db, /* Database handle */ |
| 4675 | 4675 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 4676 | 4676 | int nByte, /* Maximum length of zSql in bytes. */ |
| 4677 | | - unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */ |
| 4677 | + unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */ |
| 4678 | 4678 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 4679 | 4679 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 4680 | 4680 | ); |
| 4681 | 4681 | |
| 4682 | 4682 | /* |
| | @@ -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) routine causes the I-th parameter in |
| 4915 | +** ^The sqlite3_bind_pointer(S,I,P,T) 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. |
| 4917 | +** associated with the pointer P of type T. |
| 4918 | 4918 | ** ^The sqlite3_bind_pointer() routine can be used to pass |
| 4919 | 4919 | ** host-language pointers into [application-defined SQL functions]. |
| 4920 | 4920 | ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears |
| 4921 | 4921 | ** to be an ordinary SQL NULL value to everything other than |
| 4922 | | -** [sqlite3_value_pointer()]. |
| 4922 | +** [sqlite3_value_pointer()]. The T parameter should be a static string. |
| 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*); |
| 4957 | +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*); |
| 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,13 +5785,14 @@ |
| 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)] or [sqlite3_result_pointer(C,P)], then |
| 5791 | | -** sqlite3_value_pointer(V) will return the pointer P. Otherwise, |
| 5792 | | -** sqlite3_value_pointer(V) returns a NULL. |
| 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. |
| 5793 | 5794 | ** |
| 5794 | 5795 | ** ^(The sqlite3_value_type(V) interface returns the |
| 5795 | 5796 | ** [SQLITE_INTEGER | datatype code] for the initial datatype of the |
| 5796 | 5797 | ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], |
| 5797 | 5798 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ |
| | @@ -5821,11 +5822,11 @@ |
| 5821 | 5822 | */ |
| 5822 | 5823 | SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); |
| 5823 | 5824 | SQLITE_API double sqlite3_value_double(sqlite3_value*); |
| 5824 | 5825 | SQLITE_API int sqlite3_value_int(sqlite3_value*); |
| 5825 | 5826 | SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); |
| 5826 | | -SQLITE_API void *sqlite3_value_pointer(sqlite3_value*); |
| 5827 | +SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*); |
| 5827 | 5828 | SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); |
| 5828 | 5829 | SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); |
| 5829 | 5830 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); |
| 5830 | 5831 | SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); |
| 5831 | 5832 | SQLITE_API int sqlite3_value_bytes(sqlite3_value*); |
| | @@ -6122,15 +6123,16 @@ |
| 6122 | 6123 | ** be deallocated after sqlite3_result_value() returns without harm. |
| 6123 | 6124 | ** ^A [protected sqlite3_value] object may always be used where an |
| 6124 | 6125 | ** [unprotected sqlite3_value] object is required, so either |
| 6125 | 6126 | ** kind of [sqlite3_value] object can be used with this interface. |
| 6126 | 6127 | ** |
| 6127 | | -** ^The sqlite3_result_pointer(C,P) interface sets the result to an |
| 6128 | +** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an |
| 6128 | 6129 | ** SQL NULL value, just like [sqlite3_result_null(C)], except that it |
| 6129 | | -** also associates the host-language pointer P with that NULL value such |
| 6130 | | -** that the pointer can be retrieved within an |
| 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 |
| 6131 | 6132 | ** [application-defined SQL function] using [sqlite3_value_pointer()]. |
| 6133 | +** The T parameter should be a static string. |
| 6132 | 6134 | ** This mechanism can be used to pass non-SQL values between |
| 6133 | 6135 | ** application-defined functions. |
| 6134 | 6136 | ** |
| 6135 | 6137 | ** If these routines are called from within the different thread |
| 6136 | 6138 | ** than the one containing the application-defined function that received |
| | @@ -6153,11 +6155,11 @@ |
| 6153 | 6155 | void(*)(void*), unsigned char encoding); |
| 6154 | 6156 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6155 | 6157 | SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6156 | 6158 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 6157 | 6159 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 6158 | | -SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*); |
| 6160 | +SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*); |
| 6159 | 6161 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 6160 | 6162 | SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 6161 | 6163 | |
| 6162 | 6164 | |
| 6163 | 6165 | /* |
| | @@ -13750,16 +13752,16 @@ |
| 13750 | 13752 | #define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 13751 | 13753 | #define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */ |
| 13752 | 13754 | #define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */ |
| 13753 | 13755 | #define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */ |
| 13754 | 13756 | #define OP_CollSeq 68 |
| 13755 | | -#define OP_Function0 69 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 13757 | +#define OP_AddImm 69 /* synopsis: r[P1]=r[P1]+P2 */ |
| 13756 | 13758 | #define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 13757 | 13759 | #define OP_And 71 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 13758 | | -#define OP_Function 72 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 13759 | | -#define OP_AddImm 73 /* synopsis: r[P1]=r[P1]+P2 */ |
| 13760 | | -#define OP_RealAffinity 74 |
| 13760 | +#define OP_RealAffinity 72 |
| 13761 | +#define OP_Cast 73 /* synopsis: affinity(r[P1]) */ |
| 13762 | +#define OP_Permutation 74 |
| 13761 | 13763 | #define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 13762 | 13764 | #define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 13763 | 13765 | #define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 13764 | 13766 | #define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 13765 | 13767 | #define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| | @@ -13775,82 +13777,84 @@ |
| 13775 | 13777 | #define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 13776 | 13778 | #define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 13777 | 13779 | #define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 13778 | 13780 | #define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 13779 | 13781 | #define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 13780 | | -#define OP_Cast 94 /* synopsis: affinity(r[P1]) */ |
| 13782 | +#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 13781 | 13783 | #define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 13782 | | -#define OP_Permutation 96 |
| 13784 | +#define OP_Column 96 /* synopsis: r[P3]=PX */ |
| 13783 | 13785 | #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 13784 | | -#define OP_Compare 98 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 13785 | | -#define OP_Column 99 /* synopsis: r[P3]=PX */ |
| 13786 | | -#define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */ |
| 13787 | | -#define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 13788 | | -#define OP_Count 102 /* synopsis: r[P2]=count() */ |
| 13789 | | -#define OP_ReadCookie 103 |
| 13790 | | -#define OP_SetCookie 104 |
| 13791 | | -#define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */ |
| 13792 | | -#define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */ |
| 13793 | | -#define OP_OpenWrite 107 /* synopsis: root=P2 iDb=P3 */ |
| 13794 | | -#define OP_OpenDup 108 |
| 13795 | | -#define OP_OpenAutoindex 109 /* synopsis: nColumn=P2 */ |
| 13796 | | -#define OP_OpenEphemeral 110 /* synopsis: nColumn=P2 */ |
| 13797 | | -#define OP_SorterOpen 111 |
| 13798 | | -#define OP_SequenceTest 112 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 13799 | | -#define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */ |
| 13800 | | -#define OP_Close 114 |
| 13801 | | -#define OP_ColumnsUsed 115 |
| 13802 | | -#define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 13803 | | -#define OP_NewRowid 117 /* synopsis: r[P2]=rowid */ |
| 13804 | | -#define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 13805 | | -#define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */ |
| 13806 | | -#define OP_Delete 120 |
| 13807 | | -#define OP_ResetCount 121 |
| 13808 | | -#define OP_SorterCompare 122 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 13809 | | -#define OP_SorterData 123 /* synopsis: r[P2]=data */ |
| 13810 | | -#define OP_RowData 124 /* synopsis: r[P2]=data */ |
| 13811 | | -#define OP_Rowid 125 /* synopsis: r[P2]=rowid */ |
| 13812 | | -#define OP_NullRow 126 |
| 13813 | | -#define OP_SorterInsert 127 /* synopsis: key=r[P2] */ |
| 13814 | | -#define OP_IdxInsert 128 /* synopsis: key=r[P2] */ |
| 13815 | | -#define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */ |
| 13816 | | -#define OP_DeferredSeek 130 /* synopsis: Move P3 to P1.rowid if needed */ |
| 13817 | | -#define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */ |
| 13786 | +#define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */ |
| 13787 | +#define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 13788 | +#define OP_Count 100 /* synopsis: r[P2]=count() */ |
| 13789 | +#define OP_ReadCookie 101 |
| 13790 | +#define OP_SetCookie 102 |
| 13791 | +#define OP_ReopenIdx 103 /* synopsis: root=P2 iDb=P3 */ |
| 13792 | +#define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */ |
| 13793 | +#define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */ |
| 13794 | +#define OP_OpenDup 106 |
| 13795 | +#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */ |
| 13796 | +#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */ |
| 13797 | +#define OP_SorterOpen 109 |
| 13798 | +#define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 13799 | +#define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */ |
| 13800 | +#define OP_Close 112 |
| 13801 | +#define OP_ColumnsUsed 113 |
| 13802 | +#define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 13803 | +#define OP_NewRowid 115 /* synopsis: r[P2]=rowid */ |
| 13804 | +#define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 13805 | +#define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */ |
| 13806 | +#define OP_Delete 118 |
| 13807 | +#define OP_ResetCount 119 |
| 13808 | +#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 13809 | +#define OP_SorterData 121 /* synopsis: r[P2]=data */ |
| 13810 | +#define OP_RowData 122 /* synopsis: r[P2]=data */ |
| 13811 | +#define OP_Rowid 123 /* synopsis: r[P2]=rowid */ |
| 13812 | +#define OP_NullRow 124 |
| 13813 | +#define OP_SorterInsert 125 /* synopsis: key=r[P2] */ |
| 13814 | +#define OP_IdxInsert 126 /* synopsis: key=r[P2] */ |
| 13815 | +#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */ |
| 13816 | +#define OP_DeferredSeek 128 /* synopsis: Move P3 to P1.rowid if needed */ |
| 13817 | +#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */ |
| 13818 | +#define OP_Destroy 130 |
| 13819 | +#define OP_Clear 131 |
| 13818 | 13820 | #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 13819 | | -#define OP_Destroy 133 |
| 13820 | | -#define OP_Clear 134 |
| 13821 | | -#define OP_ResetSorter 135 |
| 13822 | | -#define OP_CreateIndex 136 /* synopsis: r[P2]=root iDb=P1 */ |
| 13823 | | -#define OP_CreateTable 137 /* synopsis: r[P2]=root iDb=P1 */ |
| 13824 | | -#define OP_SqlExec 138 |
| 13825 | | -#define OP_ParseSchema 139 |
| 13826 | | -#define OP_LoadAnalysis 140 |
| 13827 | | -#define OP_DropTable 141 |
| 13828 | | -#define OP_DropIndex 142 |
| 13829 | | -#define OP_DropTrigger 143 |
| 13830 | | -#define OP_IntegrityCk 144 |
| 13831 | | -#define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */ |
| 13832 | | -#define OP_Param 146 |
| 13833 | | -#define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */ |
| 13834 | | -#define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 13835 | | -#define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 13836 | | -#define OP_AggStep0 150 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 13837 | | -#define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 13838 | | -#define OP_AggFinal 152 /* synopsis: accum=r[P1] N=P2 */ |
| 13839 | | -#define OP_Expire 153 |
| 13840 | | -#define OP_TableLock 154 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 13841 | | -#define OP_VBegin 155 |
| 13842 | | -#define OP_VCreate 156 |
| 13843 | | -#define OP_VDestroy 157 |
| 13844 | | -#define OP_VOpen 158 |
| 13845 | | -#define OP_VColumn 159 /* synopsis: r[P3]=vcolumn(P2) */ |
| 13846 | | -#define OP_VRename 160 |
| 13847 | | -#define OP_Pagecount 161 |
| 13848 | | -#define OP_MaxPgcnt 162 |
| 13849 | | -#define OP_CursorHint 163 |
| 13850 | | -#define OP_Noop 164 |
| 13851 | | -#define OP_Explain 165 |
| 13821 | +#define OP_ResetSorter 133 |
| 13822 | +#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */ |
| 13823 | +#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */ |
| 13824 | +#define OP_SqlExec 136 |
| 13825 | +#define OP_ParseSchema 137 |
| 13826 | +#define OP_LoadAnalysis 138 |
| 13827 | +#define OP_DropTable 139 |
| 13828 | +#define OP_DropIndex 140 |
| 13829 | +#define OP_DropTrigger 141 |
| 13830 | +#define OP_IntegrityCk 142 |
| 13831 | +#define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */ |
| 13832 | +#define OP_Param 144 |
| 13833 | +#define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */ |
| 13834 | +#define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 13835 | +#define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 13836 | +#define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 13837 | +#define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 13838 | +#define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */ |
| 13839 | +#define OP_Expire 151 |
| 13840 | +#define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 13841 | +#define OP_VBegin 153 |
| 13842 | +#define OP_VCreate 154 |
| 13843 | +#define OP_VDestroy 155 |
| 13844 | +#define OP_VOpen 156 |
| 13845 | +#define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */ |
| 13846 | +#define OP_VRename 158 |
| 13847 | +#define OP_Pagecount 159 |
| 13848 | +#define OP_MaxPgcnt 160 |
| 13849 | +#define OP_PureFunc0 161 |
| 13850 | +#define OP_Function0 162 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 13851 | +#define OP_PureFunc 163 |
| 13852 | +#define OP_Function 164 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 13853 | +#define OP_CursorHint 165 |
| 13854 | +#define OP_Noop 166 |
| 13855 | +#define OP_Explain 167 |
| 13852 | 13856 | |
| 13853 | 13857 | /* Properties such as "out2" or "jump" that are specified in |
| 13854 | 13858 | ** comments following the "case" for each opcode in the vdbe.c |
| 13855 | 13859 | ** are encoded into bitvectors as follows: |
| 13856 | 13860 | */ |
| | @@ -13867,23 +13871,24 @@ |
| 13867 | 13871 | /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ |
| 13868 | 13872 | /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 13869 | 13873 | /* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\ |
| 13870 | 13874 | /* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\ |
| 13871 | 13875 | /* 56 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 13872 | | -/* 64 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 13873 | | -/* 72 */ 0x00, 0x02, 0x02, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 13876 | +/* 64 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x02, 0x26, 0x26,\ |
| 13877 | +/* 72 */ 0x02, 0x02, 0x00, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 13874 | 13878 | /* 80 */ 0x0b, 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26,\ |
| 13875 | | -/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x02, 0x12,\ |
| 13876 | | -/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 13879 | +/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\ |
| 13880 | +/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 13877 | 13881 | /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 13878 | | -/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 13879 | | -/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,\ |
| 13880 | | -/* 128 */ 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\ |
| 13881 | | -/* 136 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 13882 | | -/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\ |
| 13883 | | -/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 13884 | | -/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,} |
| 13882 | +/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 13883 | +/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\ |
| 13884 | +/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\ |
| 13885 | +/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\ |
| 13886 | +/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\ |
| 13887 | +/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ |
| 13888 | +/* 160 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 13889 | +} |
| 13885 | 13890 | |
| 13886 | 13891 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 13887 | 13892 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 13888 | 13893 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 13889 | 13894 | ** generated this include file strives to group all JUMP opcodes |
| | @@ -13977,10 +13982,12 @@ |
| 13977 | 13982 | SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); |
| 13978 | 13983 | |
| 13979 | 13984 | #ifndef SQLITE_OMIT_TRIGGER |
| 13980 | 13985 | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 13981 | 13986 | #endif |
| 13987 | + |
| 13988 | +SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*); |
| 13982 | 13989 | |
| 13983 | 13990 | /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on |
| 13984 | 13991 | ** each VDBE opcode. |
| 13985 | 13992 | ** |
| 13986 | 13993 | ** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op |
| | @@ -15356,11 +15363,18 @@ |
| 15356 | 15363 | ** |
| 15357 | 15364 | ** DFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 15358 | 15365 | ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and |
| 15359 | 15366 | ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions |
| 15360 | 15367 | ** and functions like sqlite_version() that can change, but not during |
| 15361 | | -** a single query. |
| 15368 | +** a single query. The iArg is ignored. The user-data is always set |
| 15369 | +** to a NULL pointer. The bNC parameter is not used. |
| 15370 | +** |
| 15371 | +** PURE_DATE(zName, nArg, iArg, bNC, xFunc) |
| 15372 | +** Used for "pure" date/time functions, this macro is like DFUNCTION |
| 15373 | +** except that it does set the SQLITE_FUNC_CONSTANT flags. iArg is |
| 15374 | +** ignored and the user-data for these functions is set to an |
| 15375 | +** arbitrary non-NULL pointer. The bNC parameter is not used. |
| 15362 | 15376 | ** |
| 15363 | 15377 | ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) |
| 15364 | 15378 | ** Used to create an aggregate function definition implemented by |
| 15365 | 15379 | ** the C functions xStep and xFinal. The first four parameters |
| 15366 | 15380 | ** are interpreted in the same way as the first 4 parameters to |
| | @@ -15379,12 +15393,15 @@ |
| 15379 | 15393 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15380 | 15394 | #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 15381 | 15395 | {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 15382 | 15396 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15383 | 15397 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 15384 | | - {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 15385 | | - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 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} } |
| 15386 | 15403 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 15387 | 15404 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 15388 | 15405 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} } |
| 15389 | 15406 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 15390 | 15407 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| | @@ -16681,12 +16698,12 @@ |
| 16681 | 16698 | int nErr; /* Number of errors seen */ |
| 16682 | 16699 | int nTab; /* Number of previously allocated VDBE cursors */ |
| 16683 | 16700 | int nMem; /* Number of memory cells used so far */ |
| 16684 | 16701 | int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ |
| 16685 | 16702 | int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ |
| 16686 | | - int ckBase; /* Base register of data during check constraints */ |
| 16687 | | - int iSelfTab; /* Table of an index whose exprs are being coded */ |
| 16703 | + int iSelfTab; /* Table for associated with an index on expr, or negative |
| 16704 | + ** of the base register during check-constraint eval */ |
| 16688 | 16705 | int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
| 16689 | 16706 | int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
| 16690 | 16707 | int nLabel; /* Number of labels used */ |
| 16691 | 16708 | int *aLabel; /* Space to hold the labels */ |
| 16692 | 16709 | ExprList *pConstExpr;/* Constant expressions */ |
| | @@ -18915,11 +18932,11 @@ |
| 18915 | 18932 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 18916 | 18933 | # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 |
| 18917 | 18934 | #else |
| 18918 | 18935 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 18919 | 18936 | #endif |
| 18920 | | -SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*); |
| 18937 | +SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*); |
| 18921 | 18938 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 18922 | 18939 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 18923 | 18940 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 18924 | 18941 | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); |
| 18925 | 18942 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| | @@ -19721,11 +19738,11 @@ |
| 19721 | 19738 | double r; |
| 19722 | 19739 | if( parseYyyyMmDd(zDate,p)==0 ){ |
| 19723 | 19740 | return 0; |
| 19724 | 19741 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 19725 | 19742 | return 0; |
| 19726 | | - }else if( sqlite3StrICmp(zDate,"now")==0){ |
| 19743 | + }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){ |
| 19727 | 19744 | return setDateTimeToCurrent(context, p); |
| 19728 | 19745 | }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){ |
| 19729 | 19746 | setRawDateNumber(p, r); |
| 19730 | 19747 | return 0; |
| 19731 | 19748 | } |
| | @@ -20004,11 +20021,11 @@ |
| 20004 | 20021 | /* localtime |
| 20005 | 20022 | ** |
| 20006 | 20023 | ** Assuming the current time value is UTC (a.k.a. GMT), shift it to |
| 20007 | 20024 | ** show local time. |
| 20008 | 20025 | */ |
| 20009 | | - if( sqlite3_stricmp(z, "localtime")==0 ){ |
| 20026 | + if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){ |
| 20010 | 20027 | computeJD(p); |
| 20011 | 20028 | p->iJD += localtimeOffset(p, pCtx, &rc); |
| 20012 | 20029 | clearYMD_HMS_TZ(p); |
| 20013 | 20030 | } |
| 20014 | 20031 | break; |
| | @@ -20030,11 +20047,11 @@ |
| 20030 | 20047 | p->rawS = 0; |
| 20031 | 20048 | rc = 0; |
| 20032 | 20049 | } |
| 20033 | 20050 | } |
| 20034 | 20051 | #ifndef SQLITE_OMIT_LOCALTIME |
| 20035 | | - else if( sqlite3_stricmp(z, "utc")==0 ){ |
| 20052 | + else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){ |
| 20036 | 20053 | if( p->tzSet==0 ){ |
| 20037 | 20054 | sqlite3_int64 c1; |
| 20038 | 20055 | computeJD(p); |
| 20039 | 20056 | c1 = localtimeOffset(p, pCtx, &rc); |
| 20040 | 20057 | if( rc==SQLITE_OK ){ |
| | @@ -20566,15 +20583,15 @@ |
| 20566 | 20583 | ** external linkage. |
| 20567 | 20584 | */ |
| 20568 | 20585 | SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){ |
| 20569 | 20586 | static FuncDef aDateTimeFuncs[] = { |
| 20570 | 20587 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 20571 | | - DFUNCTION(julianday, -1, 0, 0, juliandayFunc ), |
| 20572 | | - DFUNCTION(date, -1, 0, 0, dateFunc ), |
| 20573 | | - DFUNCTION(time, -1, 0, 0, timeFunc ), |
| 20574 | | - DFUNCTION(datetime, -1, 0, 0, datetimeFunc ), |
| 20575 | | - DFUNCTION(strftime, -1, 0, 0, strftimeFunc ), |
| 20588 | + PURE_DATE(julianday, -1, 0, 0, juliandayFunc ), |
| 20589 | + PURE_DATE(date, -1, 0, 0, dateFunc ), |
| 20590 | + PURE_DATE(time, -1, 0, 0, timeFunc ), |
| 20591 | + PURE_DATE(datetime, -1, 0, 0, datetimeFunc ), |
| 20592 | + PURE_DATE(strftime, -1, 0, 0, strftimeFunc ), |
| 20576 | 20593 | DFUNCTION(current_time, 0, 0, 0, ctimeFunc ), |
| 20577 | 20594 | DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), |
| 20578 | 20595 | DFUNCTION(current_date, 0, 0, 0, cdateFunc ), |
| 20579 | 20596 | #else |
| 20580 | 20597 | STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc), |
| | @@ -30088,16 +30105,16 @@ |
| 30088 | 30105 | /* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 30089 | 30106 | /* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 30090 | 30107 | /* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 30091 | 30108 | /* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 30092 | 30109 | /* 68 */ "CollSeq" OpHelp(""), |
| 30093 | | - /* 69 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 30110 | + /* 69 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 30094 | 30111 | /* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 30095 | 30112 | /* 71 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 30096 | | - /* 72 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 30097 | | - /* 73 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 30098 | | - /* 74 */ "RealAffinity" OpHelp(""), |
| 30113 | + /* 72 */ "RealAffinity" OpHelp(""), |
| 30114 | + /* 73 */ "Cast" OpHelp("affinity(r[P1])"), |
| 30115 | + /* 74 */ "Permutation" OpHelp(""), |
| 30099 | 30116 | /* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 30100 | 30117 | /* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 30101 | 30118 | /* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 30102 | 30119 | /* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 30103 | 30120 | /* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| | @@ -30113,82 +30130,84 @@ |
| 30113 | 30130 | /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 30114 | 30131 | /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 30115 | 30132 | /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 30116 | 30133 | /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 30117 | 30134 | /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 30118 | | - /* 94 */ "Cast" OpHelp("affinity(r[P1])"), |
| 30135 | + /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 30119 | 30136 | /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 30120 | | - /* 96 */ "Permutation" OpHelp(""), |
| 30137 | + /* 96 */ "Column" OpHelp("r[P3]=PX"), |
| 30121 | 30138 | /* 97 */ "String8" OpHelp("r[P2]='P4'"), |
| 30122 | | - /* 98 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 30123 | | - /* 99 */ "Column" OpHelp("r[P3]=PX"), |
| 30124 | | - /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 30125 | | - /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 30126 | | - /* 102 */ "Count" OpHelp("r[P2]=count()"), |
| 30127 | | - /* 103 */ "ReadCookie" OpHelp(""), |
| 30128 | | - /* 104 */ "SetCookie" OpHelp(""), |
| 30129 | | - /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 30130 | | - /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 30131 | | - /* 107 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 30132 | | - /* 108 */ "OpenDup" OpHelp(""), |
| 30133 | | - /* 109 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 30134 | | - /* 110 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 30135 | | - /* 111 */ "SorterOpen" OpHelp(""), |
| 30136 | | - /* 112 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 30137 | | - /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 30138 | | - /* 114 */ "Close" OpHelp(""), |
| 30139 | | - /* 115 */ "ColumnsUsed" OpHelp(""), |
| 30140 | | - /* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 30141 | | - /* 117 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 30142 | | - /* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 30143 | | - /* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 30144 | | - /* 120 */ "Delete" OpHelp(""), |
| 30145 | | - /* 121 */ "ResetCount" OpHelp(""), |
| 30146 | | - /* 122 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 30147 | | - /* 123 */ "SorterData" OpHelp("r[P2]=data"), |
| 30148 | | - /* 124 */ "RowData" OpHelp("r[P2]=data"), |
| 30149 | | - /* 125 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 30150 | | - /* 126 */ "NullRow" OpHelp(""), |
| 30151 | | - /* 127 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 30152 | | - /* 128 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 30153 | | - /* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 30154 | | - /* 130 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 30155 | | - /* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 30139 | + /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 30140 | + /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 30141 | + /* 100 */ "Count" OpHelp("r[P2]=count()"), |
| 30142 | + /* 101 */ "ReadCookie" OpHelp(""), |
| 30143 | + /* 102 */ "SetCookie" OpHelp(""), |
| 30144 | + /* 103 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 30145 | + /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 30146 | + /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 30147 | + /* 106 */ "OpenDup" OpHelp(""), |
| 30148 | + /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 30149 | + /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 30150 | + /* 109 */ "SorterOpen" OpHelp(""), |
| 30151 | + /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 30152 | + /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 30153 | + /* 112 */ "Close" OpHelp(""), |
| 30154 | + /* 113 */ "ColumnsUsed" OpHelp(""), |
| 30155 | + /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 30156 | + /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 30157 | + /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 30158 | + /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 30159 | + /* 118 */ "Delete" OpHelp(""), |
| 30160 | + /* 119 */ "ResetCount" OpHelp(""), |
| 30161 | + /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 30162 | + /* 121 */ "SorterData" OpHelp("r[P2]=data"), |
| 30163 | + /* 122 */ "RowData" OpHelp("r[P2]=data"), |
| 30164 | + /* 123 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 30165 | + /* 124 */ "NullRow" OpHelp(""), |
| 30166 | + /* 125 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 30167 | + /* 126 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 30168 | + /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 30169 | + /* 128 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 30170 | + /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 30171 | + /* 130 */ "Destroy" OpHelp(""), |
| 30172 | + /* 131 */ "Clear" OpHelp(""), |
| 30156 | 30173 | /* 132 */ "Real" OpHelp("r[P2]=P4"), |
| 30157 | | - /* 133 */ "Destroy" OpHelp(""), |
| 30158 | | - /* 134 */ "Clear" OpHelp(""), |
| 30159 | | - /* 135 */ "ResetSorter" OpHelp(""), |
| 30160 | | - /* 136 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 30161 | | - /* 137 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 30162 | | - /* 138 */ "SqlExec" OpHelp(""), |
| 30163 | | - /* 139 */ "ParseSchema" OpHelp(""), |
| 30164 | | - /* 140 */ "LoadAnalysis" OpHelp(""), |
| 30165 | | - /* 141 */ "DropTable" OpHelp(""), |
| 30166 | | - /* 142 */ "DropIndex" OpHelp(""), |
| 30167 | | - /* 143 */ "DropTrigger" OpHelp(""), |
| 30168 | | - /* 144 */ "IntegrityCk" OpHelp(""), |
| 30169 | | - /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 30170 | | - /* 146 */ "Param" OpHelp(""), |
| 30171 | | - /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 30172 | | - /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 30173 | | - /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 30174 | | - /* 150 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 30175 | | - /* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 30176 | | - /* 152 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 30177 | | - /* 153 */ "Expire" OpHelp(""), |
| 30178 | | - /* 154 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 30179 | | - /* 155 */ "VBegin" OpHelp(""), |
| 30180 | | - /* 156 */ "VCreate" OpHelp(""), |
| 30181 | | - /* 157 */ "VDestroy" OpHelp(""), |
| 30182 | | - /* 158 */ "VOpen" OpHelp(""), |
| 30183 | | - /* 159 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 30184 | | - /* 160 */ "VRename" OpHelp(""), |
| 30185 | | - /* 161 */ "Pagecount" OpHelp(""), |
| 30186 | | - /* 162 */ "MaxPgcnt" OpHelp(""), |
| 30187 | | - /* 163 */ "CursorHint" OpHelp(""), |
| 30188 | | - /* 164 */ "Noop" OpHelp(""), |
| 30189 | | - /* 165 */ "Explain" OpHelp(""), |
| 30174 | + /* 133 */ "ResetSorter" OpHelp(""), |
| 30175 | + /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 30176 | + /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 30177 | + /* 136 */ "SqlExec" OpHelp(""), |
| 30178 | + /* 137 */ "ParseSchema" OpHelp(""), |
| 30179 | + /* 138 */ "LoadAnalysis" OpHelp(""), |
| 30180 | + /* 139 */ "DropTable" OpHelp(""), |
| 30181 | + /* 140 */ "DropIndex" OpHelp(""), |
| 30182 | + /* 141 */ "DropTrigger" OpHelp(""), |
| 30183 | + /* 142 */ "IntegrityCk" OpHelp(""), |
| 30184 | + /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 30185 | + /* 144 */ "Param" OpHelp(""), |
| 30186 | + /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 30187 | + /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 30188 | + /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 30189 | + /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 30190 | + /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 30191 | + /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 30192 | + /* 151 */ "Expire" OpHelp(""), |
| 30193 | + /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 30194 | + /* 153 */ "VBegin" OpHelp(""), |
| 30195 | + /* 154 */ "VCreate" OpHelp(""), |
| 30196 | + /* 155 */ "VDestroy" OpHelp(""), |
| 30197 | + /* 156 */ "VOpen" OpHelp(""), |
| 30198 | + /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 30199 | + /* 158 */ "VRename" OpHelp(""), |
| 30200 | + /* 159 */ "Pagecount" OpHelp(""), |
| 30201 | + /* 160 */ "MaxPgcnt" OpHelp(""), |
| 30202 | + /* 161 */ "PureFunc0" OpHelp(""), |
| 30203 | + /* 162 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 30204 | + /* 163 */ "PureFunc" OpHelp(""), |
| 30205 | + /* 164 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 30206 | + /* 165 */ "CursorHint" OpHelp(""), |
| 30207 | + /* 166 */ "Noop" OpHelp(""), |
| 30208 | + /* 167 */ "Explain" OpHelp(""), |
| 30190 | 30209 | }; |
| 30191 | 30210 | return azName[i]; |
| 30192 | 30211 | } |
| 30193 | 30212 | #endif |
| 30194 | 30213 | |
| | @@ -70931,15 +70950,18 @@ |
| 70931 | 70950 | |
| 70932 | 70951 | /* |
| 70933 | 70952 | ** Set the value stored in *pMem should already be a NULL. |
| 70934 | 70953 | ** Also store a pointer to go with it. |
| 70935 | 70954 | */ |
| 70936 | | -SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){ |
| 70955 | +SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr, const char *zPType){ |
| 70937 | 70956 | assert( pMem->flags==MEM_Null ); |
| 70938 | | - pMem->flags = MEM_Null|MEM_Subtype; |
| 70939 | | - pMem->u.pPtr = pPtr; |
| 70940 | | - pMem->eSubtype = 'p'; |
| 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 | + } |
| 70941 | 70963 | } |
| 70942 | 70964 | |
| 70943 | 70965 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 70944 | 70966 | /* |
| 70945 | 70967 | ** Delete any previous value and set the value stored in *pMem to val, |
| | @@ -76531,10 +76553,29 @@ |
| 76531 | 76553 | v->expmask |= 0x80000000; |
| 76532 | 76554 | }else{ |
| 76533 | 76555 | v->expmask |= ((u32)1 << (iVar-1)); |
| 76534 | 76556 | } |
| 76535 | 76557 | } |
| 76558 | + |
| 76559 | +/* |
| 76560 | +** Cause a function to throw an error if it was call from OP_PureFunc |
| 76561 | +** rather than OP_Function. |
| 76562 | +** |
| 76563 | +** OP_PureFunc means that the function must be deterministic, and should |
| 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; |
| 76574 | + } |
| 76575 | + return 1; |
| 76576 | +} |
| 76536 | 76577 | |
| 76537 | 76578 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 76538 | 76579 | /* |
| 76539 | 76580 | ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored |
| 76540 | 76581 | ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored |
| | @@ -76841,13 +76882,17 @@ |
| 76841 | 76882 | } |
| 76842 | 76883 | SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){ |
| 76843 | 76884 | Mem *pMem = (Mem*)pVal; |
| 76844 | 76885 | return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0); |
| 76845 | 76886 | } |
| 76846 | | -SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){ |
| 76887 | +SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){ |
| 76847 | 76888 | Mem *p = (Mem*)pVal; |
| 76848 | | - if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){ |
| 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 | + ){ |
| 76849 | 76894 | return p->u.pPtr; |
| 76850 | 76895 | }else{ |
| 76851 | 76896 | return 0; |
| 76852 | 76897 | } |
| 76853 | 76898 | } |
| | @@ -77027,15 +77072,15 @@ |
| 77027 | 77072 | } |
| 77028 | 77073 | SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 77029 | 77074 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 77030 | 77075 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 77031 | 77076 | } |
| 77032 | | -SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){ |
| 77077 | +SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr, const char *zPT){ |
| 77033 | 77078 | Mem *pOut = pCtx->pOut; |
| 77034 | 77079 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77035 | 77080 | sqlite3VdbeMemSetNull(pOut); |
| 77036 | | - sqlite3VdbeMemSetPointer(pOut, pPtr); |
| 77081 | + sqlite3VdbeMemSetPointer(pOut, pPtr, zPT); |
| 77037 | 77082 | } |
| 77038 | 77083 | SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 77039 | 77084 | Mem *pOut = pCtx->pOut; |
| 77040 | 77085 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 77041 | 77086 | pOut->eSubtype = eSubtype & 0xff; |
| | @@ -78036,16 +78081,16 @@ |
| 78036 | 78081 | if( rc==SQLITE_OK ){ |
| 78037 | 78082 | sqlite3_mutex_leave(p->db->mutex); |
| 78038 | 78083 | } |
| 78039 | 78084 | return rc; |
| 78040 | 78085 | } |
| 78041 | | -SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){ |
| 78086 | +SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,const char *zT){ |
| 78042 | 78087 | int rc; |
| 78043 | 78088 | Vdbe *p = (Vdbe*)pStmt; |
| 78044 | 78089 | rc = vdbeUnbind(p, i); |
| 78045 | 78090 | if( rc==SQLITE_OK ){ |
| 78046 | | - sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr); |
| 78091 | + sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT); |
| 78047 | 78092 | sqlite3_mutex_leave(p->db->mutex); |
| 78048 | 78093 | } |
| 78049 | 78094 | return rc; |
| 78050 | 78095 | } |
| 78051 | 78096 | SQLITE_API int sqlite3_bind_text( |
| | @@ -80466,121 +80511,10 @@ |
| 80466 | 80511 | sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0); |
| 80467 | 80512 | } |
| 80468 | 80513 | break; |
| 80469 | 80514 | } |
| 80470 | 80515 | |
| 80471 | | -/* Opcode: Function0 P1 P2 P3 P4 P5 |
| 80472 | | -** Synopsis: r[P3]=func(r[P2@P5]) |
| 80473 | | -** |
| 80474 | | -** Invoke a user function (P4 is a pointer to a FuncDef object that |
| 80475 | | -** defines the function) with P5 arguments taken from register P2 and |
| 80476 | | -** successors. The result of the function is stored in register P3. |
| 80477 | | -** Register P3 must not be one of the function inputs. |
| 80478 | | -** |
| 80479 | | -** P1 is a 32-bit bitmask indicating whether or not each argument to the |
| 80480 | | -** function was determined to be constant at compile time. If the first |
| 80481 | | -** argument was constant then bit 0 of P1 is set. This is used to determine |
| 80482 | | -** whether meta data associated with a user function argument using the |
| 80483 | | -** sqlite3_set_auxdata() API may be safely retained until the next |
| 80484 | | -** invocation of this opcode. |
| 80485 | | -** |
| 80486 | | -** See also: Function, AggStep, AggFinal |
| 80487 | | -*/ |
| 80488 | | -/* Opcode: Function P1 P2 P3 P4 P5 |
| 80489 | | -** Synopsis: r[P3]=func(r[P2@P5]) |
| 80490 | | -** |
| 80491 | | -** Invoke a user function (P4 is a pointer to an sqlite3_context object that |
| 80492 | | -** contains a pointer to the function to be run) with P5 arguments taken |
| 80493 | | -** from register P2 and successors. The result of the function is stored |
| 80494 | | -** in register P3. Register P3 must not be one of the function inputs. |
| 80495 | | -** |
| 80496 | | -** P1 is a 32-bit bitmask indicating whether or not each argument to the |
| 80497 | | -** function was determined to be constant at compile time. If the first |
| 80498 | | -** argument was constant then bit 0 of P1 is set. This is used to determine |
| 80499 | | -** whether meta data associated with a user function argument using the |
| 80500 | | -** sqlite3_set_auxdata() API may be safely retained until the next |
| 80501 | | -** invocation of this opcode. |
| 80502 | | -** |
| 80503 | | -** SQL functions are initially coded as OP_Function0 with P4 pointing |
| 80504 | | -** to a FuncDef object. But on first evaluation, the P4 operand is |
| 80505 | | -** automatically converted into an sqlite3_context object and the operation |
| 80506 | | -** changed to this OP_Function opcode. In this way, the initialization of |
| 80507 | | -** the sqlite3_context object occurs only once, rather than once for each |
| 80508 | | -** evaluation of the function. |
| 80509 | | -** |
| 80510 | | -** See also: Function0, AggStep, AggFinal |
| 80511 | | -*/ |
| 80512 | | -case OP_Function0: { |
| 80513 | | - int n; |
| 80514 | | - sqlite3_context *pCtx; |
| 80515 | | - |
| 80516 | | - assert( pOp->p4type==P4_FUNCDEF ); |
| 80517 | | - n = pOp->p5; |
| 80518 | | - assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 80519 | | - assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) ); |
| 80520 | | - assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n ); |
| 80521 | | - pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*)); |
| 80522 | | - if( pCtx==0 ) goto no_mem; |
| 80523 | | - pCtx->pOut = 0; |
| 80524 | | - pCtx->pFunc = pOp->p4.pFunc; |
| 80525 | | - pCtx->iOp = (int)(pOp - aOp); |
| 80526 | | - pCtx->pVdbe = p; |
| 80527 | | - pCtx->argc = n; |
| 80528 | | - pOp->p4type = P4_FUNCCTX; |
| 80529 | | - pOp->p4.pCtx = pCtx; |
| 80530 | | - pOp->opcode = OP_Function; |
| 80531 | | - /* Fall through into OP_Function */ |
| 80532 | | -} |
| 80533 | | -case OP_Function: { |
| 80534 | | - int i; |
| 80535 | | - sqlite3_context *pCtx; |
| 80536 | | - |
| 80537 | | - assert( pOp->p4type==P4_FUNCCTX ); |
| 80538 | | - pCtx = pOp->p4.pCtx; |
| 80539 | | - |
| 80540 | | - /* If this function is inside of a trigger, the register array in aMem[] |
| 80541 | | - ** might change from one evaluation to the next. The next block of code |
| 80542 | | - ** checks to see if the register array has changed, and if so it |
| 80543 | | - ** reinitializes the relavant parts of the sqlite3_context object */ |
| 80544 | | - pOut = &aMem[pOp->p3]; |
| 80545 | | - if( pCtx->pOut != pOut ){ |
| 80546 | | - pCtx->pOut = pOut; |
| 80547 | | - for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i]; |
| 80548 | | - } |
| 80549 | | - |
| 80550 | | - memAboutToChange(p, pOut); |
| 80551 | | -#ifdef SQLITE_DEBUG |
| 80552 | | - for(i=0; i<pCtx->argc; i++){ |
| 80553 | | - assert( memIsValid(pCtx->argv[i]) ); |
| 80554 | | - REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]); |
| 80555 | | - } |
| 80556 | | -#endif |
| 80557 | | - MemSetTypeFlag(pOut, MEM_Null); |
| 80558 | | - pCtx->fErrorOrAux = 0; |
| 80559 | | - (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */ |
| 80560 | | - |
| 80561 | | - /* If the function returned an error, throw an exception */ |
| 80562 | | - if( pCtx->fErrorOrAux ){ |
| 80563 | | - if( pCtx->isError ){ |
| 80564 | | - sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut)); |
| 80565 | | - rc = pCtx->isError; |
| 80566 | | - } |
| 80567 | | - sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1); |
| 80568 | | - if( rc ) goto abort_due_to_error; |
| 80569 | | - } |
| 80570 | | - |
| 80571 | | - /* Copy the result of the function into register P3 */ |
| 80572 | | - if( pOut->flags & (MEM_Str|MEM_Blob) ){ |
| 80573 | | - sqlite3VdbeChangeEncoding(pOut, encoding); |
| 80574 | | - if( sqlite3VdbeMemTooBig(pOut) ) goto too_big; |
| 80575 | | - } |
| 80576 | | - |
| 80577 | | - REGISTER_TRACE(pOp->p3, pOut); |
| 80578 | | - UPDATE_MAX_BLOBSIZE(pOut); |
| 80579 | | - break; |
| 80580 | | -} |
| 80581 | | - |
| 80582 | 80516 | /* Opcode: BitAnd P1 P2 P3 * * |
| 80583 | 80517 | ** Synopsis: r[P3]=r[P1]&r[P2] |
| 80584 | 80518 | ** |
| 80585 | 80519 | ** Take the bit-wise AND of the values in register P1 and P2 and |
| 80586 | 80520 | ** store the result in register P3. |
| | @@ -85875,10 +85809,125 @@ |
| 85875 | 85809 | } |
| 85876 | 85810 | pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax); |
| 85877 | 85811 | break; |
| 85878 | 85812 | } |
| 85879 | 85813 | #endif |
| 85814 | + |
| 85815 | +/* Opcode: Function0 P1 P2 P3 P4 P5 |
| 85816 | +** Synopsis: r[P3]=func(r[P2@P5]) |
| 85817 | +** |
| 85818 | +** Invoke a user function (P4 is a pointer to a FuncDef object that |
| 85819 | +** defines the function) with P5 arguments taken from register P2 and |
| 85820 | +** successors. The result of the function is stored in register P3. |
| 85821 | +** Register P3 must not be one of the function inputs. |
| 85822 | +** |
| 85823 | +** P1 is a 32-bit bitmask indicating whether or not each argument to the |
| 85824 | +** function was determined to be constant at compile time. If the first |
| 85825 | +** argument was constant then bit 0 of P1 is set. This is used to determine |
| 85826 | +** whether meta data associated with a user function argument using the |
| 85827 | +** sqlite3_set_auxdata() API may be safely retained until the next |
| 85828 | +** invocation of this opcode. |
| 85829 | +** |
| 85830 | +** See also: Function, AggStep, AggFinal |
| 85831 | +*/ |
| 85832 | +/* Opcode: Function P1 P2 P3 P4 P5 |
| 85833 | +** Synopsis: r[P3]=func(r[P2@P5]) |
| 85834 | +** |
| 85835 | +** Invoke a user function (P4 is a pointer to an sqlite3_context object that |
| 85836 | +** contains a pointer to the function to be run) with P5 arguments taken |
| 85837 | +** from register P2 and successors. The result of the function is stored |
| 85838 | +** in register P3. Register P3 must not be one of the function inputs. |
| 85839 | +** |
| 85840 | +** P1 is a 32-bit bitmask indicating whether or not each argument to the |
| 85841 | +** function was determined to be constant at compile time. If the first |
| 85842 | +** argument was constant then bit 0 of P1 is set. This is used to determine |
| 85843 | +** whether meta data associated with a user function argument using the |
| 85844 | +** sqlite3_set_auxdata() API may be safely retained until the next |
| 85845 | +** invocation of this opcode. |
| 85846 | +** |
| 85847 | +** SQL functions are initially coded as OP_Function0 with P4 pointing |
| 85848 | +** to a FuncDef object. But on first evaluation, the P4 operand is |
| 85849 | +** automatically converted into an sqlite3_context object and the operation |
| 85850 | +** changed to this OP_Function opcode. In this way, the initialization of |
| 85851 | +** the sqlite3_context object occurs only once, rather than once for each |
| 85852 | +** evaluation of the function. |
| 85853 | +** |
| 85854 | +** See also: Function0, AggStep, AggFinal |
| 85855 | +*/ |
| 85856 | +case OP_PureFunc0: |
| 85857 | +case OP_Function0: { |
| 85858 | + int n; |
| 85859 | + sqlite3_context *pCtx; |
| 85860 | + |
| 85861 | + assert( pOp->p4type==P4_FUNCDEF ); |
| 85862 | + n = pOp->p5; |
| 85863 | + assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 85864 | + assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) ); |
| 85865 | + assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n ); |
| 85866 | + pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*)); |
| 85867 | + if( pCtx==0 ) goto no_mem; |
| 85868 | + pCtx->pOut = 0; |
| 85869 | + pCtx->pFunc = pOp->p4.pFunc; |
| 85870 | + pCtx->iOp = (int)(pOp - aOp); |
| 85871 | + pCtx->pVdbe = p; |
| 85872 | + pCtx->argc = n; |
| 85873 | + pOp->p4type = P4_FUNCCTX; |
| 85874 | + pOp->p4.pCtx = pCtx; |
| 85875 | + assert( OP_PureFunc == OP_PureFunc0+2 ); |
| 85876 | + assert( OP_Function == OP_Function0+2 ); |
| 85877 | + pOp->opcode += 2; |
| 85878 | + /* Fall through into OP_Function */ |
| 85879 | +} |
| 85880 | +case OP_PureFunc: |
| 85881 | +case OP_Function: { |
| 85882 | + int i; |
| 85883 | + sqlite3_context *pCtx; |
| 85884 | + |
| 85885 | + assert( pOp->p4type==P4_FUNCCTX ); |
| 85886 | + pCtx = pOp->p4.pCtx; |
| 85887 | + |
| 85888 | + /* If this function is inside of a trigger, the register array in aMem[] |
| 85889 | + ** might change from one evaluation to the next. The next block of code |
| 85890 | + ** checks to see if the register array has changed, and if so it |
| 85891 | + ** reinitializes the relavant parts of the sqlite3_context object */ |
| 85892 | + pOut = &aMem[pOp->p3]; |
| 85893 | + if( pCtx->pOut != pOut ){ |
| 85894 | + pCtx->pOut = pOut; |
| 85895 | + for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i]; |
| 85896 | + } |
| 85897 | + |
| 85898 | + memAboutToChange(p, pOut); |
| 85899 | +#ifdef SQLITE_DEBUG |
| 85900 | + for(i=0; i<pCtx->argc; i++){ |
| 85901 | + assert( memIsValid(pCtx->argv[i]) ); |
| 85902 | + REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]); |
| 85903 | + } |
| 85904 | +#endif |
| 85905 | + MemSetTypeFlag(pOut, MEM_Null); |
| 85906 | + pCtx->fErrorOrAux = 0; |
| 85907 | + (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */ |
| 85908 | + |
| 85909 | + /* If the function returned an error, throw an exception */ |
| 85910 | + if( pCtx->fErrorOrAux ){ |
| 85911 | + if( pCtx->isError ){ |
| 85912 | + sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut)); |
| 85913 | + rc = pCtx->isError; |
| 85914 | + } |
| 85915 | + sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1); |
| 85916 | + if( rc ) goto abort_due_to_error; |
| 85917 | + } |
| 85918 | + |
| 85919 | + /* Copy the result of the function into register P3 */ |
| 85920 | + if( pOut->flags & (MEM_Str|MEM_Blob) ){ |
| 85921 | + sqlite3VdbeChangeEncoding(pOut, encoding); |
| 85922 | + if( sqlite3VdbeMemTooBig(pOut) ) goto too_big; |
| 85923 | + } |
| 85924 | + |
| 85925 | + REGISTER_TRACE(pOp->p3, pOut); |
| 85926 | + UPDATE_MAX_BLOBSIZE(pOut); |
| 85927 | + break; |
| 85928 | +} |
| 85880 | 85929 | |
| 85881 | 85930 | |
| 85882 | 85931 | /* Opcode: Init P1 P2 * P4 * |
| 85883 | 85932 | ** Synopsis: Start at P2 |
| 85884 | 85933 | ** |
| | @@ -94727,12 +94776,13 @@ |
| 94727 | 94776 | ){ |
| 94728 | 94777 | i16 iTabCol = pIdx->aiColumn[iIdxCol]; |
| 94729 | 94778 | if( iTabCol==XN_EXPR ){ |
| 94730 | 94779 | assert( pIdx->aColExpr ); |
| 94731 | 94780 | assert( pIdx->aColExpr->nExpr>iIdxCol ); |
| 94732 | | - pParse->iSelfTab = iTabCur; |
| 94781 | + pParse->iSelfTab = iTabCur + 1; |
| 94733 | 94782 | sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); |
| 94783 | + pParse->iSelfTab = 0; |
| 94734 | 94784 | }else{ |
| 94735 | 94785 | sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, |
| 94736 | 94786 | iTabCol, regOut); |
| 94737 | 94787 | } |
| 94738 | 94788 | } |
| | @@ -94972,17 +95022,17 @@ |
| 94972 | 95022 | /* Otherwise, fall thru into the TK_COLUMN case */ |
| 94973 | 95023 | } |
| 94974 | 95024 | case TK_COLUMN: { |
| 94975 | 95025 | int iTab = pExpr->iTable; |
| 94976 | 95026 | if( iTab<0 ){ |
| 94977 | | - if( pParse->ckBase>0 ){ |
| 95027 | + if( pParse->iSelfTab<0 ){ |
| 94978 | 95028 | /* Generating CHECK constraints or inserting into partial index */ |
| 94979 | | - return pExpr->iColumn + pParse->ckBase; |
| 95029 | + return pExpr->iColumn - pParse->iSelfTab; |
| 94980 | 95030 | }else{ |
| 94981 | 95031 | /* Coding an expression that is part of an index where column names |
| 94982 | 95032 | ** in the index refer to the table to which the index belongs */ |
| 94983 | | - iTab = pParse->iSelfTab; |
| 95033 | + iTab = pParse->iSelfTab - 1; |
| 94984 | 95034 | } |
| 94985 | 95035 | } |
| 94986 | 95036 | return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 94987 | 95037 | pExpr->iColumn, iTab, target, |
| 94988 | 95038 | pExpr->op2); |
| | @@ -95315,12 +95365,12 @@ |
| 95315 | 95365 | #endif |
| 95316 | 95366 | if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 95317 | 95367 | if( !pColl ) pColl = db->pDfltColl; |
| 95318 | 95368 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 95319 | 95369 | } |
| 95320 | | - sqlite3VdbeAddOp4(v, OP_Function0, constMask, r1, target, |
| 95321 | | - (char*)pDef, P4_FUNCDEF); |
| 95370 | + sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0, |
| 95371 | + constMask, r1, target, (char*)pDef, P4_FUNCDEF); |
| 95322 | 95372 | sqlite3VdbeChangeP5(v, (u8)nFarg); |
| 95323 | 95373 | if( nFarg && constMask==0 ){ |
| 95324 | 95374 | sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 95325 | 95375 | } |
| 95326 | 95376 | return target; |
| | @@ -96744,12 +96794,12 @@ |
| 96744 | 96794 | */ |
| 96745 | 96795 | #ifdef SQLITE_DEBUG |
| 96746 | 96796 | SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){ |
| 96747 | 96797 | int i; |
| 96748 | 96798 | if( pParse->nRangeReg>0 |
| 96749 | | - && pParse->iRangeReg+pParse->nRangeReg<iLast |
| 96750 | | - && pParse->iRangeReg>=iFirst |
| 96799 | + && pParse->iRangeReg+pParse->nRangeReg > iFirst |
| 96800 | + && pParse->iRangeReg <= iLast |
| 96751 | 96801 | ){ |
| 96752 | 96802 | return 0; |
| 96753 | 96803 | } |
| 96754 | 96804 | for(i=0; i<pParse->nTempReg; i++){ |
| 96755 | 96805 | if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){ |
| | @@ -106134,14 +106184,15 @@ |
| 106134 | 106184 | int nCol; |
| 106135 | 106185 | |
| 106136 | 106186 | if( piPartIdxLabel ){ |
| 106137 | 106187 | if( pIdx->pPartIdxWhere ){ |
| 106138 | 106188 | *piPartIdxLabel = sqlite3VdbeMakeLabel(v); |
| 106139 | | - pParse->iSelfTab = iDataCur; |
| 106189 | + pParse->iSelfTab = iDataCur + 1; |
| 106140 | 106190 | sqlite3ExprCachePush(pParse); |
| 106141 | 106191 | sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, |
| 106142 | 106192 | SQLITE_JUMPIFNULL); |
| 106193 | + pParse->iSelfTab = 0; |
| 106143 | 106194 | }else{ |
| 106144 | 106195 | *piPartIdxLabel = 0; |
| 106145 | 106196 | } |
| 106146 | 106197 | } |
| 106147 | 106198 | nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn; |
| | @@ -110823,11 +110874,11 @@ |
| 110823 | 110874 | /* Test all CHECK constraints |
| 110824 | 110875 | */ |
| 110825 | 110876 | #ifndef SQLITE_OMIT_CHECK |
| 110826 | 110877 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 110827 | 110878 | ExprList *pCheck = pTab->pCheck; |
| 110828 | | - pParse->ckBase = regNewData+1; |
| 110879 | + pParse->iSelfTab = -(regNewData+1); |
| 110829 | 110880 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 110830 | 110881 | for(i=0; i<pCheck->nExpr; i++){ |
| 110831 | 110882 | int allOk; |
| 110832 | 110883 | Expr *pExpr = pCheck->a[i].pExpr; |
| 110833 | 110884 | if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue; |
| | @@ -110843,10 +110894,11 @@ |
| 110843 | 110894 | onError, zName, P4_TRANSIENT, |
| 110844 | 110895 | P5_ConstraintCheck); |
| 110845 | 110896 | } |
| 110846 | 110897 | sqlite3VdbeResolveLabel(v, allOk); |
| 110847 | 110898 | } |
| 110899 | + pParse->iSelfTab = 0; |
| 110848 | 110900 | } |
| 110849 | 110901 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 110850 | 110902 | |
| 110851 | 110903 | /* If rowid is changing, make sure the new rowid does not previously |
| 110852 | 110904 | ** exist in the table. |
| | @@ -110987,14 +111039,14 @@ |
| 110987 | 111039 | addrUniqueOk = sqlite3VdbeMakeLabel(v); |
| 110988 | 111040 | |
| 110989 | 111041 | /* Skip partial indices for which the WHERE clause is not true */ |
| 110990 | 111042 | if( pIdx->pPartIdxWhere ){ |
| 110991 | 111043 | sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]); |
| 110992 | | - pParse->ckBase = regNewData+1; |
| 111044 | + pParse->iSelfTab = -(regNewData+1); |
| 110993 | 111045 | sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk, |
| 110994 | 111046 | SQLITE_JUMPIFNULL); |
| 110995 | | - pParse->ckBase = 0; |
| 111047 | + pParse->iSelfTab = 0; |
| 110996 | 111048 | } |
| 110997 | 111049 | |
| 110998 | 111050 | /* Create a record for this index entry as it should appear after |
| 110999 | 111051 | ** the insert or update. Store that record in the aRegIdx[ix] register |
| 111000 | 111052 | */ |
| | @@ -111001,13 +111053,13 @@ |
| 111001 | 111053 | regIdx = aRegIdx[ix]+1; |
| 111002 | 111054 | for(i=0; i<pIdx->nColumn; i++){ |
| 111003 | 111055 | int iField = pIdx->aiColumn[i]; |
| 111004 | 111056 | int x; |
| 111005 | 111057 | if( iField==XN_EXPR ){ |
| 111006 | | - pParse->ckBase = regNewData+1; |
| 111058 | + pParse->iSelfTab = -(regNewData+1); |
| 111007 | 111059 | sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); |
| 111008 | | - pParse->ckBase = 0; |
| 111060 | + pParse->iSelfTab = 0; |
| 111009 | 111061 | VdbeComment((v, "%s column %d", pIdx->zName, i)); |
| 111010 | 111062 | }else{ |
| 111011 | 111063 | if( iField==XN_ROWID || iField==pTab->iPKey ){ |
| 111012 | 111064 | x = regNewData; |
| 111013 | 111065 | }else{ |
| | @@ -112207,13 +112259,13 @@ |
| 112207 | 112259 | /* Version 3.20.0 and later */ |
| 112208 | 112260 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, |
| 112209 | 112261 | sqlite3_stmt**,const char**); |
| 112210 | 112262 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, |
| 112211 | 112263 | sqlite3_stmt**,const void**); |
| 112212 | | - int (*bind_pointer)(sqlite3_stmt*,int,void*); |
| 112213 | | - void (*result_pointer)(sqlite3_context*,void*); |
| 112214 | | - void *(*value_pointer)(sqlite3_value*); |
| 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*); |
| 112215 | 112267 | }; |
| 112216 | 112268 | |
| 112217 | 112269 | /* |
| 112218 | 112270 | ** This is the function signature used for all extension entry points. It |
| 112219 | 112271 | ** is also defined in the file "loadext.c". |
| | @@ -115461,10 +115513,11 @@ |
| 115461 | 115513 | } |
| 115462 | 115514 | aRoot[cnt] = 0; |
| 115463 | 115515 | |
| 115464 | 115516 | /* Make sure sufficient number of registers have been allocated */ |
| 115465 | 115517 | pParse->nMem = MAX( pParse->nMem, 8+mxIdx ); |
| 115518 | + sqlite3ClearTempRegCache(pParse); |
| 115466 | 115519 | |
| 115467 | 115520 | /* Do the b-tree integrity checks */ |
| 115468 | 115521 | sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY); |
| 115469 | 115522 | sqlite3VdbeChangeP5(v, (u8)i); |
| 115470 | 115523 | addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v); |
| | @@ -115526,18 +115579,19 @@ |
| 115526 | 115579 | if( db->mallocFailed==0 ){ |
| 115527 | 115580 | int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 115528 | 115581 | int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 115529 | 115582 | char *zErr; |
| 115530 | 115583 | int k; |
| 115531 | | - pParse->iSelfTab = iDataCur; |
| 115584 | + pParse->iSelfTab = iDataCur + 1; |
| 115532 | 115585 | sqlite3ExprCachePush(pParse); |
| 115533 | 115586 | for(k=pCheck->nExpr-1; k>0; k--){ |
| 115534 | 115587 | sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 115535 | 115588 | } |
| 115536 | 115589 | sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 115537 | 115590 | SQLITE_JUMPIFNULL); |
| 115538 | 115591 | sqlite3VdbeResolveLabel(v, addrCkFault); |
| 115592 | + pParse->iSelfTab = 0; |
| 115539 | 115593 | zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 115540 | 115594 | pTab->zName); |
| 115541 | 115595 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 115542 | 115596 | integrityCheckResultRow(v, 3); |
| 115543 | 115597 | sqlite3VdbeResolveLabel(v, addrCkOk); |
| | @@ -115875,11 +115929,12 @@ |
| 115875 | 115929 | ** pragmas run by future database connections. |
| 115876 | 115930 | ** |
| 115877 | 115931 | ** 0x0008 (Not yet implemented) Create indexes that might have |
| 115878 | 115932 | ** been helpful to recent queries |
| 115879 | 115933 | ** |
| 115880 | | - ** The default MASK is and always shall be 0xfffe. 0xfffe means perform all ** of the optimizations listed above except Debug Mode, including new |
| 115934 | + ** The default MASK is and always shall be 0xfffe. 0xfffe means perform all |
| 115935 | + ** of the optimizations listed above except Debug Mode, including new |
| 115881 | 115936 | ** optimizations that have not yet been invented. If new optimizations are |
| 115882 | 115937 | ** ever added that should be off by default, those off-by-default |
| 115883 | 115938 | ** optimizations will have bitmasks of 0x10000 or larger. |
| 115884 | 115939 | ** |
| 115885 | 115940 | ** DETERMINATION OF WHEN TO RUN ANALYZE |
| | @@ -116302,14 +116357,18 @@ |
| 116302 | 116357 | UNUSED_PARAMETER(idxNum); |
| 116303 | 116358 | UNUSED_PARAMETER(idxStr); |
| 116304 | 116359 | pragmaVtabCursorClear(pCsr); |
| 116305 | 116360 | j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1; |
| 116306 | 116361 | for(i=0; i<argc; i++, j++){ |
| 116362 | + const char *zText = (const char*)sqlite3_value_text(argv[i]); |
| 116307 | 116363 | assert( j<ArraySize(pCsr->azArg) ); |
| 116308 | | - pCsr->azArg[j] = sqlite3_mprintf("%s", sqlite3_value_text(argv[i])); |
| 116309 | | - if( pCsr->azArg[j]==0 ){ |
| 116310 | | - return SQLITE_NOMEM; |
| 116364 | + assert( pCsr->azArg[j]==0 ); |
| 116365 | + if( zText ){ |
| 116366 | + pCsr->azArg[j] = sqlite3_mprintf("%s", zText); |
| 116367 | + if( pCsr->azArg[j]==0 ){ |
| 116368 | + return SQLITE_NOMEM; |
| 116369 | + } |
| 116311 | 116370 | } |
| 116312 | 116371 | } |
| 116313 | 116372 | sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]); |
| 116314 | 116373 | sqlite3StrAccumAppendAll(&acc, "PRAGMA "); |
| 116315 | 116374 | if( pCsr->azArg[1] ){ |
| | @@ -120659,12 +120718,13 @@ |
| 120659 | 120718 | ** and (2b) the outer query does not use subqueries other than the one |
| 120660 | 120719 | ** FROM-clause subquery that is a candidate for flattening. (2b is |
| 120661 | 120720 | ** due to ticket [2f7170d73bf9abf80] from 2015-02-09.) |
| 120662 | 120721 | ** |
| 120663 | 120722 | ** (3) The subquery is not the right operand of a LEFT JOIN |
| 120664 | | -** or the subquery is not itself a join and the outer query is not |
| 120665 | | -** an aggregate. |
| 120723 | +** or (a) the subquery is not itself a join and (b) the FROM clause |
| 120724 | +** of the subquery does not contain a virtual table and (c) the |
| 120725 | +** outer query is not an aggregate. |
| 120666 | 120726 | ** |
| 120667 | 120727 | ** (4) The subquery is not DISTINCT. |
| 120668 | 120728 | ** |
| 120669 | 120729 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 120670 | 120730 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -120865,11 +120925,11 @@ |
| 120865 | 120925 | ** |
| 120866 | 120926 | ** See also tickets #306, #350, and #3300. |
| 120867 | 120927 | */ |
| 120868 | 120928 | if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 120869 | 120929 | isLeftJoin = 1; |
| 120870 | | - if( pSubSrc->nSrc>1 || isAgg ){ |
| 120930 | + if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){ |
| 120871 | 120931 | return 0; /* Restriction (3) */ |
| 120872 | 120932 | } |
| 120873 | 120933 | } |
| 120874 | 120934 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 120875 | 120935 | else if( iFrom>0 && !isAgg ){ |
| | @@ -131980,10 +132040,19 @@ |
| 131980 | 132040 | Bitmask notReady /* Tables in outer loops of the join */ |
| 131981 | 132041 | ){ |
| 131982 | 132042 | char aff; |
| 131983 | 132043 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 131984 | 132044 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 132045 | + if( (pSrc->fg.jointype & JT_LEFT) |
| 132046 | + && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 132047 | + && (pTerm->eOperator & WO_IS) |
| 132048 | + ){ |
| 132049 | + /* Cannot use an IS term from the WHERE clause as an index driver for |
| 132050 | + ** the RHS of a LEFT JOIN. Such a term can only be used if it is from |
| 132051 | + ** the ON clause. */ |
| 132052 | + return 0; |
| 132053 | + } |
| 131985 | 132054 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 131986 | 132055 | if( pTerm->u.leftColumn<0 ) return 0; |
| 131987 | 132056 | aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity; |
| 131988 | 132057 | if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; |
| 131989 | 132058 | testcase( pTerm->pExpr->op==TK_IS ); |
| | @@ -150278,11 +150347,11 @@ |
| 150278 | 150347 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 150279 | 150348 | |
| 150280 | 150349 | switch( iCol-p->nColumn ){ |
| 150281 | 150350 | case 0: |
| 150282 | 150351 | /* The special 'table-name' column */ |
| 150283 | | - sqlite3_result_pointer(pCtx, pCsr); |
| 150352 | + sqlite3_result_pointer(pCtx, pCsr, "fts3cursor"); |
| 150284 | 150353 | break; |
| 150285 | 150354 | |
| 150286 | 150355 | case 1: |
| 150287 | 150356 | /* The docid column */ |
| 150288 | 150357 | sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| | @@ -150497,11 +150566,11 @@ |
| 150497 | 150566 | const char *zFunc, /* Function name */ |
| 150498 | 150567 | sqlite3_value *pVal, /* argv[0] passed to function */ |
| 150499 | 150568 | Fts3Cursor **ppCsr /* OUT: Store cursor handle here */ |
| 150500 | 150569 | ){ |
| 150501 | 150570 | int rc; |
| 150502 | | - *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal); |
| 150571 | + *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, "fts3cursor"); |
| 150503 | 150572 | if( (*ppCsr)!=0 ){ |
| 150504 | 150573 | rc = SQLITE_OK; |
| 150505 | 150574 | }else{ |
| 150506 | 150575 | char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc); |
| 150507 | 150576 | sqlite3_result_error(pContext, zErr, -1); |
| | @@ -200196,19 +200265,18 @@ |
| 200196 | 200265 | } |
| 200197 | 200266 | |
| 200198 | 200267 | static void fts5Fts5Func( |
| 200199 | 200268 | sqlite3_context *pCtx, /* Function call context */ |
| 200200 | 200269 | int nArg, /* Number of args */ |
| 200201 | | - sqlite3_value **apUnused /* Function arguments */ |
| 200270 | + sqlite3_value **apArg /* Function arguments */ |
| 200202 | 200271 | ){ |
| 200203 | 200272 | Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx); |
| 200204 | | - char buf[8]; |
| 200205 | | - UNUSED_PARAM2(nArg, apUnused); |
| 200206 | | - assert( nArg==0 ); |
| 200207 | | - assert( sizeof(buf)>=sizeof(pGlobal) ); |
| 200208 | | - memcpy(buf, (void*)&pGlobal, sizeof(pGlobal)); |
| 200209 | | - sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT); |
| 200273 | + fts5_api **ppApi; |
| 200274 | + UNUSED_PARAM(nArg); |
| 200275 | + assert( nArg==1 ); |
| 200276 | + ppApi = (fts5_api**)sqlite3_value_pointer(apArg[0], "fts5_api_ptr"); |
| 200277 | + if( ppApi ) *ppApi = &pGlobal->api; |
| 200210 | 200278 | } |
| 200211 | 200279 | |
| 200212 | 200280 | /* |
| 200213 | 200281 | ** Implementation of fts5_source_id() function. |
| 200214 | 200282 | */ |
| | @@ -200217,11 +200285,11 @@ |
| 200217 | 200285 | int nArg, /* Number of args */ |
| 200218 | 200286 | sqlite3_value **apUnused /* Function arguments */ |
| 200219 | 200287 | ){ |
| 200220 | 200288 | assert( nArg==0 ); |
| 200221 | 200289 | UNUSED_PARAM2(nArg, apUnused); |
| 200222 | | - sqlite3_result_text(pCtx, "fts5: 2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6", -1, SQLITE_TRANSIENT); |
| 200290 | + sqlite3_result_text(pCtx, "fts5: 2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51", -1, SQLITE_TRANSIENT); |
| 200223 | 200291 | } |
| 200224 | 200292 | |
| 200225 | 200293 | static int fts5Init(sqlite3 *db){ |
| 200226 | 200294 | static const sqlite3_module fts5Mod = { |
| 200227 | 200295 | /* iVersion */ 2, |
| | @@ -200269,11 +200337,11 @@ |
| 200269 | 200337 | if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api); |
| 200270 | 200338 | if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api); |
| 200271 | 200339 | if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db); |
| 200272 | 200340 | if( rc==SQLITE_OK ){ |
| 200273 | 200341 | rc = sqlite3_create_function( |
| 200274 | | - db, "fts5", 0, SQLITE_UTF8, p, fts5Fts5Func, 0, 0 |
| 200342 | + db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0 |
| 200275 | 200343 | ); |
| 200276 | 200344 | } |
| 200277 | 200345 | if( rc==SQLITE_OK ){ |
| 200278 | 200346 | rc = sqlite3_create_function( |
| 200279 | 200347 | db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0 |
| 200280 | 200348 | |