Fossil SCM

Update the built-in SQLite to the second 3.20.0 release candidate.

drh 2017-07-24 14:26 trunk
Commit c45b8f4534682a21e89715e72b20f08e0327b6f3f2d8e8bcbd367c21a2441941
3 files changed +1 -2 +410 -342 +16 -14
+1 -2
--- src/shell.c
+++ src/shell.c
@@ -8373,11 +8373,11 @@
83738373
#elif HAVE_LINENOISE
83748374
linenoiseSetCompletionCallback(linenoise_completion);
83758375
#endif
83768376
rc = process_input(&data, 0);
83778377
if( zHistory ){
8378
- shell_stifle_history(100);
8378
+ shell_stifle_history(2000);
83798379
shell_write_history(zHistory);
83808380
free(zHistory);
83818381
}
83828382
}else{
83838383
rc = process_input(&data, stdin);
@@ -8394,6 +8394,5 @@
83948394
for(i=0; i<argc; i++) sqlite3_free(argv[i]);
83958395
sqlite3_free(argv);
83968396
#endif
83978397
return rc;
83988398
}
8399
-
84008399
--- src/shell.c
+++ src/shell.c
@@ -8373,11 +8373,11 @@
8373 #elif HAVE_LINENOISE
8374 linenoiseSetCompletionCallback(linenoise_completion);
8375 #endif
8376 rc = process_input(&data, 0);
8377 if( zHistory ){
8378 shell_stifle_history(100);
8379 shell_write_history(zHistory);
8380 free(zHistory);
8381 }
8382 }else{
8383 rc = process_input(&data, stdin);
@@ -8394,6 +8394,5 @@
8394 for(i=0; i<argc; i++) sqlite3_free(argv[i]);
8395 sqlite3_free(argv);
8396 #endif
8397 return rc;
8398 }
8399
8400
--- src/shell.c
+++ src/shell.c
@@ -8373,11 +8373,11 @@
8373 #elif HAVE_LINENOISE
8374 linenoiseSetCompletionCallback(linenoise_completion);
8375 #endif
8376 rc = process_input(&data, 0);
8377 if( zHistory ){
8378 shell_stifle_history(2000);
8379 shell_write_history(zHistory);
8380 free(zHistory);
8381 }
8382 }else{
8383 rc = process_input(&data, stdin);
@@ -8394,6 +8394,5 @@
8394 for(i=0; i<argc; i++) sqlite3_free(argv[i]);
8395 sqlite3_free(argv);
8396 #endif
8397 return rc;
8398 }
 
8399
+410 -342
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
11501150
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11511151
** [sqlite_version()] and [sqlite_source_id()].
11521152
*/
11531153
#define SQLITE_VERSION "3.20.0"
11541154
#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"
11561156
11571157
/*
11581158
** CAPI3REF: Run-Time Library Version Numbers
11591159
** KEYWORDS: sqlite3_version sqlite3_sourceid
11601160
**
@@ -4672,11 +4672,11 @@
46724672
);
46734673
SQLITE_API int sqlite3_prepare16_v3(
46744674
sqlite3 *db, /* Database handle */
46754675
const void *zSql, /* SQL statement, UTF-16 encoded */
46764676
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 */
46784678
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
46794679
const void **pzTail /* OUT: Pointer to unused portion of zSql */
46804680
);
46814681
46824682
/*
@@ -4910,18 +4910,18 @@
49104910
** Zeroblobs are intended to serve as placeholders for BLOBs whose
49114911
** content is later written using
49124912
** [sqlite3_blob_open | incremental BLOB I/O] routines.
49134913
** ^A negative value for the zeroblob results in a zero-length BLOB.
49144914
**
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
49164916
** [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.
49184918
** ^The sqlite3_bind_pointer() routine can be used to pass
49194919
** host-language pointers into [application-defined SQL functions].
49204920
** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
49214921
** 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.
49234923
**
49244924
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
49254925
** for the [prepared statement] or with a prepared statement for which
49264926
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
49274927
** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -4952,11 +4952,11 @@
49524952
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
49534953
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
49544954
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
49554955
void(*)(void*), unsigned char encoding);
49564956
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*);
49584958
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
49594959
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
49604960
49614961
/*
49624962
** CAPI3REF: Number Of SQL Parameters
@@ -5785,13 +5785,14 @@
57855785
** in the native byte-order of the host machine. ^The
57865786
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
57875787
** extract UTF-16 strings as big-endian and little-endian respectively.
57885788
**
57895789
** ^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.
57935794
**
57945795
** ^(The sqlite3_value_type(V) interface returns the
57955796
** [SQLITE_INTEGER | datatype code] for the initial datatype of the
57965797
** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
57975798
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -5821,11 +5822,11 @@
58215822
*/
58225823
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
58235824
SQLITE_API double sqlite3_value_double(sqlite3_value*);
58245825
SQLITE_API int sqlite3_value_int(sqlite3_value*);
58255826
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*);
58275828
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
58285829
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
58295830
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
58305831
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
58315832
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -6122,15 +6123,16 @@
61226123
** be deallocated after sqlite3_result_value() returns without harm.
61236124
** ^A [protected sqlite3_value] object may always be used where an
61246125
** [unprotected sqlite3_value] object is required, so either
61256126
** kind of [sqlite3_value] object can be used with this interface.
61266127
**
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
61286129
** 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
61316132
** [application-defined SQL function] using [sqlite3_value_pointer()].
6133
+** The T parameter should be a static string.
61326134
** This mechanism can be used to pass non-SQL values between
61336135
** application-defined functions.
61346136
**
61356137
** If these routines are called from within the different thread
61366138
** than the one containing the application-defined function that received
@@ -6153,11 +6155,11 @@
61536155
void(*)(void*), unsigned char encoding);
61546156
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
61556157
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
61566158
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
61576159
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*);
61596161
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
61606162
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
61616163
61626164
61636165
/*
@@ -13750,16 +13752,16 @@
1375013752
#define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
1375113753
#define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */
1375213754
#define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */
1375313755
#define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */
1375413756
#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 */
1375613758
#define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1375713759
#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
1376113763
#define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1376213764
#define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1376313765
#define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */
1376413766
#define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */
1376513767
#define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */
@@ -13775,82 +13777,84 @@
1377513777
#define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1377613778
#define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1377713779
#define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1377813780
#define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1377913781
#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] */
1378113783
#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 */
1378313785
#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
1381813820
#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
1385213856
1385313857
/* Properties such as "out2" or "jump" that are specified in
1385413858
** comments following the "case" for each opcode in the vdbe.c
1385513859
** are encoded into bitvectors as follows:
1385613860
*/
@@ -13867,23 +13871,24 @@
1386713871
/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
1386813872
/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
1386913873
/* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\
1387013874
/* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\
1387113875
/* 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,\
1387413878
/* 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,\
1387713881
/* 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
+}
1388513890
1388613891
/* The sqlite3P2Values() routine is able to run faster if it knows
1388713892
** the value of the largest JUMP opcode. The smaller the maximum
1388813893
** JUMP opcode the better, so the mkopcodeh.tcl script that
1388913894
** generated this include file strives to group all JUMP opcodes
@@ -13977,10 +13982,12 @@
1397713982
SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
1397813983
1397913984
#ifndef SQLITE_OMIT_TRIGGER
1398013985
SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
1398113986
#endif
13987
+
13988
+SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
1398213989
1398313990
/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
1398413991
** each VDBE opcode.
1398513992
**
1398613993
** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op
@@ -15356,11 +15363,18 @@
1535615363
**
1535715364
** DFUNCTION(zName, nArg, iArg, bNC, xFunc)
1535815365
** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
1535915366
** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions
1536015367
** 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.
1536215376
**
1536315377
** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
1536415378
** Used to create an aggregate function definition implemented by
1536515379
** the C functions xStep and xFinal. The first four parameters
1536615380
** are interpreted in the same way as the first 4 parameters to
@@ -15379,12 +15393,15 @@
1537915393
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
1538015394
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
1538115395
{nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
1538215396
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
1538315397
#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} }
1538615403
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
1538715404
{nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
1538815405
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
1538915406
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
1539015407
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
@@ -16681,12 +16698,12 @@
1668116698
int nErr; /* Number of errors seen */
1668216699
int nTab; /* Number of previously allocated VDBE cursors */
1668316700
int nMem; /* Number of memory cells used so far */
1668416701
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
1668516702
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 */
1668816705
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
1668916706
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
1669016707
int nLabel; /* Number of labels used */
1669116708
int *aLabel; /* Space to hold the labels */
1669216709
ExprList *pConstExpr;/* Constant expressions */
@@ -18915,11 +18932,11 @@
1891518932
#ifdef SQLITE_OMIT_FLOATING_POINT
1891618933
# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
1891718934
#else
1891818935
SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
1891918936
#endif
18920
-SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*);
18937
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*);
1892118938
SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
1892218939
SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
1892318940
SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
1892418941
SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
1892518942
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
@@ -19721,11 +19738,11 @@
1972119738
double r;
1972219739
if( parseYyyyMmDd(zDate,p)==0 ){
1972319740
return 0;
1972419741
}else if( parseHhMmSs(zDate, p)==0 ){
1972519742
return 0;
19726
- }else if( sqlite3StrICmp(zDate,"now")==0){
19743
+ }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
1972719744
return setDateTimeToCurrent(context, p);
1972819745
}else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){
1972919746
setRawDateNumber(p, r);
1973019747
return 0;
1973119748
}
@@ -20004,11 +20021,11 @@
2000420021
/* localtime
2000520022
**
2000620023
** Assuming the current time value is UTC (a.k.a. GMT), shift it to
2000720024
** show local time.
2000820025
*/
20009
- if( sqlite3_stricmp(z, "localtime")==0 ){
20026
+ if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
2001020027
computeJD(p);
2001120028
p->iJD += localtimeOffset(p, pCtx, &rc);
2001220029
clearYMD_HMS_TZ(p);
2001320030
}
2001420031
break;
@@ -20030,11 +20047,11 @@
2003020047
p->rawS = 0;
2003120048
rc = 0;
2003220049
}
2003320050
}
2003420051
#ifndef SQLITE_OMIT_LOCALTIME
20035
- else if( sqlite3_stricmp(z, "utc")==0 ){
20052
+ else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
2003620053
if( p->tzSet==0 ){
2003720054
sqlite3_int64 c1;
2003820055
computeJD(p);
2003920056
c1 = localtimeOffset(p, pCtx, &rc);
2004020057
if( rc==SQLITE_OK ){
@@ -20566,15 +20583,15 @@
2056620583
** external linkage.
2056720584
*/
2056820585
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
2056920586
static FuncDef aDateTimeFuncs[] = {
2057020587
#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 ),
2057620593
DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
2057720594
DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
2057820595
DFUNCTION(current_date, 0, 0, 0, cdateFunc ),
2057920596
#else
2058020597
STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc),
@@ -30088,16 +30105,16 @@
3008830105
/* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
3008930106
/* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"),
3009030107
/* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
3009130108
/* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"),
3009230109
/* 68 */ "CollSeq" OpHelp(""),
30093
- /* 69 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
30110
+ /* 69 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
3009430111
/* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
3009530112
/* 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(""),
3009930116
/* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
3010030117
/* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
3010130118
/* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
3010230119
/* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
3010330120
/* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
@@ -30113,82 +30130,84 @@
3011330130
/* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
3011430131
/* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
3011530132
/* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
3011630133
/* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
3011730134
/* 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]"),
3011930136
/* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
30120
- /* 96 */ "Permutation" OpHelp(""),
30137
+ /* 96 */ "Column" OpHelp("r[P3]=PX"),
3012130138
/* 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(""),
3015630173
/* 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(""),
3019030209
};
3019130210
return azName[i];
3019230211
}
3019330212
#endif
3019430213
@@ -70931,15 +70950,18 @@
7093170950
7093270951
/*
7093370952
** Set the value stored in *pMem should already be a NULL.
7093470953
** Also store a pointer to go with it.
7093570954
*/
70936
-SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
70955
+SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr, const char *zPType){
7093770956
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
+ }
7094170963
}
7094270964
7094370965
#ifndef SQLITE_OMIT_FLOATING_POINT
7094470966
/*
7094570967
** Delete any previous value and set the value stored in *pMem to val,
@@ -76531,10 +76553,29 @@
7653176553
v->expmask |= 0x80000000;
7653276554
}else{
7653376555
v->expmask |= ((u32)1 << (iVar-1));
7653476556
}
7653576557
}
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
+}
7653676577
7653776578
#ifndef SQLITE_OMIT_VIRTUALTABLE
7653876579
/*
7653976580
** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
7654076581
** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
@@ -76841,13 +76882,17 @@
7684176882
}
7684276883
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
7684376884
Mem *pMem = (Mem*)pVal;
7684476885
return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
7684576886
}
76846
-SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){
76887
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){
7684776888
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
+ ){
7684976894
return p->u.pPtr;
7685076895
}else{
7685176896
return 0;
7685276897
}
7685376898
}
@@ -77027,15 +77072,15 @@
7702777072
}
7702877073
SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
7702977074
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
7703077075
sqlite3VdbeMemSetNull(pCtx->pOut);
7703177076
}
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){
7703377078
Mem *pOut = pCtx->pOut;
7703477079
assert( sqlite3_mutex_held(pOut->db->mutex) );
7703577080
sqlite3VdbeMemSetNull(pOut);
77036
- sqlite3VdbeMemSetPointer(pOut, pPtr);
77081
+ sqlite3VdbeMemSetPointer(pOut, pPtr, zPT);
7703777082
}
7703877083
SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
7703977084
Mem *pOut = pCtx->pOut;
7704077085
assert( sqlite3_mutex_held(pOut->db->mutex) );
7704177086
pOut->eSubtype = eSubtype & 0xff;
@@ -78036,16 +78081,16 @@
7803678081
if( rc==SQLITE_OK ){
7803778082
sqlite3_mutex_leave(p->db->mutex);
7803878083
}
7803978084
return rc;
7804078085
}
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){
7804278087
int rc;
7804378088
Vdbe *p = (Vdbe*)pStmt;
7804478089
rc = vdbeUnbind(p, i);
7804578090
if( rc==SQLITE_OK ){
78046
- sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
78091
+ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT);
7804778092
sqlite3_mutex_leave(p->db->mutex);
7804878093
}
7804978094
return rc;
7805078095
}
7805178096
SQLITE_API int sqlite3_bind_text(
@@ -80466,121 +80511,10 @@
8046680511
sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
8046780512
}
8046880513
break;
8046980514
}
8047080515
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
-
8058280516
/* Opcode: BitAnd P1 P2 P3 * *
8058380517
** Synopsis: r[P3]=r[P1]&r[P2]
8058480518
**
8058580519
** Take the bit-wise AND of the values in register P1 and P2 and
8058680520
** store the result in register P3.
@@ -85875,10 +85809,125 @@
8587585809
}
8587685810
pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
8587785811
break;
8587885812
}
8587985813
#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
+}
8588085929
8588185930
8588285931
/* Opcode: Init P1 P2 * P4 *
8588385932
** Synopsis: Start at P2
8588485933
**
@@ -94727,12 +94776,13 @@
9472794776
){
9472894777
i16 iTabCol = pIdx->aiColumn[iIdxCol];
9472994778
if( iTabCol==XN_EXPR ){
9473094779
assert( pIdx->aColExpr );
9473194780
assert( pIdx->aColExpr->nExpr>iIdxCol );
94732
- pParse->iSelfTab = iTabCur;
94781
+ pParse->iSelfTab = iTabCur + 1;
9473394782
sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
94783
+ pParse->iSelfTab = 0;
9473494784
}else{
9473594785
sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
9473694786
iTabCol, regOut);
9473794787
}
9473894788
}
@@ -94972,17 +95022,17 @@
9497295022
/* Otherwise, fall thru into the TK_COLUMN case */
9497395023
}
9497495024
case TK_COLUMN: {
9497595025
int iTab = pExpr->iTable;
9497695026
if( iTab<0 ){
94977
- if( pParse->ckBase>0 ){
95027
+ if( pParse->iSelfTab<0 ){
9497895028
/* Generating CHECK constraints or inserting into partial index */
94979
- return pExpr->iColumn + pParse->ckBase;
95029
+ return pExpr->iColumn - pParse->iSelfTab;
9498095030
}else{
9498195031
/* Coding an expression that is part of an index where column names
9498295032
** in the index refer to the table to which the index belongs */
94983
- iTab = pParse->iSelfTab;
95033
+ iTab = pParse->iSelfTab - 1;
9498495034
}
9498595035
}
9498695036
return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
9498795037
pExpr->iColumn, iTab, target,
9498895038
pExpr->op2);
@@ -95315,12 +95365,12 @@
9531595365
#endif
9531695366
if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
9531795367
if( !pColl ) pColl = db->pDfltColl;
9531895368
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
9531995369
}
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);
9532295372
sqlite3VdbeChangeP5(v, (u8)nFarg);
9532395373
if( nFarg && constMask==0 ){
9532495374
sqlite3ReleaseTempRange(pParse, r1, nFarg);
9532595375
}
9532695376
return target;
@@ -96744,12 +96794,12 @@
9674496794
*/
9674596795
#ifdef SQLITE_DEBUG
9674696796
SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
9674796797
int i;
9674896798
if( pParse->nRangeReg>0
96749
- && pParse->iRangeReg+pParse->nRangeReg<iLast
96750
- && pParse->iRangeReg>=iFirst
96799
+ && pParse->iRangeReg+pParse->nRangeReg > iFirst
96800
+ && pParse->iRangeReg <= iLast
9675196801
){
9675296802
return 0;
9675396803
}
9675496804
for(i=0; i<pParse->nTempReg; i++){
9675596805
if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){
@@ -106134,14 +106184,15 @@
106134106184
int nCol;
106135106185
106136106186
if( piPartIdxLabel ){
106137106187
if( pIdx->pPartIdxWhere ){
106138106188
*piPartIdxLabel = sqlite3VdbeMakeLabel(v);
106139
- pParse->iSelfTab = iDataCur;
106189
+ pParse->iSelfTab = iDataCur + 1;
106140106190
sqlite3ExprCachePush(pParse);
106141106191
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
106142106192
SQLITE_JUMPIFNULL);
106193
+ pParse->iSelfTab = 0;
106143106194
}else{
106144106195
*piPartIdxLabel = 0;
106145106196
}
106146106197
}
106147106198
nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -110823,11 +110874,11 @@
110823110874
/* Test all CHECK constraints
110824110875
*/
110825110876
#ifndef SQLITE_OMIT_CHECK
110826110877
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
110827110878
ExprList *pCheck = pTab->pCheck;
110828
- pParse->ckBase = regNewData+1;
110879
+ pParse->iSelfTab = -(regNewData+1);
110829110880
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
110830110881
for(i=0; i<pCheck->nExpr; i++){
110831110882
int allOk;
110832110883
Expr *pExpr = pCheck->a[i].pExpr;
110833110884
if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
@@ -110843,10 +110894,11 @@
110843110894
onError, zName, P4_TRANSIENT,
110844110895
P5_ConstraintCheck);
110845110896
}
110846110897
sqlite3VdbeResolveLabel(v, allOk);
110847110898
}
110899
+ pParse->iSelfTab = 0;
110848110900
}
110849110901
#endif /* !defined(SQLITE_OMIT_CHECK) */
110850110902
110851110903
/* If rowid is changing, make sure the new rowid does not previously
110852110904
** exist in the table.
@@ -110987,14 +111039,14 @@
110987111039
addrUniqueOk = sqlite3VdbeMakeLabel(v);
110988111040
110989111041
/* Skip partial indices for which the WHERE clause is not true */
110990111042
if( pIdx->pPartIdxWhere ){
110991111043
sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);
110992
- pParse->ckBase = regNewData+1;
111044
+ pParse->iSelfTab = -(regNewData+1);
110993111045
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
110994111046
SQLITE_JUMPIFNULL);
110995
- pParse->ckBase = 0;
111047
+ pParse->iSelfTab = 0;
110996111048
}
110997111049
110998111050
/* Create a record for this index entry as it should appear after
110999111051
** the insert or update. Store that record in the aRegIdx[ix] register
111000111052
*/
@@ -111001,13 +111053,13 @@
111001111053
regIdx = aRegIdx[ix]+1;
111002111054
for(i=0; i<pIdx->nColumn; i++){
111003111055
int iField = pIdx->aiColumn[i];
111004111056
int x;
111005111057
if( iField==XN_EXPR ){
111006
- pParse->ckBase = regNewData+1;
111058
+ pParse->iSelfTab = -(regNewData+1);
111007111059
sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
111008
- pParse->ckBase = 0;
111060
+ pParse->iSelfTab = 0;
111009111061
VdbeComment((v, "%s column %d", pIdx->zName, i));
111010111062
}else{
111011111063
if( iField==XN_ROWID || iField==pTab->iPKey ){
111012111064
x = regNewData;
111013111065
}else{
@@ -112207,13 +112259,13 @@
112207112259
/* Version 3.20.0 and later */
112208112260
int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
112209112261
sqlite3_stmt**,const char**);
112210112262
int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
112211112263
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*);
112215112267
};
112216112268
112217112269
/*
112218112270
** This is the function signature used for all extension entry points. It
112219112271
** is also defined in the file "loadext.c".
@@ -115461,10 +115513,11 @@
115461115513
}
115462115514
aRoot[cnt] = 0;
115463115515
115464115516
/* Make sure sufficient number of registers have been allocated */
115465115517
pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
115518
+ sqlite3ClearTempRegCache(pParse);
115466115519
115467115520
/* Do the b-tree integrity checks */
115468115521
sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
115469115522
sqlite3VdbeChangeP5(v, (u8)i);
115470115523
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
@@ -115526,18 +115579,19 @@
115526115579
if( db->mallocFailed==0 ){
115527115580
int addrCkFault = sqlite3VdbeMakeLabel(v);
115528115581
int addrCkOk = sqlite3VdbeMakeLabel(v);
115529115582
char *zErr;
115530115583
int k;
115531
- pParse->iSelfTab = iDataCur;
115584
+ pParse->iSelfTab = iDataCur + 1;
115532115585
sqlite3ExprCachePush(pParse);
115533115586
for(k=pCheck->nExpr-1; k>0; k--){
115534115587
sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
115535115588
}
115536115589
sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
115537115590
SQLITE_JUMPIFNULL);
115538115591
sqlite3VdbeResolveLabel(v, addrCkFault);
115592
+ pParse->iSelfTab = 0;
115539115593
zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
115540115594
pTab->zName);
115541115595
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
115542115596
integrityCheckResultRow(v, 3);
115543115597
sqlite3VdbeResolveLabel(v, addrCkOk);
@@ -115875,11 +115929,12 @@
115875115929
** pragmas run by future database connections.
115876115930
**
115877115931
** 0x0008 (Not yet implemented) Create indexes that might have
115878115932
** been helpful to recent queries
115879115933
**
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
115881115936
** optimizations that have not yet been invented. If new optimizations are
115882115937
** ever added that should be off by default, those off-by-default
115883115938
** optimizations will have bitmasks of 0x10000 or larger.
115884115939
**
115885115940
** DETERMINATION OF WHEN TO RUN ANALYZE
@@ -116302,14 +116357,18 @@
116302116357
UNUSED_PARAMETER(idxNum);
116303116358
UNUSED_PARAMETER(idxStr);
116304116359
pragmaVtabCursorClear(pCsr);
116305116360
j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;
116306116361
for(i=0; i<argc; i++, j++){
116362
+ const char *zText = (const char*)sqlite3_value_text(argv[i]);
116307116363
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
+ }
116311116370
}
116312116371
}
116313116372
sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
116314116373
sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
116315116374
if( pCsr->azArg[1] ){
@@ -120659,12 +120718,13 @@
120659120718
** and (2b) the outer query does not use subqueries other than the one
120660120719
** FROM-clause subquery that is a candidate for flattening. (2b is
120661120720
** due to ticket [2f7170d73bf9abf80] from 2015-02-09.)
120662120721
**
120663120722
** (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.
120666120726
**
120667120727
** (4) The subquery is not DISTINCT.
120668120728
**
120669120729
** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
120670120730
** sub-queries that were excluded from this optimization. Restriction
@@ -120865,11 +120925,11 @@
120865120925
**
120866120926
** See also tickets #306, #350, and #3300.
120867120927
*/
120868120928
if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
120869120929
isLeftJoin = 1;
120870
- if( pSubSrc->nSrc>1 || isAgg ){
120930
+ if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){
120871120931
return 0; /* Restriction (3) */
120872120932
}
120873120933
}
120874120934
#ifdef SQLITE_EXTRA_IFNULLROW
120875120935
else if( iFrom>0 && !isAgg ){
@@ -131980,10 +132040,19 @@
131980132040
Bitmask notReady /* Tables in outer loops of the join */
131981132041
){
131982132042
char aff;
131983132043
if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
131984132044
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
+ }
131985132054
if( (pTerm->prereqRight & notReady)!=0 ) return 0;
131986132055
if( pTerm->u.leftColumn<0 ) return 0;
131987132056
aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
131988132057
if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
131989132058
testcase( pTerm->pExpr->op==TK_IS );
@@ -150278,11 +150347,11 @@
150278150347
assert( iCol>=0 && iCol<=p->nColumn+2 );
150279150348
150280150349
switch( iCol-p->nColumn ){
150281150350
case 0:
150282150351
/* The special 'table-name' column */
150283
- sqlite3_result_pointer(pCtx, pCsr);
150352
+ sqlite3_result_pointer(pCtx, pCsr, "fts3cursor");
150284150353
break;
150285150354
150286150355
case 1:
150287150356
/* The docid column */
150288150357
sqlite3_result_int64(pCtx, pCsr->iPrevId);
@@ -150497,11 +150566,11 @@
150497150566
const char *zFunc, /* Function name */
150498150567
sqlite3_value *pVal, /* argv[0] passed to function */
150499150568
Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150500150569
){
150501150570
int rc;
150502
- *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal);
150571
+ *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, "fts3cursor");
150503150572
if( (*ppCsr)!=0 ){
150504150573
rc = SQLITE_OK;
150505150574
}else{
150506150575
char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150507150576
sqlite3_result_error(pContext, zErr, -1);
@@ -200196,19 +200265,18 @@
200196200265
}
200197200266
200198200267
static void fts5Fts5Func(
200199200268
sqlite3_context *pCtx, /* Function call context */
200200200269
int nArg, /* Number of args */
200201
- sqlite3_value **apUnused /* Function arguments */
200270
+ sqlite3_value **apArg /* Function arguments */
200202200271
){
200203200272
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;
200210200278
}
200211200279
200212200280
/*
200213200281
** Implementation of fts5_source_id() function.
200214200282
*/
@@ -200217,11 +200285,11 @@
200217200285
int nArg, /* Number of args */
200218200286
sqlite3_value **apUnused /* Function arguments */
200219200287
){
200220200288
assert( nArg==0 );
200221200289
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);
200223200291
}
200224200292
200225200293
static int fts5Init(sqlite3 *db){
200226200294
static const sqlite3_module fts5Mod = {
200227200295
/* iVersion */ 2,
@@ -200269,11 +200337,11 @@
200269200337
if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);
200270200338
if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);
200271200339
if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);
200272200340
if( rc==SQLITE_OK ){
200273200341
rc = sqlite3_create_function(
200274
- db, "fts5", 0, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
200342
+ db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
200275200343
);
200276200344
}
200277200345
if( rc==SQLITE_OK ){
200278200346
rc = sqlite3_create_function(
200279200347
db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0
200280200348
--- 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-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -4672,11 +4672,11 @@
4672 );
4673 SQLITE_API int sqlite3_prepare16_v3(
4674 sqlite3 *db, /* Database handle */
4675 const void *zSql, /* SQL statement, UTF-16 encoded */
4676 int nByte, /* Maximum length of zSql in bytes. */
4677 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
4678 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4679 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4680 );
4681
4682 /*
@@ -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) 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.
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()].
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*);
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,13 +5785,14 @@
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)] 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.
 
5793 **
5794 ** ^(The sqlite3_value_type(V) interface returns the
5795 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
5796 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
5797 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -5821,11 +5822,11 @@
5821 */
5822 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5823 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5824 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5825 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5826 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
5827 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5828 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5829 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5830 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5831 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -6122,15 +6123,16 @@
6122 ** be deallocated after sqlite3_result_value() returns without harm.
6123 ** ^A [protected sqlite3_value] object may always be used where an
6124 ** [unprotected sqlite3_value] object is required, so either
6125 ** kind of [sqlite3_value] object can be used with this interface.
6126 **
6127 ** ^The sqlite3_result_pointer(C,P) interface sets the result to an
6128 ** 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
6131 ** [application-defined SQL function] using [sqlite3_value_pointer()].
 
6132 ** This mechanism can be used to pass non-SQL values between
6133 ** application-defined functions.
6134 **
6135 ** If these routines are called from within the different thread
6136 ** than the one containing the application-defined function that received
@@ -6153,11 +6155,11 @@
6153 void(*)(void*), unsigned char encoding);
6154 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6155 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
6156 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
6157 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
6158 SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
6159 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
6160 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
6161
6162
6163 /*
@@ -13750,16 +13752,16 @@
13750 #define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
13751 #define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */
13752 #define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */
13753 #define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */
13754 #define OP_CollSeq 68
13755 #define OP_Function0 69 /* synopsis: r[P3]=func(r[P2@P5]) */
13756 #define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
13757 #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
13761 #define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
13762 #define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
13763 #define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */
13764 #define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */
13765 #define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */
@@ -13775,82 +13777,84 @@
13775 #define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
13776 #define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
13777 #define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
13778 #define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
13779 #define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
13780 #define OP_Cast 94 /* synopsis: affinity(r[P1]) */
13781 #define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
13782 #define OP_Permutation 96
13783 #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 */
13818 #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
 
 
13852
13853 /* Properties such as "out2" or "jump" that are specified in
13854 ** comments following the "case" for each opcode in the vdbe.c
13855 ** are encoded into bitvectors as follows:
13856 */
@@ -13867,23 +13871,24 @@
13867 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
13868 /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
13869 /* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\
13870 /* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\
13871 /* 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,\
13874 /* 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,\
13877 /* 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,}
 
13885
13886 /* The sqlite3P2Values() routine is able to run faster if it knows
13887 ** the value of the largest JUMP opcode. The smaller the maximum
13888 ** JUMP opcode the better, so the mkopcodeh.tcl script that
13889 ** generated this include file strives to group all JUMP opcodes
@@ -13977,10 +13982,12 @@
13977 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
13978
13979 #ifndef SQLITE_OMIT_TRIGGER
13980 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
13981 #endif
 
 
13982
13983 /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
13984 ** each VDBE opcode.
13985 **
13986 ** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op
@@ -15356,11 +15363,18 @@
15356 **
15357 ** DFUNCTION(zName, nArg, iArg, bNC, xFunc)
15358 ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
15359 ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions
15360 ** and functions like sqlite_version() that can change, but not during
15361 ** a single query.
 
 
 
 
 
 
 
15362 **
15363 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
15364 ** Used to create an aggregate function definition implemented by
15365 ** the C functions xStep and xFinal. The first four parameters
15366 ** are interpreted in the same way as the first 4 parameters to
@@ -15379,12 +15393,15 @@
15379 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
15380 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
15381 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
15382 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
15383 #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} }
 
 
 
15386 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
15387 {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
15388 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
15389 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
15390 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
@@ -16681,12 +16698,12 @@
16681 int nErr; /* Number of errors seen */
16682 int nTab; /* Number of previously allocated VDBE cursors */
16683 int nMem; /* Number of memory cells used so far */
16684 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
16685 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 */
16688 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
16689 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
16690 int nLabel; /* Number of labels used */
16691 int *aLabel; /* Space to hold the labels */
16692 ExprList *pConstExpr;/* Constant expressions */
@@ -18915,11 +18932,11 @@
18915 #ifdef SQLITE_OMIT_FLOATING_POINT
18916 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
18917 #else
18918 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
18919 #endif
18920 SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*);
18921 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
18922 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
18923 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
18924 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
18925 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
@@ -19721,11 +19738,11 @@
19721 double r;
19722 if( parseYyyyMmDd(zDate,p)==0 ){
19723 return 0;
19724 }else if( parseHhMmSs(zDate, p)==0 ){
19725 return 0;
19726 }else if( sqlite3StrICmp(zDate,"now")==0){
19727 return setDateTimeToCurrent(context, p);
19728 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){
19729 setRawDateNumber(p, r);
19730 return 0;
19731 }
@@ -20004,11 +20021,11 @@
20004 /* localtime
20005 **
20006 ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
20007 ** show local time.
20008 */
20009 if( sqlite3_stricmp(z, "localtime")==0 ){
20010 computeJD(p);
20011 p->iJD += localtimeOffset(p, pCtx, &rc);
20012 clearYMD_HMS_TZ(p);
20013 }
20014 break;
@@ -20030,11 +20047,11 @@
20030 p->rawS = 0;
20031 rc = 0;
20032 }
20033 }
20034 #ifndef SQLITE_OMIT_LOCALTIME
20035 else if( sqlite3_stricmp(z, "utc")==0 ){
20036 if( p->tzSet==0 ){
20037 sqlite3_int64 c1;
20038 computeJD(p);
20039 c1 = localtimeOffset(p, pCtx, &rc);
20040 if( rc==SQLITE_OK ){
@@ -20566,15 +20583,15 @@
20566 ** external linkage.
20567 */
20568 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
20569 static FuncDef aDateTimeFuncs[] = {
20570 #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 ),
20576 DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
20577 DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
20578 DFUNCTION(current_date, 0, 0, 0, cdateFunc ),
20579 #else
20580 STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc),
@@ -30088,16 +30105,16 @@
30088 /* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
30089 /* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"),
30090 /* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
30091 /* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"),
30092 /* 68 */ "CollSeq" OpHelp(""),
30093 /* 69 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
30094 /* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
30095 /* 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(""),
30099 /* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
30100 /* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
30101 /* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
30102 /* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
30103 /* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
@@ -30113,82 +30130,84 @@
30113 /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
30114 /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
30115 /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
30116 /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
30117 /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
30118 /* 94 */ "Cast" OpHelp("affinity(r[P1])"),
30119 /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
30120 /* 96 */ "Permutation" OpHelp(""),
30121 /* 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"),
30156 /* 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(""),
 
 
30190 };
30191 return azName[i];
30192 }
30193 #endif
30194
@@ -70931,15 +70950,18 @@
70931
70932 /*
70933 ** Set the value stored in *pMem should already be a NULL.
70934 ** Also store a pointer to go with it.
70935 */
70936 SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
70937 assert( pMem->flags==MEM_Null );
70938 pMem->flags = MEM_Null|MEM_Subtype;
70939 pMem->u.pPtr = pPtr;
70940 pMem->eSubtype = 'p';
 
 
 
70941 }
70942
70943 #ifndef SQLITE_OMIT_FLOATING_POINT
70944 /*
70945 ** Delete any previous value and set the value stored in *pMem to val,
@@ -76531,10 +76553,29 @@
76531 v->expmask |= 0x80000000;
76532 }else{
76533 v->expmask |= ((u32)1 << (iVar-1));
76534 }
76535 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76536
76537 #ifndef SQLITE_OMIT_VIRTUALTABLE
76538 /*
76539 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
76540 ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
@@ -76841,13 +76882,17 @@
76841 }
76842 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
76843 Mem *pMem = (Mem*)pVal;
76844 return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
76845 }
76846 SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){
76847 Mem *p = (Mem*)pVal;
76848 if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
 
 
 
 
76849 return p->u.pPtr;
76850 }else{
76851 return 0;
76852 }
76853 }
@@ -77027,15 +77072,15 @@
77027 }
77028 SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
77029 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
77030 sqlite3VdbeMemSetNull(pCtx->pOut);
77031 }
77032 SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
77033 Mem *pOut = pCtx->pOut;
77034 assert( sqlite3_mutex_held(pOut->db->mutex) );
77035 sqlite3VdbeMemSetNull(pOut);
77036 sqlite3VdbeMemSetPointer(pOut, pPtr);
77037 }
77038 SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
77039 Mem *pOut = pCtx->pOut;
77040 assert( sqlite3_mutex_held(pOut->db->mutex) );
77041 pOut->eSubtype = eSubtype & 0xff;
@@ -78036,16 +78081,16 @@
78036 if( rc==SQLITE_OK ){
78037 sqlite3_mutex_leave(p->db->mutex);
78038 }
78039 return rc;
78040 }
78041 SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
78042 int rc;
78043 Vdbe *p = (Vdbe*)pStmt;
78044 rc = vdbeUnbind(p, i);
78045 if( rc==SQLITE_OK ){
78046 sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
78047 sqlite3_mutex_leave(p->db->mutex);
78048 }
78049 return rc;
78050 }
78051 SQLITE_API int sqlite3_bind_text(
@@ -80466,121 +80511,10 @@
80466 sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
80467 }
80468 break;
80469 }
80470
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 /* Opcode: BitAnd P1 P2 P3 * *
80583 ** Synopsis: r[P3]=r[P1]&r[P2]
80584 **
80585 ** Take the bit-wise AND of the values in register P1 and P2 and
80586 ** store the result in register P3.
@@ -85875,10 +85809,125 @@
85875 }
85876 pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
85877 break;
85878 }
85879 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85880
85881
85882 /* Opcode: Init P1 P2 * P4 *
85883 ** Synopsis: Start at P2
85884 **
@@ -94727,12 +94776,13 @@
94727 ){
94728 i16 iTabCol = pIdx->aiColumn[iIdxCol];
94729 if( iTabCol==XN_EXPR ){
94730 assert( pIdx->aColExpr );
94731 assert( pIdx->aColExpr->nExpr>iIdxCol );
94732 pParse->iSelfTab = iTabCur;
94733 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
 
94734 }else{
94735 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
94736 iTabCol, regOut);
94737 }
94738 }
@@ -94972,17 +95022,17 @@
94972 /* Otherwise, fall thru into the TK_COLUMN case */
94973 }
94974 case TK_COLUMN: {
94975 int iTab = pExpr->iTable;
94976 if( iTab<0 ){
94977 if( pParse->ckBase>0 ){
94978 /* Generating CHECK constraints or inserting into partial index */
94979 return pExpr->iColumn + pParse->ckBase;
94980 }else{
94981 /* Coding an expression that is part of an index where column names
94982 ** in the index refer to the table to which the index belongs */
94983 iTab = pParse->iSelfTab;
94984 }
94985 }
94986 return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
94987 pExpr->iColumn, iTab, target,
94988 pExpr->op2);
@@ -95315,12 +95365,12 @@
95315 #endif
95316 if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
95317 if( !pColl ) pColl = db->pDfltColl;
95318 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
95319 }
95320 sqlite3VdbeAddOp4(v, OP_Function0, constMask, r1, target,
95321 (char*)pDef, P4_FUNCDEF);
95322 sqlite3VdbeChangeP5(v, (u8)nFarg);
95323 if( nFarg && constMask==0 ){
95324 sqlite3ReleaseTempRange(pParse, r1, nFarg);
95325 }
95326 return target;
@@ -96744,12 +96794,12 @@
96744 */
96745 #ifdef SQLITE_DEBUG
96746 SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
96747 int i;
96748 if( pParse->nRangeReg>0
96749 && pParse->iRangeReg+pParse->nRangeReg<iLast
96750 && pParse->iRangeReg>=iFirst
96751 ){
96752 return 0;
96753 }
96754 for(i=0; i<pParse->nTempReg; i++){
96755 if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){
@@ -106134,14 +106184,15 @@
106134 int nCol;
106135
106136 if( piPartIdxLabel ){
106137 if( pIdx->pPartIdxWhere ){
106138 *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
106139 pParse->iSelfTab = iDataCur;
106140 sqlite3ExprCachePush(pParse);
106141 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
106142 SQLITE_JUMPIFNULL);
 
106143 }else{
106144 *piPartIdxLabel = 0;
106145 }
106146 }
106147 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -110823,11 +110874,11 @@
110823 /* Test all CHECK constraints
110824 */
110825 #ifndef SQLITE_OMIT_CHECK
110826 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
110827 ExprList *pCheck = pTab->pCheck;
110828 pParse->ckBase = regNewData+1;
110829 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
110830 for(i=0; i<pCheck->nExpr; i++){
110831 int allOk;
110832 Expr *pExpr = pCheck->a[i].pExpr;
110833 if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
@@ -110843,10 +110894,11 @@
110843 onError, zName, P4_TRANSIENT,
110844 P5_ConstraintCheck);
110845 }
110846 sqlite3VdbeResolveLabel(v, allOk);
110847 }
 
110848 }
110849 #endif /* !defined(SQLITE_OMIT_CHECK) */
110850
110851 /* If rowid is changing, make sure the new rowid does not previously
110852 ** exist in the table.
@@ -110987,14 +111039,14 @@
110987 addrUniqueOk = sqlite3VdbeMakeLabel(v);
110988
110989 /* Skip partial indices for which the WHERE clause is not true */
110990 if( pIdx->pPartIdxWhere ){
110991 sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);
110992 pParse->ckBase = regNewData+1;
110993 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
110994 SQLITE_JUMPIFNULL);
110995 pParse->ckBase = 0;
110996 }
110997
110998 /* Create a record for this index entry as it should appear after
110999 ** the insert or update. Store that record in the aRegIdx[ix] register
111000 */
@@ -111001,13 +111053,13 @@
111001 regIdx = aRegIdx[ix]+1;
111002 for(i=0; i<pIdx->nColumn; i++){
111003 int iField = pIdx->aiColumn[i];
111004 int x;
111005 if( iField==XN_EXPR ){
111006 pParse->ckBase = regNewData+1;
111007 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
111008 pParse->ckBase = 0;
111009 VdbeComment((v, "%s column %d", pIdx->zName, i));
111010 }else{
111011 if( iField==XN_ROWID || iField==pTab->iPKey ){
111012 x = regNewData;
111013 }else{
@@ -112207,13 +112259,13 @@
112207 /* Version 3.20.0 and later */
112208 int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
112209 sqlite3_stmt**,const char**);
112210 int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
112211 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*);
112215 };
112216
112217 /*
112218 ** This is the function signature used for all extension entry points. It
112219 ** is also defined in the file "loadext.c".
@@ -115461,10 +115513,11 @@
115461 }
115462 aRoot[cnt] = 0;
115463
115464 /* Make sure sufficient number of registers have been allocated */
115465 pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
 
115466
115467 /* Do the b-tree integrity checks */
115468 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
115469 sqlite3VdbeChangeP5(v, (u8)i);
115470 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
@@ -115526,18 +115579,19 @@
115526 if( db->mallocFailed==0 ){
115527 int addrCkFault = sqlite3VdbeMakeLabel(v);
115528 int addrCkOk = sqlite3VdbeMakeLabel(v);
115529 char *zErr;
115530 int k;
115531 pParse->iSelfTab = iDataCur;
115532 sqlite3ExprCachePush(pParse);
115533 for(k=pCheck->nExpr-1; k>0; k--){
115534 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
115535 }
115536 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
115537 SQLITE_JUMPIFNULL);
115538 sqlite3VdbeResolveLabel(v, addrCkFault);
 
115539 zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
115540 pTab->zName);
115541 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
115542 integrityCheckResultRow(v, 3);
115543 sqlite3VdbeResolveLabel(v, addrCkOk);
@@ -115875,11 +115929,12 @@
115875 ** pragmas run by future database connections.
115876 **
115877 ** 0x0008 (Not yet implemented) Create indexes that might have
115878 ** been helpful to recent queries
115879 **
115880 ** The default MASK is and always shall be 0xfffe. 0xfffe means perform all ** of the optimizations listed above except Debug Mode, including new
 
115881 ** optimizations that have not yet been invented. If new optimizations are
115882 ** ever added that should be off by default, those off-by-default
115883 ** optimizations will have bitmasks of 0x10000 or larger.
115884 **
115885 ** DETERMINATION OF WHEN TO RUN ANALYZE
@@ -116302,14 +116357,18 @@
116302 UNUSED_PARAMETER(idxNum);
116303 UNUSED_PARAMETER(idxStr);
116304 pragmaVtabCursorClear(pCsr);
116305 j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;
116306 for(i=0; i<argc; i++, j++){
 
116307 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;
 
 
 
116311 }
116312 }
116313 sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
116314 sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
116315 if( pCsr->azArg[1] ){
@@ -120659,12 +120718,13 @@
120659 ** and (2b) the outer query does not use subqueries other than the one
120660 ** FROM-clause subquery that is a candidate for flattening. (2b is
120661 ** due to ticket [2f7170d73bf9abf80] from 2015-02-09.)
120662 **
120663 ** (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.
 
120666 **
120667 ** (4) The subquery is not DISTINCT.
120668 **
120669 ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
120670 ** sub-queries that were excluded from this optimization. Restriction
@@ -120865,11 +120925,11 @@
120865 **
120866 ** See also tickets #306, #350, and #3300.
120867 */
120868 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
120869 isLeftJoin = 1;
120870 if( pSubSrc->nSrc>1 || isAgg ){
120871 return 0; /* Restriction (3) */
120872 }
120873 }
120874 #ifdef SQLITE_EXTRA_IFNULLROW
120875 else if( iFrom>0 && !isAgg ){
@@ -131980,10 +132040,19 @@
131980 Bitmask notReady /* Tables in outer loops of the join */
131981 ){
131982 char aff;
131983 if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
131984 if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0;
 
 
 
 
 
 
 
 
 
131985 if( (pTerm->prereqRight & notReady)!=0 ) return 0;
131986 if( pTerm->u.leftColumn<0 ) return 0;
131987 aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
131988 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
131989 testcase( pTerm->pExpr->op==TK_IS );
@@ -150278,11 +150347,11 @@
150278 assert( iCol>=0 && iCol<=p->nColumn+2 );
150279
150280 switch( iCol-p->nColumn ){
150281 case 0:
150282 /* The special 'table-name' column */
150283 sqlite3_result_pointer(pCtx, pCsr);
150284 break;
150285
150286 case 1:
150287 /* The docid column */
150288 sqlite3_result_int64(pCtx, pCsr->iPrevId);
@@ -150497,11 +150566,11 @@
150497 const char *zFunc, /* Function name */
150498 sqlite3_value *pVal, /* argv[0] passed to function */
150499 Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150500 ){
150501 int rc;
150502 *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal);
150503 if( (*ppCsr)!=0 ){
150504 rc = SQLITE_OK;
150505 }else{
150506 char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150507 sqlite3_result_error(pContext, zErr, -1);
@@ -200196,19 +200265,18 @@
200196 }
200197
200198 static void fts5Fts5Func(
200199 sqlite3_context *pCtx, /* Function call context */
200200 int nArg, /* Number of args */
200201 sqlite3_value **apUnused /* Function arguments */
200202 ){
200203 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);
200210 }
200211
200212 /*
200213 ** Implementation of fts5_source_id() function.
200214 */
@@ -200217,11 +200285,11 @@
200217 int nArg, /* Number of args */
200218 sqlite3_value **apUnused /* Function arguments */
200219 ){
200220 assert( nArg==0 );
200221 UNUSED_PARAM2(nArg, apUnused);
200222 sqlite3_result_text(pCtx, "fts5: 2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6", -1, SQLITE_TRANSIENT);
200223 }
200224
200225 static int fts5Init(sqlite3 *db){
200226 static const sqlite3_module fts5Mod = {
200227 /* iVersion */ 2,
@@ -200269,11 +200337,11 @@
200269 if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);
200270 if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);
200271 if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);
200272 if( rc==SQLITE_OK ){
200273 rc = sqlite3_create_function(
200274 db, "fts5", 0, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
200275 );
200276 }
200277 if( rc==SQLITE_OK ){
200278 rc = sqlite3_create_function(
200279 db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0
200280
--- 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 **
@@ -4672,11 +4672,11 @@
4672 );
4673 SQLITE_API int sqlite3_prepare16_v3(
4674 sqlite3 *db, /* Database handle */
4675 const void *zSql, /* SQL statement, UTF-16 encoded */
4676 int nByte, /* Maximum length of zSql in bytes. */
4677 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
4678 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4679 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4680 );
4681
4682 /*
@@ -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,13 +5785,14 @@
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].)^
@@ -5821,11 +5822,11 @@
5822 */
5823 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5824 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5825 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5826 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5827 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
5828 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5829 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5830 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5831 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5832 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -6122,15 +6123,16 @@
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
@@ -6153,11 +6155,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 /*
@@ -13750,16 +13752,16 @@
13752 #define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
13753 #define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */
13754 #define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */
13755 #define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */
13756 #define OP_CollSeq 68
13757 #define OP_AddImm 69 /* synopsis: r[P1]=r[P1]+P2 */
13758 #define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
13759 #define OP_And 71 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
13760 #define OP_RealAffinity 72
13761 #define OP_Cast 73 /* synopsis: affinity(r[P1]) */
13762 #define OP_Permutation 74
13763 #define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
13764 #define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
13765 #define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */
13766 #define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */
13767 #define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */
@@ -13775,82 +13777,84 @@
13777 #define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
13778 #define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
13779 #define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
13780 #define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
13781 #define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
13782 #define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
13783 #define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
13784 #define OP_Column 96 /* synopsis: r[P3]=PX */
13785 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
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
13820 #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
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
13856
13857 /* Properties such as "out2" or "jump" that are specified in
13858 ** comments following the "case" for each opcode in the vdbe.c
13859 ** are encoded into bitvectors as follows:
13860 */
@@ -13867,23 +13871,24 @@
13871 /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
13872 /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
13873 /* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\
13874 /* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\
13875 /* 56 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\
13876 /* 64 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x02, 0x26, 0x26,\
13877 /* 72 */ 0x02, 0x02, 0x00, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
13878 /* 80 */ 0x0b, 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26,\
13879 /* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
13880 /* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
13881 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 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 }
13890
13891 /* The sqlite3P2Values() routine is able to run faster if it knows
13892 ** the value of the largest JUMP opcode. The smaller the maximum
13893 ** JUMP opcode the better, so the mkopcodeh.tcl script that
13894 ** generated this include file strives to group all JUMP opcodes
@@ -13977,10 +13982,12 @@
13982 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
13983
13984 #ifndef SQLITE_OMIT_TRIGGER
13985 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
13986 #endif
13987
13988 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
13989
13990 /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on
13991 ** each VDBE opcode.
13992 **
13993 ** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op
@@ -15356,11 +15363,18 @@
15363 **
15364 ** DFUNCTION(zName, nArg, iArg, bNC, xFunc)
15365 ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
15366 ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions
15367 ** and functions like sqlite_version() that can change, but not during
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.
15376 **
15377 ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
15378 ** Used to create an aggregate function definition implemented by
15379 ** the C functions xStep and xFinal. The first four parameters
15380 ** are interpreted in the same way as the first 4 parameters to
@@ -15379,12 +15393,15 @@
15393 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
15394 #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
15395 {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
15396 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }
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), \
@@ -16681,12 +16698,12 @@
16698 int nErr; /* Number of errors seen */
16699 int nTab; /* Number of previously allocated VDBE cursors */
16700 int nMem; /* Number of memory cells used so far */
16701 int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
16702 int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
16703 int iSelfTab; /* Table for associated with an index on expr, or negative
16704 ** of the base register during check-constraint eval */
16705 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
16706 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
16707 int nLabel; /* Number of labels used */
16708 int *aLabel; /* Space to hold the labels */
16709 ExprList *pConstExpr;/* Constant expressions */
@@ -18915,11 +18932,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*);
@@ -19721,11 +19738,11 @@
19738 double r;
19739 if( parseYyyyMmDd(zDate,p)==0 ){
19740 return 0;
19741 }else if( parseHhMmSs(zDate, p)==0 ){
19742 return 0;
19743 }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
19744 return setDateTimeToCurrent(context, p);
19745 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){
19746 setRawDateNumber(p, r);
19747 return 0;
19748 }
@@ -20004,11 +20021,11 @@
20021 /* localtime
20022 **
20023 ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
20024 ** show local time.
20025 */
20026 if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
20027 computeJD(p);
20028 p->iJD += localtimeOffset(p, pCtx, &rc);
20029 clearYMD_HMS_TZ(p);
20030 }
20031 break;
@@ -20030,11 +20047,11 @@
20047 p->rawS = 0;
20048 rc = 0;
20049 }
20050 }
20051 #ifndef SQLITE_OMIT_LOCALTIME
20052 else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
20053 if( p->tzSet==0 ){
20054 sqlite3_int64 c1;
20055 computeJD(p);
20056 c1 = localtimeOffset(p, pCtx, &rc);
20057 if( rc==SQLITE_OK ){
@@ -20566,15 +20583,15 @@
20583 ** external linkage.
20584 */
20585 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
20586 static FuncDef aDateTimeFuncs[] = {
20587 #ifndef SQLITE_OMIT_DATETIME_FUNCS
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 ),
20593 DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
20594 DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
20595 DFUNCTION(current_date, 0, 0, 0, cdateFunc ),
20596 #else
20597 STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc),
@@ -30088,16 +30105,16 @@
30105 /* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
30106 /* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"),
30107 /* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
30108 /* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"),
30109 /* 68 */ "CollSeq" OpHelp(""),
30110 /* 69 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
30111 /* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
30112 /* 71 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
30113 /* 72 */ "RealAffinity" OpHelp(""),
30114 /* 73 */ "Cast" OpHelp("affinity(r[P1])"),
30115 /* 74 */ "Permutation" OpHelp(""),
30116 /* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
30117 /* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
30118 /* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
30119 /* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
30120 /* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
@@ -30113,82 +30130,84 @@
30130 /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
30131 /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
30132 /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
30133 /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
30134 /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
30135 /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
30136 /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
30137 /* 96 */ "Column" OpHelp("r[P3]=PX"),
30138 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
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(""),
30173 /* 132 */ "Real" OpHelp("r[P2]=P4"),
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(""),
30209 };
30210 return azName[i];
30211 }
30212 #endif
30213
@@ -70931,15 +70950,18 @@
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,
@@ -76531,10 +76553,29 @@
76553 v->expmask |= 0x80000000;
76554 }else{
76555 v->expmask |= ((u32)1 << (iVar-1));
76556 }
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 }
76577
76578 #ifndef SQLITE_OMIT_VIRTUALTABLE
76579 /*
76580 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
76581 ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
@@ -76841,13 +76882,17 @@
76882 }
76883 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
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 }
@@ -77027,15 +77072,15 @@
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;
@@ -78036,16 +78081,16 @@
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(
@@ -80466,121 +80511,10 @@
80511 sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
80512 }
80513 break;
80514 }
80515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80516 /* Opcode: BitAnd P1 P2 P3 * *
80517 ** Synopsis: r[P3]=r[P1]&r[P2]
80518 **
80519 ** Take the bit-wise AND of the values in register P1 and P2 and
80520 ** store the result in register P3.
@@ -85875,10 +85809,125 @@
85809 }
85810 pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
85811 break;
85812 }
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 }
85929
85930
85931 /* Opcode: Init P1 P2 * P4 *
85932 ** Synopsis: Start at P2
85933 **
@@ -94727,12 +94776,13 @@
94776 ){
94777 i16 iTabCol = pIdx->aiColumn[iIdxCol];
94778 if( iTabCol==XN_EXPR ){
94779 assert( pIdx->aColExpr );
94780 assert( pIdx->aColExpr->nExpr>iIdxCol );
94781 pParse->iSelfTab = iTabCur + 1;
94782 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
94783 pParse->iSelfTab = 0;
94784 }else{
94785 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
94786 iTabCol, regOut);
94787 }
94788 }
@@ -94972,17 +95022,17 @@
95022 /* Otherwise, fall thru into the TK_COLUMN case */
95023 }
95024 case TK_COLUMN: {
95025 int iTab = pExpr->iTable;
95026 if( iTab<0 ){
95027 if( pParse->iSelfTab<0 ){
95028 /* Generating CHECK constraints or inserting into partial index */
95029 return pExpr->iColumn - pParse->iSelfTab;
95030 }else{
95031 /* Coding an expression that is part of an index where column names
95032 ** in the index refer to the table to which the index belongs */
95033 iTab = pParse->iSelfTab - 1;
95034 }
95035 }
95036 return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
95037 pExpr->iColumn, iTab, target,
95038 pExpr->op2);
@@ -95315,12 +95365,12 @@
95365 #endif
95366 if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
95367 if( !pColl ) pColl = db->pDfltColl;
95368 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
95369 }
95370 sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,
95371 constMask, r1, target, (char*)pDef, P4_FUNCDEF);
95372 sqlite3VdbeChangeP5(v, (u8)nFarg);
95373 if( nFarg && constMask==0 ){
95374 sqlite3ReleaseTempRange(pParse, r1, nFarg);
95375 }
95376 return target;
@@ -96744,12 +96794,12 @@
96794 */
96795 #ifdef SQLITE_DEBUG
96796 SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
96797 int i;
96798 if( pParse->nRangeReg>0
96799 && pParse->iRangeReg+pParse->nRangeReg > iFirst
96800 && pParse->iRangeReg <= iLast
96801 ){
96802 return 0;
96803 }
96804 for(i=0; i<pParse->nTempReg; i++){
96805 if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){
@@ -106134,14 +106184,15 @@
106184 int nCol;
106185
106186 if( piPartIdxLabel ){
106187 if( pIdx->pPartIdxWhere ){
106188 *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
106189 pParse->iSelfTab = iDataCur + 1;
106190 sqlite3ExprCachePush(pParse);
106191 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
106192 SQLITE_JUMPIFNULL);
106193 pParse->iSelfTab = 0;
106194 }else{
106195 *piPartIdxLabel = 0;
106196 }
106197 }
106198 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
@@ -110823,11 +110874,11 @@
110874 /* Test all CHECK constraints
110875 */
110876 #ifndef SQLITE_OMIT_CHECK
110877 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
110878 ExprList *pCheck = pTab->pCheck;
110879 pParse->iSelfTab = -(regNewData+1);
110880 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
110881 for(i=0; i<pCheck->nExpr; i++){
110882 int allOk;
110883 Expr *pExpr = pCheck->a[i].pExpr;
110884 if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
@@ -110843,10 +110894,11 @@
110894 onError, zName, P4_TRANSIENT,
110895 P5_ConstraintCheck);
110896 }
110897 sqlite3VdbeResolveLabel(v, allOk);
110898 }
110899 pParse->iSelfTab = 0;
110900 }
110901 #endif /* !defined(SQLITE_OMIT_CHECK) */
110902
110903 /* If rowid is changing, make sure the new rowid does not previously
110904 ** exist in the table.
@@ -110987,14 +111039,14 @@
111039 addrUniqueOk = sqlite3VdbeMakeLabel(v);
111040
111041 /* Skip partial indices for which the WHERE clause is not true */
111042 if( pIdx->pPartIdxWhere ){
111043 sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);
111044 pParse->iSelfTab = -(regNewData+1);
111045 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
111046 SQLITE_JUMPIFNULL);
111047 pParse->iSelfTab = 0;
111048 }
111049
111050 /* Create a record for this index entry as it should appear after
111051 ** the insert or update. Store that record in the aRegIdx[ix] register
111052 */
@@ -111001,13 +111053,13 @@
111053 regIdx = aRegIdx[ix]+1;
111054 for(i=0; i<pIdx->nColumn; i++){
111055 int iField = pIdx->aiColumn[i];
111056 int x;
111057 if( iField==XN_EXPR ){
111058 pParse->iSelfTab = -(regNewData+1);
111059 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
111060 pParse->iSelfTab = 0;
111061 VdbeComment((v, "%s column %d", pIdx->zName, i));
111062 }else{
111063 if( iField==XN_ROWID || iField==pTab->iPKey ){
111064 x = regNewData;
111065 }else{
@@ -112207,13 +112259,13 @@
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
112271 ** is also defined in the file "loadext.c".
@@ -115461,10 +115513,11 @@
115513 }
115514 aRoot[cnt] = 0;
115515
115516 /* Make sure sufficient number of registers have been allocated */
115517 pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
115518 sqlite3ClearTempRegCache(pParse);
115519
115520 /* Do the b-tree integrity checks */
115521 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
115522 sqlite3VdbeChangeP5(v, (u8)i);
115523 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
@@ -115526,18 +115579,19 @@
115579 if( db->mallocFailed==0 ){
115580 int addrCkFault = sqlite3VdbeMakeLabel(v);
115581 int addrCkOk = sqlite3VdbeMakeLabel(v);
115582 char *zErr;
115583 int k;
115584 pParse->iSelfTab = iDataCur + 1;
115585 sqlite3ExprCachePush(pParse);
115586 for(k=pCheck->nExpr-1; k>0; k--){
115587 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
115588 }
115589 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
115590 SQLITE_JUMPIFNULL);
115591 sqlite3VdbeResolveLabel(v, addrCkFault);
115592 pParse->iSelfTab = 0;
115593 zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
115594 pTab->zName);
115595 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
115596 integrityCheckResultRow(v, 3);
115597 sqlite3VdbeResolveLabel(v, addrCkOk);
@@ -115875,11 +115929,12 @@
115929 ** pragmas run by future database connections.
115930 **
115931 ** 0x0008 (Not yet implemented) Create indexes that might have
115932 ** been helpful to recent queries
115933 **
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
115936 ** optimizations that have not yet been invented. If new optimizations are
115937 ** ever added that should be off by default, those off-by-default
115938 ** optimizations will have bitmasks of 0x10000 or larger.
115939 **
115940 ** DETERMINATION OF WHEN TO RUN ANALYZE
@@ -116302,14 +116357,18 @@
116357 UNUSED_PARAMETER(idxNum);
116358 UNUSED_PARAMETER(idxStr);
116359 pragmaVtabCursorClear(pCsr);
116360 j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;
116361 for(i=0; i<argc; i++, j++){
116362 const char *zText = (const char*)sqlite3_value_text(argv[i]);
116363 assert( j<ArraySize(pCsr->azArg) );
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 }
116370 }
116371 }
116372 sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
116373 sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
116374 if( pCsr->azArg[1] ){
@@ -120659,12 +120718,13 @@
120718 ** and (2b) the outer query does not use subqueries other than the one
120719 ** FROM-clause subquery that is a candidate for flattening. (2b is
120720 ** due to ticket [2f7170d73bf9abf80] from 2015-02-09.)
120721 **
120722 ** (3) The subquery is not the right operand of a LEFT JOIN
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.
120726 **
120727 ** (4) The subquery is not DISTINCT.
120728 **
120729 ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
120730 ** sub-queries that were excluded from this optimization. Restriction
@@ -120865,11 +120925,11 @@
120925 **
120926 ** See also tickets #306, #350, and #3300.
120927 */
120928 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
120929 isLeftJoin = 1;
120930 if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){
120931 return 0; /* Restriction (3) */
120932 }
120933 }
120934 #ifdef SQLITE_EXTRA_IFNULLROW
120935 else if( iFrom>0 && !isAgg ){
@@ -131980,10 +132040,19 @@
132040 Bitmask notReady /* Tables in outer loops of the join */
132041 ){
132042 char aff;
132043 if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
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 }
132054 if( (pTerm->prereqRight & notReady)!=0 ) return 0;
132055 if( pTerm->u.leftColumn<0 ) return 0;
132056 aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
132057 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
132058 testcase( pTerm->pExpr->op==TK_IS );
@@ -150278,11 +150347,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);
@@ -150497,11 +150566,11 @@
150566 const char *zFunc, /* Function name */
150567 sqlite3_value *pVal, /* argv[0] passed to function */
150568 Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
150569 ){
150570 int rc;
150571 *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, "fts3cursor");
150572 if( (*ppCsr)!=0 ){
150573 rc = SQLITE_OK;
150574 }else{
150575 char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
150576 sqlite3_result_error(pContext, zErr, -1);
@@ -200196,19 +200265,18 @@
200265 }
200266
200267 static void fts5Fts5Func(
200268 sqlite3_context *pCtx, /* Function call context */
200269 int nArg, /* Number of args */
200270 sqlite3_value **apArg /* Function arguments */
200271 ){
200272 Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);
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;
 
200278 }
200279
200280 /*
200281 ** Implementation of fts5_source_id() function.
200282 */
@@ -200217,11 +200285,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,
@@ -200269,11 +200337,11 @@
200337 if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);
200338 if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);
200339 if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);
200340 if( rc==SQLITE_OK ){
200341 rc = sqlite3_create_function(
200342 db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
200343 );
200344 }
200345 if( rc==SQLITE_OK ){
200346 rc = sqlite3_create_function(
200347 db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0
200348
+16 -14
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.20.0"
125125
#define SQLITE_VERSION_NUMBER 3020000
126
-#define SQLITE_SOURCE_ID "2017-07-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
126
+#define SQLITE_SOURCE_ID "2017-07-21 20:31:31 8de20fc72a9b55fabd2444b2d73c88c65658430d6d182da9f0e2f3432373ab51"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -3643,11 +3643,11 @@
36433643
);
36443644
SQLITE_API int sqlite3_prepare16_v3(
36453645
sqlite3 *db, /* Database handle */
36463646
const void *zSql, /* SQL statement, UTF-16 encoded */
36473647
int nByte, /* Maximum length of zSql in bytes. */
3648
- unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3648
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
36493649
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
36503650
const void **pzTail /* OUT: Pointer to unused portion of zSql */
36513651
);
36523652
36533653
/*
@@ -3881,18 +3881,18 @@
38813881
** Zeroblobs are intended to serve as placeholders for BLOBs whose
38823882
** content is later written using
38833883
** [sqlite3_blob_open | incremental BLOB I/O] routines.
38843884
** ^A negative value for the zeroblob results in a zero-length BLOB.
38853885
**
3886
-** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
3886
+** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in
38873887
** [prepared statement] S to have an SQL value of NULL, but to also be
3888
-** associated with the pointer P.
3888
+** associated with the pointer P of type T.
38893889
** ^The sqlite3_bind_pointer() routine can be used to pass
38903890
** host-language pointers into [application-defined SQL functions].
38913891
** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
38923892
** to be an ordinary SQL NULL value to everything other than
3893
-** [sqlite3_value_pointer()].
3893
+** [sqlite3_value_pointer()]. The T parameter should be a static string.
38943894
**
38953895
** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
38963896
** for the [prepared statement] or with a prepared statement for which
38973897
** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
38983898
** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
@@ -3923,11 +3923,11 @@
39233923
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
39243924
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
39253925
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
39263926
void(*)(void*), unsigned char encoding);
39273927
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3928
-SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
3928
+SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*);
39293929
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
39303930
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
39313931
39323932
/*
39333933
** CAPI3REF: Number Of SQL Parameters
@@ -4756,13 +4756,14 @@
47564756
** in the native byte-order of the host machine. ^The
47574757
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
47584758
** extract UTF-16 strings as big-endian and little-endian respectively.
47594759
**
47604760
** ^If [sqlite3_value] object V was initialized
4761
-** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
4762
-** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
4763
-** sqlite3_value_pointer(V) returns a NULL.
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.
47644765
**
47654766
** ^(The sqlite3_value_type(V) interface returns the
47664767
** [SQLITE_INTEGER | datatype code] for the initial datatype of the
47674768
** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
47684769
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -4792,11 +4793,11 @@
47924793
*/
47934794
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
47944795
SQLITE_API double sqlite3_value_double(sqlite3_value*);
47954796
SQLITE_API int sqlite3_value_int(sqlite3_value*);
47964797
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4797
-SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
4798
+SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
47984799
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
47994800
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
48004801
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
48014802
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
48024803
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5093,15 +5094,16 @@
50935094
** be deallocated after sqlite3_result_value() returns without harm.
50945095
** ^A [protected sqlite3_value] object may always be used where an
50955096
** [unprotected sqlite3_value] object is required, so either
50965097
** kind of [sqlite3_value] object can be used with this interface.
50975098
**
5098
-** ^The sqlite3_result_pointer(C,P) interface sets the result to an
5099
+** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an
50995100
** SQL NULL value, just like [sqlite3_result_null(C)], except that it
5100
-** also associates the host-language pointer P with that NULL value such
5101
-** that the pointer can be retrieved within an
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
51025103
** [application-defined SQL function] using [sqlite3_value_pointer()].
5104
+** The T parameter should be a static string.
51035105
** This mechanism can be used to pass non-SQL values between
51045106
** application-defined functions.
51055107
**
51065108
** If these routines are called from within the different thread
51075109
** than the one containing the application-defined function that received
@@ -5124,11 +5126,11 @@
51245126
void(*)(void*), unsigned char encoding);
51255127
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
51265128
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
51275129
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
51285130
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
5129
-SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
5131
+SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*, const char*);
51305132
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
51315133
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
51325134
51335135
51345136
/*
51355137
--- 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-15 13:49:56 47cf83a0682b7b3219cf255457f5fbe05f3c1f46be42f6bbab33b78a57a252f6"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -3643,11 +3643,11 @@
3643 );
3644 SQLITE_API int sqlite3_prepare16_v3(
3645 sqlite3 *db, /* Database handle */
3646 const void *zSql, /* SQL statement, UTF-16 encoded */
3647 int nByte, /* Maximum length of zSql in bytes. */
3648 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3649 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3650 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3651 );
3652
3653 /*
@@ -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) 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.
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()].
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*);
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,13 +4756,14 @@
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)] or [sqlite3_result_pointer(C,P)], then
4762 ** sqlite3_value_pointer(V) will return the pointer P. Otherwise,
4763 ** sqlite3_value_pointer(V) returns a NULL.
 
4764 **
4765 ** ^(The sqlite3_value_type(V) interface returns the
4766 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
4767 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
4768 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
@@ -4792,11 +4793,11 @@
4792 */
4793 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4794 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4795 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4796 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4797 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*);
4798 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4799 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4800 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4801 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4802 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5093,15 +5094,16 @@
5093 ** be deallocated after sqlite3_result_value() returns without harm.
5094 ** ^A [protected sqlite3_value] object may always be used where an
5095 ** [unprotected sqlite3_value] object is required, so either
5096 ** kind of [sqlite3_value] object can be used with this interface.
5097 **
5098 ** ^The sqlite3_result_pointer(C,P) interface sets the result to an
5099 ** SQL NULL value, just like [sqlite3_result_null(C)], except that it
5100 ** also associates the host-language pointer P with that NULL value such
5101 ** that the pointer can be retrieved within an
5102 ** [application-defined SQL function] using [sqlite3_value_pointer()].
 
5103 ** This mechanism can be used to pass non-SQL values between
5104 ** application-defined functions.
5105 **
5106 ** If these routines are called from within the different thread
5107 ** than the one containing the application-defined function that received
@@ -5124,11 +5126,11 @@
5124 void(*)(void*), unsigned char encoding);
5125 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
5126 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
5127 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
5128 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
5129 SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*);
5130 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
5131 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
5132
5133
5134 /*
5135
--- 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 **
@@ -3643,11 +3643,11 @@
3643 );
3644 SQLITE_API int sqlite3_prepare16_v3(
3645 sqlite3 *db, /* Database handle */
3646 const void *zSql, /* SQL statement, UTF-16 encoded */
3647 int nByte, /* Maximum length of zSql in bytes. */
3648 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
3649 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3650 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3651 );
3652
3653 /*
@@ -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,13 +4756,14 @@
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].)^
@@ -4792,11 +4793,11 @@
4793 */
4794 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4795 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4796 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4797 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4798 SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
4799 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4800 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4801 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4802 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4803 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
@@ -5093,15 +5094,16 @@
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
@@ -5124,11 +5126,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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button