Fossil SCM

Update the built-in SQLite to the latest trunk version that includes a fix to VACUUM to prevent it from running out of memory on very large databases.

drh 2016-11-02 15:16 trunk
Commit 7fa9701b3d43f67dfe406b804ebb9c4a1b7c5e3e
3 files changed +24 -16 +174 -77 +24 -3
+24 -16
--- src/shell.c
+++ src/shell.c
@@ -666,23 +666,25 @@
666666
#define MODE_Column 1 /* One record per line in neat columns */
667667
#define MODE_List 2 /* One record per line with a separator */
668668
#define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */
669669
#define MODE_Html 4 /* Generate an XHTML table */
670670
#define MODE_Insert 5 /* Generate SQL "insert" statements */
671
-#define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */
672
-#define MODE_Csv 7 /* Quote strings, numbers are plain */
673
-#define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */
674
-#define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */
675
-#define MODE_Pretty 10 /* Pretty-print schemas */
671
+#define MODE_Quote 6 /* Quote values as for SQL */
672
+#define MODE_Tcl 7 /* Generate ANSI-C or TCL quoted elements */
673
+#define MODE_Csv 8 /* Quote strings, numbers are plain */
674
+#define MODE_Explain 9 /* Like MODE_Column, but do not truncate data */
675
+#define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */
676
+#define MODE_Pretty 11 /* Pretty-print schemas */
676677
677678
static const char *modeDescr[] = {
678679
"line",
679680
"column",
680681
"list",
681682
"semi",
682683
"html",
683684
"insert",
685
+ "quote",
684686
"tcl",
685687
"csv",
686688
"explain",
687689
"ascii",
688690
"prettyprint",
@@ -1196,23 +1198,26 @@
11961198
utf8_printf(p->out, "%s", p->rowSeparator);
11971199
}
11981200
setTextMode(p->out, 1);
11991201
break;
12001202
}
1203
+ case MODE_Quote:
12011204
case MODE_Insert: {
12021205
p->cnt++;
12031206
if( azArg==0 ) break;
1204
- utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
1205
- if( p->showHeader ){
1206
- raw_printf(p->out,"(");
1207
- for(i=0; i<nArg; i++){
1208
- char *zSep = i>0 ? ",": "";
1209
- utf8_printf(p->out, "%s%s", zSep, azCol[i]);
1210
- }
1211
- raw_printf(p->out,")");
1212
- }
1213
- raw_printf(p->out," VALUES(");
1207
+ if( p->cMode==MODE_Insert ){
1208
+ utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
1209
+ if( p->showHeader ){
1210
+ raw_printf(p->out,"(");
1211
+ for(i=0; i<nArg; i++){
1212
+ char *zSep = i>0 ? ",": "";
1213
+ utf8_printf(p->out, "%s%s", zSep, azCol[i]);
1214
+ }
1215
+ raw_printf(p->out,")");
1216
+ }
1217
+ raw_printf(p->out," VALUES(");
1218
+ }
12141219
for(i=0; i<nArg; i++){
12151220
char *zSep = i>0 ? ",": "";
12161221
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
12171222
utf8_printf(p->out,"%sNULL",zSep);
12181223
}else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1231,11 +1236,11 @@
12311236
}else{
12321237
if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
12331238
output_quoted_string(p->out, azArg[i]);
12341239
}
12351240
}
1236
- raw_printf(p->out,");\n");
1241
+ raw_printf(p->out,p->cMode==MODE_Quote?"\n":");\n");
12371242
break;
12381243
}
12391244
case MODE_Ascii: {
12401245
if( p->cnt++==0 && p->showHeader ){
12411246
for(i=0; i<nArg; i++){
@@ -2175,10 +2180,11 @@
21752180
" column Left-aligned columns. (See .width)\n"
21762181
" html HTML <table> code\n"
21772182
" insert SQL insert statements for TABLE\n"
21782183
" line One value per line\n"
21792184
" list Values delimited by .separator strings\n"
2185
+ " quote Escape answers as for SQL\n"
21802186
" tabs Tab-separated values\n"
21812187
" tcl TCL list elements\n"
21822188
".nullvalue STRING Use STRING in place of NULL values\n"
21832189
".once FILENAME Output for the next SQL command only to FILENAME\n"
21842190
".open ?--new? ?FILE? Close existing database and reopen FILE\n"
@@ -3975,10 +3981,12 @@
39753981
p->mode = MODE_List;
39763982
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
39773983
}else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
39783984
p->mode = MODE_Insert;
39793985
set_table_name(p, nArg>=3 ? azArg[2] : "table");
3986
+ }else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
3987
+ p->mode = MODE_Quote;
39803988
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
39813989
p->mode = MODE_Ascii;
39823990
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
39833991
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
39843992
}else {
39853993
--- src/shell.c
+++ src/shell.c
@@ -666,23 +666,25 @@
666 #define MODE_Column 1 /* One record per line in neat columns */
667 #define MODE_List 2 /* One record per line with a separator */
668 #define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */
669 #define MODE_Html 4 /* Generate an XHTML table */
670 #define MODE_Insert 5 /* Generate SQL "insert" statements */
671 #define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */
672 #define MODE_Csv 7 /* Quote strings, numbers are plain */
673 #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */
674 #define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */
675 #define MODE_Pretty 10 /* Pretty-print schemas */
 
676
677 static const char *modeDescr[] = {
678 "line",
679 "column",
680 "list",
681 "semi",
682 "html",
683 "insert",
 
684 "tcl",
685 "csv",
686 "explain",
687 "ascii",
688 "prettyprint",
@@ -1196,23 +1198,26 @@
1196 utf8_printf(p->out, "%s", p->rowSeparator);
1197 }
1198 setTextMode(p->out, 1);
1199 break;
1200 }
 
1201 case MODE_Insert: {
1202 p->cnt++;
1203 if( azArg==0 ) break;
1204 utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
1205 if( p->showHeader ){
1206 raw_printf(p->out,"(");
1207 for(i=0; i<nArg; i++){
1208 char *zSep = i>0 ? ",": "";
1209 utf8_printf(p->out, "%s%s", zSep, azCol[i]);
1210 }
1211 raw_printf(p->out,")");
1212 }
1213 raw_printf(p->out," VALUES(");
 
 
1214 for(i=0; i<nArg; i++){
1215 char *zSep = i>0 ? ",": "";
1216 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
1217 utf8_printf(p->out,"%sNULL",zSep);
1218 }else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1231,11 +1236,11 @@
1231 }else{
1232 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
1233 output_quoted_string(p->out, azArg[i]);
1234 }
1235 }
1236 raw_printf(p->out,");\n");
1237 break;
1238 }
1239 case MODE_Ascii: {
1240 if( p->cnt++==0 && p->showHeader ){
1241 for(i=0; i<nArg; i++){
@@ -2175,10 +2180,11 @@
2175 " column Left-aligned columns. (See .width)\n"
2176 " html HTML <table> code\n"
2177 " insert SQL insert statements for TABLE\n"
2178 " line One value per line\n"
2179 " list Values delimited by .separator strings\n"
 
2180 " tabs Tab-separated values\n"
2181 " tcl TCL list elements\n"
2182 ".nullvalue STRING Use STRING in place of NULL values\n"
2183 ".once FILENAME Output for the next SQL command only to FILENAME\n"
2184 ".open ?--new? ?FILE? Close existing database and reopen FILE\n"
@@ -3975,10 +3981,12 @@
3975 p->mode = MODE_List;
3976 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
3977 }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
3978 p->mode = MODE_Insert;
3979 set_table_name(p, nArg>=3 ? azArg[2] : "table");
 
 
3980 }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
3981 p->mode = MODE_Ascii;
3982 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
3983 sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
3984 }else {
3985
--- src/shell.c
+++ src/shell.c
@@ -666,23 +666,25 @@
666 #define MODE_Column 1 /* One record per line in neat columns */
667 #define MODE_List 2 /* One record per line with a separator */
668 #define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */
669 #define MODE_Html 4 /* Generate an XHTML table */
670 #define MODE_Insert 5 /* Generate SQL "insert" statements */
671 #define MODE_Quote 6 /* Quote values as for SQL */
672 #define MODE_Tcl 7 /* Generate ANSI-C or TCL quoted elements */
673 #define MODE_Csv 8 /* Quote strings, numbers are plain */
674 #define MODE_Explain 9 /* Like MODE_Column, but do not truncate data */
675 #define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */
676 #define MODE_Pretty 11 /* Pretty-print schemas */
677
678 static const char *modeDescr[] = {
679 "line",
680 "column",
681 "list",
682 "semi",
683 "html",
684 "insert",
685 "quote",
686 "tcl",
687 "csv",
688 "explain",
689 "ascii",
690 "prettyprint",
@@ -1196,23 +1198,26 @@
1198 utf8_printf(p->out, "%s", p->rowSeparator);
1199 }
1200 setTextMode(p->out, 1);
1201 break;
1202 }
1203 case MODE_Quote:
1204 case MODE_Insert: {
1205 p->cnt++;
1206 if( azArg==0 ) break;
1207 if( p->cMode==MODE_Insert ){
1208 utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
1209 if( p->showHeader ){
1210 raw_printf(p->out,"(");
1211 for(i=0; i<nArg; i++){
1212 char *zSep = i>0 ? ",": "";
1213 utf8_printf(p->out, "%s%s", zSep, azCol[i]);
1214 }
1215 raw_printf(p->out,")");
1216 }
1217 raw_printf(p->out," VALUES(");
1218 }
1219 for(i=0; i<nArg; i++){
1220 char *zSep = i>0 ? ",": "";
1221 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
1222 utf8_printf(p->out,"%sNULL",zSep);
1223 }else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1231,11 +1236,11 @@
1236 }else{
1237 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
1238 output_quoted_string(p->out, azArg[i]);
1239 }
1240 }
1241 raw_printf(p->out,p->cMode==MODE_Quote?"\n":");\n");
1242 break;
1243 }
1244 case MODE_Ascii: {
1245 if( p->cnt++==0 && p->showHeader ){
1246 for(i=0; i<nArg; i++){
@@ -2175,10 +2180,11 @@
2180 " column Left-aligned columns. (See .width)\n"
2181 " html HTML <table> code\n"
2182 " insert SQL insert statements for TABLE\n"
2183 " line One value per line\n"
2184 " list Values delimited by .separator strings\n"
2185 " quote Escape answers as for SQL\n"
2186 " tabs Tab-separated values\n"
2187 " tcl TCL list elements\n"
2188 ".nullvalue STRING Use STRING in place of NULL values\n"
2189 ".once FILENAME Output for the next SQL command only to FILENAME\n"
2190 ".open ?--new? ?FILE? Close existing database and reopen FILE\n"
@@ -3975,10 +3981,12 @@
3981 p->mode = MODE_List;
3982 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
3983 }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
3984 p->mode = MODE_Insert;
3985 set_table_name(p, nArg>=3 ? azArg[2] : "table");
3986 }else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
3987 p->mode = MODE_Quote;
3988 }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
3989 p->mode = MODE_Ascii;
3990 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
3991 sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
3992 }else {
3993
+174 -77
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.15.0. By combining all the individual C code files into this
3
+** version 3.16.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -379,13 +379,13 @@
379379
**
380380
** See also: [sqlite3_libversion()],
381381
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
382382
** [sqlite_version()] and [sqlite_source_id()].
383383
*/
384
-#define SQLITE_VERSION "3.15.0"
385
-#define SQLITE_VERSION_NUMBER 3015000
386
-#define SQLITE_SOURCE_ID "2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8"
384
+#define SQLITE_VERSION "3.16.0"
385
+#define SQLITE_VERSION_NUMBER 3016000
386
+#define SQLITE_SOURCE_ID "2016-11-02 14:50:19 3028845329c9b7acdec2ec8b01d00d782347454c"
387387
388388
/*
389389
** CAPI3REF: Run-Time Library Version Numbers
390390
** KEYWORDS: sqlite3_version, sqlite3_sourceid
391391
**
@@ -1235,10 +1235,16 @@
12351235
** <li>[[SQLITE_FCNTL_HAS_MOVED]]
12361236
** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
12371237
** pointer to an integer and it writes a boolean into that integer depending
12381238
** on whether or not the file has been renamed, moved, or deleted since it
12391239
** was first opened.
1240
+**
1241
+** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
1242
+** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
1243
+** underlying native file handle associated with a file handle. This file
1244
+** control interprets its argument as a pointer to a native file handle and
1245
+** writes the resulting value there.
12401246
**
12411247
** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
12421248
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
12431249
** opcode causes the xFileControl method to swap the file handle with the one
12441250
** pointed to by the pArg argument. This capability is used during testing
@@ -1286,10 +1292,12 @@
12861292
#define SQLITE_FCNTL_WAL_BLOCK 24
12871293
#define SQLITE_FCNTL_ZIPVFS 25
12881294
#define SQLITE_FCNTL_RBU 26
12891295
#define SQLITE_FCNTL_VFS_POINTER 27
12901296
#define SQLITE_FCNTL_JOURNAL_POINTER 28
1297
+#define SQLITE_FCNTL_WIN32_GET_HANDLE 29
1298
+#define SQLITE_FCNTL_PDB 30
12911299
12921300
/* deprecated names */
12931301
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
12941302
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
12951303
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -2238,18 +2246,31 @@
22382246
** does not make a copy of the new main schema name string, so the application
22392247
** must ensure that the argument passed into this DBCONFIG option is unchanged
22402248
** until after the database connection closes.
22412249
** </dd>
22422250
**
2251
+** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2252
+** <dd> Usually, when a database in wal mode is closed or detached from a
2253
+** database handle, SQLite checks if this will mean that there are now no
2254
+** connections at all to the database. If so, it performs a checkpoint
2255
+** operation before closing the connection. This option may be used to
2256
+** override this behaviour. The first parameter passed to this operation
2257
+** is an integer - non-zero to disable checkpoints-on-close, or zero (the
2258
+** default) to enable them. The second parameter is a pointer to an integer
2259
+** into which is written 0 or 1 to indicate whether checkpoints-on-close
2260
+** have been disabled - 0 if they are not disabled, 1 if they are.
2261
+** </dd>
2262
+**
22432263
** </dl>
22442264
*/
22452265
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
22462266
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
22472267
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
22482268
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
22492269
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
22502270
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2271
+#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
22512272
22522273
22532274
/*
22542275
** CAPI3REF: Enable Or Disable Extended Result Codes
22552276
** METHOD: sqlite3
@@ -12675,11 +12696,11 @@
1267512696
#define OP_SorterData 120 /* synopsis: r[P2]=data */
1267612697
#define OP_RowKey 121 /* synopsis: r[P2]=key */
1267712698
#define OP_RowData 122 /* synopsis: r[P2]=data */
1267812699
#define OP_Rowid 123 /* synopsis: r[P2]=rowid */
1267912700
#define OP_NullRow 124
12680
-#define OP_SorterInsert 125
12701
+#define OP_SorterInsert 125 /* synopsis: key=r[P2] */
1268112702
#define OP_IdxInsert 126 /* synopsis: key=r[P2] */
1268212703
#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
1268312704
#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
1268412705
#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
1268512706
#define OP_Destroy 130
@@ -13030,11 +13051,11 @@
1303013051
int,
1303113052
int,
1303213053
int,
1303313054
void(*)(DbPage*)
1303413055
);
13035
-SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager);
13056
+SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);
1303613057
SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
1303713058
1303813059
/* Functions used to configure a Pager object. */
1303913060
SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
1304013061
SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
@@ -13081,19 +13102,22 @@
1308113102
SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
1308213103
SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
1308313104
SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
1308413105
1308513106
#ifndef SQLITE_OMIT_WAL
13086
-SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
13107
+SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
1308713108
SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
1308813109
SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
1308913110
SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
13090
-SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
13111
+SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
13112
+SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager);
1309113113
# ifdef SQLITE_ENABLE_SNAPSHOT
1309213114
SQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
1309313115
SQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
1309413116
# endif
13117
+#else
13118
+# define sqlite3PagerUseWal(x) 0
1309513119
#endif
1309613120
1309713121
#ifdef SQLITE_ENABLE_ZIPVFS
1309813122
SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
1309913123
#endif
@@ -14060,10 +14084,11 @@
1406014084
#define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
1406114085
#define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
1406214086
#define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
1406314087
#define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
1406414088
#define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
14089
+#define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
1406514090
1406614091
1406714092
/*
1406814093
** Bits of the sqlite3.dbOptFlags field that are used by the
1406914094
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17268,10 +17293,13 @@
1726817293
#if SQLITE_DEFAULT_LOCKING_MODE
1726917294
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
1727017295
#endif
1727117296
#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
1727217297
"DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17298
+#endif
17299
+#if SQLITE_DIRECT_OVERFLOW_READ
17300
+ "DIRECT_OVERFLOW_READ",
1727317301
#endif
1727417302
#if SQLITE_DISABLE_DIRSYNC
1727517303
"DISABLE_DIRSYNC",
1727617304
#endif
1727717305
#if SQLITE_DISABLE_LFS
@@ -17354,10 +17382,13 @@
1735417382
#if SQLITE_ENABLE_UNLOCK_NOTIFY
1735517383
"ENABLE_UNLOCK_NOTIFY",
1735617384
#endif
1735717385
#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
1735817386
"ENABLE_UPDATE_DELETE_LIMIT",
17387
+#endif
17388
+#if defined(SQLITE_ENABLE_URI_00_ERROR)
17389
+ "ENABLE_URI_00_ERROR",
1735917390
#endif
1736017391
#if SQLITE_HAS_CODEC
1736117392
"HAS_CODEC",
1736217393
#endif
1736317394
#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
@@ -18105,12 +18136,12 @@
1810518136
UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
1810618137
UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
1810718138
int iNewReg; /* Register for new.* values */
1810818139
i64 iKey1; /* First key value passed to hook */
1810918140
i64 iKey2; /* Second key value passed to hook */
18110
- int iPKey; /* If not negative index of IPK column */
1811118141
Mem *aNew; /* Array of new.* values */
18142
+ Table *pTab; /* Schema object being upated */
1811218143
};
1811318144
1811418145
/*
1811518146
** Function prototypes
1811618147
*/
@@ -24598,13 +24629,12 @@
2459824629
char *zNew;
2459924630
size_t n;
2460024631
if( z==0 ){
2460124632
return 0;
2460224633
}
24603
- n = sqlite3Strlen30(z) + 1;
24604
- assert( (n&0x7fffffff)==n );
24605
- zNew = sqlite3DbMallocRaw(db, (int)n);
24634
+ n = strlen(z) + 1;
24635
+ zNew = sqlite3DbMallocRaw(db, n);
2460624636
if( zNew ){
2460724637
memcpy(zNew, z, n);
2460824638
}
2460924639
return zNew;
2461024640
}
@@ -29127,11 +29157,11 @@
2912729157
/* 120 */ "SorterData" OpHelp("r[P2]=data"),
2912829158
/* 121 */ "RowKey" OpHelp("r[P2]=key"),
2912929159
/* 122 */ "RowData" OpHelp("r[P2]=data"),
2913029160
/* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
2913129161
/* 124 */ "NullRow" OpHelp(""),
29132
- /* 125 */ "SorterInsert" OpHelp(""),
29162
+ /* 125 */ "SorterInsert" OpHelp("key=r[P2]"),
2913329163
/* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
2913429164
/* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
2913529165
/* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
2913629166
/* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
2913729167
/* 130 */ "Destroy" OpHelp(""),
@@ -40674,10 +40704,16 @@
4067440704
a[1] = winIoerrRetryDelay;
4067540705
}
4067640706
OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
4067740707
return SQLITE_OK;
4067840708
}
40709
+ case SQLITE_FCNTL_WIN32_GET_HANDLE: {
40710
+ LPHANDLE phFile = (LPHANDLE)pArg;
40711
+ *phFile = pFile->h;
40712
+ OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
40713
+ return SQLITE_OK;
40714
+ }
4067940715
#ifdef SQLITE_TEST
4068040716
case SQLITE_FCNTL_WIN32_SET_HANDLE: {
4068140717
LPHANDLE phFile = (LPHANDLE)pArg;
4068240718
HANDLE hOldFile = pFile->h;
4068340719
pFile->h = *phFile;
@@ -46249,21 +46285,21 @@
4624946285
#define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
4625046286
4625146287
#ifdef SQLITE_OMIT_WAL
4625246288
# define sqlite3WalOpen(x,y,z) 0
4625346289
# define sqlite3WalLimit(x,y)
46254
-# define sqlite3WalClose(w,x,y,z) 0
46290
+# define sqlite3WalClose(v,w,x,y,z) 0
4625546291
# define sqlite3WalBeginReadTransaction(y,z) 0
4625646292
# define sqlite3WalEndReadTransaction(z)
4625746293
# define sqlite3WalDbsize(y) 0
4625846294
# define sqlite3WalBeginWriteTransaction(y) 0
4625946295
# define sqlite3WalEndWriteTransaction(x) 0
4626046296
# define sqlite3WalUndo(x,y,z) 0
4626146297
# define sqlite3WalSavepoint(y,z)
4626246298
# define sqlite3WalSavepointUndo(y,z) 0
4626346299
# define sqlite3WalFrames(u,v,w,x,y,z) 0
46264
-# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0
46300
+# define sqlite3WalCheckpoint(q,r,s,t,u,v,w,x,y,z) 0
4626546301
# define sqlite3WalCallback(z) 0
4626646302
# define sqlite3WalExclusiveMode(y,z) 0
4626746303
# define sqlite3WalHeapMemory(z) 0
4626846304
# define sqlite3WalFramesize(z) 0
4626946305
# define sqlite3WalFindFrame(x,y,z) 0
@@ -46277,11 +46313,11 @@
4627746313
*/
4627846314
typedef struct Wal Wal;
4627946315
4628046316
/* Open and close a connection to a write-ahead log. */
4628146317
SQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
46282
-SQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);
46318
+SQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);
4628346319
4628446320
/* Set the limiting size of a WAL file. */
4628546321
SQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);
4628646322
4628746323
/* Used by readers to open (lock) and close (unlock) a snapshot. A
@@ -46320,10 +46356,11 @@
4632046356
SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
4632146357
4632246358
/* Copy pages from the log to the database file */
4632346359
SQLITE_PRIVATE int sqlite3WalCheckpoint(
4632446360
Wal *pWal, /* Write-ahead log connection */
46361
+ sqlite3 *db, /* Check this handle's interrupt flag */
4632546362
int eMode, /* One of PASSIVE, FULL and RESTART */
4632646363
int (*xBusy)(void*), /* Function to call when busy */
4632746364
void *pBusyArg, /* Context argument for xBusyHandler */
4632846365
int sync_flags, /* Flags to sync db file with (or 0) */
4632946366
int nBuf, /* Size of buffer nBuf */
@@ -47164,13 +47201,14 @@
4716447201
/*
4716547202
** Return true if this pager uses a write-ahead log instead of the usual
4716647203
** rollback journal. Otherwise false.
4716747204
*/
4716847205
#ifndef SQLITE_OMIT_WAL
47169
-static int pagerUseWal(Pager *pPager){
47206
+SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager){
4717047207
return (pPager->pWal!=0);
4717147208
}
47209
+# define pagerUseWal(x) sqlite3PagerUseWal(x)
4717247210
#else
4717347211
# define pagerUseWal(x) 0
4717447212
# define pagerRollbackWal(x) 0
4717547213
# define pagerWalFrames(v,w,x,y) 0
4717647214
# define pagerOpenWalIfPresent(z) SQLITE_OK
@@ -50368,21 +50406,22 @@
5036850406
** This function always succeeds. If a transaction is active an attempt
5036950407
** is made to roll it back. If an error occurs during the rollback
5037050408
** a hot journal may be left in the filesystem but no error is returned
5037150409
** to the caller.
5037250410
*/
50373
-SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
50411
+SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){
5037450412
u8 *pTmp = (u8 *)pPager->pTmpSpace;
5037550413
50414
+ assert( db || pagerUseWal(pPager)==0 );
5037650415
assert( assert_pager_state(pPager) );
5037750416
disable_simulated_io_errors();
5037850417
sqlite3BeginBenignMalloc();
5037950418
pagerFreeMapHdrs(pPager);
5038050419
/* pPager->errCode = 0; */
5038150420
pPager->exclusiveMode = 0;
5038250421
#ifndef SQLITE_OMIT_WAL
50383
- sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp);
50422
+ sqlite3WalClose(pPager->pWal,db,pPager->ckptSyncFlags,pPager->pageSize,pTmp);
5038450423
pPager->pWal = 0;
5038550424
#endif
5038650425
pager_reset(pPager);
5038750426
if( MEMDB ){
5038850427
pager_unlock(pPager);
@@ -53541,14 +53580,20 @@
5354153580
** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
5354253581
** or wal_blocking_checkpoint() API functions.
5354353582
**
5354453583
** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
5354553584
*/
53546
-SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog, int *pnCkpt){
53585
+SQLITE_PRIVATE int sqlite3PagerCheckpoint(
53586
+ Pager *pPager, /* Checkpoint on this pager */
53587
+ sqlite3 *db, /* Db handle used to check for interrupts */
53588
+ int eMode, /* Type of checkpoint */
53589
+ int *pnLog, /* OUT: Final number of frames in log */
53590
+ int *pnCkpt /* OUT: Final number of checkpointed frames */
53591
+){
5354753592
int rc = SQLITE_OK;
5354853593
if( pPager->pWal ){
53549
- rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
53594
+ rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
5355053595
(eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
5355153596
pPager->pBusyHandlerArg,
5355253597
pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
5355353598
pnLog, pnCkpt
5355453599
);
@@ -53676,11 +53721,11 @@
5367653721
** Before closing the log file, this function attempts to take an
5367753722
** EXCLUSIVE lock on the database file. If this cannot be obtained, an
5367853723
** error (SQLITE_BUSY) is returned and the log connection is not closed.
5367953724
** If successful, the EXCLUSIVE lock is not released before returning.
5368053725
*/
53681
-SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){
53726
+SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){
5368253727
int rc = SQLITE_OK;
5368353728
5368453729
assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );
5368553730
5368653731
/* If the log file is not already open, but does exist in the file-system,
@@ -53704,11 +53749,11 @@
5370453749
** the database file, the log and log-summary files will be deleted.
5370553750
*/
5370653751
if( rc==SQLITE_OK && pPager->pWal ){
5370753752
rc = pagerExclusiveLock(pPager);
5370853753
if( rc==SQLITE_OK ){
53709
- rc = sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags,
53754
+ rc = sqlite3WalClose(pPager->pWal, db, pPager->ckptSyncFlags,
5371053755
pPager->pageSize, (u8*)pPager->pTmpSpace);
5371153756
pPager->pWal = 0;
5371253757
pagerFixMaplimit(pPager);
5371353758
if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
5371453759
}
@@ -55487,10 +55532,11 @@
5548755532
** checkpoint is running (in any other thread or process) at the same
5548855533
** time.
5548955534
*/
5549055535
static int walCheckpoint(
5549155536
Wal *pWal, /* Wal connection */
55537
+ sqlite3 *db, /* Check for interrupts on this handle */
5549255538
int eMode, /* One of PASSIVE, FULL or RESTART */
5549355539
int (*xBusy)(void*), /* Function to call when busy */
5549455540
void *pBusyArg, /* Context argument for xBusyHandler */
5549555541
int sync_flags, /* Flags for OsSync() (or 0) */
5549655542
u8 *zBuf /* Temporary buffer to use */
@@ -55581,10 +55627,14 @@
5558155627
5558255628
/* Iterate through the contents of the WAL, copying data to the db file */
5558355629
while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
5558455630
i64 iOffset;
5558555631
assert( walFramePgno(pWal, iFrame)==iDbpage );
55632
+ if( db->u1.isInterrupted ){
55633
+ rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
55634
+ break;
55635
+ }
5558655636
if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
5558755637
continue;
5558855638
}
5558955639
iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
5559055640
/* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
@@ -55685,10 +55735,11 @@
5568555735
/*
5568655736
** Close a connection to a log file.
5568755737
*/
5568855738
SQLITE_PRIVATE int sqlite3WalClose(
5568955739
Wal *pWal, /* Wal to close */
55740
+ sqlite3 *db, /* For interrupt flag */
5569055741
int sync_flags, /* Flags to pass to OsSync() (or 0) */
5569155742
int nBuf,
5569255743
u8 *zBuf /* Buffer of at least nBuf bytes */
5569355744
){
5569455745
int rc = SQLITE_OK;
@@ -55701,17 +55752,18 @@
5570155752
** the database. In this case checkpoint the database and unlink both
5570255753
** the wal and wal-index files.
5570355754
**
5570455755
** The EXCLUSIVE lock is not released before returning.
5570555756
*/
55706
- rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);
55707
- if( rc==SQLITE_OK ){
55757
+ if( (db->flags & SQLITE_NoCkptOnClose)==0
55758
+ && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))
55759
+ ){
5570855760
if( pWal->exclusiveMode==WAL_NORMAL_MODE ){
5570955761
pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;
5571055762
}
55711
- rc = sqlite3WalCheckpoint(
55712
- pWal, SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
55763
+ rc = sqlite3WalCheckpoint(pWal, db,
55764
+ SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
5571355765
);
5571455766
if( rc==SQLITE_OK ){
5571555767
int bPersist = -1;
5571655768
sqlite3OsFileControlHint(
5571755769
pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist
@@ -56955,10 +57007,11 @@
5695557007
** If parameter xBusy is not NULL, it is a pointer to a busy-handler
5695657008
** callback. In this case this function runs a blocking checkpoint.
5695757009
*/
5695857010
SQLITE_PRIVATE int sqlite3WalCheckpoint(
5695957011
Wal *pWal, /* Wal connection */
57012
+ sqlite3 *db, /* Check this handle's interrupt flag */
5696057013
int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
5696157014
int (*xBusy)(void*), /* Function to call when busy */
5696257015
void *pBusyArg, /* Context argument for xBusyHandler */
5696357016
int sync_flags, /* Flags to sync db file with (or 0) */
5696457017
int nBuf, /* Size of temporary buffer */
@@ -57029,11 +57082,11 @@
5702957082
if( rc==SQLITE_OK ){
5703057083
5703157084
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
5703257085
rc = SQLITE_CORRUPT_BKPT;
5703357086
}else{
57034
- rc = walCheckpoint(pWal, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
57087
+ rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
5703557088
}
5703657089
5703757090
/* If no error occurred, set the output variables. */
5703857091
if( rc==SQLITE_OK || rc==SQLITE_BUSY ){
5703957092
if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;
@@ -60619,23 +60672,30 @@
6061960672
*ppBtree = p;
6062060673
6062160674
btree_open_out:
6062260675
if( rc!=SQLITE_OK ){
6062360676
if( pBt && pBt->pPager ){
60624
- sqlite3PagerClose(pBt->pPager);
60677
+ sqlite3PagerClose(pBt->pPager, 0);
6062560678
}
6062660679
sqlite3_free(pBt);
6062760680
sqlite3_free(p);
6062860681
*ppBtree = 0;
6062960682
}else{
60683
+ sqlite3_file *pFile;
60684
+
6063060685
/* If the B-Tree was successfully opened, set the pager-cache size to the
6063160686
** default value. Except, when opening on an existing shared pager-cache,
6063260687
** do not change the pager-cache size.
6063360688
*/
6063460689
if( sqlite3BtreeSchema(p, 0, 0)==0 ){
6063560690
sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);
6063660691
}
60692
+
60693
+ pFile = sqlite3PagerFile(pBt->pPager);
60694
+ if( pFile->pMethods ){
60695
+ sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_PDB, (void*)&pBt->db);
60696
+ }
6063760697
}
6063860698
if( mutexOpen ){
6063960699
assert( sqlite3_mutex_held(mutexOpen) );
6064060700
sqlite3_mutex_leave(mutexOpen);
6064160701
}
@@ -60761,11 +60821,11 @@
6076160821
** it without having to hold the mutex.
6076260822
**
6076360823
** Clean out and delete the BtShared object.
6076460824
*/
6076560825
assert( !pBt->pCursor );
60766
- sqlite3PagerClose(pBt->pPager);
60826
+ sqlite3PagerClose(pBt->pPager, p->db);
6076760827
if( pBt->xFreeSchema && pBt->pSchema ){
6076860828
pBt->xFreeSchema(pBt->pSchema);
6076960829
}
6077060830
sqlite3DbFree(0, pBt->pSchema);
6077160831
freeTempSpace(pBt);
@@ -62825,11 +62885,11 @@
6282562885
if( (eOp&0x01)==0 /* (1) */
6282662886
&& offset==0 /* (2) */
6282762887
&& (bEnd || a==ovflSize) /* (6) */
6282862888
&& pBt->inTransaction==TRANS_READ /* (4) */
6282962889
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
62830
- && pBt->pPage1->aData[19]==0x01 /* (5) */
62890
+ && 0==sqlite3PagerUseWal(pBt->pPager) /* (5) */
6283162891
&& &pBuf[-4]>=pBufStart /* (7) */
6283262892
){
6283362893
u8 aSave[4];
6283462894
u8 *aWrite = &pBuf[-4];
6283562895
assert( aWrite>=pBufStart ); /* hence (7) */
@@ -63081,13 +63141,16 @@
6308163141
}
6308263142
sqlite3BtreeClearCursor(pCur);
6308363143
}
6308463144
6308563145
if( pCur->iPage>=0 ){
63086
- while( pCur->iPage ){
63087
- assert( pCur->apPage[pCur->iPage]!=0 );
63088
- releasePageNotNull(pCur->apPage[pCur->iPage--]);
63146
+ if( pCur->iPage ){
63147
+ do{
63148
+ assert( pCur->apPage[pCur->iPage]!=0 );
63149
+ releasePageNotNull(pCur->apPage[pCur->iPage--]);
63150
+ }while( pCur->iPage);
63151
+ goto skip_init;
6308963152
}
6309063153
}else if( pCur->pgnoRoot==0 ){
6309163154
pCur->eState = CURSOR_INVALID;
6309263155
return SQLITE_OK;
6309363156
}else{
@@ -63094,11 +63157,11 @@
6309463157
assert( pCur->iPage==(-1) );
6309563158
rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
6309663159
0, pCur->curPagerFlags);
6309763160
if( rc!=SQLITE_OK ){
6309863161
pCur->eState = CURSOR_INVALID;
63099
- return rc;
63162
+ return rc;
6310063163
}
6310163164
pCur->iPage = 0;
6310263165
pCur->curIntKey = pCur->apPage[0]->intKey;
6310363166
}
6310463167
pRoot = pCur->apPage[0];
@@ -63117,14 +63180,16 @@
6311763180
assert( pRoot->intKey==1 || pRoot->intKey==0 );
6311863181
if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
6311963182
return SQLITE_CORRUPT_BKPT;
6312063183
}
6312163184
63185
+skip_init:
6312263186
pCur->aiIdx[0] = 0;
6312363187
pCur->info.nSize = 0;
6312463188
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
6312563189
63190
+ pRoot = pCur->apPage[0];
6312663191
if( pRoot->nCell>0 ){
6312763192
pCur->eState = CURSOR_VALID;
6312863193
}else if( !pRoot->leaf ){
6312963194
Pgno subpage;
6313063195
if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
@@ -67701,11 +67766,11 @@
6770167766
BtShared *pBt = p->pBt;
6770267767
sqlite3BtreeEnter(p);
6770367768
if( pBt->inTransaction!=TRANS_NONE ){
6770467769
rc = SQLITE_LOCKED;
6770567770
}else{
67706
- rc = sqlite3PagerCheckpoint(pBt->pPager, eMode, pnLog, pnCkpt);
67771
+ rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);
6770767772
}
6770867773
sqlite3BtreeLeave(p);
6770967774
}
6771067775
return rc;
6771167776
}
@@ -75076,11 +75141,11 @@
7507675141
preupdate.keyinfo.enc = ENC(db);
7507775142
preupdate.keyinfo.nField = pTab->nCol;
7507875143
preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
7507975144
preupdate.iKey1 = iKey1;
7508075145
preupdate.iKey2 = iKey2;
75081
- preupdate.iPKey = pTab->iPKey;
75146
+ preupdate.pTab = pTab;
7508275147
7508375148
db->pPreUpdate = &preupdate;
7508475149
db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
7508575150
db->pPreUpdate = 0;
7508675151
sqlite3DbFree(db, preupdate.aRecord);
@@ -76808,13 +76873,18 @@
7680876873
}
7680976874
7681076875
if( iIdx>=p->pUnpacked->nField ){
7681176876
*ppValue = (sqlite3_value *)columnNullValue();
7681276877
}else{
76878
+ Mem *pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
7681376879
*ppValue = &p->pUnpacked->aMem[iIdx];
76814
- if( iIdx==p->iPKey ){
76815
- sqlite3VdbeMemSetInt64(*ppValue, p->iKey1);
76880
+ if( iIdx==p->pTab->iPKey ){
76881
+ sqlite3VdbeMemSetInt64(pMem, p->iKey1);
76882
+ }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){
76883
+ if( pMem->flags & MEM_Int ){
76884
+ sqlite3VdbeMemRealify(pMem);
76885
+ }
7681676886
}
7681776887
}
7681876888
7681976889
preupdate_old_out:
7682076890
sqlite3Error(db, rc);
@@ -76887,11 +76957,11 @@
7688776957
}
7688876958
if( iIdx>=pUnpack->nField ){
7688976959
pMem = (sqlite3_value *)columnNullValue();
7689076960
}else{
7689176961
pMem = &pUnpack->aMem[iIdx];
76892
- if( iIdx==p->iPKey ){
76962
+ if( iIdx==p->pTab->iPKey ){
7689376963
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
7689476964
}
7689576965
}
7689676966
}else{
7689776967
/* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
@@ -76908,11 +76978,11 @@
7690876978
}
7690976979
}
7691076980
assert( iIdx>=0 && iIdx<p->pCsr->nField );
7691176981
pMem = &p->aNew[iIdx];
7691276982
if( pMem->flags==0 ){
76913
- if( iIdx==p->iPKey ){
76983
+ if( iIdx==p->pTab->iPKey ){
7691476984
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
7691576985
}else{
7691676986
rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
7691776987
if( rc!=SQLITE_OK ) goto preupdate_new_out;
7691876988
}
@@ -79286,12 +79356,11 @@
7928679356
** or not both operands are null.
7928779357
*/
7928879358
assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
7928979359
assert( (flags1 & MEM_Cleared)==0 );
7929079360
assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
79291
- if( (flags1&MEM_Null)!=0
79292
- && (flags3&MEM_Null)!=0
79361
+ if( (flags1&flags3&MEM_Null)!=0
7929379362
&& (flags3&MEM_Cleared)==0
7929479363
){
7929579364
res = 0; /* Operands are equal */
7929679365
}else{
7929779366
res = 1; /* Operands are not equal */
@@ -81554,11 +81623,11 @@
8155481623
8155581624
REGISTER_TRACE(pOp->p3, pMem);
8155681625
sqlite3VdbeMemIntegerify(pMem);
8155781626
assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
8155881627
if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
81559
- rc = SQLITE_FULL; /* IMP: R-12275-61338 */
81628
+ rc = SQLITE_FULL; /* IMP: R-17817-00630 */
8156081629
goto abort_due_to_error;
8156181630
}
8156281631
if( v<pMem->u.i+1 ){
8156381632
v = pMem->u.i + 1;
8156481633
}
@@ -82321,10 +82390,17 @@
8232182390
** This flag avoids doing an extra seek.
8232282391
**
8232382392
** This instruction only works for indices. The equivalent instruction
8232482393
** for tables is OP_Insert.
8232582394
*/
82395
+/* Opcode: SorterInsert P1 P2 * * *
82396
+** Synopsis: key=r[P2]
82397
+**
82398
+** Register P2 holds an SQL index key made using the
82399
+** MakeRecord instructions. This opcode writes that key
82400
+** into the sorter P1. Data for the entry is nil.
82401
+*/
8232682402
case OP_SorterInsert: /* in2 */
8232782403
case OP_IdxInsert: { /* in2 */
8232882404
VdbeCursor *pC;
8232982405
BtreePayload x;
8233082406
@@ -83549,11 +83625,11 @@
8354983625
/* If leaving WAL mode, close the log file. If successful, the call
8355083626
** to PagerCloseWal() checkpoints and deletes the write-ahead-log
8355183627
** file. An EXCLUSIVE lock may still be held on the database file
8355283628
** after a successful return.
8355383629
*/
83554
- rc = sqlite3PagerCloseWal(pPager);
83630
+ rc = sqlite3PagerCloseWal(pPager, db);
8355583631
if( rc==SQLITE_OK ){
8355683632
sqlite3PagerSetJournalMode(pPager, eNew);
8355783633
}
8355883634
}else if( eOld==PAGER_JOURNALMODE_MEMORY ){
8355983635
/* Cannot transition directly from MEMORY to WAL. Use mode OFF
@@ -94292,15 +94368,14 @@
9429294368
&& (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
9429394369
|| sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
9429494370
){
9429594371
return 1;
9429694372
}
94297
- if( pE2->op==TK_NOTNULL
94298
- && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
94299
- && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
94300
- ){
94301
- return 1;
94373
+ if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
94374
+ Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
94375
+ testcase( pX!=pE1->pLeft );
94376
+ if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
9430294377
}
9430394378
return 0;
9430494379
}
9430594380
9430694381
/*
@@ -122354,11 +122429,11 @@
122354122429
}
122355122430
#endif
122356122431
122357122432
sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
122358122433
sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
122359
- sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF);
122434
+ sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);
122360122435
122361122436
/* Begin a transaction and take an exclusive lock on the main database
122362122437
** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
122363122438
** to ensure that we do not try to change the page-size on a WAL database.
122364122439
*/
@@ -127537,10 +127612,11 @@
127537127612
Expr *pNew;
127538127613
Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
127539127614
Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
127540127615
127541127616
pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
127617
+ transferJoinMarkings(pNew, pExpr);
127542127618
idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
127543127619
exprAnalyze(pSrc, pWC, idxNew);
127544127620
}
127545127621
pTerm = &pWC->a[idxTerm];
127546127622
pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL; /* Disable the original */
@@ -127978,15 +128054,17 @@
127978128054
Expr *pX; /* An expression being tested */
127979128055
WhereClause *pWC; /* Shorthand for pScan->pWC */
127980128056
WhereTerm *pTerm; /* The term being tested */
127981128057
int k = pScan->k; /* Where to start scanning */
127982128058
127983
- while( pScan->iEquiv<=pScan->nEquiv ){
127984
- iCur = pScan->aiCur[pScan->iEquiv-1];
128059
+ assert( pScan->iEquiv<=pScan->nEquiv );
128060
+ pWC = pScan->pWC;
128061
+ while(1){
127985128062
iColumn = pScan->aiColumn[pScan->iEquiv-1];
127986
- if( iColumn==XN_EXPR && pScan->pIdxExpr==0 ) return 0;
127987
- while( (pWC = pScan->pWC)!=0 ){
128063
+ iCur = pScan->aiCur[pScan->iEquiv-1];
128064
+ assert( pWC!=0 );
128065
+ do{
127988128066
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
127989128067
if( pTerm->leftCursor==iCur
127990128068
&& pTerm->u.leftColumn==iColumn
127991128069
&& (iColumn!=XN_EXPR
127992128070
|| sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
@@ -128032,19 +128110,21 @@
128032128110
&& pX->iColumn==pScan->aiColumn[0]
128033128111
){
128034128112
testcase( pTerm->eOperator & WO_IS );
128035128113
continue;
128036128114
}
128115
+ pScan->pWC = pWC;
128037128116
pScan->k = k+1;
128038128117
return pTerm;
128039128118
}
128040128119
}
128041128120
}
128042
- pScan->pWC = pScan->pWC->pOuter;
128121
+ pWC = pWC->pOuter;
128043128122
k = 0;
128044
- }
128045
- pScan->pWC = pScan->pOrigWC;
128123
+ }while( pWC!=0 );
128124
+ if( pScan->iEquiv>=pScan->nEquiv ) break;
128125
+ pWC = pScan->pOrigWC;
128046128126
k = 0;
128047128127
pScan->iEquiv++;
128048128128
}
128049128129
return 0;
128050128130
}
@@ -128074,28 +128154,28 @@
128074128154
int iCur, /* Cursor to scan for */
128075128155
int iColumn, /* Column to scan for */
128076128156
u32 opMask, /* Operator(s) to scan for */
128077128157
Index *pIdx /* Must be compatible with this index */
128078128158
){
128079
- int j = 0;
128080
-
128081
- /* memset(pScan, 0, sizeof(*pScan)); */
128082128159
pScan->pOrigWC = pWC;
128083128160
pScan->pWC = pWC;
128084128161
pScan->pIdxExpr = 0;
128162
+ pScan->idxaff = 0;
128163
+ pScan->zCollName = 0;
128085128164
if( pIdx ){
128086
- j = iColumn;
128165
+ int j = iColumn;
128087128166
iColumn = pIdx->aiColumn[j];
128088
- if( iColumn==XN_EXPR ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
128089
- if( iColumn==pIdx->pTable->iPKey ) iColumn = XN_ROWID;
128090
- }
128091
- if( pIdx && iColumn>=0 ){
128092
- pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
128093
- pScan->zCollName = pIdx->azColl[j];
128094
- }else{
128095
- pScan->idxaff = 0;
128096
- pScan->zCollName = 0;
128167
+ if( iColumn==XN_EXPR ){
128168
+ pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
128169
+ }else if( iColumn==pIdx->pTable->iPKey ){
128170
+ iColumn = XN_ROWID;
128171
+ }else if( iColumn>=0 ){
128172
+ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
128173
+ pScan->zCollName = pIdx->azColl[j];
128174
+ }
128175
+ }else if( iColumn==XN_EXPR ){
128176
+ return 0;
128097128177
}
128098128178
pScan->opMask = opMask;
128099128179
pScan->k = 0;
128100128180
pScan->aiCur[0] = iCur;
128101128181
pScan->aiColumn[0] = iColumn;
@@ -132640,17 +132720,19 @@
132640132720
pLevel->addrLikeRep);
132641132721
VdbeCoverage(v);
132642132722
}
132643132723
#endif
132644132724
if( pLevel->iLeftJoin ){
132725
+ int ws = pLoop->wsFlags;
132645132726
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
132646
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
132647
- || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
132648
- if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
132727
+ assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );
132728
+ if( (ws & WHERE_IDX_ONLY)==0 ){
132649132729
sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
132650132730
}
132651
- if( pLoop->wsFlags & WHERE_INDEXED ){
132731
+ if( (ws & WHERE_INDEXED)
132732
+ || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx)
132733
+ ){
132652132734
sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
132653132735
}
132654132736
if( pLevel->op==OP_Return ){
132655132737
sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
132656132738
}else{
@@ -138612,10 +138694,11 @@
138612138694
} aFlagOp[] = {
138613138695
{ SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
138614138696
{ SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
138615138697
{ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
138616138698
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
138699
+ { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
138617138700
};
138618138701
unsigned int i;
138619138702
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
138620138703
for(i=0; i<ArraySize(aFlagOp); i++){
138621138704
if( aFlagOp[i].op==op ){
@@ -139908,10 +139991,17 @@
139908139991
db->busyHandler.nBusy = 0;
139909139992
rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
139910139993
sqlite3Error(db, rc);
139911139994
}
139912139995
rc = sqlite3ApiExit(db, rc);
139996
+
139997
+ /* If there are no active statements, clear the interrupt flag at this
139998
+ ** point. */
139999
+ if( db->nVdbeActive==0 ){
140000
+ db->u1.isInterrupted = 0;
140001
+ }
140002
+
139913140003
sqlite3_mutex_leave(db->mutex);
139914140004
return rc;
139915140005
#endif
139916140006
}
139917140007
@@ -140410,10 +140500,11 @@
140410140500
int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);
140411140501
octet += sqlite3HexToInt(zUri[iIn++]);
140412140502
140413140503
assert( octet>=0 && octet<256 );
140414140504
if( octet==0 ){
140505
+#ifndef SQLITE_ENABLE_URI_00_ERROR
140415140506
/* This branch is taken when "%00" appears within the URI. In this
140416140507
** case we ignore all text in the remainder of the path, name or
140417140508
** value currently being parsed. So ignore the current character
140418140509
** and skip to the next "?", "=" or "&", as appropriate. */
140419140510
while( (c = zUri[iIn])!=0 && c!='#'
@@ -140422,10 +140513,16 @@
140422140513
&& (eState!=2 || c!='&')
140423140514
){
140424140515
iIn++;
140425140516
}
140426140517
continue;
140518
+#else
140519
+ /* If ENABLE_URI_00_ERROR is defined, "%00" in a URI is an error. */
140520
+ *pzErrMsg = sqlite3_mprintf("unexpected %%00 in uri");
140521
+ rc = SQLITE_ERROR;
140522
+ goto parse_uri_out;
140523
+#endif
140427140524
}
140428140525
c = octet;
140429140526
}else if( eState==1 && (c=='&' || c=='=') ){
140430140527
if( zFile[iOut-1]==0 ){
140431140528
/* An empty option name. Ignore this option altogether. */
@@ -165207,11 +165304,11 @@
165207165304
** of the locale to use. Passing an empty string ("") or SQL NULL value
165208165305
** as the second argument is the same as invoking the 1 argument version
165209165306
** of upper() or lower().
165210165307
**
165211165308
** lower('I', 'en_us') -> 'i'
165212
-** lower('I', 'tr_tr') -> 'ı' (small dotless i)
165309
+** lower('I', 'tr_tr') -> '\u131' (small dotless i)
165213165310
**
165214165311
** http://www.icu-project.org/userguide/posix.html#case_mappings
165215165312
*/
165216165313
static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
165217165314
const UChar *zInput; /* Pointer to input string */
@@ -195596,11 +195693,11 @@
195596195693
int nArg, /* Number of args */
195597195694
sqlite3_value **apUnused /* Function arguments */
195598195695
){
195599195696
assert( nArg==0 );
195600195697
UNUSED_PARAM2(nArg, apUnused);
195601
- sqlite3_result_text(pCtx, "fts5: 2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8", -1, SQLITE_TRANSIENT);
195698
+ sqlite3_result_text(pCtx, "fts5: 2016-10-26 16:05:10 ec9dab8054c71d112c68f58a45821b38c2a45677", -1, SQLITE_TRANSIENT);
195602195699
}
195603195700
195604195701
static int fts5Init(sqlite3 *db){
195605195702
static const sqlite3_module fts5Mod = {
195606195703
/* iVersion */ 2,
195607195704
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.15.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -379,13 +379,13 @@
379 **
380 ** See also: [sqlite3_libversion()],
381 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
382 ** [sqlite_version()] and [sqlite_source_id()].
383 */
384 #define SQLITE_VERSION "3.15.0"
385 #define SQLITE_VERSION_NUMBER 3015000
386 #define SQLITE_SOURCE_ID "2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8"
387
388 /*
389 ** CAPI3REF: Run-Time Library Version Numbers
390 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
391 **
@@ -1235,10 +1235,16 @@
1235 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
1236 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
1237 ** pointer to an integer and it writes a boolean into that integer depending
1238 ** on whether or not the file has been renamed, moved, or deleted since it
1239 ** was first opened.
 
 
 
 
 
 
1240 **
1241 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
1242 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
1243 ** opcode causes the xFileControl method to swap the file handle with the one
1244 ** pointed to by the pArg argument. This capability is used during testing
@@ -1286,10 +1292,12 @@
1286 #define SQLITE_FCNTL_WAL_BLOCK 24
1287 #define SQLITE_FCNTL_ZIPVFS 25
1288 #define SQLITE_FCNTL_RBU 26
1289 #define SQLITE_FCNTL_VFS_POINTER 27
1290 #define SQLITE_FCNTL_JOURNAL_POINTER 28
 
 
1291
1292 /* deprecated names */
1293 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1294 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1295 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -2238,18 +2246,31 @@
2238 ** does not make a copy of the new main schema name string, so the application
2239 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2240 ** until after the database connection closes.
2241 ** </dd>
2242 **
 
 
 
 
 
 
 
 
 
 
 
 
2243 ** </dl>
2244 */
2245 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2246 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2247 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2248 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2249 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2250 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
 
2251
2252
2253 /*
2254 ** CAPI3REF: Enable Or Disable Extended Result Codes
2255 ** METHOD: sqlite3
@@ -12675,11 +12696,11 @@
12675 #define OP_SorterData 120 /* synopsis: r[P2]=data */
12676 #define OP_RowKey 121 /* synopsis: r[P2]=key */
12677 #define OP_RowData 122 /* synopsis: r[P2]=data */
12678 #define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12679 #define OP_NullRow 124
12680 #define OP_SorterInsert 125
12681 #define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12682 #define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12683 #define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12684 #define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12685 #define OP_Destroy 130
@@ -13030,11 +13051,11 @@
13030 int,
13031 int,
13032 int,
13033 void(*)(DbPage*)
13034 );
13035 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager);
13036 SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
13037
13038 /* Functions used to configure a Pager object. */
13039 SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
13040 SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
@@ -13081,19 +13102,22 @@
13081 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
13082 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
13083 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
13084
13085 #ifndef SQLITE_OMIT_WAL
13086 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
13087 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
13088 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
13089 SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
13090 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
 
13091 # ifdef SQLITE_ENABLE_SNAPSHOT
13092 SQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
13093 SQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
13094 # endif
 
 
13095 #endif
13096
13097 #ifdef SQLITE_ENABLE_ZIPVFS
13098 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
13099 #endif
@@ -14060,10 +14084,11 @@
14060 #define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
14061 #define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
14062 #define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
14063 #define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
14064 #define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
 
14065
14066
14067 /*
14068 ** Bits of the sqlite3.dbOptFlags field that are used by the
14069 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17268,10 +17293,13 @@
17268 #if SQLITE_DEFAULT_LOCKING_MODE
17269 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17270 #endif
17271 #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17272 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
 
 
 
17273 #endif
17274 #if SQLITE_DISABLE_DIRSYNC
17275 "DISABLE_DIRSYNC",
17276 #endif
17277 #if SQLITE_DISABLE_LFS
@@ -17354,10 +17382,13 @@
17354 #if SQLITE_ENABLE_UNLOCK_NOTIFY
17355 "ENABLE_UNLOCK_NOTIFY",
17356 #endif
17357 #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
17358 "ENABLE_UPDATE_DELETE_LIMIT",
 
 
 
17359 #endif
17360 #if SQLITE_HAS_CODEC
17361 "HAS_CODEC",
17362 #endif
17363 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
@@ -18105,12 +18136,12 @@
18105 UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
18106 UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
18107 int iNewReg; /* Register for new.* values */
18108 i64 iKey1; /* First key value passed to hook */
18109 i64 iKey2; /* Second key value passed to hook */
18110 int iPKey; /* If not negative index of IPK column */
18111 Mem *aNew; /* Array of new.* values */
 
18112 };
18113
18114 /*
18115 ** Function prototypes
18116 */
@@ -24598,13 +24629,12 @@
24598 char *zNew;
24599 size_t n;
24600 if( z==0 ){
24601 return 0;
24602 }
24603 n = sqlite3Strlen30(z) + 1;
24604 assert( (n&0x7fffffff)==n );
24605 zNew = sqlite3DbMallocRaw(db, (int)n);
24606 if( zNew ){
24607 memcpy(zNew, z, n);
24608 }
24609 return zNew;
24610 }
@@ -29127,11 +29157,11 @@
29127 /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29128 /* 121 */ "RowKey" OpHelp("r[P2]=key"),
29129 /* 122 */ "RowData" OpHelp("r[P2]=data"),
29130 /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29131 /* 124 */ "NullRow" OpHelp(""),
29132 /* 125 */ "SorterInsert" OpHelp(""),
29133 /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29134 /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29135 /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29136 /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29137 /* 130 */ "Destroy" OpHelp(""),
@@ -40674,10 +40704,16 @@
40674 a[1] = winIoerrRetryDelay;
40675 }
40676 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
40677 return SQLITE_OK;
40678 }
 
 
 
 
 
 
40679 #ifdef SQLITE_TEST
40680 case SQLITE_FCNTL_WIN32_SET_HANDLE: {
40681 LPHANDLE phFile = (LPHANDLE)pArg;
40682 HANDLE hOldFile = pFile->h;
40683 pFile->h = *phFile;
@@ -46249,21 +46285,21 @@
46249 #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
46250
46251 #ifdef SQLITE_OMIT_WAL
46252 # define sqlite3WalOpen(x,y,z) 0
46253 # define sqlite3WalLimit(x,y)
46254 # define sqlite3WalClose(w,x,y,z) 0
46255 # define sqlite3WalBeginReadTransaction(y,z) 0
46256 # define sqlite3WalEndReadTransaction(z)
46257 # define sqlite3WalDbsize(y) 0
46258 # define sqlite3WalBeginWriteTransaction(y) 0
46259 # define sqlite3WalEndWriteTransaction(x) 0
46260 # define sqlite3WalUndo(x,y,z) 0
46261 # define sqlite3WalSavepoint(y,z)
46262 # define sqlite3WalSavepointUndo(y,z) 0
46263 # define sqlite3WalFrames(u,v,w,x,y,z) 0
46264 # define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0
46265 # define sqlite3WalCallback(z) 0
46266 # define sqlite3WalExclusiveMode(y,z) 0
46267 # define sqlite3WalHeapMemory(z) 0
46268 # define sqlite3WalFramesize(z) 0
46269 # define sqlite3WalFindFrame(x,y,z) 0
@@ -46277,11 +46313,11 @@
46277 */
46278 typedef struct Wal Wal;
46279
46280 /* Open and close a connection to a write-ahead log. */
46281 SQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
46282 SQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);
46283
46284 /* Set the limiting size of a WAL file. */
46285 SQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);
46286
46287 /* Used by readers to open (lock) and close (unlock) a snapshot. A
@@ -46320,10 +46356,11 @@
46320 SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
46321
46322 /* Copy pages from the log to the database file */
46323 SQLITE_PRIVATE int sqlite3WalCheckpoint(
46324 Wal *pWal, /* Write-ahead log connection */
 
46325 int eMode, /* One of PASSIVE, FULL and RESTART */
46326 int (*xBusy)(void*), /* Function to call when busy */
46327 void *pBusyArg, /* Context argument for xBusyHandler */
46328 int sync_flags, /* Flags to sync db file with (or 0) */
46329 int nBuf, /* Size of buffer nBuf */
@@ -47164,13 +47201,14 @@
47164 /*
47165 ** Return true if this pager uses a write-ahead log instead of the usual
47166 ** rollback journal. Otherwise false.
47167 */
47168 #ifndef SQLITE_OMIT_WAL
47169 static int pagerUseWal(Pager *pPager){
47170 return (pPager->pWal!=0);
47171 }
 
47172 #else
47173 # define pagerUseWal(x) 0
47174 # define pagerRollbackWal(x) 0
47175 # define pagerWalFrames(v,w,x,y) 0
47176 # define pagerOpenWalIfPresent(z) SQLITE_OK
@@ -50368,21 +50406,22 @@
50368 ** This function always succeeds. If a transaction is active an attempt
50369 ** is made to roll it back. If an error occurs during the rollback
50370 ** a hot journal may be left in the filesystem but no error is returned
50371 ** to the caller.
50372 */
50373 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
50374 u8 *pTmp = (u8 *)pPager->pTmpSpace;
50375
 
50376 assert( assert_pager_state(pPager) );
50377 disable_simulated_io_errors();
50378 sqlite3BeginBenignMalloc();
50379 pagerFreeMapHdrs(pPager);
50380 /* pPager->errCode = 0; */
50381 pPager->exclusiveMode = 0;
50382 #ifndef SQLITE_OMIT_WAL
50383 sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp);
50384 pPager->pWal = 0;
50385 #endif
50386 pager_reset(pPager);
50387 if( MEMDB ){
50388 pager_unlock(pPager);
@@ -53541,14 +53580,20 @@
53541 ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
53542 ** or wal_blocking_checkpoint() API functions.
53543 **
53544 ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
53545 */
53546 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog, int *pnCkpt){
 
 
 
 
 
 
53547 int rc = SQLITE_OK;
53548 if( pPager->pWal ){
53549 rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
53550 (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
53551 pPager->pBusyHandlerArg,
53552 pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
53553 pnLog, pnCkpt
53554 );
@@ -53676,11 +53721,11 @@
53676 ** Before closing the log file, this function attempts to take an
53677 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
53678 ** error (SQLITE_BUSY) is returned and the log connection is not closed.
53679 ** If successful, the EXCLUSIVE lock is not released before returning.
53680 */
53681 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){
53682 int rc = SQLITE_OK;
53683
53684 assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );
53685
53686 /* If the log file is not already open, but does exist in the file-system,
@@ -53704,11 +53749,11 @@
53704 ** the database file, the log and log-summary files will be deleted.
53705 */
53706 if( rc==SQLITE_OK && pPager->pWal ){
53707 rc = pagerExclusiveLock(pPager);
53708 if( rc==SQLITE_OK ){
53709 rc = sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags,
53710 pPager->pageSize, (u8*)pPager->pTmpSpace);
53711 pPager->pWal = 0;
53712 pagerFixMaplimit(pPager);
53713 if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
53714 }
@@ -55487,10 +55532,11 @@
55487 ** checkpoint is running (in any other thread or process) at the same
55488 ** time.
55489 */
55490 static int walCheckpoint(
55491 Wal *pWal, /* Wal connection */
 
55492 int eMode, /* One of PASSIVE, FULL or RESTART */
55493 int (*xBusy)(void*), /* Function to call when busy */
55494 void *pBusyArg, /* Context argument for xBusyHandler */
55495 int sync_flags, /* Flags for OsSync() (or 0) */
55496 u8 *zBuf /* Temporary buffer to use */
@@ -55581,10 +55627,14 @@
55581
55582 /* Iterate through the contents of the WAL, copying data to the db file */
55583 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
55584 i64 iOffset;
55585 assert( walFramePgno(pWal, iFrame)==iDbpage );
 
 
 
 
55586 if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
55587 continue;
55588 }
55589 iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
55590 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
@@ -55685,10 +55735,11 @@
55685 /*
55686 ** Close a connection to a log file.
55687 */
55688 SQLITE_PRIVATE int sqlite3WalClose(
55689 Wal *pWal, /* Wal to close */
 
55690 int sync_flags, /* Flags to pass to OsSync() (or 0) */
55691 int nBuf,
55692 u8 *zBuf /* Buffer of at least nBuf bytes */
55693 ){
55694 int rc = SQLITE_OK;
@@ -55701,17 +55752,18 @@
55701 ** the database. In this case checkpoint the database and unlink both
55702 ** the wal and wal-index files.
55703 **
55704 ** The EXCLUSIVE lock is not released before returning.
55705 */
55706 rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);
55707 if( rc==SQLITE_OK ){
 
55708 if( pWal->exclusiveMode==WAL_NORMAL_MODE ){
55709 pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;
55710 }
55711 rc = sqlite3WalCheckpoint(
55712 pWal, SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
55713 );
55714 if( rc==SQLITE_OK ){
55715 int bPersist = -1;
55716 sqlite3OsFileControlHint(
55717 pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist
@@ -56955,10 +57007,11 @@
56955 ** If parameter xBusy is not NULL, it is a pointer to a busy-handler
56956 ** callback. In this case this function runs a blocking checkpoint.
56957 */
56958 SQLITE_PRIVATE int sqlite3WalCheckpoint(
56959 Wal *pWal, /* Wal connection */
 
56960 int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
56961 int (*xBusy)(void*), /* Function to call when busy */
56962 void *pBusyArg, /* Context argument for xBusyHandler */
56963 int sync_flags, /* Flags to sync db file with (or 0) */
56964 int nBuf, /* Size of temporary buffer */
@@ -57029,11 +57082,11 @@
57029 if( rc==SQLITE_OK ){
57030
57031 if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
57032 rc = SQLITE_CORRUPT_BKPT;
57033 }else{
57034 rc = walCheckpoint(pWal, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
57035 }
57036
57037 /* If no error occurred, set the output variables. */
57038 if( rc==SQLITE_OK || rc==SQLITE_BUSY ){
57039 if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;
@@ -60619,23 +60672,30 @@
60619 *ppBtree = p;
60620
60621 btree_open_out:
60622 if( rc!=SQLITE_OK ){
60623 if( pBt && pBt->pPager ){
60624 sqlite3PagerClose(pBt->pPager);
60625 }
60626 sqlite3_free(pBt);
60627 sqlite3_free(p);
60628 *ppBtree = 0;
60629 }else{
 
 
60630 /* If the B-Tree was successfully opened, set the pager-cache size to the
60631 ** default value. Except, when opening on an existing shared pager-cache,
60632 ** do not change the pager-cache size.
60633 */
60634 if( sqlite3BtreeSchema(p, 0, 0)==0 ){
60635 sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);
60636 }
 
 
 
 
 
60637 }
60638 if( mutexOpen ){
60639 assert( sqlite3_mutex_held(mutexOpen) );
60640 sqlite3_mutex_leave(mutexOpen);
60641 }
@@ -60761,11 +60821,11 @@
60761 ** it without having to hold the mutex.
60762 **
60763 ** Clean out and delete the BtShared object.
60764 */
60765 assert( !pBt->pCursor );
60766 sqlite3PagerClose(pBt->pPager);
60767 if( pBt->xFreeSchema && pBt->pSchema ){
60768 pBt->xFreeSchema(pBt->pSchema);
60769 }
60770 sqlite3DbFree(0, pBt->pSchema);
60771 freeTempSpace(pBt);
@@ -62825,11 +62885,11 @@
62825 if( (eOp&0x01)==0 /* (1) */
62826 && offset==0 /* (2) */
62827 && (bEnd || a==ovflSize) /* (6) */
62828 && pBt->inTransaction==TRANS_READ /* (4) */
62829 && (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
62830 && pBt->pPage1->aData[19]==0x01 /* (5) */
62831 && &pBuf[-4]>=pBufStart /* (7) */
62832 ){
62833 u8 aSave[4];
62834 u8 *aWrite = &pBuf[-4];
62835 assert( aWrite>=pBufStart ); /* hence (7) */
@@ -63081,13 +63141,16 @@
63081 }
63082 sqlite3BtreeClearCursor(pCur);
63083 }
63084
63085 if( pCur->iPage>=0 ){
63086 while( pCur->iPage ){
63087 assert( pCur->apPage[pCur->iPage]!=0 );
63088 releasePageNotNull(pCur->apPage[pCur->iPage--]);
 
 
 
63089 }
63090 }else if( pCur->pgnoRoot==0 ){
63091 pCur->eState = CURSOR_INVALID;
63092 return SQLITE_OK;
63093 }else{
@@ -63094,11 +63157,11 @@
63094 assert( pCur->iPage==(-1) );
63095 rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
63096 0, pCur->curPagerFlags);
63097 if( rc!=SQLITE_OK ){
63098 pCur->eState = CURSOR_INVALID;
63099 return rc;
63100 }
63101 pCur->iPage = 0;
63102 pCur->curIntKey = pCur->apPage[0]->intKey;
63103 }
63104 pRoot = pCur->apPage[0];
@@ -63117,14 +63180,16 @@
63117 assert( pRoot->intKey==1 || pRoot->intKey==0 );
63118 if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
63119 return SQLITE_CORRUPT_BKPT;
63120 }
63121
 
63122 pCur->aiIdx[0] = 0;
63123 pCur->info.nSize = 0;
63124 pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
63125
 
63126 if( pRoot->nCell>0 ){
63127 pCur->eState = CURSOR_VALID;
63128 }else if( !pRoot->leaf ){
63129 Pgno subpage;
63130 if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
@@ -67701,11 +67766,11 @@
67701 BtShared *pBt = p->pBt;
67702 sqlite3BtreeEnter(p);
67703 if( pBt->inTransaction!=TRANS_NONE ){
67704 rc = SQLITE_LOCKED;
67705 }else{
67706 rc = sqlite3PagerCheckpoint(pBt->pPager, eMode, pnLog, pnCkpt);
67707 }
67708 sqlite3BtreeLeave(p);
67709 }
67710 return rc;
67711 }
@@ -75076,11 +75141,11 @@
75076 preupdate.keyinfo.enc = ENC(db);
75077 preupdate.keyinfo.nField = pTab->nCol;
75078 preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
75079 preupdate.iKey1 = iKey1;
75080 preupdate.iKey2 = iKey2;
75081 preupdate.iPKey = pTab->iPKey;
75082
75083 db->pPreUpdate = &preupdate;
75084 db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
75085 db->pPreUpdate = 0;
75086 sqlite3DbFree(db, preupdate.aRecord);
@@ -76808,13 +76873,18 @@
76808 }
76809
76810 if( iIdx>=p->pUnpacked->nField ){
76811 *ppValue = (sqlite3_value *)columnNullValue();
76812 }else{
 
76813 *ppValue = &p->pUnpacked->aMem[iIdx];
76814 if( iIdx==p->iPKey ){
76815 sqlite3VdbeMemSetInt64(*ppValue, p->iKey1);
 
 
 
 
76816 }
76817 }
76818
76819 preupdate_old_out:
76820 sqlite3Error(db, rc);
@@ -76887,11 +76957,11 @@
76887 }
76888 if( iIdx>=pUnpack->nField ){
76889 pMem = (sqlite3_value *)columnNullValue();
76890 }else{
76891 pMem = &pUnpack->aMem[iIdx];
76892 if( iIdx==p->iPKey ){
76893 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
76894 }
76895 }
76896 }else{
76897 /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
@@ -76908,11 +76978,11 @@
76908 }
76909 }
76910 assert( iIdx>=0 && iIdx<p->pCsr->nField );
76911 pMem = &p->aNew[iIdx];
76912 if( pMem->flags==0 ){
76913 if( iIdx==p->iPKey ){
76914 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
76915 }else{
76916 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
76917 if( rc!=SQLITE_OK ) goto preupdate_new_out;
76918 }
@@ -79286,12 +79356,11 @@
79286 ** or not both operands are null.
79287 */
79288 assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
79289 assert( (flags1 & MEM_Cleared)==0 );
79290 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
79291 if( (flags1&MEM_Null)!=0
79292 && (flags3&MEM_Null)!=0
79293 && (flags3&MEM_Cleared)==0
79294 ){
79295 res = 0; /* Operands are equal */
79296 }else{
79297 res = 1; /* Operands are not equal */
@@ -81554,11 +81623,11 @@
81554
81555 REGISTER_TRACE(pOp->p3, pMem);
81556 sqlite3VdbeMemIntegerify(pMem);
81557 assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
81558 if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
81559 rc = SQLITE_FULL; /* IMP: R-12275-61338 */
81560 goto abort_due_to_error;
81561 }
81562 if( v<pMem->u.i+1 ){
81563 v = pMem->u.i + 1;
81564 }
@@ -82321,10 +82390,17 @@
82321 ** This flag avoids doing an extra seek.
82322 **
82323 ** This instruction only works for indices. The equivalent instruction
82324 ** for tables is OP_Insert.
82325 */
 
 
 
 
 
 
 
82326 case OP_SorterInsert: /* in2 */
82327 case OP_IdxInsert: { /* in2 */
82328 VdbeCursor *pC;
82329 BtreePayload x;
82330
@@ -83549,11 +83625,11 @@
83549 /* If leaving WAL mode, close the log file. If successful, the call
83550 ** to PagerCloseWal() checkpoints and deletes the write-ahead-log
83551 ** file. An EXCLUSIVE lock may still be held on the database file
83552 ** after a successful return.
83553 */
83554 rc = sqlite3PagerCloseWal(pPager);
83555 if( rc==SQLITE_OK ){
83556 sqlite3PagerSetJournalMode(pPager, eNew);
83557 }
83558 }else if( eOld==PAGER_JOURNALMODE_MEMORY ){
83559 /* Cannot transition directly from MEMORY to WAL. Use mode OFF
@@ -94292,15 +94368,14 @@
94292 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
94293 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
94294 ){
94295 return 1;
94296 }
94297 if( pE2->op==TK_NOTNULL
94298 && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
94299 && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
94300 ){
94301 return 1;
94302 }
94303 return 0;
94304 }
94305
94306 /*
@@ -122354,11 +122429,11 @@
122354 }
122355 #endif
122356
122357 sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
122358 sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
122359 sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF);
122360
122361 /* Begin a transaction and take an exclusive lock on the main database
122362 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
122363 ** to ensure that we do not try to change the page-size on a WAL database.
122364 */
@@ -127537,10 +127612,11 @@
127537 Expr *pNew;
127538 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
127539 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
127540
127541 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
 
127542 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
127543 exprAnalyze(pSrc, pWC, idxNew);
127544 }
127545 pTerm = &pWC->a[idxTerm];
127546 pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL; /* Disable the original */
@@ -127978,15 +128054,17 @@
127978 Expr *pX; /* An expression being tested */
127979 WhereClause *pWC; /* Shorthand for pScan->pWC */
127980 WhereTerm *pTerm; /* The term being tested */
127981 int k = pScan->k; /* Where to start scanning */
127982
127983 while( pScan->iEquiv<=pScan->nEquiv ){
127984 iCur = pScan->aiCur[pScan->iEquiv-1];
 
127985 iColumn = pScan->aiColumn[pScan->iEquiv-1];
127986 if( iColumn==XN_EXPR && pScan->pIdxExpr==0 ) return 0;
127987 while( (pWC = pScan->pWC)!=0 ){
 
127988 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
127989 if( pTerm->leftCursor==iCur
127990 && pTerm->u.leftColumn==iColumn
127991 && (iColumn!=XN_EXPR
127992 || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
@@ -128032,19 +128110,21 @@
128032 && pX->iColumn==pScan->aiColumn[0]
128033 ){
128034 testcase( pTerm->eOperator & WO_IS );
128035 continue;
128036 }
 
128037 pScan->k = k+1;
128038 return pTerm;
128039 }
128040 }
128041 }
128042 pScan->pWC = pScan->pWC->pOuter;
128043 k = 0;
128044 }
128045 pScan->pWC = pScan->pOrigWC;
 
128046 k = 0;
128047 pScan->iEquiv++;
128048 }
128049 return 0;
128050 }
@@ -128074,28 +128154,28 @@
128074 int iCur, /* Cursor to scan for */
128075 int iColumn, /* Column to scan for */
128076 u32 opMask, /* Operator(s) to scan for */
128077 Index *pIdx /* Must be compatible with this index */
128078 ){
128079 int j = 0;
128080
128081 /* memset(pScan, 0, sizeof(*pScan)); */
128082 pScan->pOrigWC = pWC;
128083 pScan->pWC = pWC;
128084 pScan->pIdxExpr = 0;
 
 
128085 if( pIdx ){
128086 j = iColumn;
128087 iColumn = pIdx->aiColumn[j];
128088 if( iColumn==XN_EXPR ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
128089 if( iColumn==pIdx->pTable->iPKey ) iColumn = XN_ROWID;
128090 }
128091 if( pIdx && iColumn>=0 ){
128092 pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
128093 pScan->zCollName = pIdx->azColl[j];
128094 }else{
128095 pScan->idxaff = 0;
128096 pScan->zCollName = 0;
 
128097 }
128098 pScan->opMask = opMask;
128099 pScan->k = 0;
128100 pScan->aiCur[0] = iCur;
128101 pScan->aiColumn[0] = iColumn;
@@ -132640,17 +132720,19 @@
132640 pLevel->addrLikeRep);
132641 VdbeCoverage(v);
132642 }
132643 #endif
132644 if( pLevel->iLeftJoin ){
 
132645 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
132646 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
132647 || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
132648 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
132649 sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
132650 }
132651 if( pLoop->wsFlags & WHERE_INDEXED ){
 
 
132652 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
132653 }
132654 if( pLevel->op==OP_Return ){
132655 sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
132656 }else{
@@ -138612,10 +138694,11 @@
138612 } aFlagOp[] = {
138613 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
138614 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
138615 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
138616 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
 
138617 };
138618 unsigned int i;
138619 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
138620 for(i=0; i<ArraySize(aFlagOp); i++){
138621 if( aFlagOp[i].op==op ){
@@ -139908,10 +139991,17 @@
139908 db->busyHandler.nBusy = 0;
139909 rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
139910 sqlite3Error(db, rc);
139911 }
139912 rc = sqlite3ApiExit(db, rc);
 
 
 
 
 
 
 
139913 sqlite3_mutex_leave(db->mutex);
139914 return rc;
139915 #endif
139916 }
139917
@@ -140410,10 +140500,11 @@
140410 int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);
140411 octet += sqlite3HexToInt(zUri[iIn++]);
140412
140413 assert( octet>=0 && octet<256 );
140414 if( octet==0 ){
 
140415 /* This branch is taken when "%00" appears within the URI. In this
140416 ** case we ignore all text in the remainder of the path, name or
140417 ** value currently being parsed. So ignore the current character
140418 ** and skip to the next "?", "=" or "&", as appropriate. */
140419 while( (c = zUri[iIn])!=0 && c!='#'
@@ -140422,10 +140513,16 @@
140422 && (eState!=2 || c!='&')
140423 ){
140424 iIn++;
140425 }
140426 continue;
 
 
 
 
 
 
140427 }
140428 c = octet;
140429 }else if( eState==1 && (c=='&' || c=='=') ){
140430 if( zFile[iOut-1]==0 ){
140431 /* An empty option name. Ignore this option altogether. */
@@ -165207,11 +165304,11 @@
165207 ** of the locale to use. Passing an empty string ("") or SQL NULL value
165208 ** as the second argument is the same as invoking the 1 argument version
165209 ** of upper() or lower().
165210 **
165211 ** lower('I', 'en_us') -> 'i'
165212 ** lower('I', 'tr_tr') -> 'ı' (small dotless i)
165213 **
165214 ** http://www.icu-project.org/userguide/posix.html#case_mappings
165215 */
165216 static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
165217 const UChar *zInput; /* Pointer to input string */
@@ -195596,11 +195693,11 @@
195596 int nArg, /* Number of args */
195597 sqlite3_value **apUnused /* Function arguments */
195598 ){
195599 assert( nArg==0 );
195600 UNUSED_PARAM2(nArg, apUnused);
195601 sqlite3_result_text(pCtx, "fts5: 2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8", -1, SQLITE_TRANSIENT);
195602 }
195603
195604 static int fts5Init(sqlite3 *db){
195605 static const sqlite3_module fts5Mod = {
195606 /* iVersion */ 2,
195607
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.16.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -379,13 +379,13 @@
379 **
380 ** See also: [sqlite3_libversion()],
381 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
382 ** [sqlite_version()] and [sqlite_source_id()].
383 */
384 #define SQLITE_VERSION "3.16.0"
385 #define SQLITE_VERSION_NUMBER 3016000
386 #define SQLITE_SOURCE_ID "2016-11-02 14:50:19 3028845329c9b7acdec2ec8b01d00d782347454c"
387
388 /*
389 ** CAPI3REF: Run-Time Library Version Numbers
390 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
391 **
@@ -1235,10 +1235,16 @@
1235 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
1236 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
1237 ** pointer to an integer and it writes a boolean into that integer depending
1238 ** on whether or not the file has been renamed, moved, or deleted since it
1239 ** was first opened.
1240 **
1241 ** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
1242 ** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
1243 ** underlying native file handle associated with a file handle. This file
1244 ** control interprets its argument as a pointer to a native file handle and
1245 ** writes the resulting value there.
1246 **
1247 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
1248 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
1249 ** opcode causes the xFileControl method to swap the file handle with the one
1250 ** pointed to by the pArg argument. This capability is used during testing
@@ -1286,10 +1292,12 @@
1292 #define SQLITE_FCNTL_WAL_BLOCK 24
1293 #define SQLITE_FCNTL_ZIPVFS 25
1294 #define SQLITE_FCNTL_RBU 26
1295 #define SQLITE_FCNTL_VFS_POINTER 27
1296 #define SQLITE_FCNTL_JOURNAL_POINTER 28
1297 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29
1298 #define SQLITE_FCNTL_PDB 30
1299
1300 /* deprecated names */
1301 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1302 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1303 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -2238,18 +2246,31 @@
2246 ** does not make a copy of the new main schema name string, so the application
2247 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2248 ** until after the database connection closes.
2249 ** </dd>
2250 **
2251 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2252 ** <dd> Usually, when a database in wal mode is closed or detached from a
2253 ** database handle, SQLite checks if this will mean that there are now no
2254 ** connections at all to the database. If so, it performs a checkpoint
2255 ** operation before closing the connection. This option may be used to
2256 ** override this behaviour. The first parameter passed to this operation
2257 ** is an integer - non-zero to disable checkpoints-on-close, or zero (the
2258 ** default) to enable them. The second parameter is a pointer to an integer
2259 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2260 ** have been disabled - 0 if they are not disabled, 1 if they are.
2261 ** </dd>
2262 **
2263 ** </dl>
2264 */
2265 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2266 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2267 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2268 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2269 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2270 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2271 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2272
2273
2274 /*
2275 ** CAPI3REF: Enable Or Disable Extended Result Codes
2276 ** METHOD: sqlite3
@@ -12675,11 +12696,11 @@
12696 #define OP_SorterData 120 /* synopsis: r[P2]=data */
12697 #define OP_RowKey 121 /* synopsis: r[P2]=key */
12698 #define OP_RowData 122 /* synopsis: r[P2]=data */
12699 #define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12700 #define OP_NullRow 124
12701 #define OP_SorterInsert 125 /* synopsis: key=r[P2] */
12702 #define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12703 #define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12704 #define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12705 #define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12706 #define OP_Destroy 130
@@ -13030,11 +13051,11 @@
13051 int,
13052 int,
13053 int,
13054 void(*)(DbPage*)
13055 );
13056 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);
13057 SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
13058
13059 /* Functions used to configure a Pager object. */
13060 SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
13061 SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
@@ -13081,19 +13102,22 @@
13102 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
13103 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
13104 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
13105
13106 #ifndef SQLITE_OMIT_WAL
13107 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
13108 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
13109 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
13110 SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
13111 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
13112 SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager);
13113 # ifdef SQLITE_ENABLE_SNAPSHOT
13114 SQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
13115 SQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
13116 # endif
13117 #else
13118 # define sqlite3PagerUseWal(x) 0
13119 #endif
13120
13121 #ifdef SQLITE_ENABLE_ZIPVFS
13122 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
13123 #endif
@@ -14060,10 +14084,11 @@
14084 #define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
14085 #define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
14086 #define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
14087 #define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
14088 #define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
14089 #define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
14090
14091
14092 /*
14093 ** Bits of the sqlite3.dbOptFlags field that are used by the
14094 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17268,10 +17293,13 @@
17293 #if SQLITE_DEFAULT_LOCKING_MODE
17294 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17295 #endif
17296 #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17297 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17298 #endif
17299 #if SQLITE_DIRECT_OVERFLOW_READ
17300 "DIRECT_OVERFLOW_READ",
17301 #endif
17302 #if SQLITE_DISABLE_DIRSYNC
17303 "DISABLE_DIRSYNC",
17304 #endif
17305 #if SQLITE_DISABLE_LFS
@@ -17354,10 +17382,13 @@
17382 #if SQLITE_ENABLE_UNLOCK_NOTIFY
17383 "ENABLE_UNLOCK_NOTIFY",
17384 #endif
17385 #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
17386 "ENABLE_UPDATE_DELETE_LIMIT",
17387 #endif
17388 #if defined(SQLITE_ENABLE_URI_00_ERROR)
17389 "ENABLE_URI_00_ERROR",
17390 #endif
17391 #if SQLITE_HAS_CODEC
17392 "HAS_CODEC",
17393 #endif
17394 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
@@ -18105,12 +18136,12 @@
18136 UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */
18137 UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */
18138 int iNewReg; /* Register for new.* values */
18139 i64 iKey1; /* First key value passed to hook */
18140 i64 iKey2; /* Second key value passed to hook */
 
18141 Mem *aNew; /* Array of new.* values */
18142 Table *pTab; /* Schema object being upated */
18143 };
18144
18145 /*
18146 ** Function prototypes
18147 */
@@ -24598,13 +24629,12 @@
24629 char *zNew;
24630 size_t n;
24631 if( z==0 ){
24632 return 0;
24633 }
24634 n = strlen(z) + 1;
24635 zNew = sqlite3DbMallocRaw(db, n);
 
24636 if( zNew ){
24637 memcpy(zNew, z, n);
24638 }
24639 return zNew;
24640 }
@@ -29127,11 +29157,11 @@
29157 /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29158 /* 121 */ "RowKey" OpHelp("r[P2]=key"),
29159 /* 122 */ "RowData" OpHelp("r[P2]=data"),
29160 /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29161 /* 124 */ "NullRow" OpHelp(""),
29162 /* 125 */ "SorterInsert" OpHelp("key=r[P2]"),
29163 /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29164 /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29165 /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29166 /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29167 /* 130 */ "Destroy" OpHelp(""),
@@ -40674,10 +40704,16 @@
40704 a[1] = winIoerrRetryDelay;
40705 }
40706 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
40707 return SQLITE_OK;
40708 }
40709 case SQLITE_FCNTL_WIN32_GET_HANDLE: {
40710 LPHANDLE phFile = (LPHANDLE)pArg;
40711 *phFile = pFile->h;
40712 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
40713 return SQLITE_OK;
40714 }
40715 #ifdef SQLITE_TEST
40716 case SQLITE_FCNTL_WIN32_SET_HANDLE: {
40717 LPHANDLE phFile = (LPHANDLE)pArg;
40718 HANDLE hOldFile = pFile->h;
40719 pFile->h = *phFile;
@@ -46249,21 +46285,21 @@
46285 #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */
46286
46287 #ifdef SQLITE_OMIT_WAL
46288 # define sqlite3WalOpen(x,y,z) 0
46289 # define sqlite3WalLimit(x,y)
46290 # define sqlite3WalClose(v,w,x,y,z) 0
46291 # define sqlite3WalBeginReadTransaction(y,z) 0
46292 # define sqlite3WalEndReadTransaction(z)
46293 # define sqlite3WalDbsize(y) 0
46294 # define sqlite3WalBeginWriteTransaction(y) 0
46295 # define sqlite3WalEndWriteTransaction(x) 0
46296 # define sqlite3WalUndo(x,y,z) 0
46297 # define sqlite3WalSavepoint(y,z)
46298 # define sqlite3WalSavepointUndo(y,z) 0
46299 # define sqlite3WalFrames(u,v,w,x,y,z) 0
46300 # define sqlite3WalCheckpoint(q,r,s,t,u,v,w,x,y,z) 0
46301 # define sqlite3WalCallback(z) 0
46302 # define sqlite3WalExclusiveMode(y,z) 0
46303 # define sqlite3WalHeapMemory(z) 0
46304 # define sqlite3WalFramesize(z) 0
46305 # define sqlite3WalFindFrame(x,y,z) 0
@@ -46277,11 +46313,11 @@
46313 */
46314 typedef struct Wal Wal;
46315
46316 /* Open and close a connection to a write-ahead log. */
46317 SQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
46318 SQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);
46319
46320 /* Set the limiting size of a WAL file. */
46321 SQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);
46322
46323 /* Used by readers to open (lock) and close (unlock) a snapshot. A
@@ -46320,10 +46356,11 @@
46356 SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
46357
46358 /* Copy pages from the log to the database file */
46359 SQLITE_PRIVATE int sqlite3WalCheckpoint(
46360 Wal *pWal, /* Write-ahead log connection */
46361 sqlite3 *db, /* Check this handle's interrupt flag */
46362 int eMode, /* One of PASSIVE, FULL and RESTART */
46363 int (*xBusy)(void*), /* Function to call when busy */
46364 void *pBusyArg, /* Context argument for xBusyHandler */
46365 int sync_flags, /* Flags to sync db file with (or 0) */
46366 int nBuf, /* Size of buffer nBuf */
@@ -47164,13 +47201,14 @@
47201 /*
47202 ** Return true if this pager uses a write-ahead log instead of the usual
47203 ** rollback journal. Otherwise false.
47204 */
47205 #ifndef SQLITE_OMIT_WAL
47206 SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager){
47207 return (pPager->pWal!=0);
47208 }
47209 # define pagerUseWal(x) sqlite3PagerUseWal(x)
47210 #else
47211 # define pagerUseWal(x) 0
47212 # define pagerRollbackWal(x) 0
47213 # define pagerWalFrames(v,w,x,y) 0
47214 # define pagerOpenWalIfPresent(z) SQLITE_OK
@@ -50368,21 +50406,22 @@
50406 ** This function always succeeds. If a transaction is active an attempt
50407 ** is made to roll it back. If an error occurs during the rollback
50408 ** a hot journal may be left in the filesystem but no error is returned
50409 ** to the caller.
50410 */
50411 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){
50412 u8 *pTmp = (u8 *)pPager->pTmpSpace;
50413
50414 assert( db || pagerUseWal(pPager)==0 );
50415 assert( assert_pager_state(pPager) );
50416 disable_simulated_io_errors();
50417 sqlite3BeginBenignMalloc();
50418 pagerFreeMapHdrs(pPager);
50419 /* pPager->errCode = 0; */
50420 pPager->exclusiveMode = 0;
50421 #ifndef SQLITE_OMIT_WAL
50422 sqlite3WalClose(pPager->pWal,db,pPager->ckptSyncFlags,pPager->pageSize,pTmp);
50423 pPager->pWal = 0;
50424 #endif
50425 pager_reset(pPager);
50426 if( MEMDB ){
50427 pager_unlock(pPager);
@@ -53541,14 +53580,20 @@
53580 ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
53581 ** or wal_blocking_checkpoint() API functions.
53582 **
53583 ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
53584 */
53585 SQLITE_PRIVATE int sqlite3PagerCheckpoint(
53586 Pager *pPager, /* Checkpoint on this pager */
53587 sqlite3 *db, /* Db handle used to check for interrupts */
53588 int eMode, /* Type of checkpoint */
53589 int *pnLog, /* OUT: Final number of frames in log */
53590 int *pnCkpt /* OUT: Final number of checkpointed frames */
53591 ){
53592 int rc = SQLITE_OK;
53593 if( pPager->pWal ){
53594 rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
53595 (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
53596 pPager->pBusyHandlerArg,
53597 pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
53598 pnLog, pnCkpt
53599 );
@@ -53676,11 +53721,11 @@
53721 ** Before closing the log file, this function attempts to take an
53722 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
53723 ** error (SQLITE_BUSY) is returned and the log connection is not closed.
53724 ** If successful, the EXCLUSIVE lock is not released before returning.
53725 */
53726 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){
53727 int rc = SQLITE_OK;
53728
53729 assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );
53730
53731 /* If the log file is not already open, but does exist in the file-system,
@@ -53704,11 +53749,11 @@
53749 ** the database file, the log and log-summary files will be deleted.
53750 */
53751 if( rc==SQLITE_OK && pPager->pWal ){
53752 rc = pagerExclusiveLock(pPager);
53753 if( rc==SQLITE_OK ){
53754 rc = sqlite3WalClose(pPager->pWal, db, pPager->ckptSyncFlags,
53755 pPager->pageSize, (u8*)pPager->pTmpSpace);
53756 pPager->pWal = 0;
53757 pagerFixMaplimit(pPager);
53758 if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
53759 }
@@ -55487,10 +55532,11 @@
55532 ** checkpoint is running (in any other thread or process) at the same
55533 ** time.
55534 */
55535 static int walCheckpoint(
55536 Wal *pWal, /* Wal connection */
55537 sqlite3 *db, /* Check for interrupts on this handle */
55538 int eMode, /* One of PASSIVE, FULL or RESTART */
55539 int (*xBusy)(void*), /* Function to call when busy */
55540 void *pBusyArg, /* Context argument for xBusyHandler */
55541 int sync_flags, /* Flags for OsSync() (or 0) */
55542 u8 *zBuf /* Temporary buffer to use */
@@ -55581,10 +55627,14 @@
55627
55628 /* Iterate through the contents of the WAL, copying data to the db file */
55629 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
55630 i64 iOffset;
55631 assert( walFramePgno(pWal, iFrame)==iDbpage );
55632 if( db->u1.isInterrupted ){
55633 rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
55634 break;
55635 }
55636 if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
55637 continue;
55638 }
55639 iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
55640 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
@@ -55685,10 +55735,11 @@
55735 /*
55736 ** Close a connection to a log file.
55737 */
55738 SQLITE_PRIVATE int sqlite3WalClose(
55739 Wal *pWal, /* Wal to close */
55740 sqlite3 *db, /* For interrupt flag */
55741 int sync_flags, /* Flags to pass to OsSync() (or 0) */
55742 int nBuf,
55743 u8 *zBuf /* Buffer of at least nBuf bytes */
55744 ){
55745 int rc = SQLITE_OK;
@@ -55701,17 +55752,18 @@
55752 ** the database. In this case checkpoint the database and unlink both
55753 ** the wal and wal-index files.
55754 **
55755 ** The EXCLUSIVE lock is not released before returning.
55756 */
55757 if( (db->flags & SQLITE_NoCkptOnClose)==0
55758 && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))
55759 ){
55760 if( pWal->exclusiveMode==WAL_NORMAL_MODE ){
55761 pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;
55762 }
55763 rc = sqlite3WalCheckpoint(pWal, db,
55764 SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
55765 );
55766 if( rc==SQLITE_OK ){
55767 int bPersist = -1;
55768 sqlite3OsFileControlHint(
55769 pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist
@@ -56955,10 +57007,11 @@
57007 ** If parameter xBusy is not NULL, it is a pointer to a busy-handler
57008 ** callback. In this case this function runs a blocking checkpoint.
57009 */
57010 SQLITE_PRIVATE int sqlite3WalCheckpoint(
57011 Wal *pWal, /* Wal connection */
57012 sqlite3 *db, /* Check this handle's interrupt flag */
57013 int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
57014 int (*xBusy)(void*), /* Function to call when busy */
57015 void *pBusyArg, /* Context argument for xBusyHandler */
57016 int sync_flags, /* Flags to sync db file with (or 0) */
57017 int nBuf, /* Size of temporary buffer */
@@ -57029,11 +57082,11 @@
57082 if( rc==SQLITE_OK ){
57083
57084 if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
57085 rc = SQLITE_CORRUPT_BKPT;
57086 }else{
57087 rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
57088 }
57089
57090 /* If no error occurred, set the output variables. */
57091 if( rc==SQLITE_OK || rc==SQLITE_BUSY ){
57092 if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;
@@ -60619,23 +60672,30 @@
60672 *ppBtree = p;
60673
60674 btree_open_out:
60675 if( rc!=SQLITE_OK ){
60676 if( pBt && pBt->pPager ){
60677 sqlite3PagerClose(pBt->pPager, 0);
60678 }
60679 sqlite3_free(pBt);
60680 sqlite3_free(p);
60681 *ppBtree = 0;
60682 }else{
60683 sqlite3_file *pFile;
60684
60685 /* If the B-Tree was successfully opened, set the pager-cache size to the
60686 ** default value. Except, when opening on an existing shared pager-cache,
60687 ** do not change the pager-cache size.
60688 */
60689 if( sqlite3BtreeSchema(p, 0, 0)==0 ){
60690 sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);
60691 }
60692
60693 pFile = sqlite3PagerFile(pBt->pPager);
60694 if( pFile->pMethods ){
60695 sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_PDB, (void*)&pBt->db);
60696 }
60697 }
60698 if( mutexOpen ){
60699 assert( sqlite3_mutex_held(mutexOpen) );
60700 sqlite3_mutex_leave(mutexOpen);
60701 }
@@ -60761,11 +60821,11 @@
60821 ** it without having to hold the mutex.
60822 **
60823 ** Clean out and delete the BtShared object.
60824 */
60825 assert( !pBt->pCursor );
60826 sqlite3PagerClose(pBt->pPager, p->db);
60827 if( pBt->xFreeSchema && pBt->pSchema ){
60828 pBt->xFreeSchema(pBt->pSchema);
60829 }
60830 sqlite3DbFree(0, pBt->pSchema);
60831 freeTempSpace(pBt);
@@ -62825,11 +62885,11 @@
62885 if( (eOp&0x01)==0 /* (1) */
62886 && offset==0 /* (2) */
62887 && (bEnd || a==ovflSize) /* (6) */
62888 && pBt->inTransaction==TRANS_READ /* (4) */
62889 && (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
62890 && 0==sqlite3PagerUseWal(pBt->pPager) /* (5) */
62891 && &pBuf[-4]>=pBufStart /* (7) */
62892 ){
62893 u8 aSave[4];
62894 u8 *aWrite = &pBuf[-4];
62895 assert( aWrite>=pBufStart ); /* hence (7) */
@@ -63081,13 +63141,16 @@
63141 }
63142 sqlite3BtreeClearCursor(pCur);
63143 }
63144
63145 if( pCur->iPage>=0 ){
63146 if( pCur->iPage ){
63147 do{
63148 assert( pCur->apPage[pCur->iPage]!=0 );
63149 releasePageNotNull(pCur->apPage[pCur->iPage--]);
63150 }while( pCur->iPage);
63151 goto skip_init;
63152 }
63153 }else if( pCur->pgnoRoot==0 ){
63154 pCur->eState = CURSOR_INVALID;
63155 return SQLITE_OK;
63156 }else{
@@ -63094,11 +63157,11 @@
63157 assert( pCur->iPage==(-1) );
63158 rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
63159 0, pCur->curPagerFlags);
63160 if( rc!=SQLITE_OK ){
63161 pCur->eState = CURSOR_INVALID;
63162 return rc;
63163 }
63164 pCur->iPage = 0;
63165 pCur->curIntKey = pCur->apPage[0]->intKey;
63166 }
63167 pRoot = pCur->apPage[0];
@@ -63117,14 +63180,16 @@
63180 assert( pRoot->intKey==1 || pRoot->intKey==0 );
63181 if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
63182 return SQLITE_CORRUPT_BKPT;
63183 }
63184
63185 skip_init:
63186 pCur->aiIdx[0] = 0;
63187 pCur->info.nSize = 0;
63188 pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
63189
63190 pRoot = pCur->apPage[0];
63191 if( pRoot->nCell>0 ){
63192 pCur->eState = CURSOR_VALID;
63193 }else if( !pRoot->leaf ){
63194 Pgno subpage;
63195 if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
@@ -67701,11 +67766,11 @@
67766 BtShared *pBt = p->pBt;
67767 sqlite3BtreeEnter(p);
67768 if( pBt->inTransaction!=TRANS_NONE ){
67769 rc = SQLITE_LOCKED;
67770 }else{
67771 rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);
67772 }
67773 sqlite3BtreeLeave(p);
67774 }
67775 return rc;
67776 }
@@ -75076,11 +75141,11 @@
75141 preupdate.keyinfo.enc = ENC(db);
75142 preupdate.keyinfo.nField = pTab->nCol;
75143 preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;
75144 preupdate.iKey1 = iKey1;
75145 preupdate.iKey2 = iKey2;
75146 preupdate.pTab = pTab;
75147
75148 db->pPreUpdate = &preupdate;
75149 db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);
75150 db->pPreUpdate = 0;
75151 sqlite3DbFree(db, preupdate.aRecord);
@@ -76808,13 +76873,18 @@
76873 }
76874
76875 if( iIdx>=p->pUnpacked->nField ){
76876 *ppValue = (sqlite3_value *)columnNullValue();
76877 }else{
76878 Mem *pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
76879 *ppValue = &p->pUnpacked->aMem[iIdx];
76880 if( iIdx==p->pTab->iPKey ){
76881 sqlite3VdbeMemSetInt64(pMem, p->iKey1);
76882 }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){
76883 if( pMem->flags & MEM_Int ){
76884 sqlite3VdbeMemRealify(pMem);
76885 }
76886 }
76887 }
76888
76889 preupdate_old_out:
76890 sqlite3Error(db, rc);
@@ -76887,11 +76957,11 @@
76957 }
76958 if( iIdx>=pUnpack->nField ){
76959 pMem = (sqlite3_value *)columnNullValue();
76960 }else{
76961 pMem = &pUnpack->aMem[iIdx];
76962 if( iIdx==p->pTab->iPKey ){
76963 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
76964 }
76965 }
76966 }else{
76967 /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
@@ -76908,11 +76978,11 @@
76978 }
76979 }
76980 assert( iIdx>=0 && iIdx<p->pCsr->nField );
76981 pMem = &p->aNew[iIdx];
76982 if( pMem->flags==0 ){
76983 if( iIdx==p->pTab->iPKey ){
76984 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
76985 }else{
76986 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
76987 if( rc!=SQLITE_OK ) goto preupdate_new_out;
76988 }
@@ -79286,12 +79356,11 @@
79356 ** or not both operands are null.
79357 */
79358 assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
79359 assert( (flags1 & MEM_Cleared)==0 );
79360 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
79361 if( (flags1&flags3&MEM_Null)!=0
 
79362 && (flags3&MEM_Cleared)==0
79363 ){
79364 res = 0; /* Operands are equal */
79365 }else{
79366 res = 1; /* Operands are not equal */
@@ -81554,11 +81623,11 @@
81623
81624 REGISTER_TRACE(pOp->p3, pMem);
81625 sqlite3VdbeMemIntegerify(pMem);
81626 assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
81627 if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
81628 rc = SQLITE_FULL; /* IMP: R-17817-00630 */
81629 goto abort_due_to_error;
81630 }
81631 if( v<pMem->u.i+1 ){
81632 v = pMem->u.i + 1;
81633 }
@@ -82321,10 +82390,17 @@
82390 ** This flag avoids doing an extra seek.
82391 **
82392 ** This instruction only works for indices. The equivalent instruction
82393 ** for tables is OP_Insert.
82394 */
82395 /* Opcode: SorterInsert P1 P2 * * *
82396 ** Synopsis: key=r[P2]
82397 **
82398 ** Register P2 holds an SQL index key made using the
82399 ** MakeRecord instructions. This opcode writes that key
82400 ** into the sorter P1. Data for the entry is nil.
82401 */
82402 case OP_SorterInsert: /* in2 */
82403 case OP_IdxInsert: { /* in2 */
82404 VdbeCursor *pC;
82405 BtreePayload x;
82406
@@ -83549,11 +83625,11 @@
83625 /* If leaving WAL mode, close the log file. If successful, the call
83626 ** to PagerCloseWal() checkpoints and deletes the write-ahead-log
83627 ** file. An EXCLUSIVE lock may still be held on the database file
83628 ** after a successful return.
83629 */
83630 rc = sqlite3PagerCloseWal(pPager, db);
83631 if( rc==SQLITE_OK ){
83632 sqlite3PagerSetJournalMode(pPager, eNew);
83633 }
83634 }else if( eOld==PAGER_JOURNALMODE_MEMORY ){
83635 /* Cannot transition directly from MEMORY to WAL. Use mode OFF
@@ -94292,15 +94368,14 @@
94368 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
94369 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
94370 ){
94371 return 1;
94372 }
94373 if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
94374 Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
94375 testcase( pX!=pE1->pLeft );
94376 if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
 
94377 }
94378 return 0;
94379 }
94380
94381 /*
@@ -122354,11 +122429,11 @@
122429 }
122430 #endif
122431
122432 sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
122433 sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
122434 sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);
122435
122436 /* Begin a transaction and take an exclusive lock on the main database
122437 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
122438 ** to ensure that we do not try to change the page-size on a WAL database.
122439 */
@@ -127537,10 +127612,11 @@
127612 Expr *pNew;
127613 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
127614 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
127615
127616 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
127617 transferJoinMarkings(pNew, pExpr);
127618 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
127619 exprAnalyze(pSrc, pWC, idxNew);
127620 }
127621 pTerm = &pWC->a[idxTerm];
127622 pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL; /* Disable the original */
@@ -127978,15 +128054,17 @@
128054 Expr *pX; /* An expression being tested */
128055 WhereClause *pWC; /* Shorthand for pScan->pWC */
128056 WhereTerm *pTerm; /* The term being tested */
128057 int k = pScan->k; /* Where to start scanning */
128058
128059 assert( pScan->iEquiv<=pScan->nEquiv );
128060 pWC = pScan->pWC;
128061 while(1){
128062 iColumn = pScan->aiColumn[pScan->iEquiv-1];
128063 iCur = pScan->aiCur[pScan->iEquiv-1];
128064 assert( pWC!=0 );
128065 do{
128066 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
128067 if( pTerm->leftCursor==iCur
128068 && pTerm->u.leftColumn==iColumn
128069 && (iColumn!=XN_EXPR
128070 || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
@@ -128032,19 +128110,21 @@
128110 && pX->iColumn==pScan->aiColumn[0]
128111 ){
128112 testcase( pTerm->eOperator & WO_IS );
128113 continue;
128114 }
128115 pScan->pWC = pWC;
128116 pScan->k = k+1;
128117 return pTerm;
128118 }
128119 }
128120 }
128121 pWC = pWC->pOuter;
128122 k = 0;
128123 }while( pWC!=0 );
128124 if( pScan->iEquiv>=pScan->nEquiv ) break;
128125 pWC = pScan->pOrigWC;
128126 k = 0;
128127 pScan->iEquiv++;
128128 }
128129 return 0;
128130 }
@@ -128074,28 +128154,28 @@
128154 int iCur, /* Cursor to scan for */
128155 int iColumn, /* Column to scan for */
128156 u32 opMask, /* Operator(s) to scan for */
128157 Index *pIdx /* Must be compatible with this index */
128158 ){
 
 
 
128159 pScan->pOrigWC = pWC;
128160 pScan->pWC = pWC;
128161 pScan->pIdxExpr = 0;
128162 pScan->idxaff = 0;
128163 pScan->zCollName = 0;
128164 if( pIdx ){
128165 int j = iColumn;
128166 iColumn = pIdx->aiColumn[j];
128167 if( iColumn==XN_EXPR ){
128168 pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
128169 }else if( iColumn==pIdx->pTable->iPKey ){
128170 iColumn = XN_ROWID;
128171 }else if( iColumn>=0 ){
128172 pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
128173 pScan->zCollName = pIdx->azColl[j];
128174 }
128175 }else if( iColumn==XN_EXPR ){
128176 return 0;
128177 }
128178 pScan->opMask = opMask;
128179 pScan->k = 0;
128180 pScan->aiCur[0] = iCur;
128181 pScan->aiColumn[0] = iColumn;
@@ -132640,17 +132720,19 @@
132720 pLevel->addrLikeRep);
132721 VdbeCoverage(v);
132722 }
132723 #endif
132724 if( pLevel->iLeftJoin ){
132725 int ws = pLoop->wsFlags;
132726 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
132727 assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );
132728 if( (ws & WHERE_IDX_ONLY)==0 ){
 
132729 sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
132730 }
132731 if( (ws & WHERE_INDEXED)
132732 || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx)
132733 ){
132734 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
132735 }
132736 if( pLevel->op==OP_Return ){
132737 sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
132738 }else{
@@ -138612,10 +138694,11 @@
138694 } aFlagOp[] = {
138695 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
138696 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
138697 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
138698 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
138699 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
138700 };
138701 unsigned int i;
138702 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
138703 for(i=0; i<ArraySize(aFlagOp); i++){
138704 if( aFlagOp[i].op==op ){
@@ -139908,10 +139991,17 @@
139991 db->busyHandler.nBusy = 0;
139992 rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
139993 sqlite3Error(db, rc);
139994 }
139995 rc = sqlite3ApiExit(db, rc);
139996
139997 /* If there are no active statements, clear the interrupt flag at this
139998 ** point. */
139999 if( db->nVdbeActive==0 ){
140000 db->u1.isInterrupted = 0;
140001 }
140002
140003 sqlite3_mutex_leave(db->mutex);
140004 return rc;
140005 #endif
140006 }
140007
@@ -140410,10 +140500,11 @@
140500 int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);
140501 octet += sqlite3HexToInt(zUri[iIn++]);
140502
140503 assert( octet>=0 && octet<256 );
140504 if( octet==0 ){
140505 #ifndef SQLITE_ENABLE_URI_00_ERROR
140506 /* This branch is taken when "%00" appears within the URI. In this
140507 ** case we ignore all text in the remainder of the path, name or
140508 ** value currently being parsed. So ignore the current character
140509 ** and skip to the next "?", "=" or "&", as appropriate. */
140510 while( (c = zUri[iIn])!=0 && c!='#'
@@ -140422,10 +140513,16 @@
140513 && (eState!=2 || c!='&')
140514 ){
140515 iIn++;
140516 }
140517 continue;
140518 #else
140519 /* If ENABLE_URI_00_ERROR is defined, "%00" in a URI is an error. */
140520 *pzErrMsg = sqlite3_mprintf("unexpected %%00 in uri");
140521 rc = SQLITE_ERROR;
140522 goto parse_uri_out;
140523 #endif
140524 }
140525 c = octet;
140526 }else if( eState==1 && (c=='&' || c=='=') ){
140527 if( zFile[iOut-1]==0 ){
140528 /* An empty option name. Ignore this option altogether. */
@@ -165207,11 +165304,11 @@
165304 ** of the locale to use. Passing an empty string ("") or SQL NULL value
165305 ** as the second argument is the same as invoking the 1 argument version
165306 ** of upper() or lower().
165307 **
165308 ** lower('I', 'en_us') -> 'i'
165309 ** lower('I', 'tr_tr') -> '\u131' (small dotless i)
165310 **
165311 ** http://www.icu-project.org/userguide/posix.html#case_mappings
165312 */
165313 static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
165314 const UChar *zInput; /* Pointer to input string */
@@ -195596,11 +195693,11 @@
195693 int nArg, /* Number of args */
195694 sqlite3_value **apUnused /* Function arguments */
195695 ){
195696 assert( nArg==0 );
195697 UNUSED_PARAM2(nArg, apUnused);
195698 sqlite3_result_text(pCtx, "fts5: 2016-10-26 16:05:10 ec9dab8054c71d112c68f58a45821b38c2a45677", -1, SQLITE_TRANSIENT);
195699 }
195700
195701 static int fts5Init(sqlite3 *db){
195702 static const sqlite3_module fts5Mod = {
195703 /* iVersion */ 2,
195704
+24 -3
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119119
**
120120
** See also: [sqlite3_libversion()],
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124
-#define SQLITE_VERSION "3.15.0"
125
-#define SQLITE_VERSION_NUMBER 3015000
126
-#define SQLITE_SOURCE_ID "2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8"
124
+#define SQLITE_VERSION "3.16.0"
125
+#define SQLITE_VERSION_NUMBER 3016000
126
+#define SQLITE_SOURCE_ID "2016-11-02 14:50:19 3028845329c9b7acdec2ec8b01d00d782347454c"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version, sqlite3_sourceid
131131
**
@@ -975,10 +975,16 @@
975975
** <li>[[SQLITE_FCNTL_HAS_MOVED]]
976976
** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
977977
** pointer to an integer and it writes a boolean into that integer depending
978978
** on whether or not the file has been renamed, moved, or deleted since it
979979
** was first opened.
980
+**
981
+** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
982
+** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
983
+** underlying native file handle associated with a file handle. This file
984
+** control interprets its argument as a pointer to a native file handle and
985
+** writes the resulting value there.
980986
**
981987
** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
982988
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
983989
** opcode causes the xFileControl method to swap the file handle with the one
984990
** pointed to by the pArg argument. This capability is used during testing
@@ -1026,10 +1032,12 @@
10261032
#define SQLITE_FCNTL_WAL_BLOCK 24
10271033
#define SQLITE_FCNTL_ZIPVFS 25
10281034
#define SQLITE_FCNTL_RBU 26
10291035
#define SQLITE_FCNTL_VFS_POINTER 27
10301036
#define SQLITE_FCNTL_JOURNAL_POINTER 28
1037
+#define SQLITE_FCNTL_WIN32_GET_HANDLE 29
1038
+#define SQLITE_FCNTL_PDB 30
10311039
10321040
/* deprecated names */
10331041
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
10341042
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
10351043
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1978,18 +1986,31 @@
19781986
** does not make a copy of the new main schema name string, so the application
19791987
** must ensure that the argument passed into this DBCONFIG option is unchanged
19801988
** until after the database connection closes.
19811989
** </dd>
19821990
**
1991
+** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
1992
+** <dd> Usually, when a database in wal mode is closed or detached from a
1993
+** database handle, SQLite checks if this will mean that there are now no
1994
+** connections at all to the database. If so, it performs a checkpoint
1995
+** operation before closing the connection. This option may be used to
1996
+** override this behaviour. The first parameter passed to this operation
1997
+** is an integer - non-zero to disable checkpoints-on-close, or zero (the
1998
+** default) to enable them. The second parameter is a pointer to an integer
1999
+** into which is written 0 or 1 to indicate whether checkpoints-on-close
2000
+** have been disabled - 0 if they are not disabled, 1 if they are.
2001
+** </dd>
2002
+**
19832003
** </dl>
19842004
*/
19852005
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
19862006
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
19872007
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
19882008
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
19892009
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
19902010
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2011
+#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
19912012
19922013
19932014
/*
19942015
** CAPI3REF: Enable Or Disable Extended Result Codes
19952016
** METHOD: sqlite3
19962017
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.15.0"
125 #define SQLITE_VERSION_NUMBER 3015000
126 #define SQLITE_SOURCE_ID "2016-10-14 10:20:30 707875582fcba352b4906a595ad89198d84711d8"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
131 **
@@ -975,10 +975,16 @@
975 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
976 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
977 ** pointer to an integer and it writes a boolean into that integer depending
978 ** on whether or not the file has been renamed, moved, or deleted since it
979 ** was first opened.
 
 
 
 
 
 
980 **
981 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
982 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
983 ** opcode causes the xFileControl method to swap the file handle with the one
984 ** pointed to by the pArg argument. This capability is used during testing
@@ -1026,10 +1032,12 @@
1026 #define SQLITE_FCNTL_WAL_BLOCK 24
1027 #define SQLITE_FCNTL_ZIPVFS 25
1028 #define SQLITE_FCNTL_RBU 26
1029 #define SQLITE_FCNTL_VFS_POINTER 27
1030 #define SQLITE_FCNTL_JOURNAL_POINTER 28
 
 
1031
1032 /* deprecated names */
1033 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1034 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1035 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1978,18 +1986,31 @@
1978 ** does not make a copy of the new main schema name string, so the application
1979 ** must ensure that the argument passed into this DBCONFIG option is unchanged
1980 ** until after the database connection closes.
1981 ** </dd>
1982 **
 
 
 
 
 
 
 
 
 
 
 
 
1983 ** </dl>
1984 */
1985 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
1986 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1987 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
1988 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
1989 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
1990 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
 
1991
1992
1993 /*
1994 ** CAPI3REF: Enable Or Disable Extended Result Codes
1995 ** METHOD: sqlite3
1996
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.16.0"
125 #define SQLITE_VERSION_NUMBER 3016000
126 #define SQLITE_SOURCE_ID "2016-11-02 14:50:19 3028845329c9b7acdec2ec8b01d00d782347454c"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
131 **
@@ -975,10 +975,16 @@
975 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
976 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
977 ** pointer to an integer and it writes a boolean into that integer depending
978 ** on whether or not the file has been renamed, moved, or deleted since it
979 ** was first opened.
980 **
981 ** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
982 ** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
983 ** underlying native file handle associated with a file handle. This file
984 ** control interprets its argument as a pointer to a native file handle and
985 ** writes the resulting value there.
986 **
987 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
988 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
989 ** opcode causes the xFileControl method to swap the file handle with the one
990 ** pointed to by the pArg argument. This capability is used during testing
@@ -1026,10 +1032,12 @@
1032 #define SQLITE_FCNTL_WAL_BLOCK 24
1033 #define SQLITE_FCNTL_ZIPVFS 25
1034 #define SQLITE_FCNTL_RBU 26
1035 #define SQLITE_FCNTL_VFS_POINTER 27
1036 #define SQLITE_FCNTL_JOURNAL_POINTER 28
1037 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29
1038 #define SQLITE_FCNTL_PDB 30
1039
1040 /* deprecated names */
1041 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1042 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1043 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
@@ -1978,18 +1986,31 @@
1986 ** does not make a copy of the new main schema name string, so the application
1987 ** must ensure that the argument passed into this DBCONFIG option is unchanged
1988 ** until after the database connection closes.
1989 ** </dd>
1990 **
1991 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
1992 ** <dd> Usually, when a database in wal mode is closed or detached from a
1993 ** database handle, SQLite checks if this will mean that there are now no
1994 ** connections at all to the database. If so, it performs a checkpoint
1995 ** operation before closing the connection. This option may be used to
1996 ** override this behaviour. The first parameter passed to this operation
1997 ** is an integer - non-zero to disable checkpoints-on-close, or zero (the
1998 ** default) to enable them. The second parameter is a pointer to an integer
1999 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2000 ** have been disabled - 0 if they are not disabled, 1 if they are.
2001 ** </dd>
2002 **
2003 ** </dl>
2004 */
2005 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2006 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2007 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2008 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2009 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2010 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2011 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2012
2013
2014 /*
2015 ** CAPI3REF: Enable Or Disable Extended Result Codes
2016 ** METHOD: sqlite3
2017

Keyboard Shortcuts

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