Fossil SCM

upgrade SQLite to latest pre-release

jan.nijtmans 2015-03-19 09:25 trunk
Commit d1db1e47a4acdb7b13f311eafbd608330883c700
3 files changed +46 -19 +481 -221 +33 -32
+46 -19
--- src/shell.c
+++ src/shell.c
@@ -22,10 +22,17 @@
2222
*/
2323
#if defined(INCLUDE_MSVC_H)
2424
#include "msvc.h"
2525
#endif
2626
27
+/*
28
+** No support for loadable extensions in VxWorks.
29
+*/
30
+#if defined(_WRS_KERNEL) && !SQLITE_OMIT_LOAD_EXTENSION
31
+# define SQLITE_OMIT_LOAD_EXTENSION 1
32
+#endif
33
+
2734
/*
2835
** Enable large-file support for fopen() and friends on unix.
2936
*/
3037
#ifndef SQLITE_DISABLE_LFS
3138
# define _LARGE_FILE 1
@@ -105,14 +112,19 @@
105112
#else
106113
/* Make sure isatty() has a prototype.
107114
*/
108115
extern int isatty(int);
109116
110
-/* popen and pclose are not C89 functions and so are sometimes omitted from
111
-** the <stdio.h> header */
112
-extern FILE *popen(const char*,const char*);
113
-extern int pclose(FILE*);
117
+#if !defined(__RTP__) && !defined(_WRS_KERNEL)
118
+ /* popen and pclose are not C89 functions and so are sometimes omitted from
119
+ ** the <stdio.h> header */
120
+ extern FILE *popen(const char*,const char*);
121
+ extern int pclose(FILE*);
122
+#else
123
+# define SQLITE_OMIT_POPEN 1
124
+#endif
125
+
114126
#endif
115127
116128
#if defined(_WIN32_WCE)
117129
/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
118130
* thus we always assume that we have a console. That can be
@@ -163,14 +175,22 @@
163175
t = (sqlite3_int64)(r*86400000.0);
164176
}
165177
return t;
166178
}
167179
168
-#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \
169
- && !defined(__minux)
180
+#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
170181
#include <sys/time.h>
171182
#include <sys/resource.h>
183
+
184
+/* VxWorks does not support getrusage() as far as we can determine */
185
+#if defined(_WRS_KERNEL) || defined(__RTP__)
186
+struct rusage {
187
+ struct timeval ru_utime; /* user CPU time used */
188
+ struct timeval ru_stime; /* system CPU time used */
189
+};
190
+#define getrusage(A,B) memset(B,0,sizeof(*B))
191
+#endif
172192
173193
/* Saved resource information for the beginning of an operation */
174194
static struct rusage sBegin; /* CPU time at start */
175195
static sqlite3_int64 iBegin; /* Wall-clock time at start */
176196
@@ -193,12 +213,12 @@
193213
/*
194214
** Print the timing results.
195215
*/
196216
static void endTimer(void){
197217
if( enableTimer ){
198
- struct rusage sEnd;
199218
sqlite3_int64 iEnd = timeOfDay();
219
+ struct rusage sEnd;
200220
getrusage(RUSAGE_SELF, &sEnd);
201221
printf("Run Time: real %.3f user %f sys %f\n",
202222
(iEnd - iBegin)*0.001,
203223
timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
204224
timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
@@ -2437,11 +2457,13 @@
24372457
/*
24382458
** Change the output file back to stdout
24392459
*/
24402460
static void output_reset(ShellState *p){
24412461
if( p->outfile[0]=='|' ){
2462
+#ifndef SQLITE_OMIT_POPEN
24422463
pclose(p->out);
2464
+#endif
24432465
}else{
24442466
output_file_close(p->out);
24452467
}
24462468
p->outfile[0] = 0;
24472469
p->out = stdout;
@@ -2930,13 +2952,18 @@
29302952
return 1;
29312953
}
29322954
sCtx.zFile = zFile;
29332955
sCtx.nLine = 1;
29342956
if( sCtx.zFile[0]=='|' ){
2957
+#ifdef SQLITE_OMIT_POPEN
2958
+ fprintf(stderr, "Error: pipes are not supporte in this OS\n");
2959
+ return 1;
2960
+#else
29352961
sCtx.in = popen(sCtx.zFile+1, "r");
29362962
sCtx.zFile = "<pipe>";
29372963
xCloser = pclose;
2964
+#endif
29382965
}else{
29392966
sCtx.in = fopen(sCtx.zFile, "rb");
29402967
xCloser = fclose;
29412968
}
29422969
if( p->mode==MODE_Ascii ){
@@ -3255,18 +3282,24 @@
32553282
}else{
32563283
p->outCount = 0;
32573284
}
32583285
output_reset(p);
32593286
if( zFile[0]=='|' ){
3287
+#ifdef SQLITE_OMIT_POPEN
3288
+ fprintf(stderr,"Error: pipes are not supported in this OS\n");
3289
+ rc = 1;
3290
+ p->out = stdout;
3291
+#else
32603292
p->out = popen(zFile + 1, "w");
32613293
if( p->out==0 ){
32623294
fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
32633295
p->out = stdout;
32643296
rc = 1;
32653297
}else{
32663298
sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
32673299
}
3300
+#endif
32683301
}else{
32693302
p->out = output_file_open(zFile);
32703303
if( p->out==0 ){
32713304
if( strcmp(zFile,"off")!=0 ){
32723305
fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
@@ -4187,27 +4220,25 @@
41874220
** Read input from the file given by sqliterc_override. Or if that
41884221
** parameter is NULL, take input from ~/.sqliterc
41894222
**
41904223
** Returns the number of errors.
41914224
*/
4192
-static int process_sqliterc(
4225
+static void process_sqliterc(
41934226
ShellState *p, /* Configuration data */
41944227
const char *sqliterc_override /* Name of config file. NULL to use default */
41954228
){
41964229
char *home_dir = NULL;
41974230
const char *sqliterc = sqliterc_override;
41984231
char *zBuf = 0;
41994232
FILE *in = NULL;
4200
- int rc = 0;
42014233
42024234
if (sqliterc == NULL) {
42034235
home_dir = find_home_dir();
42044236
if( home_dir==0 ){
4205
-#if !defined(__RTP__) && !defined(_WRS_KERNEL)
4206
- fprintf(stderr,"%s: Error: cannot locate your home directory\n", Argv0);
4207
-#endif
4208
- return 1;
4237
+ fprintf(stderr, "-- warning: cannot find home directory;"
4238
+ " cannot read ~/.sqliterc\n");
4239
+ return;
42094240
}
42104241
sqlite3_initialize();
42114242
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
42124243
sqliterc = zBuf;
42134244
}
@@ -4214,15 +4245,14 @@
42144245
in = fopen(sqliterc,"rb");
42154246
if( in ){
42164247
if( stdin_is_interactive ){
42174248
fprintf(stderr,"-- Loading resources from %s\n",sqliterc);
42184249
}
4219
- rc = process_input(p,in);
4250
+ process_input(p,in);
42204251
fclose(in);
42214252
}
42224253
sqlite3_free(zBuf);
4223
- return rc;
42244254
}
42254255
42264256
/*
42274257
** Show available command line options
42284258
*/
@@ -4494,14 +4524,11 @@
44944524
44954525
/* Process the initialization file if there is one. If no -init option
44964526
** is given on the command line, look for a file named ~/.sqliterc and
44974527
** try to process it.
44984528
*/
4499
- rc = process_sqliterc(&data,zInitFile);
4500
- if( rc>0 ){
4501
- return rc;
4502
- }
4529
+ process_sqliterc(&data,zInitFile);
45034530
45044531
/* Make a second pass through the command-line argument and set
45054532
** options. This second pass is delayed until after the initialization
45064533
** file is processed so that the command-line arguments will override
45074534
** settings in the initialization file.
45084535
--- src/shell.c
+++ src/shell.c
@@ -22,10 +22,17 @@
22 */
23 #if defined(INCLUDE_MSVC_H)
24 #include "msvc.h"
25 #endif
26
 
 
 
 
 
 
 
27 /*
28 ** Enable large-file support for fopen() and friends on unix.
29 */
30 #ifndef SQLITE_DISABLE_LFS
31 # define _LARGE_FILE 1
@@ -105,14 +112,19 @@
105 #else
106 /* Make sure isatty() has a prototype.
107 */
108 extern int isatty(int);
109
110 /* popen and pclose are not C89 functions and so are sometimes omitted from
111 ** the <stdio.h> header */
112 extern FILE *popen(const char*,const char*);
113 extern int pclose(FILE*);
 
 
 
 
 
114 #endif
115
116 #if defined(_WIN32_WCE)
117 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
118 * thus we always assume that we have a console. That can be
@@ -163,14 +175,22 @@
163 t = (sqlite3_int64)(r*86400000.0);
164 }
165 return t;
166 }
167
168 #if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \
169 && !defined(__minux)
170 #include <sys/time.h>
171 #include <sys/resource.h>
 
 
 
 
 
 
 
 
 
172
173 /* Saved resource information for the beginning of an operation */
174 static struct rusage sBegin; /* CPU time at start */
175 static sqlite3_int64 iBegin; /* Wall-clock time at start */
176
@@ -193,12 +213,12 @@
193 /*
194 ** Print the timing results.
195 */
196 static void endTimer(void){
197 if( enableTimer ){
198 struct rusage sEnd;
199 sqlite3_int64 iEnd = timeOfDay();
 
200 getrusage(RUSAGE_SELF, &sEnd);
201 printf("Run Time: real %.3f user %f sys %f\n",
202 (iEnd - iBegin)*0.001,
203 timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
204 timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
@@ -2437,11 +2457,13 @@
2437 /*
2438 ** Change the output file back to stdout
2439 */
2440 static void output_reset(ShellState *p){
2441 if( p->outfile[0]=='|' ){
 
2442 pclose(p->out);
 
2443 }else{
2444 output_file_close(p->out);
2445 }
2446 p->outfile[0] = 0;
2447 p->out = stdout;
@@ -2930,13 +2952,18 @@
2930 return 1;
2931 }
2932 sCtx.zFile = zFile;
2933 sCtx.nLine = 1;
2934 if( sCtx.zFile[0]=='|' ){
 
 
 
 
2935 sCtx.in = popen(sCtx.zFile+1, "r");
2936 sCtx.zFile = "<pipe>";
2937 xCloser = pclose;
 
2938 }else{
2939 sCtx.in = fopen(sCtx.zFile, "rb");
2940 xCloser = fclose;
2941 }
2942 if( p->mode==MODE_Ascii ){
@@ -3255,18 +3282,24 @@
3255 }else{
3256 p->outCount = 0;
3257 }
3258 output_reset(p);
3259 if( zFile[0]=='|' ){
 
 
 
 
 
3260 p->out = popen(zFile + 1, "w");
3261 if( p->out==0 ){
3262 fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
3263 p->out = stdout;
3264 rc = 1;
3265 }else{
3266 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
3267 }
 
3268 }else{
3269 p->out = output_file_open(zFile);
3270 if( p->out==0 ){
3271 if( strcmp(zFile,"off")!=0 ){
3272 fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
@@ -4187,27 +4220,25 @@
4187 ** Read input from the file given by sqliterc_override. Or if that
4188 ** parameter is NULL, take input from ~/.sqliterc
4189 **
4190 ** Returns the number of errors.
4191 */
4192 static int process_sqliterc(
4193 ShellState *p, /* Configuration data */
4194 const char *sqliterc_override /* Name of config file. NULL to use default */
4195 ){
4196 char *home_dir = NULL;
4197 const char *sqliterc = sqliterc_override;
4198 char *zBuf = 0;
4199 FILE *in = NULL;
4200 int rc = 0;
4201
4202 if (sqliterc == NULL) {
4203 home_dir = find_home_dir();
4204 if( home_dir==0 ){
4205 #if !defined(__RTP__) && !defined(_WRS_KERNEL)
4206 fprintf(stderr,"%s: Error: cannot locate your home directory\n", Argv0);
4207 #endif
4208 return 1;
4209 }
4210 sqlite3_initialize();
4211 zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
4212 sqliterc = zBuf;
4213 }
@@ -4214,15 +4245,14 @@
4214 in = fopen(sqliterc,"rb");
4215 if( in ){
4216 if( stdin_is_interactive ){
4217 fprintf(stderr,"-- Loading resources from %s\n",sqliterc);
4218 }
4219 rc = process_input(p,in);
4220 fclose(in);
4221 }
4222 sqlite3_free(zBuf);
4223 return rc;
4224 }
4225
4226 /*
4227 ** Show available command line options
4228 */
@@ -4494,14 +4524,11 @@
4494
4495 /* Process the initialization file if there is one. If no -init option
4496 ** is given on the command line, look for a file named ~/.sqliterc and
4497 ** try to process it.
4498 */
4499 rc = process_sqliterc(&data,zInitFile);
4500 if( rc>0 ){
4501 return rc;
4502 }
4503
4504 /* Make a second pass through the command-line argument and set
4505 ** options. This second pass is delayed until after the initialization
4506 ** file is processed so that the command-line arguments will override
4507 ** settings in the initialization file.
4508
--- src/shell.c
+++ src/shell.c
@@ -22,10 +22,17 @@
22 */
23 #if defined(INCLUDE_MSVC_H)
24 #include "msvc.h"
25 #endif
26
27 /*
28 ** No support for loadable extensions in VxWorks.
29 */
30 #if defined(_WRS_KERNEL) && !SQLITE_OMIT_LOAD_EXTENSION
31 # define SQLITE_OMIT_LOAD_EXTENSION 1
32 #endif
33
34 /*
35 ** Enable large-file support for fopen() and friends on unix.
36 */
37 #ifndef SQLITE_DISABLE_LFS
38 # define _LARGE_FILE 1
@@ -105,14 +112,19 @@
112 #else
113 /* Make sure isatty() has a prototype.
114 */
115 extern int isatty(int);
116
117 #if !defined(__RTP__) && !defined(_WRS_KERNEL)
118 /* popen and pclose are not C89 functions and so are sometimes omitted from
119 ** the <stdio.h> header */
120 extern FILE *popen(const char*,const char*);
121 extern int pclose(FILE*);
122 #else
123 # define SQLITE_OMIT_POPEN 1
124 #endif
125
126 #endif
127
128 #if defined(_WIN32_WCE)
129 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
130 * thus we always assume that we have a console. That can be
@@ -163,14 +175,22 @@
175 t = (sqlite3_int64)(r*86400000.0);
176 }
177 return t;
178 }
179
180 #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
 
181 #include <sys/time.h>
182 #include <sys/resource.h>
183
184 /* VxWorks does not support getrusage() as far as we can determine */
185 #if defined(_WRS_KERNEL) || defined(__RTP__)
186 struct rusage {
187 struct timeval ru_utime; /* user CPU time used */
188 struct timeval ru_stime; /* system CPU time used */
189 };
190 #define getrusage(A,B) memset(B,0,sizeof(*B))
191 #endif
192
193 /* Saved resource information for the beginning of an operation */
194 static struct rusage sBegin; /* CPU time at start */
195 static sqlite3_int64 iBegin; /* Wall-clock time at start */
196
@@ -193,12 +213,12 @@
213 /*
214 ** Print the timing results.
215 */
216 static void endTimer(void){
217 if( enableTimer ){
 
218 sqlite3_int64 iEnd = timeOfDay();
219 struct rusage sEnd;
220 getrusage(RUSAGE_SELF, &sEnd);
221 printf("Run Time: real %.3f user %f sys %f\n",
222 (iEnd - iBegin)*0.001,
223 timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
224 timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
@@ -2437,11 +2457,13 @@
2457 /*
2458 ** Change the output file back to stdout
2459 */
2460 static void output_reset(ShellState *p){
2461 if( p->outfile[0]=='|' ){
2462 #ifndef SQLITE_OMIT_POPEN
2463 pclose(p->out);
2464 #endif
2465 }else{
2466 output_file_close(p->out);
2467 }
2468 p->outfile[0] = 0;
2469 p->out = stdout;
@@ -2930,13 +2952,18 @@
2952 return 1;
2953 }
2954 sCtx.zFile = zFile;
2955 sCtx.nLine = 1;
2956 if( sCtx.zFile[0]=='|' ){
2957 #ifdef SQLITE_OMIT_POPEN
2958 fprintf(stderr, "Error: pipes are not supporte in this OS\n");
2959 return 1;
2960 #else
2961 sCtx.in = popen(sCtx.zFile+1, "r");
2962 sCtx.zFile = "<pipe>";
2963 xCloser = pclose;
2964 #endif
2965 }else{
2966 sCtx.in = fopen(sCtx.zFile, "rb");
2967 xCloser = fclose;
2968 }
2969 if( p->mode==MODE_Ascii ){
@@ -3255,18 +3282,24 @@
3282 }else{
3283 p->outCount = 0;
3284 }
3285 output_reset(p);
3286 if( zFile[0]=='|' ){
3287 #ifdef SQLITE_OMIT_POPEN
3288 fprintf(stderr,"Error: pipes are not supported in this OS\n");
3289 rc = 1;
3290 p->out = stdout;
3291 #else
3292 p->out = popen(zFile + 1, "w");
3293 if( p->out==0 ){
3294 fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
3295 p->out = stdout;
3296 rc = 1;
3297 }else{
3298 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
3299 }
3300 #endif
3301 }else{
3302 p->out = output_file_open(zFile);
3303 if( p->out==0 ){
3304 if( strcmp(zFile,"off")!=0 ){
3305 fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
@@ -4187,27 +4220,25 @@
4220 ** Read input from the file given by sqliterc_override. Or if that
4221 ** parameter is NULL, take input from ~/.sqliterc
4222 **
4223 ** Returns the number of errors.
4224 */
4225 static void process_sqliterc(
4226 ShellState *p, /* Configuration data */
4227 const char *sqliterc_override /* Name of config file. NULL to use default */
4228 ){
4229 char *home_dir = NULL;
4230 const char *sqliterc = sqliterc_override;
4231 char *zBuf = 0;
4232 FILE *in = NULL;
 
4233
4234 if (sqliterc == NULL) {
4235 home_dir = find_home_dir();
4236 if( home_dir==0 ){
4237 fprintf(stderr, "-- warning: cannot find home directory;"
4238 " cannot read ~/.sqliterc\n");
4239 return;
 
4240 }
4241 sqlite3_initialize();
4242 zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
4243 sqliterc = zBuf;
4244 }
@@ -4214,15 +4245,14 @@
4245 in = fopen(sqliterc,"rb");
4246 if( in ){
4247 if( stdin_is_interactive ){
4248 fprintf(stderr,"-- Loading resources from %s\n",sqliterc);
4249 }
4250 process_input(p,in);
4251 fclose(in);
4252 }
4253 sqlite3_free(zBuf);
 
4254 }
4255
4256 /*
4257 ** Show available command line options
4258 */
@@ -4494,14 +4524,11 @@
4524
4525 /* Process the initialization file if there is one. If no -init option
4526 ** is given on the command line, look for a file named ~/.sqliterc and
4527 ** try to process it.
4528 */
4529 process_sqliterc(&data,zInitFile);
 
 
 
4530
4531 /* Make a second pass through the command-line argument and set
4532 ** options. This second pass is delayed until after the initialization
4533 ** file is processed so that the command-line arguments will override
4534 ** settings in the initialization file.
4535
+481 -221
--- 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.8.8. By combining all the individual C code files into this
3
+** version 3.8.9. 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.
@@ -88,10 +88,48 @@
8888
#endif /* _MSVC_H_ */
8989
9090
/************** End of msvc.h ************************************************/
9191
/************** Continuing where we left off in sqliteInt.h ******************/
9292
93
+/*
94
+** Special setup for VxWorks
95
+*/
96
+/************** Include vxworks.h in the middle of sqliteInt.h ***************/
97
+/************** Begin file vxworks.h *****************************************/
98
+/*
99
+** 2015-03-02
100
+**
101
+** The author disclaims copyright to this source code. In place of
102
+** a legal notice, here is a blessing:
103
+**
104
+** May you do good and not evil.
105
+** May you find forgiveness for yourself and forgive others.
106
+** May you share freely, never taking more than you give.
107
+**
108
+******************************************************************************
109
+**
110
+** This file contains code that is specific to Wind River's VxWorks
111
+*/
112
+#if defined(__RTP__) || defined(_WRS_KERNEL)
113
+/* This is VxWorks. Set up things specially for that OS
114
+*/
115
+#include <vxWorks.h>
116
+#include <pthread.h> /* amalgamator: dontcache */
117
+#define OS_VXWORKS 1
118
+#define SQLITE_OS_OTHER 0
119
+#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
120
+#define SQLITE_OMIT_LOAD_EXTENSION 1
121
+#define SQLITE_ENABLE_LOCKING_STYLE 0
122
+#define HAVE_UTIME 1
123
+#else
124
+/* This is not VxWorks. */
125
+#define OS_VXWORKS 0
126
+#endif /* defined(_WRS_KERNEL) */
127
+
128
+/************** End of vxworks.h *********************************************/
129
+/************** Continuing where we left off in sqliteInt.h ******************/
130
+
93131
/*
94132
** These #defines should enable >2GB file support on POSIX if the
95133
** underlying operating system supports it. If the OS lacks
96134
** large file support, or if the OS is windows, these should be no-ops.
97135
**
@@ -276,13 +314,13 @@
276314
**
277315
** See also: [sqlite3_libversion()],
278316
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
279317
** [sqlite_version()] and [sqlite_source_id()].
280318
*/
281
-#define SQLITE_VERSION "3.8.8"
282
-#define SQLITE_VERSION_NUMBER 3008008
283
-#define SQLITE_SOURCE_ID "2015-02-25 14:25:31 6d132e7a224ee68b5cefe9222944aac5760ffc20"
319
+#define SQLITE_VERSION "3.8.9"
320
+#define SQLITE_VERSION_NUMBER 3008009
321
+#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
284322
285323
/*
286324
** CAPI3REF: Run-Time Library Version Numbers
287325
** KEYWORDS: sqlite3_version, sqlite3_sourceid
288326
**
@@ -925,18 +963,20 @@
925963
**
926964
** These integer constants are opcodes for the xFileControl method
927965
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
928966
** interface.
929967
**
968
+** <ul>
969
+** <li>[[SQLITE_FCNTL_LOCKSTATE]]
930970
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
931971
** opcode causes the xFileControl method to write the current state of
932972
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
933973
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
934974
** into an integer that the pArg argument points to. This capability
935
-** is used during testing and only needs to be supported when SQLITE_TEST
936
-** is defined.
937
-** <ul>
975
+** is used during testing and is only available when the SQLITE_TEST
976
+** compile-time option is used.
977
+**
938978
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
939979
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
940980
** layer a hint of how large the database file will grow to be during the
941981
** current transaction. This hint is not guaranteed to be accurate but it
942982
** is often close. The underlying VFS might choose to preallocate database
@@ -1057,11 +1097,13 @@
10571097
** the error message if the pragma fails. ^If the
10581098
** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
10591099
** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
10601100
** file control returns [SQLITE_OK], then the parser assumes that the
10611101
** VFS has handled the PRAGMA itself and the parser generates a no-op
1062
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
1102
+** prepared statement if result string is NULL, or that returns a copy
1103
+** of the result string if the string is non-NULL.
1104
+** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
10631105
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
10641106
** that the VFS encountered an error while handling the [PRAGMA] and the
10651107
** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
10661108
** file control occurs at the beginning of pragma statement analysis and so
10671109
** it is able to override built-in [PRAGMA] statements.
@@ -1916,11 +1958,10 @@
19161958
** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
19171959
** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
19181960
** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
19191961
** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
19201962
** that specifies the maximum size of the created heap.
1921
-** </dl>
19221963
**
19231964
** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
19241965
** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
19251966
** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
19261967
** is a pointer to an integer and writes into that integer the number of extra
@@ -3356,20 +3397,18 @@
33563397
** The second argument, "zSql", is the statement to be compiled, encoded
33573398
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
33583399
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
33593400
** use UTF-16.
33603401
**
3361
-** ^If the nByte argument is less than zero, then zSql is read up to the
3362
-** first zero terminator. ^If nByte is non-negative, then it is the maximum
3363
-** number of bytes read from zSql. ^When nByte is non-negative, the
3364
-** zSql string ends at either the first '\000' or '\u0000' character or
3365
-** the nByte-th byte, whichever comes first. If the caller knows
3366
-** that the supplied string is nul-terminated, then there is a small
3367
-** performance advantage to be gained by passing an nByte parameter that
3368
-** is equal to the number of bytes in the input string <i>including</i>
3369
-** the nul-terminator bytes as this saves SQLite from having to
3370
-** make a copy of the input string.
3402
+** ^If the nByte argument is negative, then zSql is read up to the
3403
+** first zero terminator. ^If nByte is positive, then it is the
3404
+** number of bytes read from zSql. ^If nByte is zero, then no prepared
3405
+** statement is generated.
3406
+** If the caller knows that the supplied string is nul-terminated, then
3407
+** there is a small performance advantage to passing an nByte parameter that
3408
+** is the number of bytes in the input string <i>including</i>
3409
+** the nul-terminator.
33713410
**
33723411
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
33733412
** past the end of the first SQL statement in zSql. These routines only
33743413
** compile the first statement in zSql, so *pzTail is left pointing to
33753414
** what remains uncompiled.
@@ -4394,12 +4433,12 @@
43944433
** DEPRECATED
43954434
**
43964435
** These functions are [deprecated]. In order to maintain
43974436
** backwards compatibility with older code, these functions continue
43984437
** to be supported. However, new applications should avoid
4399
-** the use of these functions. To help encourage people to avoid
4400
-** using these functions, we are not going to tell you what they do.
4438
+** the use of these functions. To encourage programmers to avoid
4439
+** these functions, we will not explain what they do.
44014440
*/
44024441
#ifndef SQLITE_OMIT_DEPRECATED
44034442
SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
44044443
SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
44054444
SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -7157,24 +7196,24 @@
71577196
**
71587197
** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
71597198
** is not a permanent error and does not affect the return value of
71607199
** sqlite3_backup_finish().
71617200
**
7162
-** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
7201
+** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
71637202
** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
71647203
**
7165
-** ^Each call to sqlite3_backup_step() sets two values inside
7166
-** the [sqlite3_backup] object: the number of pages still to be backed
7167
-** up and the total number of pages in the source database file.
7168
-** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
7169
-** retrieve these two values, respectively.
7170
-**
7171
-** ^The values returned by these functions are only updated by
7172
-** sqlite3_backup_step(). ^If the source database is modified during a backup
7173
-** operation, then the values are not updated to account for any extra
7174
-** pages that need to be updated or the size of the source database file
7175
-** changing.
7204
+** ^The sqlite3_backup_remaining() routine returns the number of pages still
7205
+** to be backed up at the conclusion of the most recent sqlite3_backup_step().
7206
+** ^The sqlite3_backup_pagecount() routine returns the total number of pages
7207
+** in the source database at the conclusion of the most recent
7208
+** sqlite3_backup_step().
7209
+** ^(The values returned by these functions are only updated by
7210
+** sqlite3_backup_step(). If the source database is modified in a way that
7211
+** changes the size of the source database or the number of pages remaining,
7212
+** those changes are not reflected in the output of sqlite3_backup_pagecount()
7213
+** and sqlite3_backup_remaining() until after the next
7214
+** sqlite3_backup_step().)^
71767215
**
71777216
** <b>Concurrent Usage of Database Handles</b>
71787217
**
71797218
** ^The source [database connection] may be used by the application for other
71807219
** purposes while a backup operation is underway or being initialized.
@@ -8018,19 +8057,21 @@
80188057
#ifndef SQLITE_MAX_FUNCTION_ARG
80198058
# define SQLITE_MAX_FUNCTION_ARG 127
80208059
#endif
80218060
80228061
/*
8023
-** The maximum number of in-memory pages to use for the main database
8024
-** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
8062
+** The suggested maximum number of in-memory pages to use for
8063
+** the main database table and for temporary tables.
8064
+**
8065
+** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
8066
+** is 2000 pages.
8067
+** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
8068
+** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
80258069
*/
80268070
#ifndef SQLITE_DEFAULT_CACHE_SIZE
80278071
# define SQLITE_DEFAULT_CACHE_SIZE 2000
80288072
#endif
8029
-#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
8030
-# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
8031
-#endif
80328073
80338074
/*
80348075
** The default number of frames to accumulate in the log file before
80358076
** checkpointing the database in WAL mode.
80368077
*/
@@ -9733,27 +9774,29 @@
97339774
#define OP_FkCounter 134 /* synopsis: fkctr[P1]+=P2 */
97349775
#define OP_FkIfZero 135 /* synopsis: if fkctr[P1]==0 goto P2 */
97359776
#define OP_MemMax 136 /* synopsis: r[P1]=max(r[P1],r[P2]) */
97369777
#define OP_IfPos 137 /* synopsis: if r[P1]>0 goto P2 */
97379778
#define OP_IfNeg 138 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2 */
9738
-#define OP_IfZero 139 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */
9739
-#define OP_AggFinal 140 /* synopsis: accum=r[P1] N=P2 */
9740
-#define OP_IncrVacuum 141
9741
-#define OP_Expire 142
9742
-#define OP_TableLock 143 /* synopsis: iDb=P1 root=P2 write=P3 */
9743
-#define OP_VBegin 144
9744
-#define OP_VCreate 145
9745
-#define OP_VDestroy 146
9746
-#define OP_VOpen 147
9747
-#define OP_VColumn 148 /* synopsis: r[P3]=vcolumn(P2) */
9748
-#define OP_VNext 149
9749
-#define OP_VRename 150
9750
-#define OP_Pagecount 151
9751
-#define OP_MaxPgcnt 152
9752
-#define OP_Init 153 /* synopsis: Start at P2 */
9753
-#define OP_Noop 154
9754
-#define OP_Explain 155
9779
+#define OP_IfNotZero 139 /* synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2 */
9780
+#define OP_DecrJumpZero 140 /* synopsis: if (--r[P1])==0 goto P2 */
9781
+#define OP_JumpZeroIncr 141 /* synopsis: if (r[P1]++)==0 ) goto P2 */
9782
+#define OP_AggFinal 142 /* synopsis: accum=r[P1] N=P2 */
9783
+#define OP_IncrVacuum 143
9784
+#define OP_Expire 144
9785
+#define OP_TableLock 145 /* synopsis: iDb=P1 root=P2 write=P3 */
9786
+#define OP_VBegin 146
9787
+#define OP_VCreate 147
9788
+#define OP_VDestroy 148
9789
+#define OP_VOpen 149
9790
+#define OP_VColumn 150 /* synopsis: r[P3]=vcolumn(P2) */
9791
+#define OP_VNext 151
9792
+#define OP_VRename 152
9793
+#define OP_Pagecount 153
9794
+#define OP_MaxPgcnt 154
9795
+#define OP_Init 155 /* synopsis: Start at P2 */
9796
+#define OP_Noop 156
9797
+#define OP_Explain 157
97559798
97569799
97579800
/* Properties such as "out2" or "jump" that are specified in
97589801
** comments following the "case" for each opcode in the vdbe.c
97599802
** are encoded into bitvectors as follows:
@@ -9781,13 +9824,13 @@
97819824
/* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\
97829825
/* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\
97839826
/* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
97849827
/* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
97859828
/* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
9786
-/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x01, 0x00, 0x00,\
9787
-/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,\
9788
-/* 152 */ 0x02, 0x01, 0x00, 0x00,}
9829
+/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\
9830
+/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
9831
+/* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
97899832
97909833
/************** End of opcodes.h *********************************************/
97919834
/************** Continuing where we left off in vdbe.h ***********************/
97929835
97939836
/*
@@ -12022,11 +12065,11 @@
1202212065
#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
1202312066
#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
1202412067
#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
1202512068
#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
1202612069
#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
12027
- /* 0x0080 // not currently used */
12070
+#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
1202812071
#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
1202912072
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
1203012073
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
1203112074
#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
1203212075
#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
@@ -24969,27 +25012,29 @@
2496925012
/* 134 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
2497025013
/* 135 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
2497125014
/* 136 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
2497225015
/* 137 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
2497325016
/* 138 */ "IfNeg" OpHelp("r[P1]+=P3, if r[P1]<0 goto P2"),
24974
- /* 139 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"),
24975
- /* 140 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
24976
- /* 141 */ "IncrVacuum" OpHelp(""),
24977
- /* 142 */ "Expire" OpHelp(""),
24978
- /* 143 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
24979
- /* 144 */ "VBegin" OpHelp(""),
24980
- /* 145 */ "VCreate" OpHelp(""),
24981
- /* 146 */ "VDestroy" OpHelp(""),
24982
- /* 147 */ "VOpen" OpHelp(""),
24983
- /* 148 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
24984
- /* 149 */ "VNext" OpHelp(""),
24985
- /* 150 */ "VRename" OpHelp(""),
24986
- /* 151 */ "Pagecount" OpHelp(""),
24987
- /* 152 */ "MaxPgcnt" OpHelp(""),
24988
- /* 153 */ "Init" OpHelp("Start at P2"),
24989
- /* 154 */ "Noop" OpHelp(""),
24990
- /* 155 */ "Explain" OpHelp(""),
25017
+ /* 139 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]+=P3, goto P2"),
25018
+ /* 140 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
25019
+ /* 141 */ "JumpZeroIncr" OpHelp("if (r[P1]++)==0 ) goto P2"),
25020
+ /* 142 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
25021
+ /* 143 */ "IncrVacuum" OpHelp(""),
25022
+ /* 144 */ "Expire" OpHelp(""),
25023
+ /* 145 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
25024
+ /* 146 */ "VBegin" OpHelp(""),
25025
+ /* 147 */ "VCreate" OpHelp(""),
25026
+ /* 148 */ "VDestroy" OpHelp(""),
25027
+ /* 149 */ "VOpen" OpHelp(""),
25028
+ /* 150 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
25029
+ /* 151 */ "VNext" OpHelp(""),
25030
+ /* 152 */ "VRename" OpHelp(""),
25031
+ /* 153 */ "Pagecount" OpHelp(""),
25032
+ /* 154 */ "MaxPgcnt" OpHelp(""),
25033
+ /* 155 */ "Init" OpHelp("Start at P2"),
25034
+ /* 156 */ "Noop" OpHelp(""),
25035
+ /* 157 */ "Explain" OpHelp(""),
2499125036
};
2499225037
return azName[i];
2499325038
}
2499425039
#endif
2499525040
@@ -25065,22 +25110,10 @@
2506525110
# else
2506625111
# define SQLITE_ENABLE_LOCKING_STYLE 0
2506725112
# endif
2506825113
#endif
2506925114
25070
-/*
25071
-** Define the OS_VXWORKS pre-processor macro to 1 if building on
25072
-** vxworks, or 0 otherwise.
25073
-*/
25074
-#ifndef OS_VXWORKS
25075
-# if defined(__RTP__) || defined(_WRS_KERNEL)
25076
-# define OS_VXWORKS 1
25077
-# else
25078
-# define OS_VXWORKS 0
25079
-# endif
25080
-#endif
25081
-
2508225115
/*
2508325116
** standard include files.
2508425117
*/
2508525118
#include <sys/types.h>
2508625119
#include <sys/stat.h>
@@ -25091,22 +25124,23 @@
2509125124
#include <errno.h>
2509225125
#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
2509325126
# include <sys/mman.h>
2509425127
#endif
2509525128
25096
-#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
25129
+#if SQLITE_ENABLE_LOCKING_STYLE
2509725130
# include <sys/ioctl.h>
25098
-# if OS_VXWORKS
25099
-# include <semaphore.h>
25100
-# include <limits.h>
25101
-# else
25102
-# include <sys/file.h>
25103
-# include <sys/param.h>
25104
-# endif
25131
+# include <sys/file.h>
25132
+# include <sys/param.h>
2510525133
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
2510625134
25107
-#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
25135
+#if OS_VXWORKS
25136
+/* # include <sys/ioctl.h> */
25137
+# include <semaphore.h>
25138
+# include <limits.h>
25139
+#endif /* OS_VXWORKS */
25140
+
25141
+#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
2510825142
# include <sys/mount.h>
2510925143
#endif
2511025144
2511125145
#ifdef HAVE_UTIME
2511225146
# include <utime.h>
@@ -25142,10 +25176,14 @@
2514225176
2514325177
/*
2514425178
** Maximum supported path-length.
2514525179
*/
2514625180
#define MAX_PATHNAME 512
25181
+
25182
+/* Always cast the getpid() return type for compatibility with
25183
+** kernel modules in VxWorks. */
25184
+#define osGetpid(X) (pid_t)getpid()
2514725185
2514825186
/*
2514925187
** Only set the lastErrno if the error code is a real error and not
2515025188
** a normal expected return code of SQLITE_BUSY or SQLITE_OK
2515125189
*/
@@ -25231,11 +25269,11 @@
2523125269
2523225270
/* This variable holds the process id (pid) from when the xRandomness()
2523325271
** method was called. If xOpen() is called from a different process id,
2523425272
** indicating that a fork() has occurred, the PRNG will be reset.
2523525273
*/
25236
-static int randomnessPid = 0;
25274
+static pid_t randomnessPid = 0;
2523725275
2523825276
/*
2523925277
** Allowed values for the unixFile.ctrlFlags bitmask:
2524025278
*/
2524125279
#define UNIXFILE_EXCL 0x01 /* Connections from one process only */
@@ -25587,11 +25625,11 @@
2558725625
#define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
2558825626
2558925627
{ "read", (sqlite3_syscall_ptr)read, 0 },
2559025628
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
2559125629
25592
-#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
25630
+#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
2559325631
{ "pread", (sqlite3_syscall_ptr)pread, 0 },
2559425632
#else
2559525633
{ "pread", (sqlite3_syscall_ptr)0, 0 },
2559625634
#endif
2559725635
#define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25604,11 +25642,11 @@
2560425642
#define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
2560525643
2560625644
{ "write", (sqlite3_syscall_ptr)write, 0 },
2560725645
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
2560825646
25609
-#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
25647
+#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
2561025648
{ "pwrite", (sqlite3_syscall_ptr)pwrite, 0 },
2561125649
#else
2561225650
{ "pwrite", (sqlite3_syscall_ptr)0, 0 },
2561325651
#endif
2561425652
#define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\
@@ -26743,11 +26781,12 @@
2674326781
int tErrno = 0;
2674426782
2674526783
assert( pFile );
2674626784
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
2674726785
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
26748
- azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid()));
26786
+ azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
26787
+ osGetpid()));
2674926788
2675026789
/* If there is already a lock of this type or more restrictive on the
2675126790
** unixFile, do nothing. Don't use the end_lock: exit path, as
2675226791
** unixEnterMutex() hasn't been called yet.
2675326792
*/
@@ -26951,11 +26990,11 @@
2695126990
int rc = SQLITE_OK;
2695226991
2695326992
assert( pFile );
2695426993
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
2695526994
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
26956
- getpid()));
26995
+ osGetpid()));
2695726996
2695826997
assert( eFileLock<=SHARED_LOCK );
2695926998
if( pFile->eFileLock<=eFileLock ){
2696026999
return SQLITE_OK;
2696127000
}
@@ -27378,11 +27417,11 @@
2737827417
char *zLockFile = (char *)pFile->lockingContext;
2737927418
int rc;
2738027419
2738127420
assert( pFile );
2738227421
OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27383
- pFile->eFileLock, getpid()));
27422
+ pFile->eFileLock, osGetpid()));
2738427423
assert( eFileLock<=SHARED_LOCK );
2738527424
2738627425
/* no-op if possible */
2738727426
if( pFile->eFileLock==eFileLock ){
2738827427
return SQLITE_OK;
@@ -27441,14 +27480,13 @@
2744127480
** a single exclusive lock. In other words, SHARED, RESERVED, and
2744227481
** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
2744327482
** still works when you do this, but concurrency is reduced since
2744427483
** only a single process can be reading the database at a time.
2744527484
**
27446
-** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if
27447
-** compiling for VXWORKS.
27485
+** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off
2744827486
*/
27449
-#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
27487
+#if SQLITE_ENABLE_LOCKING_STYLE
2745027488
2745127489
/*
2745227490
** Retry flock() calls that fail with EINTR
2745327491
*/
2745427492
#ifdef EINTR
@@ -27597,11 +27635,11 @@
2759727635
static int flockUnlock(sqlite3_file *id, int eFileLock) {
2759827636
unixFile *pFile = (unixFile*)id;
2759927637
2760027638
assert( pFile );
2760127639
OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27602
- pFile->eFileLock, getpid()));
27640
+ pFile->eFileLock, osGetpid()));
2760327641
assert( eFileLock<=SHARED_LOCK );
2760427642
2760527643
/* no-op if possible */
2760627644
if( pFile->eFileLock==eFileLock ){
2760727645
return SQLITE_OK;
@@ -27658,11 +27696,11 @@
2765827696
** This routine checks if there is a RESERVED lock held on the specified
2765927697
** file by this or any other process. If such a lock is held, set *pResOut
2766027698
** to a non-zero value otherwise *pResOut is set to zero. The return value
2766127699
** is set to SQLITE_OK unless an I/O error occurs during lock checking.
2766227700
*/
27663
-static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
27701
+static int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {
2766427702
int rc = SQLITE_OK;
2766527703
int reserved = 0;
2766627704
unixFile *pFile = (unixFile*)id;
2766727705
2766827706
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
@@ -27725,11 +27763,11 @@
2772527763
** access the file.
2772627764
**
2772727765
** This routine will only increase a lock. Use the sqlite3OsUnlock()
2772827766
** routine to lower a locking level.
2772927767
*/
27730
-static int semLock(sqlite3_file *id, int eFileLock) {
27768
+static int semXLock(sqlite3_file *id, int eFileLock) {
2773127769
unixFile *pFile = (unixFile*)id;
2773227770
sem_t *pSem = pFile->pInode->pSem;
2773327771
int rc = SQLITE_OK;
2773427772
2773527773
/* if we already have a lock, it is exclusive.
@@ -27758,18 +27796,18 @@
2775827796
** must be either NO_LOCK or SHARED_LOCK.
2775927797
**
2776027798
** If the locking level of the file descriptor is already at or below
2776127799
** the requested locking level, this routine is a no-op.
2776227800
*/
27763
-static int semUnlock(sqlite3_file *id, int eFileLock) {
27801
+static int semXUnlock(sqlite3_file *id, int eFileLock) {
2776427802
unixFile *pFile = (unixFile*)id;
2776527803
sem_t *pSem = pFile->pInode->pSem;
2776627804
2776727805
assert( pFile );
2776827806
assert( pSem );
2776927807
OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27770
- pFile->eFileLock, getpid()));
27808
+ pFile->eFileLock, osGetpid()));
2777127809
assert( eFileLock<=SHARED_LOCK );
2777227810
2777327811
/* no-op if possible */
2777427812
if( pFile->eFileLock==eFileLock ){
2777527813
return SQLITE_OK;
@@ -27795,14 +27833,14 @@
2779527833
}
2779627834
2779727835
/*
2779827836
** Close a file.
2779927837
*/
27800
-static int semClose(sqlite3_file *id) {
27838
+static int semXClose(sqlite3_file *id) {
2780127839
if( id ){
2780227840
unixFile *pFile = (unixFile*)id;
27803
- semUnlock(id, NO_LOCK);
27841
+ semXUnlock(id, NO_LOCK);
2780427842
assert( pFile );
2780527843
unixEnterMutex();
2780627844
releaseInodeInfo(pFile);
2780727845
unixLeaveMutex();
2780827846
closeUnixFile(id);
@@ -27979,11 +28017,11 @@
2797928017
afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
2798028018
2798128019
assert( pFile );
2798228020
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
2798328021
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
27984
- azFileLock(pInode->eFileLock), pInode->nShared , getpid()));
28022
+ azFileLock(pInode->eFileLock), pInode->nShared , osGetpid()));
2798528023
2798628024
/* If there is already a lock of this type or more restrictive on the
2798728025
** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
2798828026
** unixEnterMutex() hasn't been called yet.
2798928027
*/
@@ -28165,11 +28203,11 @@
2816528203
#endif
2816628204
2816728205
assert( pFile );
2816828206
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
2816928207
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28170
- getpid()));
28208
+ osGetpid()));
2817128209
2817228210
assert( eFileLock<=SHARED_LOCK );
2817328211
if( pFile->eFileLock<=eFileLock ){
2817428212
return SQLITE_OK;
2817528213
}
@@ -29204,11 +29242,13 @@
2920429242
**
2920529243
** This function should not be called directly by other code in this file.
2920629244
** Instead, it should be called via macro osGetpagesize().
2920729245
*/
2920829246
static int unixGetpagesize(void){
29209
-#if defined(_BSD_SOURCE)
29247
+#if OS_VXWORKS
29248
+ return 1024;
29249
+#elif defined(_BSD_SOURCE)
2921029250
return getpagesize();
2921129251
#else
2921229252
return (int)sysconf(_SC_PAGESIZE);
2921329253
#endif
2921429254
}
@@ -29833,11 +29873,11 @@
2983329873
}
2983429874
}
2983529875
}
2983629876
sqlite3_mutex_leave(pShmNode->mutex);
2983729877
OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
29838
- p->id, getpid(), p->sharedMask, p->exclMask));
29878
+ p->id, osGetpid(), p->sharedMask, p->exclMask));
2983929879
return rc;
2984029880
}
2984129881
2984229882
/*
2984329883
** Implement a memory barrier or memory fence on shared memory.
@@ -30236,11 +30276,11 @@
3023630276
dotlockUnlock, /* xUnlock method */
3023730277
dotlockCheckReservedLock, /* xCheckReservedLock method */
3023830278
0 /* xShmMap method */
3023930279
)
3024030280
30241
-#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
30281
+#if SQLITE_ENABLE_LOCKING_STYLE
3024230282
IOMETHODS(
3024330283
flockIoFinder, /* Finder function name */
3024430284
flockIoMethods, /* sqlite3_io_methods object name */
3024530285
1, /* shared memory is disabled */
3024630286
flockClose, /* xClose method */
@@ -30254,14 +30294,14 @@
3025430294
#if OS_VXWORKS
3025530295
IOMETHODS(
3025630296
semIoFinder, /* Finder function name */
3025730297
semIoMethods, /* sqlite3_io_methods object name */
3025830298
1, /* shared memory is disabled */
30259
- semClose, /* xClose method */
30260
- semLock, /* xLock method */
30261
- semUnlock, /* xUnlock method */
30262
- semCheckReservedLock, /* xCheckReservedLock method */
30299
+ semXClose, /* xClose method */
30300
+ semXLock, /* xLock method */
30301
+ semXUnlock, /* xUnlock method */
30302
+ semXCheckReservedLock, /* xCheckReservedLock method */
3026330303
0 /* xShmMap method */
3026430304
)
3026530305
#endif
3026630306
3026730307
#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
@@ -30381,19 +30421,17 @@
3038130421
static const sqlite3_io_methods
3038230422
*(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
3038330423
3038430424
#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
3038530425
30386
-#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
30387
-/*
30388
-** This "finder" function attempts to determine the best locking strategy
30389
-** for the database file "filePath". It then returns the sqlite3_io_methods
30390
-** object that implements that strategy.
30391
-**
30392
-** This is for VXWorks only.
30426
+#if OS_VXWORKS
30427
+/*
30428
+** This "finder" function for VxWorks checks to see if posix advisory
30429
+** locking works. If it does, then that is what is used. If it does not
30430
+** work, then fallback to named semaphore locking.
3039330431
*/
30394
-static const sqlite3_io_methods *autolockIoFinderImpl(
30432
+static const sqlite3_io_methods *vxworksIoFinderImpl(
3039530433
const char *filePath, /* name of the database file */
3039630434
unixFile *pNew /* the open file object */
3039730435
){
3039830436
struct flock lockInfo;
3039930437
@@ -30415,13 +30453,13 @@
3041530453
}else{
3041630454
return &semIoMethods;
3041730455
}
3041830456
}
3041930457
static const sqlite3_io_methods
30420
- *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
30458
+ *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;
3042130459
30422
-#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
30460
+#endif /* OS_VXWORKS */
3042330461
3042430462
/*
3042530463
** An abstract type for a pointer to an IO method finder function:
3042630464
*/
3042730465
typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);
@@ -30930,12 +30968,12 @@
3093030968
/* Detect a pid change and reset the PRNG. There is a race condition
3093130969
** here such that two or more threads all trying to open databases at
3093230970
** the same instant might all reset the PRNG. But multiple resets
3093330971
** are harmless.
3093430972
*/
30935
- if( randomnessPid!=getpid() ){
30936
- randomnessPid = getpid();
30973
+ if( randomnessPid!=osGetpid() ){
30974
+ randomnessPid = osGetpid();
3093730975
sqlite3_randomness(0,0);
3093830976
}
3093930977
3094030978
memset(p, 0, sizeof(unixFile));
3094130979
@@ -31322,11 +31360,11 @@
3132231360
** When testing, initializing zBuf[] to zero is all we do. That means
3132331361
** that we always use the same random number sequence. This makes the
3132431362
** tests repeatable.
3132531363
*/
3132631364
memset(zBuf, 0, nBuf);
31327
- randomnessPid = getpid();
31365
+ randomnessPid = osGetpid();
3132831366
#if !defined(SQLITE_TEST)
3132931367
{
3133031368
int fd, got;
3133131369
fd = robust_open("/dev/urandom", O_RDONLY, 0);
3133231370
if( fd<0 ){
@@ -31643,11 +31681,11 @@
3164331681
#else
3164431682
# ifdef _CS_DARWIN_USER_TEMP_DIR
3164531683
{
3164631684
if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
3164731685
OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31648
- lPath, errno, getpid()));
31686
+ lPath, errno, osGetpid()));
3164931687
return SQLITE_IOERR_LOCK;
3165031688
}
3165131689
len = strlcat(lPath, "sqliteplocks", maxLen);
3165231690
}
3165331691
# else
@@ -31665,11 +31703,11 @@
3166531703
char c = dbPath[i];
3166631704
lPath[i+len] = (c=='/')?'_':c;
3166731705
}
3166831706
lPath[i+len]='\0';
3166931707
strlcat(lPath, ":auto:", maxLen);
31670
- OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, getpid()));
31708
+ OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid()));
3167131709
return SQLITE_OK;
3167231710
}
3167331711
3167431712
/*
3167531713
** Creates the lock file and any missing directories in lockPath
@@ -31692,20 +31730,20 @@
3169231730
if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
3169331731
int err=errno;
3169431732
if( err!=EEXIST ) {
3169531733
OSTRACE(("CREATELOCKPATH FAILED creating %s, "
3169631734
"'%s' proxy lock path=%s pid=%d\n",
31697
- buf, strerror(err), lockPath, getpid()));
31735
+ buf, strerror(err), lockPath, osGetpid()));
3169831736
return err;
3169931737
}
3170031738
}
3170131739
}
3170231740
start=i+1;
3170331741
}
3170431742
buf[i] = lockPath[i];
3170531743
}
31706
- OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, getpid()));
31744
+ OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid()));
3170731745
return 0;
3170831746
}
3170931747
3171031748
/*
3171131749
** Create a new VFS file descriptor (stored in memory obtained from
@@ -32006,11 +32044,12 @@
3200632044
int readLen = 0;
3200732045
int tryOldLockPath = 0;
3200832046
int forceNewLockPath = 0;
3200932047
3201032048
OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
32011
- (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid()));
32049
+ (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32050
+ osGetpid()));
3201232051
3201332052
rc = proxyGetHostID(myHostID, &pError);
3201432053
if( (rc&0xff)==SQLITE_IOERR ){
3201532054
storeLastErrno(pFile, pError);
3201632055
goto end_takeconch;
@@ -32216,11 +32255,11 @@
3221632255
3221732256
pCtx = (proxyLockingContext *)pFile->lockingContext;
3221832257
conchFile = pCtx->conchFile;
3221932258
OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
3222032259
(pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32221
- getpid()));
32260
+ osGetpid()));
3222232261
if( pCtx->conchHeld>0 ){
3222332262
rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
3222432263
}
3222532264
pCtx->conchHeld = 0;
3222632265
OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32358,11 +32397,11 @@
3235832397
}else{
3235932398
lockPath=(char *)path;
3236032399
}
3236132400
3236232401
OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32363
- (lockPath ? lockPath : ":auto:"), getpid()));
32402
+ (lockPath ? lockPath : ":auto:"), osGetpid()));
3236432403
3236532404
pCtx = sqlite3_malloc( sizeof(*pCtx) );
3236632405
if( pCtx==0 ){
3236732406
return SQLITE_NOMEM;
3236832407
}
@@ -32699,26 +32738,28 @@
3269932738
** Note that the sqlite3_vfs.pNext field of the VFS object is modified
3270032739
** by the SQLite core when the VFS is registered. So the following
3270132740
** array cannot be const.
3270232741
*/
3270332742
static sqlite3_vfs aVfs[] = {
32704
-#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
32743
+#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
3270532744
UNIXVFS("unix", autolockIoFinder ),
32745
+#elif OS_VXWORKS
32746
+ UNIXVFS("unix", vxworksIoFinder ),
3270632747
#else
3270732748
UNIXVFS("unix", posixIoFinder ),
3270832749
#endif
3270932750
UNIXVFS("unix-none", nolockIoFinder ),
3271032751
UNIXVFS("unix-dotfile", dotlockIoFinder ),
3271132752
UNIXVFS("unix-excl", posixIoFinder ),
3271232753
#if OS_VXWORKS
3271332754
UNIXVFS("unix-namedsem", semIoFinder ),
3271432755
#endif
32715
-#if SQLITE_ENABLE_LOCKING_STYLE
32756
+#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
3271632757
UNIXVFS("unix-posix", posixIoFinder ),
32717
-#if !OS_VXWORKS
32758
+#endif
32759
+#if SQLITE_ENABLE_LOCKING_STYLE
3271832760
UNIXVFS("unix-flock", flockIoFinder ),
32719
-#endif
3272032761
#endif
3272132762
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
3272232763
UNIXVFS("unix-afp", afpIoFinder ),
3272332764
UNIXVFS("unix-nfs", nfsIoFinder ),
3272432765
UNIXVFS("unix-proxy", proxyIoFinder ),
@@ -39072,16 +39113,24 @@
3907239113
sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);
3907339114
}
3907439115
}
3907539116
3907639117
/*
39077
-** Compute the number of pages of cache requested.
39118
+** Compute the number of pages of cache requested. p->szCache is the
39119
+** cache size requested by the "PRAGMA cache_size" statement.
39120
+**
39121
+**
3907839122
*/
3907939123
static int numberOfCachePages(PCache *p){
3908039124
if( p->szCache>=0 ){
39125
+ /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the
39126
+ ** suggested cache size is set to N. */
3908139127
return p->szCache;
3908239128
}else{
39129
+ /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then
39130
+ ** the number of cache pages is adjusted to use approximately abs(N*1024)
39131
+ ** bytes of memory. */
3908339132
return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
3908439133
}
3908539134
}
3908639135
3908739136
/*************************************************** General Interfaces ******
@@ -68615,10 +68664,14 @@
6861568664
}
6861668665
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
6861768666
return sqlite3ValueText(pVal, SQLITE_UTF16LE);
6861868667
}
6861968668
#endif /* SQLITE_OMIT_UTF16 */
68669
+/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
68670
+** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
68671
+** point number string BLOB NULL
68672
+*/
6862068673
SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
6862168674
static const u8 aType[] = {
6862268675
SQLITE_BLOB, /* 0x00 */
6862368676
SQLITE_NULL, /* 0x01 */
6862468677
SQLITE_TEXT, /* 0x02 */
@@ -71290,11 +71343,11 @@
7129071343
7129171344
/* Opcode: String8 * P2 * P4 *
7129271345
** Synopsis: r[P2]='P4'
7129371346
**
7129471347
** P4 points to a nul terminated UTF-8 string. This opcode is transformed
71295
-** into a String before it is executed for the first time. During
71348
+** into a String opcode before it is executed for the first time. During
7129671349
** this transformation, the length of string P4 is computed and stored
7129771350
** as the P1 parameter.
7129871351
*/
7129971352
case OP_String8: { /* same as TK_STRING, out2-prerelease */
7130071353
assert( pOp->p4.z!=0 );
@@ -71322,22 +71375,34 @@
7132271375
goto too_big;
7132371376
}
7132471377
/* Fall through to the next case, OP_String */
7132571378
}
7132671379
71327
-/* Opcode: String P1 P2 * P4 *
71380
+/* Opcode: String P1 P2 P3 P4 P5
7132871381
** Synopsis: r[P2]='P4' (len=P1)
7132971382
**
7133071383
** The string value P4 of length P1 (bytes) is stored in register P2.
71384
+**
71385
+** If P5!=0 and the content of register P3 is greater than zero, then
71386
+** the datatype of the register P2 is converted to BLOB. The content is
71387
+** the same sequence of bytes, it is merely interpreted as a BLOB instead
71388
+** of a string, as if it had been CAST.
7133171389
*/
7133271390
case OP_String: { /* out2-prerelease */
7133371391
assert( pOp->p4.z!=0 );
7133471392
pOut->flags = MEM_Str|MEM_Static|MEM_Term;
7133571393
pOut->z = pOp->p4.z;
7133671394
pOut->n = pOp->p1;
7133771395
pOut->enc = encoding;
7133871396
UPDATE_MAX_BLOBSIZE(pOut);
71397
+ if( pOp->p5 ){
71398
+ assert( pOp->p3>0 );
71399
+ assert( pOp->p3<=(p->nMem-p->nCursor) );
71400
+ pIn3 = &aMem[pOp->p3];
71401
+ assert( pIn3->flags & MEM_Int );
71402
+ if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;
71403
+ }
7133971404
break;
7134071405
}
7134171406
7134271407
/* Opcode: Null P1 P2 P3 * *
7134371408
** Synopsis: r[P2..P3]=NULL
@@ -73325,11 +73390,16 @@
7332573390
** the value of this counter needs to be restored too. */
7332673391
p->nStmtDefCons = db->nDeferredCons;
7332773392
p->nStmtDefImmCons = db->nDeferredImmCons;
7332873393
}
7332973394
73330
- /* Gather the schema version number for checking */
73395
+ /* Gather the schema version number for checking:
73396
+ ** IMPLEMENTATION-OF: R-32195-19465 The schema version is used by SQLite
73397
+ ** each time a query is executed to ensure that the internal cache of the
73398
+ ** schema used when compiling the SQL query matches the schema of the
73399
+ ** database against which the compiled query is actually executed.
73400
+ */
7333173401
sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
7333273402
iGen = db->aDb[pOp->p1].pSchema->iGeneration;
7333373403
}else{
7333473404
iGen = iMeta = 0;
7333573405
}
@@ -75843,14 +75913,16 @@
7584375913
#endif /* SQLITE_OMIT_AUTOINCREMENT */
7584475914
7584575915
/* Opcode: IfPos P1 P2 * * *
7584675916
** Synopsis: if r[P1]>0 goto P2
7584775917
**
75848
-** If the value of register P1 is 1 or greater, jump to P2.
75918
+** Register P1 must contain an integer.
75919
+** If the value of register P1 is 1 or greater, jump to P2 and
75920
+** add the literal value P3 to register P1.
7584975921
**
75850
-** It is illegal to use this instruction on a register that does
75851
-** not contain an integer. An assertion fault will result if you try.
75922
+** If the initial value of register P1 is less than 1, then the
75923
+** value is unchanged and control passes through to the next instruction.
7585275924
*/
7585375925
case OP_IfPos: { /* jump, in1 */
7585475926
pIn1 = &aMem[pOp->p1];
7585575927
assert( pIn1->flags&MEM_Int );
7585675928
VdbeBranchTaken( pIn1->u.i>0, 2);
@@ -75875,27 +75947,63 @@
7587575947
pc = pOp->p2 - 1;
7587675948
}
7587775949
break;
7587875950
}
7587975951
75880
-/* Opcode: IfZero P1 P2 P3 * *
75881
-** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2
75952
+/* Opcode: IfNotZero P1 P2 P3 * *
75953
+** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
7588275954
**
75883
-** The register P1 must contain an integer. Add literal P3 to the
75884
-** value in register P1. If the result is exactly 0, jump to P2.
75955
+** Register P1 must contain an integer. If the content of register P1 is
75956
+** initially nonzero, then add P3 to P1 and jump to P2. If register P1 is
75957
+** initially zero, leave it unchanged and fall through.
7588575958
*/
75886
-case OP_IfZero: { /* jump, in1 */
75959
+case OP_IfNotZero: { /* jump, in1 */
75960
+ pIn1 = &aMem[pOp->p1];
75961
+ assert( pIn1->flags&MEM_Int );
75962
+ VdbeBranchTaken(pIn1->u.i<0, 2);
75963
+ if( pIn1->u.i ){
75964
+ pIn1->u.i += pOp->p3;
75965
+ pc = pOp->p2 - 1;
75966
+ }
75967
+ break;
75968
+}
75969
+
75970
+/* Opcode: DecrJumpZero P1 P2 * * *
75971
+** Synopsis: if (--r[P1])==0 goto P2
75972
+**
75973
+** Register P1 must hold an integer. Decrement the value in register P1
75974
+** then jump to P2 if the new value is exactly zero.
75975
+*/
75976
+case OP_DecrJumpZero: { /* jump, in1 */
7588775977
pIn1 = &aMem[pOp->p1];
7588875978
assert( pIn1->flags&MEM_Int );
75889
- pIn1->u.i += pOp->p3;
75979
+ pIn1->u.i--;
7589075980
VdbeBranchTaken(pIn1->u.i==0, 2);
7589175981
if( pIn1->u.i==0 ){
7589275982
pc = pOp->p2 - 1;
7589375983
}
7589475984
break;
7589575985
}
7589675986
75987
+
75988
+/* Opcode: JumpZeroIncr P1 P2 * * *
75989
+** Synopsis: if (r[P1]++)==0 ) goto P2
75990
+**
75991
+** The register P1 must contain an integer. If register P1 is initially
75992
+** zero, then jump to P2. Increment register P1 regardless of whether or
75993
+** not the jump is taken.
75994
+*/
75995
+case OP_JumpZeroIncr: { /* jump, in1 */
75996
+ pIn1 = &aMem[pOp->p1];
75997
+ assert( pIn1->flags&MEM_Int );
75998
+ VdbeBranchTaken(pIn1->u.i==0, 2);
75999
+ if( (pIn1->u.i++)==0 ){
76000
+ pc = pOp->p2 - 1;
76001
+ }
76002
+ break;
76003
+}
76004
+
7589776005
/* Opcode: AggStep * P2 P3 P4 P5
7589876006
** Synopsis: accum=r[P3] step(r[P2@P5])
7589976007
**
7590076008
** Execute the step function for an aggregate. The
7590176009
** function has P5 arguments. P4 is a pointer to the FuncDef
@@ -97181,10 +97289,15 @@
9718197289
** pExpr points to an expression which implements a function. If
9718297290
** it is appropriate to apply the LIKE optimization to that function
9718397291
** then set aWc[0] through aWc[2] to the wildcard characters and
9718497292
** return TRUE. If the function is not a LIKE-style function then
9718597293
** return FALSE.
97294
+**
97295
+** *pIsNocase is set to true if uppercase and lowercase are equivalent for
97296
+** the function (default for LIKE). If the function makes the distinction
97297
+** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to
97298
+** false.
9718697299
*/
9718797300
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
9718897301
FuncDef *pDef;
9718997302
if( pExpr->op!=TK_FUNCTION
9719097303
|| !pExpr->x.pList
@@ -102972,10 +103085,21 @@
102972103085
}
102973103086
102974103087
/* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
102975103088
** connection. If it returns SQLITE_OK, then assume that the VFS
102976103089
** handled the pragma and generate a no-op prepared statement.
103090
+ **
103091
+ ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,
103092
+ ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file
103093
+ ** object corresponding to the database file to which the pragma
103094
+ ** statement refers.
103095
+ **
103096
+ ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA
103097
+ ** file control is an array of pointers to strings (char**) in which the
103098
+ ** second element of the array is the name of the pragma and the third
103099
+ ** element is the argument to the pragma or NULL if the pragma has no
103100
+ ** argument.
102977103101
*/
102978103102
aFcntl[0] = 0;
102979103103
aFcntl[1] = zLeft;
102980103104
aFcntl[2] = zRight;
102981103105
aFcntl[3] = 0;
@@ -103732,34 +103856,46 @@
103732103856
Index *pIdx;
103733103857
Table *pTab;
103734103858
pIdx = sqlite3FindIndex(db, zRight, zDb);
103735103859
if( pIdx ){
103736103860
int i;
103737
- int mx = pPragma->iArg ? pIdx->nColumn : pIdx->nKeyCol;
103861
+ int mx;
103862
+ if( pPragma->iArg ){
103863
+ /* PRAGMA index_xinfo (newer version with more rows and columns) */
103864
+ mx = pIdx->nColumn;
103865
+ pParse->nMem = 6;
103866
+ }else{
103867
+ /* PRAGMA index_info (legacy version) */
103868
+ mx = pIdx->nKeyCol;
103869
+ pParse->nMem = 3;
103870
+ }
103738103871
pTab = pIdx->pTable;
103739
- sqlite3VdbeSetNumCols(v, 6);
103740
- pParse->nMem = 6;
103872
+ sqlite3VdbeSetNumCols(v, pParse->nMem);
103741103873
sqlite3CodeVerifySchema(pParse, iDb);
103742103874
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC);
103743103875
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC);
103744103876
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC);
103745
- sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC);
103746
- sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC);
103747
- sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC);
103877
+ if( pPragma->iArg ){
103878
+ sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC);
103879
+ sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC);
103880
+ sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC);
103881
+ }
103748103882
for(i=0; i<mx; i++){
103749103883
i16 cnum = pIdx->aiColumn[i];
103750103884
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
103751103885
sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
103752103886
if( cnum<0 ){
103753103887
sqlite3VdbeAddOp2(v, OP_Null, 0, 3);
103754103888
}else{
103755103889
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
103756103890
}
103757
- sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
103758
- sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
103759
- sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
103760
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
103891
+ if( pPragma->iArg ){
103892
+ sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
103893
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
103894
+ sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
103895
+ }
103896
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
103761103897
}
103762103898
}
103763103899
}
103764103900
break;
103765103901
@@ -104457,12 +104593,13 @@
104457104593
#endif
104458104594
104459104595
/*
104460104596
** PRAGMA shrink_memory
104461104597
**
104462
- ** This pragma attempts to free as much memory as possible from the
104463
- ** current database connection.
104598
+ ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database
104599
+ ** connection on which it is invoked to free up as much memory as it
104600
+ ** can, by calling sqlite3_db_release_memory().
104464104601
*/
104465104602
case PragTyp_SHRINK_MEMORY: {
104466104603
sqlite3_db_release_memory(db);
104467104604
break;
104468104605
}
@@ -104487,12 +104624,16 @@
104487104624
104488104625
/*
104489104626
** PRAGMA soft_heap_limit
104490104627
** PRAGMA soft_heap_limit = N
104491104628
**
104492
- ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted,
104493
- ** use -1.
104629
+ ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the
104630
+ ** sqlite3_soft_heap_limit64() interface with the argument N, if N is
104631
+ ** specified and is a non-negative integer.
104632
+ ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always
104633
+ ** returns the same integer that would be returned by the
104634
+ ** sqlite3_soft_heap_limit64(-1) C-language function.
104494104635
*/
104495104636
case PragTyp_SOFT_HEAP_LIMIT: {
104496104637
sqlite3_int64 N;
104497104638
if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
104498104639
sqlite3_soft_heap_limit64(N);
@@ -106065,24 +106206,21 @@
106065106206
}else{
106066106207
op = OP_IdxInsert;
106067106208
}
106068106209
sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
106069106210
if( pSelect->iLimit ){
106070
- int addr1, addr2;
106211
+ int addr;
106071106212
int iLimit;
106072106213
if( pSelect->iOffset ){
106073106214
iLimit = pSelect->iOffset+1;
106074106215
}else{
106075106216
iLimit = pSelect->iLimit;
106076106217
}
106077
- addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); VdbeCoverage(v);
106078
- sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1);
106079
- addr2 = sqlite3VdbeAddOp0(v, OP_Goto);
106080
- sqlite3VdbeJumpHere(v, addr1);
106218
+ addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, -1); VdbeCoverage(v);
106081106219
sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
106082106220
sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
106083
- sqlite3VdbeJumpHere(v, addr2);
106221
+ sqlite3VdbeJumpHere(v, addr);
106084106222
}
106085106223
}
106086106224
106087106225
/*
106088106226
** Add code to implement the OFFSET
@@ -106475,11 +106613,11 @@
106475106613
/* Jump to the end of the loop if the LIMIT is reached. Except, if
106476106614
** there is a sorter, in which case the sorter has already limited
106477106615
** the output for us.
106478106616
*/
106479106617
if( pSort==0 && p->iLimit ){
106480
- sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
106618
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
106481106619
}
106482106620
}
106483106621
106484106622
/*
106485106623
** Allocate a KeyInfo object sufficient for an index of N key columns and
@@ -107328,11 +107466,11 @@
107328107466
}
107329107467
}else{
107330107468
sqlite3ExprCode(pParse, p->pLimit, iLimit);
107331107469
sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);
107332107470
VdbeComment((v, "LIMIT counter"));
107333
- sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); VdbeCoverage(v);
107471
+ sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);
107334107472
}
107335107473
if( p->pOffset ){
107336107474
p->iOffset = iOffset = ++pParse->nMem;
107337107475
pParse->nMem++; /* Allocate an extra register for limit+offset */
107338107476
sqlite3ExprCode(pParse, p->pOffset, iOffset);
@@ -107547,11 +107685,11 @@
107547107685
addrCont = sqlite3VdbeMakeLabel(v);
107548107686
codeOffset(v, regOffset, addrCont);
107549107687
selectInnerLoop(pParse, p, p->pEList, iCurrent,
107550107688
0, 0, pDest, addrCont, addrBreak);
107551107689
if( regLimit ){
107552
- sqlite3VdbeAddOp3(v, OP_IfZero, regLimit, addrBreak, -1);
107690
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);
107553107691
VdbeCoverage(v);
107554107692
}
107555107693
sqlite3VdbeResolveLabel(v, addrCont);
107556107694
107557107695
/* Execute the recursive SELECT taking the single row in Current as
@@ -107772,11 +107910,11 @@
107772107910
}
107773107911
p->pPrior = 0;
107774107912
p->iLimit = pPrior->iLimit;
107775107913
p->iOffset = pPrior->iOffset;
107776107914
if( p->iLimit ){
107777
- addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit); VdbeCoverage(v);
107915
+ addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
107778107916
VdbeComment((v, "Jump ahead if LIMIT reached"));
107779107917
}
107780107918
explainSetInteger(iSub2, pParse->iNextSelectId);
107781107919
rc = sqlite3Select(pParse, p, &dest);
107782107920
testcase( rc!=SQLITE_OK );
@@ -108173,11 +108311,11 @@
108173108311
}
108174108312
108175108313
/* Jump to the end of the loop if the LIMIT is reached.
108176108314
*/
108177108315
if( p->iLimit ){
108178
- sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
108316
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
108179108317
}
108180108318
108181108319
/* Generate the subroutine return
108182108320
*/
108183108321
sqlite3VdbeResolveLabel(v, iContinue);
@@ -114787,10 +114925,12 @@
114787114925
int addrNxt; /* Jump here to start the next IN combination */
114788114926
int addrSkip; /* Jump here for next iteration of skip-scan */
114789114927
int addrCont; /* Jump here to continue with the next loop cycle */
114790114928
int addrFirst; /* First instruction of interior of the loop */
114791114929
int addrBody; /* Beginning of the body of this loop */
114930
+ int iLikeRepCntr; /* LIKE range processing counter register */
114931
+ int addrLikeRep; /* LIKE range processing address */
114792114932
u8 iFrom; /* Which entry in the FROM clause */
114793114933
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
114794114934
int p1, p2; /* Operands of the opcode used to ends the loop */
114795114935
union { /* Information that depends on pWLoop->wsFlags */
114796114936
struct {
@@ -114971,11 +115111,11 @@
114971115111
WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
114972115112
WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
114973115113
} u;
114974115114
LogEst truthProb; /* Probability of truth for this expression */
114975115115
u16 eOperator; /* A WO_xx value describing <op> */
114976
- u8 wtFlags; /* TERM_xxx bit flags. See below */
115116
+ u16 wtFlags; /* TERM_xxx bit flags. See below */
114977115117
u8 nChild; /* Number of children that must disable us */
114978115118
WhereClause *pWC; /* The clause this term is part of */
114979115119
Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
114980115120
Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
114981115121
};
@@ -114993,10 +115133,13 @@
114993115133
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
114994115134
# define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
114995115135
#else
114996115136
# define TERM_VNULL 0x00 /* Disabled if not using stat3 */
114997115137
#endif
115138
+#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
115139
+#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
115140
+#define TERM_LIKE 0x400 /* The original LIKE operator */
114998115141
114999115142
/*
115000115143
** An instance of the WhereScan object is used as an iterator for locating
115001115144
** terms in the WHERE clause that are useful to the query planner.
115002115145
*/
@@ -115368,11 +115511,11 @@
115368115511
** WARNING: This routine might reallocate the space used to store
115369115512
** WhereTerms. All pointers to WhereTerms should be invalidated after
115370115513
** calling this routine. Such pointers may be reinitialized by referencing
115371115514
** the pWC->a[] array.
115372115515
*/
115373
-static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
115516
+static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
115374115517
WhereTerm *pTerm;
115375115518
int idx;
115376115519
testcase( wtFlags & TERM_VIRTUAL );
115377115520
if( pWC->nTerm>=pWC->nSlot ){
115378115521
WhereTerm *pOld = pWC->a;
@@ -115793,11 +115936,15 @@
115793115936
** Check to see if the given expression is a LIKE or GLOB operator that
115794115937
** can be optimized using inequality constraints. Return TRUE if it is
115795115938
** so and false if not.
115796115939
**
115797115940
** In order for the operator to be optimizible, the RHS must be a string
115798
-** literal that does not begin with a wildcard.
115941
+** literal that does not begin with a wildcard. The LHS must be a column
115942
+** that may only be NULL, a string, or a BLOB, never a number. (This means
115943
+** that virtual tables cannot participate in the LIKE optimization.) If the
115944
+** collating sequence for the column on the LHS must be appropriate for
115945
+** the operator.
115799115946
*/
115800115947
static int isLikeOrGlob(
115801115948
Parse *pParse, /* Parsing and code generating context */
115802115949
Expr *pExpr, /* Test this expression */
115803115950
Expr **ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */
@@ -115822,11 +115969,11 @@
115822115969
#endif
115823115970
pList = pExpr->x.pList;
115824115971
pLeft = pList->a[1].pExpr;
115825115972
if( pLeft->op!=TK_COLUMN
115826115973
|| sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
115827
- || IsVirtual(pLeft->pTab)
115974
+ || IsVirtual(pLeft->pTab) /* Value might be numeric */
115828115975
){
115829115976
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
115830115977
** be the name of an indexed column with TEXT affinity. */
115831115978
return 0;
115832115979
}
@@ -116271,11 +116418,11 @@
116271116418
Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
116272116419
Bitmask prereqAll; /* Prerequesites of pExpr */
116273116420
Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */
116274116421
Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */
116275116422
int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */
116276
- int noCase = 0; /* LIKE/GLOB distinguishes case */
116423
+ int noCase = 0; /* uppercase equivalent to lowercase */
116277116424
int op; /* Top-level operator. pExpr->op */
116278116425
Parse *pParse = pWInfo->pParse; /* Parsing context */
116279116426
sqlite3 *db = pParse->db; /* Database connection */
116280116427
116281116428
if( db->mallocFailed ){
@@ -116409,16 +116556,19 @@
116409116556
116410116557
#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
116411116558
/* Add constraints to reduce the search space on a LIKE or GLOB
116412116559
** operator.
116413116560
**
116414
- ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints
116561
+ ** A like pattern of the form "x LIKE 'aBc%'" is changed into constraints
116415116562
**
116416
- ** x>='abc' AND x<'abd' AND x LIKE 'abc%'
116563
+ ** x>='ABC' AND x<'abd' AND x LIKE 'aBc%'
116417116564
**
116418116565
** The last character of the prefix "abc" is incremented to form the
116419
- ** termination condition "abd".
116566
+ ** termination condition "abd". If case is not significant (the default
116567
+ ** for LIKE) then the lower-bound is made all uppercase and the upper-
116568
+ ** bound is made all lowercase so that the bounds also work when comparing
116569
+ ** BLOBs.
116420116570
*/
116421116571
if( pWC->op==TK_AND
116422116572
&& isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
116423116573
){
116424116574
Expr *pLeft; /* LHS of LIKE/GLOB operator */
@@ -116426,13 +116576,29 @@
116426116576
Expr *pNewExpr1;
116427116577
Expr *pNewExpr2;
116428116578
int idxNew1;
116429116579
int idxNew2;
116430116580
Token sCollSeqName; /* Name of collating sequence */
116581
+ const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
116431116582
116432116583
pLeft = pExpr->x.pList->a[1].pExpr;
116433116584
pStr2 = sqlite3ExprDup(db, pStr1, 0);
116585
+
116586
+ /* Convert the lower bound to upper-case and the upper bound to
116587
+ ** lower-case (upper-case is less than lower-case in ASCII) so that
116588
+ ** the range constraints also work for BLOBs
116589
+ */
116590
+ if( noCase && !pParse->db->mallocFailed ){
116591
+ int i;
116592
+ char c;
116593
+ pTerm->wtFlags |= TERM_LIKE;
116594
+ for(i=0; (c = pStr1->u.zToken[i])!=0; i++){
116595
+ pStr1->u.zToken[i] = sqlite3Toupper(c);
116596
+ pStr2->u.zToken[i] = sqlite3Tolower(c);
116597
+ }
116598
+ }
116599
+
116434116600
if( !db->mallocFailed ){
116435116601
u8 c, *pC; /* Last character before the first wildcard */
116436116602
pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
116437116603
c = *pC;
116438116604
if( noCase ){
@@ -116448,23 +116614,23 @@
116448116614
*pC = c + 1;
116449116615
}
116450116616
sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
116451116617
sCollSeqName.n = 6;
116452116618
pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
116453
- pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116619
+ pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116454116620
sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
116455116621
pStr1, 0);
116456116622
transferJoinMarkings(pNewExpr1, pExpr);
116457
- idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);
116623
+ idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
116458116624
testcase( idxNew1==0 );
116459116625
exprAnalyze(pSrc, pWC, idxNew1);
116460116626
pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
116461116627
pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
116462116628
sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
116463116629
pStr2, 0);
116464116630
transferJoinMarkings(pNewExpr2, pExpr);
116465
- idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC);
116631
+ idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
116466116632
testcase( idxNew2==0 );
116467116633
exprAnalyze(pSrc, pWC, idxNew2);
116468116634
pTerm = &pWC->a[idxTerm];
116469116635
if( isComplete ){
116470116636
markTermAsChild(pWC, idxNew1, idxTerm);
@@ -117635,24 +117801,47 @@
117635117801
** by indices, we disable them to prevent redundant tests in the inner
117636117802
** loop. We would get the correct results if nothing were ever disabled,
117637117803
** but joins might run a little slower. The trick is to disable as much
117638117804
** as we can without disabling too much. If we disabled in (1), we'd get
117639117805
** the wrong answer. See ticket #813.
117806
+**
117807
+** If all the children of a term are disabled, then that term is also
117808
+** automatically disabled. In this way, terms get disabled if derived
117809
+** virtual terms are tested first. For example:
117810
+**
117811
+** x GLOB 'abc*' AND x>='abc' AND x<'acd'
117812
+** \___________/ \______/ \_____/
117813
+** parent child1 child2
117814
+**
117815
+** Only the parent term was in the original WHERE clause. The child1
117816
+** and child2 terms were added by the LIKE optimization. If both of
117817
+** the virtual child terms are valid, then testing of the parent can be
117818
+** skipped.
117819
+**
117820
+** Usually the parent term is marked as TERM_CODED. But if the parent
117821
+** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.
117822
+** The TERM_LIKECOND marking indicates that the term should be coded inside
117823
+** a conditional such that is only evaluated on the second pass of a
117824
+** LIKE-optimization loop, when scanning BLOBs instead of strings.
117640117825
*/
117641117826
static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
117642
- if( pTerm
117827
+ int nLoop = 0;
117828
+ while( pTerm
117643117829
&& (pTerm->wtFlags & TERM_CODED)==0
117644117830
&& (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
117645117831
&& (pLevel->notReady & pTerm->prereqAll)==0
117646117832
){
117647
- pTerm->wtFlags |= TERM_CODED;
117648
- if( pTerm->iParent>=0 ){
117649
- WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent];
117650
- if( (--pOther->nChild)==0 ){
117651
- disableTerm(pLevel, pOther);
117652
- }
117833
+ if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
117834
+ pTerm->wtFlags |= TERM_LIKECOND;
117835
+ }else{
117836
+ pTerm->wtFlags |= TERM_CODED;
117653117837
}
117838
+ if( pTerm->iParent<0 ) break;
117839
+ pTerm = &pTerm->pWC->a[pTerm->iParent];
117840
+ pTerm->nChild--;
117841
+ if( pTerm->nChild!=0 ) break;
117842
+ nLoop++;
117654117843
}
117655117844
}
117656117845
117657117846
/*
117658117847
** Code an OP_Affinity opcode to apply the column affinity string zAff
@@ -118132,11 +118321,30 @@
118132118321
}
118133118322
#else
118134118323
# define addScanStatus(a, b, c, d) ((void)d)
118135118324
#endif
118136118325
118137
-
118326
+/*
118327
+** Look at the last instruction coded. If that instruction is OP_String8
118328
+** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be
118329
+** pLoop->iLikeRepCntr and set P5.
118330
+**
118331
+** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
118332
+** expression: "x>='ABC' AND x<'abd'". But this requires that the range
118333
+** scan loop run twice, once for strings and a second time for BLOBs.
118334
+** The OP_String opcodes on the second pass convert the upper and lower
118335
+** bound string contants to blobs. This routine makes the necessary changes
118336
+** to the OP_String opcodes for that to happen.
118337
+*/
118338
+static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){
118339
+ VdbeOp *pOp;
118340
+ pOp = sqlite3VdbeGetOp(v, -1);
118341
+ if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){
118342
+ pOp->p3 = pLevel->iLikeRepCntr;
118343
+ pOp->p5 = 1;
118344
+ }
118345
+}
118138118346
118139118347
/*
118140118348
** Generate code for the start of the iLevel-th loop in the WHERE clause
118141118349
** implementation described by pWInfo.
118142118350
*/
@@ -118466,10 +118674,23 @@
118466118674
nExtraReg = 1;
118467118675
}
118468118676
if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
118469118677
pRangeEnd = pLoop->aLTerm[j++];
118470118678
nExtraReg = 1;
118679
+ if( pRangeStart
118680
+ && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0
118681
+ && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0
118682
+ ){
118683
+ pLevel->iLikeRepCntr = ++pParse->nMem;
118684
+ testcase( bRev );
118685
+ testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
118686
+ sqlite3VdbeAddOp2(v, OP_Integer,
118687
+ bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
118688
+ pLevel->iLikeRepCntr);
118689
+ VdbeComment((v, "LIKE loop counter"));
118690
+ pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);
118691
+ }
118471118692
if( pRangeStart==0
118472118693
&& (j = pIdx->aiColumn[nEq])>=0
118473118694
&& pIdx->pTable->aCol[j].notNull==0
118474118695
){
118475118696
bSeekPastNull = 1;
@@ -118508,10 +118729,11 @@
118508118729
/* Seek the index cursor to the start of the range. */
118509118730
nConstraint = nEq;
118510118731
if( pRangeStart ){
118511118732
Expr *pRight = pRangeStart->pExpr->pRight;
118512118733
sqlite3ExprCode(pParse, pRight, regBase+nEq);
118734
+ whereLikeOptimizationStringFixup(v, pLevel);
118513118735
if( (pRangeStart->wtFlags & TERM_VNULL)==0
118514118736
&& sqlite3ExprCanBeNull(pRight)
118515118737
){
118516118738
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118517118739
VdbeCoverage(v);
@@ -118553,10 +118775,11 @@
118553118775
nConstraint = nEq;
118554118776
if( pRangeEnd ){
118555118777
Expr *pRight = pRangeEnd->pExpr->pRight;
118556118778
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
118557118779
sqlite3ExprCode(pParse, pRight, regBase+nEq);
118780
+ whereLikeOptimizationStringFixup(v, pLevel);
118558118781
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
118559118782
&& sqlite3ExprCanBeNull(pRight)
118560118783
){
118561118784
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118562118785
VdbeCoverage(v);
@@ -118780,11 +119003,12 @@
118780119003
** eliminating duplicates from other WHERE clauses, the action for each
118781119004
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
118782119005
*/
118783119006
wctrlFlags = WHERE_OMIT_OPEN_CLOSE
118784119007
| WHERE_FORCE_TABLE
118785
- | WHERE_ONETABLE_ONLY;
119008
+ | WHERE_ONETABLE_ONLY
119009
+ | WHERE_NO_AUTOINDEX;
118786119010
for(ii=0; ii<pOrWc->nTerm; ii++){
118787119011
WhereTerm *pOrTerm = &pOrWc->a[ii];
118788119012
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
118789119013
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
118790119014
Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -118942,10 +119166,11 @@
118942119166
/* Insert code to test every subexpression that can be completely
118943119167
** computed using the current set of tables.
118944119168
*/
118945119169
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
118946119170
Expr *pE;
119171
+ int skipLikeAddr = 0;
118947119172
testcase( pTerm->wtFlags & TERM_VIRTUAL );
118948119173
testcase( pTerm->wtFlags & TERM_CODED );
118949119174
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
118950119175
if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
118951119176
testcase( pWInfo->untestedTerms==0
@@ -118955,12 +119180,18 @@
118955119180
}
118956119181
pE = pTerm->pExpr;
118957119182
assert( pE!=0 );
118958119183
if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
118959119184
continue;
119185
+ }
119186
+ if( pTerm->wtFlags & TERM_LIKECOND ){
119187
+ assert( pLevel->iLikeRepCntr>0 );
119188
+ skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr);
119189
+ VdbeCoverage(v);
118960119190
}
118961119191
sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
119192
+ if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
118962119193
pTerm->wtFlags |= TERM_CODED;
118963119194
}
118964119195
118965119196
/* Insert code to test for implied constraints based on transitivity
118966119197
** of the "==" operator.
@@ -119974,10 +120205,11 @@
119974120205
rLogSize = estLog(rSize);
119975120206
119976120207
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
119977120208
/* Automatic indexes */
119978120209
if( !pBuilder->pOrSet
120210
+ && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
119979120211
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
119980120212
&& pSrc->pIndex==0
119981120213
&& !pSrc->viaCoroutine
119982120214
&& !pSrc->notIndexed
119983120215
&& HasRowid(pTab)
@@ -121758,10 +121990,20 @@
121758121990
if( pLevel->addrSkip ){
121759121991
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
121760121992
VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
121761121993
sqlite3VdbeJumpHere(v, pLevel->addrSkip);
121762121994
sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
121995
+ }
121996
+ if( pLevel->addrLikeRep ){
121997
+ int op;
121998
+ if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){
121999
+ op = OP_DecrJumpZero;
122000
+ }else{
122001
+ op = OP_JumpZeroIncr;
122002
+ }
122003
+ sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep);
122004
+ VdbeCoverage(v);
121763122005
}
121764122006
if( pLevel->iLeftJoin ){
121765122007
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
121766122008
assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
121767122009
|| (pLoop->wsFlags & WHERE_INDEXED)!=0 );
@@ -126982,30 +127224,32 @@
126982127224
/* Mutex configuration options are only available in a threadsafe
126983127225
** compile.
126984127226
*/
126985127227
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-54466-46756 */
126986127228
case SQLITE_CONFIG_SINGLETHREAD: {
126987
- /* Disable all mutexing */
126988
- sqlite3GlobalConfig.bCoreMutex = 0;
126989
- sqlite3GlobalConfig.bFullMutex = 0;
127229
+ /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to
127230
+ ** Single-thread. */
127231
+ sqlite3GlobalConfig.bCoreMutex = 0; /* Disable mutex on core */
127232
+ sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
126990127233
break;
126991127234
}
126992127235
#endif
126993127236
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */
126994127237
case SQLITE_CONFIG_MULTITHREAD: {
126995
- /* Disable mutexing of database connections */
126996
- /* Enable mutexing of core data structures */
126997
- sqlite3GlobalConfig.bCoreMutex = 1;
126998
- sqlite3GlobalConfig.bFullMutex = 0;
127238
+ /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to
127239
+ ** Multi-thread. */
127240
+ sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
127241
+ sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
126999127242
break;
127000127243
}
127001127244
#endif
127002127245
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */
127003127246
case SQLITE_CONFIG_SERIALIZED: {
127004
- /* Enable all mutexing */
127005
- sqlite3GlobalConfig.bCoreMutex = 1;
127006
- sqlite3GlobalConfig.bFullMutex = 1;
127247
+ /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to
127248
+ ** Serialized. */
127249
+ sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
127250
+ sqlite3GlobalConfig.bFullMutex = 1; /* Enable mutex on connections */
127007127251
break;
127008127252
}
127009127253
#endif
127010127254
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */
127011127255
case SQLITE_CONFIG_MUTEX: {
@@ -127113,11 +127357,12 @@
127113127357
** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */
127114127358
#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
127115127359
case SQLITE_CONFIG_HEAP: {
127116127360
/* EVIDENCE-OF: R-19854-42126 There are three arguments to
127117127361
** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the
127118
- ** number of bytes in the memory buffer, and the minimum allocation size. */
127362
+ ** number of bytes in the memory buffer, and the minimum allocation size.
127363
+ */
127119127364
sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
127120127365
sqlite3GlobalConfig.nHeap = va_arg(ap, int);
127121127366
sqlite3GlobalConfig.mnReq = va_arg(ap, int);
127122127367
127123127368
if( sqlite3GlobalConfig.mnReq<1 ){
@@ -127218,11 +127463,13 @@
127218127463
** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
127219127464
** silently truncated if necessary so that it does not exceed the
127220127465
** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE
127221127466
** compile-time option.
127222127467
*/
127223
- if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ) mxMmap = SQLITE_MAX_MMAP_SIZE;
127468
+ if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){
127469
+ mxMmap = SQLITE_MAX_MMAP_SIZE;
127470
+ }
127224127471
if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
127225127472
if( szMmap>mxMmap) szMmap = mxMmap;
127226127473
sqlite3GlobalConfig.mxMmap = mxMmap;
127227127474
sqlite3GlobalConfig.szMmap = szMmap;
127228127475
break;
@@ -129062,11 +129309,23 @@
129062129309
for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
129063129310
zFile = sqlite3_malloc(nByte);
129064129311
if( !zFile ) return SQLITE_NOMEM;
129065129312
129066129313
iIn = 5;
129067
-#ifndef SQLITE_ALLOW_URI_AUTHORITY
129314
+#ifdef SQLITE_ALLOW_URI_AUTHORITY
129315
+ if( strncmp(zUri+5, "///", 3)==0 ){
129316
+ iIn = 7;
129317
+ /* The following condition causes URIs with five leading / characters
129318
+ ** like file://///host/path to be converted into UNCs like //host/path.
129319
+ ** The correct URI for that UNC has only two or four leading / characters
129320
+ ** file://host/path or file:////host/path. But 5 leading slashes is a
129321
+ ** common error, we are told, so we handle it as a special case. */
129322
+ if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; }
129323
+ }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){
129324
+ iIn = 16;
129325
+ }
129326
+#else
129068129327
/* Discard the scheme and authority segments of the URI. */
129069129328
if( zUri[5]=='/' && zUri[6]=='/' ){
129070129329
iIn = 7;
129071129330
while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;
129072129331
if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){
@@ -129505,11 +129764,12 @@
129505129764
sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
129506129765
129507129766
opendb_out:
129508129767
sqlite3_free(zOpen);
129509129768
if( db ){
129510
- assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 );
129769
+ assert( db->mutex!=0 || isThreadsafe==0
129770
+ || sqlite3GlobalConfig.bFullMutex==0 );
129511129771
sqlite3_mutex_leave(db->mutex);
129512129772
}
129513129773
rc = sqlite3_errcode(db);
129514129774
assert( db!=0 || rc==SQLITE_NOMEM );
129515129775
if( rc==SQLITE_NOMEM ){
@@ -130250,21 +130510,21 @@
130250130510
case SQLITE_TESTCTRL_ISINIT: {
130251130511
if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
130252130512
break;
130253130513
}
130254130514
130255
- /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);
130515
+ /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);
130256130516
**
130257130517
** This test control is used to create imposter tables. "db" is a pointer
130258130518
** to the database connection. dbName is the database name (ex: "main" or
130259130519
** "temp") which will receive the imposter. "onOff" turns imposter mode on
130260130520
** or off. "tnum" is the root page of the b-tree to which the imposter
130261130521
** table should connect.
130262130522
**
130263130523
** Enable imposter mode only when the schema has already been parsed. Then
130264
- ** run a single CREATE TABLE statement to construct the imposter table in the
130265
- ** parsed schema. Then turn imposter mode back off again.
130524
+ ** run a single CREATE TABLE statement to construct the imposter table in
130525
+ ** the parsed schema. Then turn imposter mode back off again.
130266130526
**
130267130527
** If onOff==0 and tnum>0 then reset the schema for all databases, causing
130268130528
** the schema to be reparsed the next time it is needed. This has the
130269130529
** effect of erasing all imposter tables.
130270130530
*/
130271130531
--- 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.8.8. 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.
@@ -88,10 +88,48 @@
88 #endif /* _MSVC_H_ */
89
90 /************** End of msvc.h ************************************************/
91 /************** Continuing where we left off in sqliteInt.h ******************/
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93 /*
94 ** These #defines should enable >2GB file support on POSIX if the
95 ** underlying operating system supports it. If the OS lacks
96 ** large file support, or if the OS is windows, these should be no-ops.
97 **
@@ -276,13 +314,13 @@
276 **
277 ** See also: [sqlite3_libversion()],
278 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
279 ** [sqlite_version()] and [sqlite_source_id()].
280 */
281 #define SQLITE_VERSION "3.8.8"
282 #define SQLITE_VERSION_NUMBER 3008008
283 #define SQLITE_SOURCE_ID "2015-02-25 14:25:31 6d132e7a224ee68b5cefe9222944aac5760ffc20"
284
285 /*
286 ** CAPI3REF: Run-Time Library Version Numbers
287 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
288 **
@@ -925,18 +963,20 @@
925 **
926 ** These integer constants are opcodes for the xFileControl method
927 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
928 ** interface.
929 **
 
 
930 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
931 ** opcode causes the xFileControl method to write the current state of
932 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
933 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
934 ** into an integer that the pArg argument points to. This capability
935 ** is used during testing and only needs to be supported when SQLITE_TEST
936 ** is defined.
937 ** <ul>
938 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
939 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
940 ** layer a hint of how large the database file will grow to be during the
941 ** current transaction. This hint is not guaranteed to be accurate but it
942 ** is often close. The underlying VFS might choose to preallocate database
@@ -1057,11 +1097,13 @@
1057 ** the error message if the pragma fails. ^If the
1058 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
1059 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
1060 ** file control returns [SQLITE_OK], then the parser assumes that the
1061 ** VFS has handled the PRAGMA itself and the parser generates a no-op
1062 ** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
 
 
1063 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
1064 ** that the VFS encountered an error while handling the [PRAGMA] and the
1065 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
1066 ** file control occurs at the beginning of pragma statement analysis and so
1067 ** it is able to override built-in [PRAGMA] statements.
@@ -1916,11 +1958,10 @@
1916 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1917 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
1918 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
1919 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1920 ** that specifies the maximum size of the created heap.
1921 ** </dl>
1922 **
1923 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
1924 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
1925 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
1926 ** is a pointer to an integer and writes into that integer the number of extra
@@ -3356,20 +3397,18 @@
3356 ** The second argument, "zSql", is the statement to be compiled, encoded
3357 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3358 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3359 ** use UTF-16.
3360 **
3361 ** ^If the nByte argument is less than zero, then zSql is read up to the
3362 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
3363 ** number of bytes read from zSql. ^When nByte is non-negative, the
3364 ** zSql string ends at either the first '\000' or '\u0000' character or
3365 ** the nByte-th byte, whichever comes first. If the caller knows
3366 ** that the supplied string is nul-terminated, then there is a small
3367 ** performance advantage to be gained by passing an nByte parameter that
3368 ** is equal to the number of bytes in the input string <i>including</i>
3369 ** the nul-terminator bytes as this saves SQLite from having to
3370 ** make a copy of the input string.
3371 **
3372 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
3373 ** past the end of the first SQL statement in zSql. These routines only
3374 ** compile the first statement in zSql, so *pzTail is left pointing to
3375 ** what remains uncompiled.
@@ -4394,12 +4433,12 @@
4394 ** DEPRECATED
4395 **
4396 ** These functions are [deprecated]. In order to maintain
4397 ** backwards compatibility with older code, these functions continue
4398 ** to be supported. However, new applications should avoid
4399 ** the use of these functions. To help encourage people to avoid
4400 ** using these functions, we are not going to tell you what they do.
4401 */
4402 #ifndef SQLITE_OMIT_DEPRECATED
4403 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4404 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4405 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -7157,24 +7196,24 @@
7157 **
7158 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
7159 ** is not a permanent error and does not affect the return value of
7160 ** sqlite3_backup_finish().
7161 **
7162 ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
7163 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
7164 **
7165 ** ^Each call to sqlite3_backup_step() sets two values inside
7166 ** the [sqlite3_backup] object: the number of pages still to be backed
7167 ** up and the total number of pages in the source database file.
7168 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
7169 ** retrieve these two values, respectively.
7170 **
7171 ** ^The values returned by these functions are only updated by
7172 ** sqlite3_backup_step(). ^If the source database is modified during a backup
7173 ** operation, then the values are not updated to account for any extra
7174 ** pages that need to be updated or the size of the source database file
7175 ** changing.
7176 **
7177 ** <b>Concurrent Usage of Database Handles</b>
7178 **
7179 ** ^The source [database connection] may be used by the application for other
7180 ** purposes while a backup operation is underway or being initialized.
@@ -8018,19 +8057,21 @@
8018 #ifndef SQLITE_MAX_FUNCTION_ARG
8019 # define SQLITE_MAX_FUNCTION_ARG 127
8020 #endif
8021
8022 /*
8023 ** The maximum number of in-memory pages to use for the main database
8024 ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
 
 
 
 
 
8025 */
8026 #ifndef SQLITE_DEFAULT_CACHE_SIZE
8027 # define SQLITE_DEFAULT_CACHE_SIZE 2000
8028 #endif
8029 #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
8030 # define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
8031 #endif
8032
8033 /*
8034 ** The default number of frames to accumulate in the log file before
8035 ** checkpointing the database in WAL mode.
8036 */
@@ -9733,27 +9774,29 @@
9733 #define OP_FkCounter 134 /* synopsis: fkctr[P1]+=P2 */
9734 #define OP_FkIfZero 135 /* synopsis: if fkctr[P1]==0 goto P2 */
9735 #define OP_MemMax 136 /* synopsis: r[P1]=max(r[P1],r[P2]) */
9736 #define OP_IfPos 137 /* synopsis: if r[P1]>0 goto P2 */
9737 #define OP_IfNeg 138 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2 */
9738 #define OP_IfZero 139 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */
9739 #define OP_AggFinal 140 /* synopsis: accum=r[P1] N=P2 */
9740 #define OP_IncrVacuum 141
9741 #define OP_Expire 142
9742 #define OP_TableLock 143 /* synopsis: iDb=P1 root=P2 write=P3 */
9743 #define OP_VBegin 144
9744 #define OP_VCreate 145
9745 #define OP_VDestroy 146
9746 #define OP_VOpen 147
9747 #define OP_VColumn 148 /* synopsis: r[P3]=vcolumn(P2) */
9748 #define OP_VNext 149
9749 #define OP_VRename 150
9750 #define OP_Pagecount 151
9751 #define OP_MaxPgcnt 152
9752 #define OP_Init 153 /* synopsis: Start at P2 */
9753 #define OP_Noop 154
9754 #define OP_Explain 155
 
 
9755
9756
9757 /* Properties such as "out2" or "jump" that are specified in
9758 ** comments following the "case" for each opcode in the vdbe.c
9759 ** are encoded into bitvectors as follows:
@@ -9781,13 +9824,13 @@
9781 /* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\
9782 /* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\
9783 /* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
9784 /* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9785 /* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
9786 /* 136 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x01, 0x00, 0x00,\
9787 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,\
9788 /* 152 */ 0x02, 0x01, 0x00, 0x00,}
9789
9790 /************** End of opcodes.h *********************************************/
9791 /************** Continuing where we left off in vdbe.h ***********************/
9792
9793 /*
@@ -12022,11 +12065,11 @@
12022 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
12023 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
12024 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
12025 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
12026 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
12027 /* 0x0080 // not currently used */
12028 #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
12029 #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
12030 #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
12031 #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
12032 #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
@@ -24969,27 +25012,29 @@
24969 /* 134 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
24970 /* 135 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
24971 /* 136 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
24972 /* 137 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
24973 /* 138 */ "IfNeg" OpHelp("r[P1]+=P3, if r[P1]<0 goto P2"),
24974 /* 139 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"),
24975 /* 140 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
24976 /* 141 */ "IncrVacuum" OpHelp(""),
24977 /* 142 */ "Expire" OpHelp(""),
24978 /* 143 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
24979 /* 144 */ "VBegin" OpHelp(""),
24980 /* 145 */ "VCreate" OpHelp(""),
24981 /* 146 */ "VDestroy" OpHelp(""),
24982 /* 147 */ "VOpen" OpHelp(""),
24983 /* 148 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
24984 /* 149 */ "VNext" OpHelp(""),
24985 /* 150 */ "VRename" OpHelp(""),
24986 /* 151 */ "Pagecount" OpHelp(""),
24987 /* 152 */ "MaxPgcnt" OpHelp(""),
24988 /* 153 */ "Init" OpHelp("Start at P2"),
24989 /* 154 */ "Noop" OpHelp(""),
24990 /* 155 */ "Explain" OpHelp(""),
 
 
24991 };
24992 return azName[i];
24993 }
24994 #endif
24995
@@ -25065,22 +25110,10 @@
25065 # else
25066 # define SQLITE_ENABLE_LOCKING_STYLE 0
25067 # endif
25068 #endif
25069
25070 /*
25071 ** Define the OS_VXWORKS pre-processor macro to 1 if building on
25072 ** vxworks, or 0 otherwise.
25073 */
25074 #ifndef OS_VXWORKS
25075 # if defined(__RTP__) || defined(_WRS_KERNEL)
25076 # define OS_VXWORKS 1
25077 # else
25078 # define OS_VXWORKS 0
25079 # endif
25080 #endif
25081
25082 /*
25083 ** standard include files.
25084 */
25085 #include <sys/types.h>
25086 #include <sys/stat.h>
@@ -25091,22 +25124,23 @@
25091 #include <errno.h>
25092 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
25093 # include <sys/mman.h>
25094 #endif
25095
25096 #if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
25097 # include <sys/ioctl.h>
25098 # if OS_VXWORKS
25099 # include <semaphore.h>
25100 # include <limits.h>
25101 # else
25102 # include <sys/file.h>
25103 # include <sys/param.h>
25104 # endif
25105 #endif /* SQLITE_ENABLE_LOCKING_STYLE */
25106
25107 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
 
 
 
 
 
 
25108 # include <sys/mount.h>
25109 #endif
25110
25111 #ifdef HAVE_UTIME
25112 # include <utime.h>
@@ -25142,10 +25176,14 @@
25142
25143 /*
25144 ** Maximum supported path-length.
25145 */
25146 #define MAX_PATHNAME 512
 
 
 
 
25147
25148 /*
25149 ** Only set the lastErrno if the error code is a real error and not
25150 ** a normal expected return code of SQLITE_BUSY or SQLITE_OK
25151 */
@@ -25231,11 +25269,11 @@
25231
25232 /* This variable holds the process id (pid) from when the xRandomness()
25233 ** method was called. If xOpen() is called from a different process id,
25234 ** indicating that a fork() has occurred, the PRNG will be reset.
25235 */
25236 static int randomnessPid = 0;
25237
25238 /*
25239 ** Allowed values for the unixFile.ctrlFlags bitmask:
25240 */
25241 #define UNIXFILE_EXCL 0x01 /* Connections from one process only */
@@ -25587,11 +25625,11 @@
25587 #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
25588
25589 { "read", (sqlite3_syscall_ptr)read, 0 },
25590 #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
25591
25592 #if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
25593 { "pread", (sqlite3_syscall_ptr)pread, 0 },
25594 #else
25595 { "pread", (sqlite3_syscall_ptr)0, 0 },
25596 #endif
25597 #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25604,11 +25642,11 @@
25604 #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
25605
25606 { "write", (sqlite3_syscall_ptr)write, 0 },
25607 #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
25608
25609 #if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
25610 { "pwrite", (sqlite3_syscall_ptr)pwrite, 0 },
25611 #else
25612 { "pwrite", (sqlite3_syscall_ptr)0, 0 },
25613 #endif
25614 #define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\
@@ -26743,11 +26781,12 @@
26743 int tErrno = 0;
26744
26745 assert( pFile );
26746 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
26747 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
26748 azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid()));
 
26749
26750 /* If there is already a lock of this type or more restrictive on the
26751 ** unixFile, do nothing. Don't use the end_lock: exit path, as
26752 ** unixEnterMutex() hasn't been called yet.
26753 */
@@ -26951,11 +26990,11 @@
26951 int rc = SQLITE_OK;
26952
26953 assert( pFile );
26954 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
26955 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
26956 getpid()));
26957
26958 assert( eFileLock<=SHARED_LOCK );
26959 if( pFile->eFileLock<=eFileLock ){
26960 return SQLITE_OK;
26961 }
@@ -27378,11 +27417,11 @@
27378 char *zLockFile = (char *)pFile->lockingContext;
27379 int rc;
27380
27381 assert( pFile );
27382 OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27383 pFile->eFileLock, getpid()));
27384 assert( eFileLock<=SHARED_LOCK );
27385
27386 /* no-op if possible */
27387 if( pFile->eFileLock==eFileLock ){
27388 return SQLITE_OK;
@@ -27441,14 +27480,13 @@
27441 ** a single exclusive lock. In other words, SHARED, RESERVED, and
27442 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
27443 ** still works when you do this, but concurrency is reduced since
27444 ** only a single process can be reading the database at a time.
27445 **
27446 ** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if
27447 ** compiling for VXWORKS.
27448 */
27449 #if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
27450
27451 /*
27452 ** Retry flock() calls that fail with EINTR
27453 */
27454 #ifdef EINTR
@@ -27597,11 +27635,11 @@
27597 static int flockUnlock(sqlite3_file *id, int eFileLock) {
27598 unixFile *pFile = (unixFile*)id;
27599
27600 assert( pFile );
27601 OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27602 pFile->eFileLock, getpid()));
27603 assert( eFileLock<=SHARED_LOCK );
27604
27605 /* no-op if possible */
27606 if( pFile->eFileLock==eFileLock ){
27607 return SQLITE_OK;
@@ -27658,11 +27696,11 @@
27658 ** This routine checks if there is a RESERVED lock held on the specified
27659 ** file by this or any other process. If such a lock is held, set *pResOut
27660 ** to a non-zero value otherwise *pResOut is set to zero. The return value
27661 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27662 */
27663 static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
27664 int rc = SQLITE_OK;
27665 int reserved = 0;
27666 unixFile *pFile = (unixFile*)id;
27667
27668 SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
@@ -27725,11 +27763,11 @@
27725 ** access the file.
27726 **
27727 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
27728 ** routine to lower a locking level.
27729 */
27730 static int semLock(sqlite3_file *id, int eFileLock) {
27731 unixFile *pFile = (unixFile*)id;
27732 sem_t *pSem = pFile->pInode->pSem;
27733 int rc = SQLITE_OK;
27734
27735 /* if we already have a lock, it is exclusive.
@@ -27758,18 +27796,18 @@
27758 ** must be either NO_LOCK or SHARED_LOCK.
27759 **
27760 ** If the locking level of the file descriptor is already at or below
27761 ** the requested locking level, this routine is a no-op.
27762 */
27763 static int semUnlock(sqlite3_file *id, int eFileLock) {
27764 unixFile *pFile = (unixFile*)id;
27765 sem_t *pSem = pFile->pInode->pSem;
27766
27767 assert( pFile );
27768 assert( pSem );
27769 OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27770 pFile->eFileLock, getpid()));
27771 assert( eFileLock<=SHARED_LOCK );
27772
27773 /* no-op if possible */
27774 if( pFile->eFileLock==eFileLock ){
27775 return SQLITE_OK;
@@ -27795,14 +27833,14 @@
27795 }
27796
27797 /*
27798 ** Close a file.
27799 */
27800 static int semClose(sqlite3_file *id) {
27801 if( id ){
27802 unixFile *pFile = (unixFile*)id;
27803 semUnlock(id, NO_LOCK);
27804 assert( pFile );
27805 unixEnterMutex();
27806 releaseInodeInfo(pFile);
27807 unixLeaveMutex();
27808 closeUnixFile(id);
@@ -27979,11 +28017,11 @@
27979 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
27980
27981 assert( pFile );
27982 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
27983 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
27984 azFileLock(pInode->eFileLock), pInode->nShared , getpid()));
27985
27986 /* If there is already a lock of this type or more restrictive on the
27987 ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
27988 ** unixEnterMutex() hasn't been called yet.
27989 */
@@ -28165,11 +28203,11 @@
28165 #endif
28166
28167 assert( pFile );
28168 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
28169 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28170 getpid()));
28171
28172 assert( eFileLock<=SHARED_LOCK );
28173 if( pFile->eFileLock<=eFileLock ){
28174 return SQLITE_OK;
28175 }
@@ -29204,11 +29242,13 @@
29204 **
29205 ** This function should not be called directly by other code in this file.
29206 ** Instead, it should be called via macro osGetpagesize().
29207 */
29208 static int unixGetpagesize(void){
29209 #if defined(_BSD_SOURCE)
 
 
29210 return getpagesize();
29211 #else
29212 return (int)sysconf(_SC_PAGESIZE);
29213 #endif
29214 }
@@ -29833,11 +29873,11 @@
29833 }
29834 }
29835 }
29836 sqlite3_mutex_leave(pShmNode->mutex);
29837 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
29838 p->id, getpid(), p->sharedMask, p->exclMask));
29839 return rc;
29840 }
29841
29842 /*
29843 ** Implement a memory barrier or memory fence on shared memory.
@@ -30236,11 +30276,11 @@
30236 dotlockUnlock, /* xUnlock method */
30237 dotlockCheckReservedLock, /* xCheckReservedLock method */
30238 0 /* xShmMap method */
30239 )
30240
30241 #if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
30242 IOMETHODS(
30243 flockIoFinder, /* Finder function name */
30244 flockIoMethods, /* sqlite3_io_methods object name */
30245 1, /* shared memory is disabled */
30246 flockClose, /* xClose method */
@@ -30254,14 +30294,14 @@
30254 #if OS_VXWORKS
30255 IOMETHODS(
30256 semIoFinder, /* Finder function name */
30257 semIoMethods, /* sqlite3_io_methods object name */
30258 1, /* shared memory is disabled */
30259 semClose, /* xClose method */
30260 semLock, /* xLock method */
30261 semUnlock, /* xUnlock method */
30262 semCheckReservedLock, /* xCheckReservedLock method */
30263 0 /* xShmMap method */
30264 )
30265 #endif
30266
30267 #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
@@ -30381,19 +30421,17 @@
30381 static const sqlite3_io_methods
30382 *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
30383
30384 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
30385
30386 #if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
30387 /*
30388 ** This "finder" function attempts to determine the best locking strategy
30389 ** for the database file "filePath". It then returns the sqlite3_io_methods
30390 ** object that implements that strategy.
30391 **
30392 ** This is for VXWorks only.
30393 */
30394 static const sqlite3_io_methods *autolockIoFinderImpl(
30395 const char *filePath, /* name of the database file */
30396 unixFile *pNew /* the open file object */
30397 ){
30398 struct flock lockInfo;
30399
@@ -30415,13 +30453,13 @@
30415 }else{
30416 return &semIoMethods;
30417 }
30418 }
30419 static const sqlite3_io_methods
30420 *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
30421
30422 #endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
30423
30424 /*
30425 ** An abstract type for a pointer to an IO method finder function:
30426 */
30427 typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);
@@ -30930,12 +30968,12 @@
30930 /* Detect a pid change and reset the PRNG. There is a race condition
30931 ** here such that two or more threads all trying to open databases at
30932 ** the same instant might all reset the PRNG. But multiple resets
30933 ** are harmless.
30934 */
30935 if( randomnessPid!=getpid() ){
30936 randomnessPid = getpid();
30937 sqlite3_randomness(0,0);
30938 }
30939
30940 memset(p, 0, sizeof(unixFile));
30941
@@ -31322,11 +31360,11 @@
31322 ** When testing, initializing zBuf[] to zero is all we do. That means
31323 ** that we always use the same random number sequence. This makes the
31324 ** tests repeatable.
31325 */
31326 memset(zBuf, 0, nBuf);
31327 randomnessPid = getpid();
31328 #if !defined(SQLITE_TEST)
31329 {
31330 int fd, got;
31331 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31332 if( fd<0 ){
@@ -31643,11 +31681,11 @@
31643 #else
31644 # ifdef _CS_DARWIN_USER_TEMP_DIR
31645 {
31646 if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
31647 OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31648 lPath, errno, getpid()));
31649 return SQLITE_IOERR_LOCK;
31650 }
31651 len = strlcat(lPath, "sqliteplocks", maxLen);
31652 }
31653 # else
@@ -31665,11 +31703,11 @@
31665 char c = dbPath[i];
31666 lPath[i+len] = (c=='/')?'_':c;
31667 }
31668 lPath[i+len]='\0';
31669 strlcat(lPath, ":auto:", maxLen);
31670 OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, getpid()));
31671 return SQLITE_OK;
31672 }
31673
31674 /*
31675 ** Creates the lock file and any missing directories in lockPath
@@ -31692,20 +31730,20 @@
31692 if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
31693 int err=errno;
31694 if( err!=EEXIST ) {
31695 OSTRACE(("CREATELOCKPATH FAILED creating %s, "
31696 "'%s' proxy lock path=%s pid=%d\n",
31697 buf, strerror(err), lockPath, getpid()));
31698 return err;
31699 }
31700 }
31701 }
31702 start=i+1;
31703 }
31704 buf[i] = lockPath[i];
31705 }
31706 OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, getpid()));
31707 return 0;
31708 }
31709
31710 /*
31711 ** Create a new VFS file descriptor (stored in memory obtained from
@@ -32006,11 +32044,12 @@
32006 int readLen = 0;
32007 int tryOldLockPath = 0;
32008 int forceNewLockPath = 0;
32009
32010 OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
32011 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid()));
 
32012
32013 rc = proxyGetHostID(myHostID, &pError);
32014 if( (rc&0xff)==SQLITE_IOERR ){
32015 storeLastErrno(pFile, pError);
32016 goto end_takeconch;
@@ -32216,11 +32255,11 @@
32216
32217 pCtx = (proxyLockingContext *)pFile->lockingContext;
32218 conchFile = pCtx->conchFile;
32219 OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
32220 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32221 getpid()));
32222 if( pCtx->conchHeld>0 ){
32223 rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
32224 }
32225 pCtx->conchHeld = 0;
32226 OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32358,11 +32397,11 @@
32358 }else{
32359 lockPath=(char *)path;
32360 }
32361
32362 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32363 (lockPath ? lockPath : ":auto:"), getpid()));
32364
32365 pCtx = sqlite3_malloc( sizeof(*pCtx) );
32366 if( pCtx==0 ){
32367 return SQLITE_NOMEM;
32368 }
@@ -32699,26 +32738,28 @@
32699 ** Note that the sqlite3_vfs.pNext field of the VFS object is modified
32700 ** by the SQLite core when the VFS is registered. So the following
32701 ** array cannot be const.
32702 */
32703 static sqlite3_vfs aVfs[] = {
32704 #if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
32705 UNIXVFS("unix", autolockIoFinder ),
 
 
32706 #else
32707 UNIXVFS("unix", posixIoFinder ),
32708 #endif
32709 UNIXVFS("unix-none", nolockIoFinder ),
32710 UNIXVFS("unix-dotfile", dotlockIoFinder ),
32711 UNIXVFS("unix-excl", posixIoFinder ),
32712 #if OS_VXWORKS
32713 UNIXVFS("unix-namedsem", semIoFinder ),
32714 #endif
32715 #if SQLITE_ENABLE_LOCKING_STYLE
32716 UNIXVFS("unix-posix", posixIoFinder ),
32717 #if !OS_VXWORKS
 
32718 UNIXVFS("unix-flock", flockIoFinder ),
32719 #endif
32720 #endif
32721 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
32722 UNIXVFS("unix-afp", afpIoFinder ),
32723 UNIXVFS("unix-nfs", nfsIoFinder ),
32724 UNIXVFS("unix-proxy", proxyIoFinder ),
@@ -39072,16 +39113,24 @@
39072 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);
39073 }
39074 }
39075
39076 /*
39077 ** Compute the number of pages of cache requested.
 
 
 
39078 */
39079 static int numberOfCachePages(PCache *p){
39080 if( p->szCache>=0 ){
 
 
39081 return p->szCache;
39082 }else{
 
 
 
39083 return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
39084 }
39085 }
39086
39087 /*************************************************** General Interfaces ******
@@ -68615,10 +68664,14 @@
68615 }
68616 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
68617 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
68618 }
68619 #endif /* SQLITE_OMIT_UTF16 */
 
 
 
 
68620 SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
68621 static const u8 aType[] = {
68622 SQLITE_BLOB, /* 0x00 */
68623 SQLITE_NULL, /* 0x01 */
68624 SQLITE_TEXT, /* 0x02 */
@@ -71290,11 +71343,11 @@
71290
71291 /* Opcode: String8 * P2 * P4 *
71292 ** Synopsis: r[P2]='P4'
71293 **
71294 ** P4 points to a nul terminated UTF-8 string. This opcode is transformed
71295 ** into a String before it is executed for the first time. During
71296 ** this transformation, the length of string P4 is computed and stored
71297 ** as the P1 parameter.
71298 */
71299 case OP_String8: { /* same as TK_STRING, out2-prerelease */
71300 assert( pOp->p4.z!=0 );
@@ -71322,22 +71375,34 @@
71322 goto too_big;
71323 }
71324 /* Fall through to the next case, OP_String */
71325 }
71326
71327 /* Opcode: String P1 P2 * P4 *
71328 ** Synopsis: r[P2]='P4' (len=P1)
71329 **
71330 ** The string value P4 of length P1 (bytes) is stored in register P2.
 
 
 
 
 
71331 */
71332 case OP_String: { /* out2-prerelease */
71333 assert( pOp->p4.z!=0 );
71334 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
71335 pOut->z = pOp->p4.z;
71336 pOut->n = pOp->p1;
71337 pOut->enc = encoding;
71338 UPDATE_MAX_BLOBSIZE(pOut);
 
 
 
 
 
 
 
71339 break;
71340 }
71341
71342 /* Opcode: Null P1 P2 P3 * *
71343 ** Synopsis: r[P2..P3]=NULL
@@ -73325,11 +73390,16 @@
73325 ** the value of this counter needs to be restored too. */
73326 p->nStmtDefCons = db->nDeferredCons;
73327 p->nStmtDefImmCons = db->nDeferredImmCons;
73328 }
73329
73330 /* Gather the schema version number for checking */
 
 
 
 
 
73331 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
73332 iGen = db->aDb[pOp->p1].pSchema->iGeneration;
73333 }else{
73334 iGen = iMeta = 0;
73335 }
@@ -75843,14 +75913,16 @@
75843 #endif /* SQLITE_OMIT_AUTOINCREMENT */
75844
75845 /* Opcode: IfPos P1 P2 * * *
75846 ** Synopsis: if r[P1]>0 goto P2
75847 **
75848 ** If the value of register P1 is 1 or greater, jump to P2.
 
 
75849 **
75850 ** It is illegal to use this instruction on a register that does
75851 ** not contain an integer. An assertion fault will result if you try.
75852 */
75853 case OP_IfPos: { /* jump, in1 */
75854 pIn1 = &aMem[pOp->p1];
75855 assert( pIn1->flags&MEM_Int );
75856 VdbeBranchTaken( pIn1->u.i>0, 2);
@@ -75875,27 +75947,63 @@
75875 pc = pOp->p2 - 1;
75876 }
75877 break;
75878 }
75879
75880 /* Opcode: IfZero P1 P2 P3 * *
75881 ** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2
75882 **
75883 ** The register P1 must contain an integer. Add literal P3 to the
75884 ** value in register P1. If the result is exactly 0, jump to P2.
 
75885 */
75886 case OP_IfZero: { /* jump, in1 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75887 pIn1 = &aMem[pOp->p1];
75888 assert( pIn1->flags&MEM_Int );
75889 pIn1->u.i += pOp->p3;
75890 VdbeBranchTaken(pIn1->u.i==0, 2);
75891 if( pIn1->u.i==0 ){
75892 pc = pOp->p2 - 1;
75893 }
75894 break;
75895 }
75896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75897 /* Opcode: AggStep * P2 P3 P4 P5
75898 ** Synopsis: accum=r[P3] step(r[P2@P5])
75899 **
75900 ** Execute the step function for an aggregate. The
75901 ** function has P5 arguments. P4 is a pointer to the FuncDef
@@ -97181,10 +97289,15 @@
97181 ** pExpr points to an expression which implements a function. If
97182 ** it is appropriate to apply the LIKE optimization to that function
97183 ** then set aWc[0] through aWc[2] to the wildcard characters and
97184 ** return TRUE. If the function is not a LIKE-style function then
97185 ** return FALSE.
 
 
 
 
 
97186 */
97187 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
97188 FuncDef *pDef;
97189 if( pExpr->op!=TK_FUNCTION
97190 || !pExpr->x.pList
@@ -102972,10 +103085,21 @@
102972 }
102973
102974 /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
102975 ** connection. If it returns SQLITE_OK, then assume that the VFS
102976 ** handled the pragma and generate a no-op prepared statement.
 
 
 
 
 
 
 
 
 
 
 
102977 */
102978 aFcntl[0] = 0;
102979 aFcntl[1] = zLeft;
102980 aFcntl[2] = zRight;
102981 aFcntl[3] = 0;
@@ -103732,34 +103856,46 @@
103732 Index *pIdx;
103733 Table *pTab;
103734 pIdx = sqlite3FindIndex(db, zRight, zDb);
103735 if( pIdx ){
103736 int i;
103737 int mx = pPragma->iArg ? pIdx->nColumn : pIdx->nKeyCol;
 
 
 
 
 
 
 
 
 
103738 pTab = pIdx->pTable;
103739 sqlite3VdbeSetNumCols(v, 6);
103740 pParse->nMem = 6;
103741 sqlite3CodeVerifySchema(pParse, iDb);
103742 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC);
103743 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC);
103744 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC);
103745 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC);
103746 sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC);
103747 sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC);
 
 
103748 for(i=0; i<mx; i++){
103749 i16 cnum = pIdx->aiColumn[i];
103750 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
103751 sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
103752 if( cnum<0 ){
103753 sqlite3VdbeAddOp2(v, OP_Null, 0, 3);
103754 }else{
103755 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
103756 }
103757 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
103758 sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
103759 sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
103760 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
 
 
103761 }
103762 }
103763 }
103764 break;
103765
@@ -104457,12 +104593,13 @@
104457 #endif
104458
104459 /*
104460 ** PRAGMA shrink_memory
104461 **
104462 ** This pragma attempts to free as much memory as possible from the
104463 ** current database connection.
 
104464 */
104465 case PragTyp_SHRINK_MEMORY: {
104466 sqlite3_db_release_memory(db);
104467 break;
104468 }
@@ -104487,12 +104624,16 @@
104487
104488 /*
104489 ** PRAGMA soft_heap_limit
104490 ** PRAGMA soft_heap_limit = N
104491 **
104492 ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted,
104493 ** use -1.
 
 
 
 
104494 */
104495 case PragTyp_SOFT_HEAP_LIMIT: {
104496 sqlite3_int64 N;
104497 if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
104498 sqlite3_soft_heap_limit64(N);
@@ -106065,24 +106206,21 @@
106065 }else{
106066 op = OP_IdxInsert;
106067 }
106068 sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
106069 if( pSelect->iLimit ){
106070 int addr1, addr2;
106071 int iLimit;
106072 if( pSelect->iOffset ){
106073 iLimit = pSelect->iOffset+1;
106074 }else{
106075 iLimit = pSelect->iLimit;
106076 }
106077 addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); VdbeCoverage(v);
106078 sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1);
106079 addr2 = sqlite3VdbeAddOp0(v, OP_Goto);
106080 sqlite3VdbeJumpHere(v, addr1);
106081 sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
106082 sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
106083 sqlite3VdbeJumpHere(v, addr2);
106084 }
106085 }
106086
106087 /*
106088 ** Add code to implement the OFFSET
@@ -106475,11 +106613,11 @@
106475 /* Jump to the end of the loop if the LIMIT is reached. Except, if
106476 ** there is a sorter, in which case the sorter has already limited
106477 ** the output for us.
106478 */
106479 if( pSort==0 && p->iLimit ){
106480 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
106481 }
106482 }
106483
106484 /*
106485 ** Allocate a KeyInfo object sufficient for an index of N key columns and
@@ -107328,11 +107466,11 @@
107328 }
107329 }else{
107330 sqlite3ExprCode(pParse, p->pLimit, iLimit);
107331 sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);
107332 VdbeComment((v, "LIMIT counter"));
107333 sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); VdbeCoverage(v);
107334 }
107335 if( p->pOffset ){
107336 p->iOffset = iOffset = ++pParse->nMem;
107337 pParse->nMem++; /* Allocate an extra register for limit+offset */
107338 sqlite3ExprCode(pParse, p->pOffset, iOffset);
@@ -107547,11 +107685,11 @@
107547 addrCont = sqlite3VdbeMakeLabel(v);
107548 codeOffset(v, regOffset, addrCont);
107549 selectInnerLoop(pParse, p, p->pEList, iCurrent,
107550 0, 0, pDest, addrCont, addrBreak);
107551 if( regLimit ){
107552 sqlite3VdbeAddOp3(v, OP_IfZero, regLimit, addrBreak, -1);
107553 VdbeCoverage(v);
107554 }
107555 sqlite3VdbeResolveLabel(v, addrCont);
107556
107557 /* Execute the recursive SELECT taking the single row in Current as
@@ -107772,11 +107910,11 @@
107772 }
107773 p->pPrior = 0;
107774 p->iLimit = pPrior->iLimit;
107775 p->iOffset = pPrior->iOffset;
107776 if( p->iLimit ){
107777 addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit); VdbeCoverage(v);
107778 VdbeComment((v, "Jump ahead if LIMIT reached"));
107779 }
107780 explainSetInteger(iSub2, pParse->iNextSelectId);
107781 rc = sqlite3Select(pParse, p, &dest);
107782 testcase( rc!=SQLITE_OK );
@@ -108173,11 +108311,11 @@
108173 }
108174
108175 /* Jump to the end of the loop if the LIMIT is reached.
108176 */
108177 if( p->iLimit ){
108178 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
108179 }
108180
108181 /* Generate the subroutine return
108182 */
108183 sqlite3VdbeResolveLabel(v, iContinue);
@@ -114787,10 +114925,12 @@
114787 int addrNxt; /* Jump here to start the next IN combination */
114788 int addrSkip; /* Jump here for next iteration of skip-scan */
114789 int addrCont; /* Jump here to continue with the next loop cycle */
114790 int addrFirst; /* First instruction of interior of the loop */
114791 int addrBody; /* Beginning of the body of this loop */
 
 
114792 u8 iFrom; /* Which entry in the FROM clause */
114793 u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
114794 int p1, p2; /* Operands of the opcode used to ends the loop */
114795 union { /* Information that depends on pWLoop->wsFlags */
114796 struct {
@@ -114971,11 +115111,11 @@
114971 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
114972 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
114973 } u;
114974 LogEst truthProb; /* Probability of truth for this expression */
114975 u16 eOperator; /* A WO_xx value describing <op> */
114976 u8 wtFlags; /* TERM_xxx bit flags. See below */
114977 u8 nChild; /* Number of children that must disable us */
114978 WhereClause *pWC; /* The clause this term is part of */
114979 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
114980 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
114981 };
@@ -114993,10 +115133,13 @@
114993 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
114994 # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
114995 #else
114996 # define TERM_VNULL 0x00 /* Disabled if not using stat3 */
114997 #endif
 
 
 
114998
114999 /*
115000 ** An instance of the WhereScan object is used as an iterator for locating
115001 ** terms in the WHERE clause that are useful to the query planner.
115002 */
@@ -115368,11 +115511,11 @@
115368 ** WARNING: This routine might reallocate the space used to store
115369 ** WhereTerms. All pointers to WhereTerms should be invalidated after
115370 ** calling this routine. Such pointers may be reinitialized by referencing
115371 ** the pWC->a[] array.
115372 */
115373 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
115374 WhereTerm *pTerm;
115375 int idx;
115376 testcase( wtFlags & TERM_VIRTUAL );
115377 if( pWC->nTerm>=pWC->nSlot ){
115378 WhereTerm *pOld = pWC->a;
@@ -115793,11 +115936,15 @@
115793 ** Check to see if the given expression is a LIKE or GLOB operator that
115794 ** can be optimized using inequality constraints. Return TRUE if it is
115795 ** so and false if not.
115796 **
115797 ** In order for the operator to be optimizible, the RHS must be a string
115798 ** literal that does not begin with a wildcard.
 
 
 
 
115799 */
115800 static int isLikeOrGlob(
115801 Parse *pParse, /* Parsing and code generating context */
115802 Expr *pExpr, /* Test this expression */
115803 Expr **ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */
@@ -115822,11 +115969,11 @@
115822 #endif
115823 pList = pExpr->x.pList;
115824 pLeft = pList->a[1].pExpr;
115825 if( pLeft->op!=TK_COLUMN
115826 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
115827 || IsVirtual(pLeft->pTab)
115828 ){
115829 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
115830 ** be the name of an indexed column with TEXT affinity. */
115831 return 0;
115832 }
@@ -116271,11 +116418,11 @@
116271 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
116272 Bitmask prereqAll; /* Prerequesites of pExpr */
116273 Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */
116274 Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */
116275 int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */
116276 int noCase = 0; /* LIKE/GLOB distinguishes case */
116277 int op; /* Top-level operator. pExpr->op */
116278 Parse *pParse = pWInfo->pParse; /* Parsing context */
116279 sqlite3 *db = pParse->db; /* Database connection */
116280
116281 if( db->mallocFailed ){
@@ -116409,16 +116556,19 @@
116409
116410 #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
116411 /* Add constraints to reduce the search space on a LIKE or GLOB
116412 ** operator.
116413 **
116414 ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints
116415 **
116416 ** x>='abc' AND x<'abd' AND x LIKE 'abc%'
116417 **
116418 ** The last character of the prefix "abc" is incremented to form the
116419 ** termination condition "abd".
 
 
 
116420 */
116421 if( pWC->op==TK_AND
116422 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
116423 ){
116424 Expr *pLeft; /* LHS of LIKE/GLOB operator */
@@ -116426,13 +116576,29 @@
116426 Expr *pNewExpr1;
116427 Expr *pNewExpr2;
116428 int idxNew1;
116429 int idxNew2;
116430 Token sCollSeqName; /* Name of collating sequence */
 
116431
116432 pLeft = pExpr->x.pList->a[1].pExpr;
116433 pStr2 = sqlite3ExprDup(db, pStr1, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116434 if( !db->mallocFailed ){
116435 u8 c, *pC; /* Last character before the first wildcard */
116436 pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
116437 c = *pC;
116438 if( noCase ){
@@ -116448,23 +116614,23 @@
116448 *pC = c + 1;
116449 }
116450 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
116451 sCollSeqName.n = 6;
116452 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
116453 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116454 sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
116455 pStr1, 0);
116456 transferJoinMarkings(pNewExpr1, pExpr);
116457 idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);
116458 testcase( idxNew1==0 );
116459 exprAnalyze(pSrc, pWC, idxNew1);
116460 pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
116461 pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
116462 sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
116463 pStr2, 0);
116464 transferJoinMarkings(pNewExpr2, pExpr);
116465 idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC);
116466 testcase( idxNew2==0 );
116467 exprAnalyze(pSrc, pWC, idxNew2);
116468 pTerm = &pWC->a[idxTerm];
116469 if( isComplete ){
116470 markTermAsChild(pWC, idxNew1, idxTerm);
@@ -117635,24 +117801,47 @@
117635 ** by indices, we disable them to prevent redundant tests in the inner
117636 ** loop. We would get the correct results if nothing were ever disabled,
117637 ** but joins might run a little slower. The trick is to disable as much
117638 ** as we can without disabling too much. If we disabled in (1), we'd get
117639 ** the wrong answer. See ticket #813.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117640 */
117641 static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
117642 if( pTerm
 
117643 && (pTerm->wtFlags & TERM_CODED)==0
117644 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
117645 && (pLevel->notReady & pTerm->prereqAll)==0
117646 ){
117647 pTerm->wtFlags |= TERM_CODED;
117648 if( pTerm->iParent>=0 ){
117649 WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent];
117650 if( (--pOther->nChild)==0 ){
117651 disableTerm(pLevel, pOther);
117652 }
117653 }
 
 
 
 
 
117654 }
117655 }
117656
117657 /*
117658 ** Code an OP_Affinity opcode to apply the column affinity string zAff
@@ -118132,11 +118321,30 @@
118132 }
118133 #else
118134 # define addScanStatus(a, b, c, d) ((void)d)
118135 #endif
118136
118137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118138
118139 /*
118140 ** Generate code for the start of the iLevel-th loop in the WHERE clause
118141 ** implementation described by pWInfo.
118142 */
@@ -118466,10 +118674,23 @@
118466 nExtraReg = 1;
118467 }
118468 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
118469 pRangeEnd = pLoop->aLTerm[j++];
118470 nExtraReg = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
118471 if( pRangeStart==0
118472 && (j = pIdx->aiColumn[nEq])>=0
118473 && pIdx->pTable->aCol[j].notNull==0
118474 ){
118475 bSeekPastNull = 1;
@@ -118508,10 +118729,11 @@
118508 /* Seek the index cursor to the start of the range. */
118509 nConstraint = nEq;
118510 if( pRangeStart ){
118511 Expr *pRight = pRangeStart->pExpr->pRight;
118512 sqlite3ExprCode(pParse, pRight, regBase+nEq);
 
118513 if( (pRangeStart->wtFlags & TERM_VNULL)==0
118514 && sqlite3ExprCanBeNull(pRight)
118515 ){
118516 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118517 VdbeCoverage(v);
@@ -118553,10 +118775,11 @@
118553 nConstraint = nEq;
118554 if( pRangeEnd ){
118555 Expr *pRight = pRangeEnd->pExpr->pRight;
118556 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
118557 sqlite3ExprCode(pParse, pRight, regBase+nEq);
 
118558 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
118559 && sqlite3ExprCanBeNull(pRight)
118560 ){
118561 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118562 VdbeCoverage(v);
@@ -118780,11 +119003,12 @@
118780 ** eliminating duplicates from other WHERE clauses, the action for each
118781 ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
118782 */
118783 wctrlFlags = WHERE_OMIT_OPEN_CLOSE
118784 | WHERE_FORCE_TABLE
118785 | WHERE_ONETABLE_ONLY;
 
118786 for(ii=0; ii<pOrWc->nTerm; ii++){
118787 WhereTerm *pOrTerm = &pOrWc->a[ii];
118788 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
118789 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
118790 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -118942,10 +119166,11 @@
118942 /* Insert code to test every subexpression that can be completely
118943 ** computed using the current set of tables.
118944 */
118945 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
118946 Expr *pE;
 
118947 testcase( pTerm->wtFlags & TERM_VIRTUAL );
118948 testcase( pTerm->wtFlags & TERM_CODED );
118949 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
118950 if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
118951 testcase( pWInfo->untestedTerms==0
@@ -118955,12 +119180,18 @@
118955 }
118956 pE = pTerm->pExpr;
118957 assert( pE!=0 );
118958 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
118959 continue;
 
 
 
 
 
118960 }
118961 sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
 
118962 pTerm->wtFlags |= TERM_CODED;
118963 }
118964
118965 /* Insert code to test for implied constraints based on transitivity
118966 ** of the "==" operator.
@@ -119974,10 +120205,11 @@
119974 rLogSize = estLog(rSize);
119975
119976 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
119977 /* Automatic indexes */
119978 if( !pBuilder->pOrSet
 
119979 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
119980 && pSrc->pIndex==0
119981 && !pSrc->viaCoroutine
119982 && !pSrc->notIndexed
119983 && HasRowid(pTab)
@@ -121758,10 +121990,20 @@
121758 if( pLevel->addrSkip ){
121759 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
121760 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
121761 sqlite3VdbeJumpHere(v, pLevel->addrSkip);
121762 sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
 
 
 
 
 
 
 
 
 
 
121763 }
121764 if( pLevel->iLeftJoin ){
121765 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
121766 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
121767 || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
@@ -126982,30 +127224,32 @@
126982 /* Mutex configuration options are only available in a threadsafe
126983 ** compile.
126984 */
126985 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-54466-46756 */
126986 case SQLITE_CONFIG_SINGLETHREAD: {
126987 /* Disable all mutexing */
126988 sqlite3GlobalConfig.bCoreMutex = 0;
126989 sqlite3GlobalConfig.bFullMutex = 0;
 
126990 break;
126991 }
126992 #endif
126993 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */
126994 case SQLITE_CONFIG_MULTITHREAD: {
126995 /* Disable mutexing of database connections */
126996 /* Enable mutexing of core data structures */
126997 sqlite3GlobalConfig.bCoreMutex = 1;
126998 sqlite3GlobalConfig.bFullMutex = 0;
126999 break;
127000 }
127001 #endif
127002 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */
127003 case SQLITE_CONFIG_SERIALIZED: {
127004 /* Enable all mutexing */
127005 sqlite3GlobalConfig.bCoreMutex = 1;
127006 sqlite3GlobalConfig.bFullMutex = 1;
 
127007 break;
127008 }
127009 #endif
127010 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */
127011 case SQLITE_CONFIG_MUTEX: {
@@ -127113,11 +127357,12 @@
127113 ** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */
127114 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
127115 case SQLITE_CONFIG_HEAP: {
127116 /* EVIDENCE-OF: R-19854-42126 There are three arguments to
127117 ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the
127118 ** number of bytes in the memory buffer, and the minimum allocation size. */
 
127119 sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
127120 sqlite3GlobalConfig.nHeap = va_arg(ap, int);
127121 sqlite3GlobalConfig.mnReq = va_arg(ap, int);
127122
127123 if( sqlite3GlobalConfig.mnReq<1 ){
@@ -127218,11 +127463,13 @@
127218 ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
127219 ** silently truncated if necessary so that it does not exceed the
127220 ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE
127221 ** compile-time option.
127222 */
127223 if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ) mxMmap = SQLITE_MAX_MMAP_SIZE;
 
 
127224 if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
127225 if( szMmap>mxMmap) szMmap = mxMmap;
127226 sqlite3GlobalConfig.mxMmap = mxMmap;
127227 sqlite3GlobalConfig.szMmap = szMmap;
127228 break;
@@ -129062,11 +129309,23 @@
129062 for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
129063 zFile = sqlite3_malloc(nByte);
129064 if( !zFile ) return SQLITE_NOMEM;
129065
129066 iIn = 5;
129067 #ifndef SQLITE_ALLOW_URI_AUTHORITY
 
 
 
 
 
 
 
 
 
 
 
 
129068 /* Discard the scheme and authority segments of the URI. */
129069 if( zUri[5]=='/' && zUri[6]=='/' ){
129070 iIn = 7;
129071 while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;
129072 if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){
@@ -129505,11 +129764,12 @@
129505 sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
129506
129507 opendb_out:
129508 sqlite3_free(zOpen);
129509 if( db ){
129510 assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 );
 
129511 sqlite3_mutex_leave(db->mutex);
129512 }
129513 rc = sqlite3_errcode(db);
129514 assert( db!=0 || rc==SQLITE_NOMEM );
129515 if( rc==SQLITE_NOMEM ){
@@ -130250,21 +130510,21 @@
130250 case SQLITE_TESTCTRL_ISINIT: {
130251 if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
130252 break;
130253 }
130254
130255 /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);
130256 **
130257 ** This test control is used to create imposter tables. "db" is a pointer
130258 ** to the database connection. dbName is the database name (ex: "main" or
130259 ** "temp") which will receive the imposter. "onOff" turns imposter mode on
130260 ** or off. "tnum" is the root page of the b-tree to which the imposter
130261 ** table should connect.
130262 **
130263 ** Enable imposter mode only when the schema has already been parsed. Then
130264 ** run a single CREATE TABLE statement to construct the imposter table in the
130265 ** parsed schema. Then turn imposter mode back off again.
130266 **
130267 ** If onOff==0 and tnum>0 then reset the schema for all databases, causing
130268 ** the schema to be reparsed the next time it is needed. This has the
130269 ** effect of erasing all imposter tables.
130270 */
130271
--- 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.8.9. 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.
@@ -88,10 +88,48 @@
88 #endif /* _MSVC_H_ */
89
90 /************** End of msvc.h ************************************************/
91 /************** Continuing where we left off in sqliteInt.h ******************/
92
93 /*
94 ** Special setup for VxWorks
95 */
96 /************** Include vxworks.h in the middle of sqliteInt.h ***************/
97 /************** Begin file vxworks.h *****************************************/
98 /*
99 ** 2015-03-02
100 **
101 ** The author disclaims copyright to this source code. In place of
102 ** a legal notice, here is a blessing:
103 **
104 ** May you do good and not evil.
105 ** May you find forgiveness for yourself and forgive others.
106 ** May you share freely, never taking more than you give.
107 **
108 ******************************************************************************
109 **
110 ** This file contains code that is specific to Wind River's VxWorks
111 */
112 #if defined(__RTP__) || defined(_WRS_KERNEL)
113 /* This is VxWorks. Set up things specially for that OS
114 */
115 #include <vxWorks.h>
116 #include <pthread.h> /* amalgamator: dontcache */
117 #define OS_VXWORKS 1
118 #define SQLITE_OS_OTHER 0
119 #define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
120 #define SQLITE_OMIT_LOAD_EXTENSION 1
121 #define SQLITE_ENABLE_LOCKING_STYLE 0
122 #define HAVE_UTIME 1
123 #else
124 /* This is not VxWorks. */
125 #define OS_VXWORKS 0
126 #endif /* defined(_WRS_KERNEL) */
127
128 /************** End of vxworks.h *********************************************/
129 /************** Continuing where we left off in sqliteInt.h ******************/
130
131 /*
132 ** These #defines should enable >2GB file support on POSIX if the
133 ** underlying operating system supports it. If the OS lacks
134 ** large file support, or if the OS is windows, these should be no-ops.
135 **
@@ -276,13 +314,13 @@
314 **
315 ** See also: [sqlite3_libversion()],
316 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
317 ** [sqlite_version()] and [sqlite_source_id()].
318 */
319 #define SQLITE_VERSION "3.8.9"
320 #define SQLITE_VERSION_NUMBER 3008009
321 #define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
322
323 /*
324 ** CAPI3REF: Run-Time Library Version Numbers
325 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
326 **
@@ -925,18 +963,20 @@
963 **
964 ** These integer constants are opcodes for the xFileControl method
965 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
966 ** interface.
967 **
968 ** <ul>
969 ** <li>[[SQLITE_FCNTL_LOCKSTATE]]
970 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
971 ** opcode causes the xFileControl method to write the current state of
972 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
973 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
974 ** into an integer that the pArg argument points to. This capability
975 ** is used during testing and is only available when the SQLITE_TEST
976 ** compile-time option is used.
977 **
978 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
979 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
980 ** layer a hint of how large the database file will grow to be during the
981 ** current transaction. This hint is not guaranteed to be accurate but it
982 ** is often close. The underlying VFS might choose to preallocate database
@@ -1057,11 +1097,13 @@
1097 ** the error message if the pragma fails. ^If the
1098 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
1099 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
1100 ** file control returns [SQLITE_OK], then the parser assumes that the
1101 ** VFS has handled the PRAGMA itself and the parser generates a no-op
1102 ** prepared statement if result string is NULL, or that returns a copy
1103 ** of the result string if the string is non-NULL.
1104 ** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
1105 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
1106 ** that the VFS encountered an error while handling the [PRAGMA] and the
1107 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
1108 ** file control occurs at the beginning of pragma statement analysis and so
1109 ** it is able to override built-in [PRAGMA] statements.
@@ -1916,11 +1958,10 @@
1958 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1959 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
1960 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
1961 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1962 ** that specifies the maximum size of the created heap.
 
1963 **
1964 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
1965 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
1966 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
1967 ** is a pointer to an integer and writes into that integer the number of extra
@@ -3356,20 +3397,18 @@
3397 ** The second argument, "zSql", is the statement to be compiled, encoded
3398 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3399 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3400 ** use UTF-16.
3401 **
3402 ** ^If the nByte argument is negative, then zSql is read up to the
3403 ** first zero terminator. ^If nByte is positive, then it is the
3404 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3405 ** statement is generated.
3406 ** If the caller knows that the supplied string is nul-terminated, then
3407 ** there is a small performance advantage to passing an nByte parameter that
3408 ** is the number of bytes in the input string <i>including</i>
3409 ** the nul-terminator.
 
 
3410 **
3411 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
3412 ** past the end of the first SQL statement in zSql. These routines only
3413 ** compile the first statement in zSql, so *pzTail is left pointing to
3414 ** what remains uncompiled.
@@ -4394,12 +4433,12 @@
4433 ** DEPRECATED
4434 **
4435 ** These functions are [deprecated]. In order to maintain
4436 ** backwards compatibility with older code, these functions continue
4437 ** to be supported. However, new applications should avoid
4438 ** the use of these functions. To encourage programmers to avoid
4439 ** these functions, we will not explain what they do.
4440 */
4441 #ifndef SQLITE_OMIT_DEPRECATED
4442 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4443 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4444 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -7157,24 +7196,24 @@
7196 **
7197 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
7198 ** is not a permanent error and does not affect the return value of
7199 ** sqlite3_backup_finish().
7200 **
7201 ** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
7202 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
7203 **
7204 ** ^The sqlite3_backup_remaining() routine returns the number of pages still
7205 ** to be backed up at the conclusion of the most recent sqlite3_backup_step().
7206 ** ^The sqlite3_backup_pagecount() routine returns the total number of pages
7207 ** in the source database at the conclusion of the most recent
7208 ** sqlite3_backup_step().
7209 ** ^(The values returned by these functions are only updated by
7210 ** sqlite3_backup_step(). If the source database is modified in a way that
7211 ** changes the size of the source database or the number of pages remaining,
7212 ** those changes are not reflected in the output of sqlite3_backup_pagecount()
7213 ** and sqlite3_backup_remaining() until after the next
7214 ** sqlite3_backup_step().)^
7215 **
7216 ** <b>Concurrent Usage of Database Handles</b>
7217 **
7218 ** ^The source [database connection] may be used by the application for other
7219 ** purposes while a backup operation is underway or being initialized.
@@ -8018,19 +8057,21 @@
8057 #ifndef SQLITE_MAX_FUNCTION_ARG
8058 # define SQLITE_MAX_FUNCTION_ARG 127
8059 #endif
8060
8061 /*
8062 ** The suggested maximum number of in-memory pages to use for
8063 ** the main database table and for temporary tables.
8064 **
8065 ** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
8066 ** is 2000 pages.
8067 ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
8068 ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
8069 */
8070 #ifndef SQLITE_DEFAULT_CACHE_SIZE
8071 # define SQLITE_DEFAULT_CACHE_SIZE 2000
8072 #endif
 
 
 
8073
8074 /*
8075 ** The default number of frames to accumulate in the log file before
8076 ** checkpointing the database in WAL mode.
8077 */
@@ -9733,27 +9774,29 @@
9774 #define OP_FkCounter 134 /* synopsis: fkctr[P1]+=P2 */
9775 #define OP_FkIfZero 135 /* synopsis: if fkctr[P1]==0 goto P2 */
9776 #define OP_MemMax 136 /* synopsis: r[P1]=max(r[P1],r[P2]) */
9777 #define OP_IfPos 137 /* synopsis: if r[P1]>0 goto P2 */
9778 #define OP_IfNeg 138 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2 */
9779 #define OP_IfNotZero 139 /* synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2 */
9780 #define OP_DecrJumpZero 140 /* synopsis: if (--r[P1])==0 goto P2 */
9781 #define OP_JumpZeroIncr 141 /* synopsis: if (r[P1]++)==0 ) goto P2 */
9782 #define OP_AggFinal 142 /* synopsis: accum=r[P1] N=P2 */
9783 #define OP_IncrVacuum 143
9784 #define OP_Expire 144
9785 #define OP_TableLock 145 /* synopsis: iDb=P1 root=P2 write=P3 */
9786 #define OP_VBegin 146
9787 #define OP_VCreate 147
9788 #define OP_VDestroy 148
9789 #define OP_VOpen 149
9790 #define OP_VColumn 150 /* synopsis: r[P3]=vcolumn(P2) */
9791 #define OP_VNext 151
9792 #define OP_VRename 152
9793 #define OP_Pagecount 153
9794 #define OP_MaxPgcnt 154
9795 #define OP_Init 155 /* synopsis: Start at P2 */
9796 #define OP_Noop 156
9797 #define OP_Explain 157
9798
9799
9800 /* Properties such as "out2" or "jump" that are specified in
9801 ** comments following the "case" for each opcode in the vdbe.c
9802 ** are encoded into bitvectors as follows:
@@ -9781,13 +9824,13 @@
9824 /* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\
9825 /* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\
9826 /* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
9827 /* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9828 /* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
9829 /* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\
9830 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
9831 /* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
9832
9833 /************** End of opcodes.h *********************************************/
9834 /************** Continuing where we left off in vdbe.h ***********************/
9835
9836 /*
@@ -12022,11 +12065,11 @@
12065 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
12066 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
12067 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
12068 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
12069 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
12070 #define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
12071 #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
12072 #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
12073 #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
12074 #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
12075 #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
@@ -24969,27 +25012,29 @@
25012 /* 134 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
25013 /* 135 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
25014 /* 136 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
25015 /* 137 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
25016 /* 138 */ "IfNeg" OpHelp("r[P1]+=P3, if r[P1]<0 goto P2"),
25017 /* 139 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]+=P3, goto P2"),
25018 /* 140 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
25019 /* 141 */ "JumpZeroIncr" OpHelp("if (r[P1]++)==0 ) goto P2"),
25020 /* 142 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
25021 /* 143 */ "IncrVacuum" OpHelp(""),
25022 /* 144 */ "Expire" OpHelp(""),
25023 /* 145 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
25024 /* 146 */ "VBegin" OpHelp(""),
25025 /* 147 */ "VCreate" OpHelp(""),
25026 /* 148 */ "VDestroy" OpHelp(""),
25027 /* 149 */ "VOpen" OpHelp(""),
25028 /* 150 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
25029 /* 151 */ "VNext" OpHelp(""),
25030 /* 152 */ "VRename" OpHelp(""),
25031 /* 153 */ "Pagecount" OpHelp(""),
25032 /* 154 */ "MaxPgcnt" OpHelp(""),
25033 /* 155 */ "Init" OpHelp("Start at P2"),
25034 /* 156 */ "Noop" OpHelp(""),
25035 /* 157 */ "Explain" OpHelp(""),
25036 };
25037 return azName[i];
25038 }
25039 #endif
25040
@@ -25065,22 +25110,10 @@
25110 # else
25111 # define SQLITE_ENABLE_LOCKING_STYLE 0
25112 # endif
25113 #endif
25114
 
 
 
 
 
 
 
 
 
 
 
 
25115 /*
25116 ** standard include files.
25117 */
25118 #include <sys/types.h>
25119 #include <sys/stat.h>
@@ -25091,22 +25124,23 @@
25124 #include <errno.h>
25125 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
25126 # include <sys/mman.h>
25127 #endif
25128
25129 #if SQLITE_ENABLE_LOCKING_STYLE
25130 # include <sys/ioctl.h>
25131 # include <sys/file.h>
25132 # include <sys/param.h>
 
 
 
 
 
25133 #endif /* SQLITE_ENABLE_LOCKING_STYLE */
25134
25135 #if OS_VXWORKS
25136 /* # include <sys/ioctl.h> */
25137 # include <semaphore.h>
25138 # include <limits.h>
25139 #endif /* OS_VXWORKS */
25140
25141 #if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
25142 # include <sys/mount.h>
25143 #endif
25144
25145 #ifdef HAVE_UTIME
25146 # include <utime.h>
@@ -25142,10 +25176,14 @@
25176
25177 /*
25178 ** Maximum supported path-length.
25179 */
25180 #define MAX_PATHNAME 512
25181
25182 /* Always cast the getpid() return type for compatibility with
25183 ** kernel modules in VxWorks. */
25184 #define osGetpid(X) (pid_t)getpid()
25185
25186 /*
25187 ** Only set the lastErrno if the error code is a real error and not
25188 ** a normal expected return code of SQLITE_BUSY or SQLITE_OK
25189 */
@@ -25231,11 +25269,11 @@
25269
25270 /* This variable holds the process id (pid) from when the xRandomness()
25271 ** method was called. If xOpen() is called from a different process id,
25272 ** indicating that a fork() has occurred, the PRNG will be reset.
25273 */
25274 static pid_t randomnessPid = 0;
25275
25276 /*
25277 ** Allowed values for the unixFile.ctrlFlags bitmask:
25278 */
25279 #define UNIXFILE_EXCL 0x01 /* Connections from one process only */
@@ -25587,11 +25625,11 @@
25625 #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
25626
25627 { "read", (sqlite3_syscall_ptr)read, 0 },
25628 #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
25629
25630 #if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
25631 { "pread", (sqlite3_syscall_ptr)pread, 0 },
25632 #else
25633 { "pread", (sqlite3_syscall_ptr)0, 0 },
25634 #endif
25635 #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25604,11 +25642,11 @@
25642 #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
25643
25644 { "write", (sqlite3_syscall_ptr)write, 0 },
25645 #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
25646
25647 #if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
25648 { "pwrite", (sqlite3_syscall_ptr)pwrite, 0 },
25649 #else
25650 { "pwrite", (sqlite3_syscall_ptr)0, 0 },
25651 #endif
25652 #define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\
@@ -26743,11 +26781,12 @@
26781 int tErrno = 0;
26782
26783 assert( pFile );
26784 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
26785 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
26786 azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
26787 osGetpid()));
26788
26789 /* If there is already a lock of this type or more restrictive on the
26790 ** unixFile, do nothing. Don't use the end_lock: exit path, as
26791 ** unixEnterMutex() hasn't been called yet.
26792 */
@@ -26951,11 +26990,11 @@
26990 int rc = SQLITE_OK;
26991
26992 assert( pFile );
26993 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
26994 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
26995 osGetpid()));
26996
26997 assert( eFileLock<=SHARED_LOCK );
26998 if( pFile->eFileLock<=eFileLock ){
26999 return SQLITE_OK;
27000 }
@@ -27378,11 +27417,11 @@
27417 char *zLockFile = (char *)pFile->lockingContext;
27418 int rc;
27419
27420 assert( pFile );
27421 OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
27422 pFile->eFileLock, osGetpid()));
27423 assert( eFileLock<=SHARED_LOCK );
27424
27425 /* no-op if possible */
27426 if( pFile->eFileLock==eFileLock ){
27427 return SQLITE_OK;
@@ -27441,14 +27480,13 @@
27480 ** a single exclusive lock. In other words, SHARED, RESERVED, and
27481 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
27482 ** still works when you do this, but concurrency is reduced since
27483 ** only a single process can be reading the database at a time.
27484 **
27485 ** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off
 
27486 */
27487 #if SQLITE_ENABLE_LOCKING_STYLE
27488
27489 /*
27490 ** Retry flock() calls that fail with EINTR
27491 */
27492 #ifdef EINTR
@@ -27597,11 +27635,11 @@
27635 static int flockUnlock(sqlite3_file *id, int eFileLock) {
27636 unixFile *pFile = (unixFile*)id;
27637
27638 assert( pFile );
27639 OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
27640 pFile->eFileLock, osGetpid()));
27641 assert( eFileLock<=SHARED_LOCK );
27642
27643 /* no-op if possible */
27644 if( pFile->eFileLock==eFileLock ){
27645 return SQLITE_OK;
@@ -27658,11 +27696,11 @@
27696 ** This routine checks if there is a RESERVED lock held on the specified
27697 ** file by this or any other process. If such a lock is held, set *pResOut
27698 ** to a non-zero value otherwise *pResOut is set to zero. The return value
27699 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27700 */
27701 static int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {
27702 int rc = SQLITE_OK;
27703 int reserved = 0;
27704 unixFile *pFile = (unixFile*)id;
27705
27706 SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
@@ -27725,11 +27763,11 @@
27763 ** access the file.
27764 **
27765 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
27766 ** routine to lower a locking level.
27767 */
27768 static int semXLock(sqlite3_file *id, int eFileLock) {
27769 unixFile *pFile = (unixFile*)id;
27770 sem_t *pSem = pFile->pInode->pSem;
27771 int rc = SQLITE_OK;
27772
27773 /* if we already have a lock, it is exclusive.
@@ -27758,18 +27796,18 @@
27796 ** must be either NO_LOCK or SHARED_LOCK.
27797 **
27798 ** If the locking level of the file descriptor is already at or below
27799 ** the requested locking level, this routine is a no-op.
27800 */
27801 static int semXUnlock(sqlite3_file *id, int eFileLock) {
27802 unixFile *pFile = (unixFile*)id;
27803 sem_t *pSem = pFile->pInode->pSem;
27804
27805 assert( pFile );
27806 assert( pSem );
27807 OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
27808 pFile->eFileLock, osGetpid()));
27809 assert( eFileLock<=SHARED_LOCK );
27810
27811 /* no-op if possible */
27812 if( pFile->eFileLock==eFileLock ){
27813 return SQLITE_OK;
@@ -27795,14 +27833,14 @@
27833 }
27834
27835 /*
27836 ** Close a file.
27837 */
27838 static int semXClose(sqlite3_file *id) {
27839 if( id ){
27840 unixFile *pFile = (unixFile*)id;
27841 semXUnlock(id, NO_LOCK);
27842 assert( pFile );
27843 unixEnterMutex();
27844 releaseInodeInfo(pFile);
27845 unixLeaveMutex();
27846 closeUnixFile(id);
@@ -27979,11 +28017,11 @@
28017 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
28018
28019 assert( pFile );
28020 OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
28021 azFileLock(eFileLock), azFileLock(pFile->eFileLock),
28022 azFileLock(pInode->eFileLock), pInode->nShared , osGetpid()));
28023
28024 /* If there is already a lock of this type or more restrictive on the
28025 ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
28026 ** unixEnterMutex() hasn't been called yet.
28027 */
@@ -28165,11 +28203,11 @@
28203 #endif
28204
28205 assert( pFile );
28206 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
28207 pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
28208 osGetpid()));
28209
28210 assert( eFileLock<=SHARED_LOCK );
28211 if( pFile->eFileLock<=eFileLock ){
28212 return SQLITE_OK;
28213 }
@@ -29204,11 +29242,13 @@
29242 **
29243 ** This function should not be called directly by other code in this file.
29244 ** Instead, it should be called via macro osGetpagesize().
29245 */
29246 static int unixGetpagesize(void){
29247 #if OS_VXWORKS
29248 return 1024;
29249 #elif defined(_BSD_SOURCE)
29250 return getpagesize();
29251 #else
29252 return (int)sysconf(_SC_PAGESIZE);
29253 #endif
29254 }
@@ -29833,11 +29873,11 @@
29873 }
29874 }
29875 }
29876 sqlite3_mutex_leave(pShmNode->mutex);
29877 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
29878 p->id, osGetpid(), p->sharedMask, p->exclMask));
29879 return rc;
29880 }
29881
29882 /*
29883 ** Implement a memory barrier or memory fence on shared memory.
@@ -30236,11 +30276,11 @@
30276 dotlockUnlock, /* xUnlock method */
30277 dotlockCheckReservedLock, /* xCheckReservedLock method */
30278 0 /* xShmMap method */
30279 )
30280
30281 #if SQLITE_ENABLE_LOCKING_STYLE
30282 IOMETHODS(
30283 flockIoFinder, /* Finder function name */
30284 flockIoMethods, /* sqlite3_io_methods object name */
30285 1, /* shared memory is disabled */
30286 flockClose, /* xClose method */
@@ -30254,14 +30294,14 @@
30294 #if OS_VXWORKS
30295 IOMETHODS(
30296 semIoFinder, /* Finder function name */
30297 semIoMethods, /* sqlite3_io_methods object name */
30298 1, /* shared memory is disabled */
30299 semXClose, /* xClose method */
30300 semXLock, /* xLock method */
30301 semXUnlock, /* xUnlock method */
30302 semXCheckReservedLock, /* xCheckReservedLock method */
30303 0 /* xShmMap method */
30304 )
30305 #endif
30306
30307 #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
@@ -30381,19 +30421,17 @@
30421 static const sqlite3_io_methods
30422 *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
30423
30424 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
30425
30426 #if OS_VXWORKS
30427 /*
30428 ** This "finder" function for VxWorks checks to see if posix advisory
30429 ** locking works. If it does, then that is what is used. If it does not
30430 ** work, then fallback to named semaphore locking.
 
 
30431 */
30432 static const sqlite3_io_methods *vxworksIoFinderImpl(
30433 const char *filePath, /* name of the database file */
30434 unixFile *pNew /* the open file object */
30435 ){
30436 struct flock lockInfo;
30437
@@ -30415,13 +30453,13 @@
30453 }else{
30454 return &semIoMethods;
30455 }
30456 }
30457 static const sqlite3_io_methods
30458 *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;
30459
30460 #endif /* OS_VXWORKS */
30461
30462 /*
30463 ** An abstract type for a pointer to an IO method finder function:
30464 */
30465 typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);
@@ -30930,12 +30968,12 @@
30968 /* Detect a pid change and reset the PRNG. There is a race condition
30969 ** here such that two or more threads all trying to open databases at
30970 ** the same instant might all reset the PRNG. But multiple resets
30971 ** are harmless.
30972 */
30973 if( randomnessPid!=osGetpid() ){
30974 randomnessPid = osGetpid();
30975 sqlite3_randomness(0,0);
30976 }
30977
30978 memset(p, 0, sizeof(unixFile));
30979
@@ -31322,11 +31360,11 @@
31360 ** When testing, initializing zBuf[] to zero is all we do. That means
31361 ** that we always use the same random number sequence. This makes the
31362 ** tests repeatable.
31363 */
31364 memset(zBuf, 0, nBuf);
31365 randomnessPid = osGetpid();
31366 #if !defined(SQLITE_TEST)
31367 {
31368 int fd, got;
31369 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31370 if( fd<0 ){
@@ -31643,11 +31681,11 @@
31681 #else
31682 # ifdef _CS_DARWIN_USER_TEMP_DIR
31683 {
31684 if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
31685 OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
31686 lPath, errno, osGetpid()));
31687 return SQLITE_IOERR_LOCK;
31688 }
31689 len = strlcat(lPath, "sqliteplocks", maxLen);
31690 }
31691 # else
@@ -31665,11 +31703,11 @@
31703 char c = dbPath[i];
31704 lPath[i+len] = (c=='/')?'_':c;
31705 }
31706 lPath[i+len]='\0';
31707 strlcat(lPath, ":auto:", maxLen);
31708 OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid()));
31709 return SQLITE_OK;
31710 }
31711
31712 /*
31713 ** Creates the lock file and any missing directories in lockPath
@@ -31692,20 +31730,20 @@
31730 if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
31731 int err=errno;
31732 if( err!=EEXIST ) {
31733 OSTRACE(("CREATELOCKPATH FAILED creating %s, "
31734 "'%s' proxy lock path=%s pid=%d\n",
31735 buf, strerror(err), lockPath, osGetpid()));
31736 return err;
31737 }
31738 }
31739 }
31740 start=i+1;
31741 }
31742 buf[i] = lockPath[i];
31743 }
31744 OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid()));
31745 return 0;
31746 }
31747
31748 /*
31749 ** Create a new VFS file descriptor (stored in memory obtained from
@@ -32006,11 +32044,12 @@
32044 int readLen = 0;
32045 int tryOldLockPath = 0;
32046 int forceNewLockPath = 0;
32047
32048 OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
32049 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32050 osGetpid()));
32051
32052 rc = proxyGetHostID(myHostID, &pError);
32053 if( (rc&0xff)==SQLITE_IOERR ){
32054 storeLastErrno(pFile, pError);
32055 goto end_takeconch;
@@ -32216,11 +32255,11 @@
32255
32256 pCtx = (proxyLockingContext *)pFile->lockingContext;
32257 conchFile = pCtx->conchFile;
32258 OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
32259 (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
32260 osGetpid()));
32261 if( pCtx->conchHeld>0 ){
32262 rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
32263 }
32264 pCtx->conchHeld = 0;
32265 OSTRACE(("RELEASECONCH %d %s\n", conchFile->h,
@@ -32358,11 +32397,11 @@
32397 }else{
32398 lockPath=(char *)path;
32399 }
32400
32401 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32402 (lockPath ? lockPath : ":auto:"), osGetpid()));
32403
32404 pCtx = sqlite3_malloc( sizeof(*pCtx) );
32405 if( pCtx==0 ){
32406 return SQLITE_NOMEM;
32407 }
@@ -32699,26 +32738,28 @@
32738 ** Note that the sqlite3_vfs.pNext field of the VFS object is modified
32739 ** by the SQLite core when the VFS is registered. So the following
32740 ** array cannot be const.
32741 */
32742 static sqlite3_vfs aVfs[] = {
32743 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
32744 UNIXVFS("unix", autolockIoFinder ),
32745 #elif OS_VXWORKS
32746 UNIXVFS("unix", vxworksIoFinder ),
32747 #else
32748 UNIXVFS("unix", posixIoFinder ),
32749 #endif
32750 UNIXVFS("unix-none", nolockIoFinder ),
32751 UNIXVFS("unix-dotfile", dotlockIoFinder ),
32752 UNIXVFS("unix-excl", posixIoFinder ),
32753 #if OS_VXWORKS
32754 UNIXVFS("unix-namedsem", semIoFinder ),
32755 #endif
32756 #if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
32757 UNIXVFS("unix-posix", posixIoFinder ),
32758 #endif
32759 #if SQLITE_ENABLE_LOCKING_STYLE
32760 UNIXVFS("unix-flock", flockIoFinder ),
 
32761 #endif
32762 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
32763 UNIXVFS("unix-afp", afpIoFinder ),
32764 UNIXVFS("unix-nfs", nfsIoFinder ),
32765 UNIXVFS("unix-proxy", proxyIoFinder ),
@@ -39072,16 +39113,24 @@
39113 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);
39114 }
39115 }
39116
39117 /*
39118 ** Compute the number of pages of cache requested. p->szCache is the
39119 ** cache size requested by the "PRAGMA cache_size" statement.
39120 **
39121 **
39122 */
39123 static int numberOfCachePages(PCache *p){
39124 if( p->szCache>=0 ){
39125 /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the
39126 ** suggested cache size is set to N. */
39127 return p->szCache;
39128 }else{
39129 /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then
39130 ** the number of cache pages is adjusted to use approximately abs(N*1024)
39131 ** bytes of memory. */
39132 return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
39133 }
39134 }
39135
39136 /*************************************************** General Interfaces ******
@@ -68615,10 +68664,14 @@
68664 }
68665 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
68666 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
68667 }
68668 #endif /* SQLITE_OMIT_UTF16 */
68669 /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
68670 ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
68671 ** point number string BLOB NULL
68672 */
68673 SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
68674 static const u8 aType[] = {
68675 SQLITE_BLOB, /* 0x00 */
68676 SQLITE_NULL, /* 0x01 */
68677 SQLITE_TEXT, /* 0x02 */
@@ -71290,11 +71343,11 @@
71343
71344 /* Opcode: String8 * P2 * P4 *
71345 ** Synopsis: r[P2]='P4'
71346 **
71347 ** P4 points to a nul terminated UTF-8 string. This opcode is transformed
71348 ** into a String opcode before it is executed for the first time. During
71349 ** this transformation, the length of string P4 is computed and stored
71350 ** as the P1 parameter.
71351 */
71352 case OP_String8: { /* same as TK_STRING, out2-prerelease */
71353 assert( pOp->p4.z!=0 );
@@ -71322,22 +71375,34 @@
71375 goto too_big;
71376 }
71377 /* Fall through to the next case, OP_String */
71378 }
71379
71380 /* Opcode: String P1 P2 P3 P4 P5
71381 ** Synopsis: r[P2]='P4' (len=P1)
71382 **
71383 ** The string value P4 of length P1 (bytes) is stored in register P2.
71384 **
71385 ** If P5!=0 and the content of register P3 is greater than zero, then
71386 ** the datatype of the register P2 is converted to BLOB. The content is
71387 ** the same sequence of bytes, it is merely interpreted as a BLOB instead
71388 ** of a string, as if it had been CAST.
71389 */
71390 case OP_String: { /* out2-prerelease */
71391 assert( pOp->p4.z!=0 );
71392 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
71393 pOut->z = pOp->p4.z;
71394 pOut->n = pOp->p1;
71395 pOut->enc = encoding;
71396 UPDATE_MAX_BLOBSIZE(pOut);
71397 if( pOp->p5 ){
71398 assert( pOp->p3>0 );
71399 assert( pOp->p3<=(p->nMem-p->nCursor) );
71400 pIn3 = &aMem[pOp->p3];
71401 assert( pIn3->flags & MEM_Int );
71402 if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;
71403 }
71404 break;
71405 }
71406
71407 /* Opcode: Null P1 P2 P3 * *
71408 ** Synopsis: r[P2..P3]=NULL
@@ -73325,11 +73390,16 @@
73390 ** the value of this counter needs to be restored too. */
73391 p->nStmtDefCons = db->nDeferredCons;
73392 p->nStmtDefImmCons = db->nDeferredImmCons;
73393 }
73394
73395 /* Gather the schema version number for checking:
73396 ** IMPLEMENTATION-OF: R-32195-19465 The schema version is used by SQLite
73397 ** each time a query is executed to ensure that the internal cache of the
73398 ** schema used when compiling the SQL query matches the schema of the
73399 ** database against which the compiled query is actually executed.
73400 */
73401 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
73402 iGen = db->aDb[pOp->p1].pSchema->iGeneration;
73403 }else{
73404 iGen = iMeta = 0;
73405 }
@@ -75843,14 +75913,16 @@
75913 #endif /* SQLITE_OMIT_AUTOINCREMENT */
75914
75915 /* Opcode: IfPos P1 P2 * * *
75916 ** Synopsis: if r[P1]>0 goto P2
75917 **
75918 ** Register P1 must contain an integer.
75919 ** If the value of register P1 is 1 or greater, jump to P2 and
75920 ** add the literal value P3 to register P1.
75921 **
75922 ** If the initial value of register P1 is less than 1, then the
75923 ** value is unchanged and control passes through to the next instruction.
75924 */
75925 case OP_IfPos: { /* jump, in1 */
75926 pIn1 = &aMem[pOp->p1];
75927 assert( pIn1->flags&MEM_Int );
75928 VdbeBranchTaken( pIn1->u.i>0, 2);
@@ -75875,27 +75947,63 @@
75947 pc = pOp->p2 - 1;
75948 }
75949 break;
75950 }
75951
75952 /* Opcode: IfNotZero P1 P2 P3 * *
75953 ** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
75954 **
75955 ** Register P1 must contain an integer. If the content of register P1 is
75956 ** initially nonzero, then add P3 to P1 and jump to P2. If register P1 is
75957 ** initially zero, leave it unchanged and fall through.
75958 */
75959 case OP_IfNotZero: { /* jump, in1 */
75960 pIn1 = &aMem[pOp->p1];
75961 assert( pIn1->flags&MEM_Int );
75962 VdbeBranchTaken(pIn1->u.i<0, 2);
75963 if( pIn1->u.i ){
75964 pIn1->u.i += pOp->p3;
75965 pc = pOp->p2 - 1;
75966 }
75967 break;
75968 }
75969
75970 /* Opcode: DecrJumpZero P1 P2 * * *
75971 ** Synopsis: if (--r[P1])==0 goto P2
75972 **
75973 ** Register P1 must hold an integer. Decrement the value in register P1
75974 ** then jump to P2 if the new value is exactly zero.
75975 */
75976 case OP_DecrJumpZero: { /* jump, in1 */
75977 pIn1 = &aMem[pOp->p1];
75978 assert( pIn1->flags&MEM_Int );
75979 pIn1->u.i--;
75980 VdbeBranchTaken(pIn1->u.i==0, 2);
75981 if( pIn1->u.i==0 ){
75982 pc = pOp->p2 - 1;
75983 }
75984 break;
75985 }
75986
75987
75988 /* Opcode: JumpZeroIncr P1 P2 * * *
75989 ** Synopsis: if (r[P1]++)==0 ) goto P2
75990 **
75991 ** The register P1 must contain an integer. If register P1 is initially
75992 ** zero, then jump to P2. Increment register P1 regardless of whether or
75993 ** not the jump is taken.
75994 */
75995 case OP_JumpZeroIncr: { /* jump, in1 */
75996 pIn1 = &aMem[pOp->p1];
75997 assert( pIn1->flags&MEM_Int );
75998 VdbeBranchTaken(pIn1->u.i==0, 2);
75999 if( (pIn1->u.i++)==0 ){
76000 pc = pOp->p2 - 1;
76001 }
76002 break;
76003 }
76004
76005 /* Opcode: AggStep * P2 P3 P4 P5
76006 ** Synopsis: accum=r[P3] step(r[P2@P5])
76007 **
76008 ** Execute the step function for an aggregate. The
76009 ** function has P5 arguments. P4 is a pointer to the FuncDef
@@ -97181,10 +97289,15 @@
97289 ** pExpr points to an expression which implements a function. If
97290 ** it is appropriate to apply the LIKE optimization to that function
97291 ** then set aWc[0] through aWc[2] to the wildcard characters and
97292 ** return TRUE. If the function is not a LIKE-style function then
97293 ** return FALSE.
97294 **
97295 ** *pIsNocase is set to true if uppercase and lowercase are equivalent for
97296 ** the function (default for LIKE). If the function makes the distinction
97297 ** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to
97298 ** false.
97299 */
97300 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
97301 FuncDef *pDef;
97302 if( pExpr->op!=TK_FUNCTION
97303 || !pExpr->x.pList
@@ -102972,10 +103085,21 @@
103085 }
103086
103087 /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
103088 ** connection. If it returns SQLITE_OK, then assume that the VFS
103089 ** handled the pragma and generate a no-op prepared statement.
103090 **
103091 ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,
103092 ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file
103093 ** object corresponding to the database file to which the pragma
103094 ** statement refers.
103095 **
103096 ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA
103097 ** file control is an array of pointers to strings (char**) in which the
103098 ** second element of the array is the name of the pragma and the third
103099 ** element is the argument to the pragma or NULL if the pragma has no
103100 ** argument.
103101 */
103102 aFcntl[0] = 0;
103103 aFcntl[1] = zLeft;
103104 aFcntl[2] = zRight;
103105 aFcntl[3] = 0;
@@ -103732,34 +103856,46 @@
103856 Index *pIdx;
103857 Table *pTab;
103858 pIdx = sqlite3FindIndex(db, zRight, zDb);
103859 if( pIdx ){
103860 int i;
103861 int mx;
103862 if( pPragma->iArg ){
103863 /* PRAGMA index_xinfo (newer version with more rows and columns) */
103864 mx = pIdx->nColumn;
103865 pParse->nMem = 6;
103866 }else{
103867 /* PRAGMA index_info (legacy version) */
103868 mx = pIdx->nKeyCol;
103869 pParse->nMem = 3;
103870 }
103871 pTab = pIdx->pTable;
103872 sqlite3VdbeSetNumCols(v, pParse->nMem);
 
103873 sqlite3CodeVerifySchema(pParse, iDb);
103874 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC);
103875 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC);
103876 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC);
103877 if( pPragma->iArg ){
103878 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC);
103879 sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC);
103880 sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC);
103881 }
103882 for(i=0; i<mx; i++){
103883 i16 cnum = pIdx->aiColumn[i];
103884 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
103885 sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
103886 if( cnum<0 ){
103887 sqlite3VdbeAddOp2(v, OP_Null, 0, 3);
103888 }else{
103889 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
103890 }
103891 if( pPragma->iArg ){
103892 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
103893 sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
103894 sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
103895 }
103896 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
103897 }
103898 }
103899 }
103900 break;
103901
@@ -104457,12 +104593,13 @@
104593 #endif
104594
104595 /*
104596 ** PRAGMA shrink_memory
104597 **
104598 ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database
104599 ** connection on which it is invoked to free up as much memory as it
104600 ** can, by calling sqlite3_db_release_memory().
104601 */
104602 case PragTyp_SHRINK_MEMORY: {
104603 sqlite3_db_release_memory(db);
104604 break;
104605 }
@@ -104487,12 +104624,16 @@
104624
104625 /*
104626 ** PRAGMA soft_heap_limit
104627 ** PRAGMA soft_heap_limit = N
104628 **
104629 ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the
104630 ** sqlite3_soft_heap_limit64() interface with the argument N, if N is
104631 ** specified and is a non-negative integer.
104632 ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always
104633 ** returns the same integer that would be returned by the
104634 ** sqlite3_soft_heap_limit64(-1) C-language function.
104635 */
104636 case PragTyp_SOFT_HEAP_LIMIT: {
104637 sqlite3_int64 N;
104638 if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
104639 sqlite3_soft_heap_limit64(N);
@@ -106065,24 +106206,21 @@
106206 }else{
106207 op = OP_IdxInsert;
106208 }
106209 sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
106210 if( pSelect->iLimit ){
106211 int addr;
106212 int iLimit;
106213 if( pSelect->iOffset ){
106214 iLimit = pSelect->iOffset+1;
106215 }else{
106216 iLimit = pSelect->iLimit;
106217 }
106218 addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, -1); VdbeCoverage(v);
 
 
 
106219 sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
106220 sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
106221 sqlite3VdbeJumpHere(v, addr);
106222 }
106223 }
106224
106225 /*
106226 ** Add code to implement the OFFSET
@@ -106475,11 +106613,11 @@
106613 /* Jump to the end of the loop if the LIMIT is reached. Except, if
106614 ** there is a sorter, in which case the sorter has already limited
106615 ** the output for us.
106616 */
106617 if( pSort==0 && p->iLimit ){
106618 sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
106619 }
106620 }
106621
106622 /*
106623 ** Allocate a KeyInfo object sufficient for an index of N key columns and
@@ -107328,11 +107466,11 @@
107466 }
107467 }else{
107468 sqlite3ExprCode(pParse, p->pLimit, iLimit);
107469 sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);
107470 VdbeComment((v, "LIMIT counter"));
107471 sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);
107472 }
107473 if( p->pOffset ){
107474 p->iOffset = iOffset = ++pParse->nMem;
107475 pParse->nMem++; /* Allocate an extra register for limit+offset */
107476 sqlite3ExprCode(pParse, p->pOffset, iOffset);
@@ -107547,11 +107685,11 @@
107685 addrCont = sqlite3VdbeMakeLabel(v);
107686 codeOffset(v, regOffset, addrCont);
107687 selectInnerLoop(pParse, p, p->pEList, iCurrent,
107688 0, 0, pDest, addrCont, addrBreak);
107689 if( regLimit ){
107690 sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);
107691 VdbeCoverage(v);
107692 }
107693 sqlite3VdbeResolveLabel(v, addrCont);
107694
107695 /* Execute the recursive SELECT taking the single row in Current as
@@ -107772,11 +107910,11 @@
107910 }
107911 p->pPrior = 0;
107912 p->iLimit = pPrior->iLimit;
107913 p->iOffset = pPrior->iOffset;
107914 if( p->iLimit ){
107915 addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
107916 VdbeComment((v, "Jump ahead if LIMIT reached"));
107917 }
107918 explainSetInteger(iSub2, pParse->iNextSelectId);
107919 rc = sqlite3Select(pParse, p, &dest);
107920 testcase( rc!=SQLITE_OK );
@@ -108173,11 +108311,11 @@
108311 }
108312
108313 /* Jump to the end of the loop if the LIMIT is reached.
108314 */
108315 if( p->iLimit ){
108316 sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
108317 }
108318
108319 /* Generate the subroutine return
108320 */
108321 sqlite3VdbeResolveLabel(v, iContinue);
@@ -114787,10 +114925,12 @@
114925 int addrNxt; /* Jump here to start the next IN combination */
114926 int addrSkip; /* Jump here for next iteration of skip-scan */
114927 int addrCont; /* Jump here to continue with the next loop cycle */
114928 int addrFirst; /* First instruction of interior of the loop */
114929 int addrBody; /* Beginning of the body of this loop */
114930 int iLikeRepCntr; /* LIKE range processing counter register */
114931 int addrLikeRep; /* LIKE range processing address */
114932 u8 iFrom; /* Which entry in the FROM clause */
114933 u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
114934 int p1, p2; /* Operands of the opcode used to ends the loop */
114935 union { /* Information that depends on pWLoop->wsFlags */
114936 struct {
@@ -114971,11 +115111,11 @@
115111 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
115112 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
115113 } u;
115114 LogEst truthProb; /* Probability of truth for this expression */
115115 u16 eOperator; /* A WO_xx value describing <op> */
115116 u16 wtFlags; /* TERM_xxx bit flags. See below */
115117 u8 nChild; /* Number of children that must disable us */
115118 WhereClause *pWC; /* The clause this term is part of */
115119 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
115120 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
115121 };
@@ -114993,10 +115133,13 @@
115133 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
115134 # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */
115135 #else
115136 # define TERM_VNULL 0x00 /* Disabled if not using stat3 */
115137 #endif
115138 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
115139 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
115140 #define TERM_LIKE 0x400 /* The original LIKE operator */
115141
115142 /*
115143 ** An instance of the WhereScan object is used as an iterator for locating
115144 ** terms in the WHERE clause that are useful to the query planner.
115145 */
@@ -115368,11 +115511,11 @@
115511 ** WARNING: This routine might reallocate the space used to store
115512 ** WhereTerms. All pointers to WhereTerms should be invalidated after
115513 ** calling this routine. Such pointers may be reinitialized by referencing
115514 ** the pWC->a[] array.
115515 */
115516 static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
115517 WhereTerm *pTerm;
115518 int idx;
115519 testcase( wtFlags & TERM_VIRTUAL );
115520 if( pWC->nTerm>=pWC->nSlot ){
115521 WhereTerm *pOld = pWC->a;
@@ -115793,11 +115936,15 @@
115936 ** Check to see if the given expression is a LIKE or GLOB operator that
115937 ** can be optimized using inequality constraints. Return TRUE if it is
115938 ** so and false if not.
115939 **
115940 ** In order for the operator to be optimizible, the RHS must be a string
115941 ** literal that does not begin with a wildcard. The LHS must be a column
115942 ** that may only be NULL, a string, or a BLOB, never a number. (This means
115943 ** that virtual tables cannot participate in the LIKE optimization.) If the
115944 ** collating sequence for the column on the LHS must be appropriate for
115945 ** the operator.
115946 */
115947 static int isLikeOrGlob(
115948 Parse *pParse, /* Parsing and code generating context */
115949 Expr *pExpr, /* Test this expression */
115950 Expr **ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */
@@ -115822,11 +115969,11 @@
115969 #endif
115970 pList = pExpr->x.pList;
115971 pLeft = pList->a[1].pExpr;
115972 if( pLeft->op!=TK_COLUMN
115973 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
115974 || IsVirtual(pLeft->pTab) /* Value might be numeric */
115975 ){
115976 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
115977 ** be the name of an indexed column with TEXT affinity. */
115978 return 0;
115979 }
@@ -116271,11 +116418,11 @@
116418 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
116419 Bitmask prereqAll; /* Prerequesites of pExpr */
116420 Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */
116421 Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */
116422 int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */
116423 int noCase = 0; /* uppercase equivalent to lowercase */
116424 int op; /* Top-level operator. pExpr->op */
116425 Parse *pParse = pWInfo->pParse; /* Parsing context */
116426 sqlite3 *db = pParse->db; /* Database connection */
116427
116428 if( db->mallocFailed ){
@@ -116409,16 +116556,19 @@
116556
116557 #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION
116558 /* Add constraints to reduce the search space on a LIKE or GLOB
116559 ** operator.
116560 **
116561 ** A like pattern of the form "x LIKE 'aBc%'" is changed into constraints
116562 **
116563 ** x>='ABC' AND x<'abd' AND x LIKE 'aBc%'
116564 **
116565 ** The last character of the prefix "abc" is incremented to form the
116566 ** termination condition "abd". If case is not significant (the default
116567 ** for LIKE) then the lower-bound is made all uppercase and the upper-
116568 ** bound is made all lowercase so that the bounds also work when comparing
116569 ** BLOBs.
116570 */
116571 if( pWC->op==TK_AND
116572 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
116573 ){
116574 Expr *pLeft; /* LHS of LIKE/GLOB operator */
@@ -116426,13 +116576,29 @@
116576 Expr *pNewExpr1;
116577 Expr *pNewExpr2;
116578 int idxNew1;
116579 int idxNew2;
116580 Token sCollSeqName; /* Name of collating sequence */
116581 const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
116582
116583 pLeft = pExpr->x.pList->a[1].pExpr;
116584 pStr2 = sqlite3ExprDup(db, pStr1, 0);
116585
116586 /* Convert the lower bound to upper-case and the upper bound to
116587 ** lower-case (upper-case is less than lower-case in ASCII) so that
116588 ** the range constraints also work for BLOBs
116589 */
116590 if( noCase && !pParse->db->mallocFailed ){
116591 int i;
116592 char c;
116593 pTerm->wtFlags |= TERM_LIKE;
116594 for(i=0; (c = pStr1->u.zToken[i])!=0; i++){
116595 pStr1->u.zToken[i] = sqlite3Toupper(c);
116596 pStr2->u.zToken[i] = sqlite3Tolower(c);
116597 }
116598 }
116599
116600 if( !db->mallocFailed ){
116601 u8 c, *pC; /* Last character before the first wildcard */
116602 pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
116603 c = *pC;
116604 if( noCase ){
@@ -116448,23 +116614,23 @@
116614 *pC = c + 1;
116615 }
116616 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
116617 sCollSeqName.n = 6;
116618 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
116619 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
116620 sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
116621 pStr1, 0);
116622 transferJoinMarkings(pNewExpr1, pExpr);
116623 idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
116624 testcase( idxNew1==0 );
116625 exprAnalyze(pSrc, pWC, idxNew1);
116626 pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
116627 pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
116628 sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
116629 pStr2, 0);
116630 transferJoinMarkings(pNewExpr2, pExpr);
116631 idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
116632 testcase( idxNew2==0 );
116633 exprAnalyze(pSrc, pWC, idxNew2);
116634 pTerm = &pWC->a[idxTerm];
116635 if( isComplete ){
116636 markTermAsChild(pWC, idxNew1, idxTerm);
@@ -117635,24 +117801,47 @@
117801 ** by indices, we disable them to prevent redundant tests in the inner
117802 ** loop. We would get the correct results if nothing were ever disabled,
117803 ** but joins might run a little slower. The trick is to disable as much
117804 ** as we can without disabling too much. If we disabled in (1), we'd get
117805 ** the wrong answer. See ticket #813.
117806 **
117807 ** If all the children of a term are disabled, then that term is also
117808 ** automatically disabled. In this way, terms get disabled if derived
117809 ** virtual terms are tested first. For example:
117810 **
117811 ** x GLOB 'abc*' AND x>='abc' AND x<'acd'
117812 ** \___________/ \______/ \_____/
117813 ** parent child1 child2
117814 **
117815 ** Only the parent term was in the original WHERE clause. The child1
117816 ** and child2 terms were added by the LIKE optimization. If both of
117817 ** the virtual child terms are valid, then testing of the parent can be
117818 ** skipped.
117819 **
117820 ** Usually the parent term is marked as TERM_CODED. But if the parent
117821 ** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.
117822 ** The TERM_LIKECOND marking indicates that the term should be coded inside
117823 ** a conditional such that is only evaluated on the second pass of a
117824 ** LIKE-optimization loop, when scanning BLOBs instead of strings.
117825 */
117826 static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
117827 int nLoop = 0;
117828 while( pTerm
117829 && (pTerm->wtFlags & TERM_CODED)==0
117830 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
117831 && (pLevel->notReady & pTerm->prereqAll)==0
117832 ){
117833 if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
117834 pTerm->wtFlags |= TERM_LIKECOND;
117835 }else{
117836 pTerm->wtFlags |= TERM_CODED;
 
 
117837 }
117838 if( pTerm->iParent<0 ) break;
117839 pTerm = &pTerm->pWC->a[pTerm->iParent];
117840 pTerm->nChild--;
117841 if( pTerm->nChild!=0 ) break;
117842 nLoop++;
117843 }
117844 }
117845
117846 /*
117847 ** Code an OP_Affinity opcode to apply the column affinity string zAff
@@ -118132,11 +118321,30 @@
118321 }
118322 #else
118323 # define addScanStatus(a, b, c, d) ((void)d)
118324 #endif
118325
118326 /*
118327 ** Look at the last instruction coded. If that instruction is OP_String8
118328 ** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be
118329 ** pLoop->iLikeRepCntr and set P5.
118330 **
118331 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
118332 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
118333 ** scan loop run twice, once for strings and a second time for BLOBs.
118334 ** The OP_String opcodes on the second pass convert the upper and lower
118335 ** bound string contants to blobs. This routine makes the necessary changes
118336 ** to the OP_String opcodes for that to happen.
118337 */
118338 static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){
118339 VdbeOp *pOp;
118340 pOp = sqlite3VdbeGetOp(v, -1);
118341 if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){
118342 pOp->p3 = pLevel->iLikeRepCntr;
118343 pOp->p5 = 1;
118344 }
118345 }
118346
118347 /*
118348 ** Generate code for the start of the iLevel-th loop in the WHERE clause
118349 ** implementation described by pWInfo.
118350 */
@@ -118466,10 +118674,23 @@
118674 nExtraReg = 1;
118675 }
118676 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
118677 pRangeEnd = pLoop->aLTerm[j++];
118678 nExtraReg = 1;
118679 if( pRangeStart
118680 && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0
118681 && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0
118682 ){
118683 pLevel->iLikeRepCntr = ++pParse->nMem;
118684 testcase( bRev );
118685 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
118686 sqlite3VdbeAddOp2(v, OP_Integer,
118687 bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
118688 pLevel->iLikeRepCntr);
118689 VdbeComment((v, "LIKE loop counter"));
118690 pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);
118691 }
118692 if( pRangeStart==0
118693 && (j = pIdx->aiColumn[nEq])>=0
118694 && pIdx->pTable->aCol[j].notNull==0
118695 ){
118696 bSeekPastNull = 1;
@@ -118508,10 +118729,11 @@
118729 /* Seek the index cursor to the start of the range. */
118730 nConstraint = nEq;
118731 if( pRangeStart ){
118732 Expr *pRight = pRangeStart->pExpr->pRight;
118733 sqlite3ExprCode(pParse, pRight, regBase+nEq);
118734 whereLikeOptimizationStringFixup(v, pLevel);
118735 if( (pRangeStart->wtFlags & TERM_VNULL)==0
118736 && sqlite3ExprCanBeNull(pRight)
118737 ){
118738 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118739 VdbeCoverage(v);
@@ -118553,10 +118775,11 @@
118775 nConstraint = nEq;
118776 if( pRangeEnd ){
118777 Expr *pRight = pRangeEnd->pExpr->pRight;
118778 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
118779 sqlite3ExprCode(pParse, pRight, regBase+nEq);
118780 whereLikeOptimizationStringFixup(v, pLevel);
118781 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
118782 && sqlite3ExprCanBeNull(pRight)
118783 ){
118784 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
118785 VdbeCoverage(v);
@@ -118780,11 +119003,12 @@
119003 ** eliminating duplicates from other WHERE clauses, the action for each
119004 ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
119005 */
119006 wctrlFlags = WHERE_OMIT_OPEN_CLOSE
119007 | WHERE_FORCE_TABLE
119008 | WHERE_ONETABLE_ONLY
119009 | WHERE_NO_AUTOINDEX;
119010 for(ii=0; ii<pOrWc->nTerm; ii++){
119011 WhereTerm *pOrTerm = &pOrWc->a[ii];
119012 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
119013 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
119014 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -118942,10 +119166,11 @@
119166 /* Insert code to test every subexpression that can be completely
119167 ** computed using the current set of tables.
119168 */
119169 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
119170 Expr *pE;
119171 int skipLikeAddr = 0;
119172 testcase( pTerm->wtFlags & TERM_VIRTUAL );
119173 testcase( pTerm->wtFlags & TERM_CODED );
119174 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
119175 if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
119176 testcase( pWInfo->untestedTerms==0
@@ -118955,12 +119180,18 @@
119180 }
119181 pE = pTerm->pExpr;
119182 assert( pE!=0 );
119183 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
119184 continue;
119185 }
119186 if( pTerm->wtFlags & TERM_LIKECOND ){
119187 assert( pLevel->iLikeRepCntr>0 );
119188 skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr);
119189 VdbeCoverage(v);
119190 }
119191 sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
119192 if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
119193 pTerm->wtFlags |= TERM_CODED;
119194 }
119195
119196 /* Insert code to test for implied constraints based on transitivity
119197 ** of the "==" operator.
@@ -119974,10 +120205,11 @@
120205 rLogSize = estLog(rSize);
120206
120207 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
120208 /* Automatic indexes */
120209 if( !pBuilder->pOrSet
120210 && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
120211 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
120212 && pSrc->pIndex==0
120213 && !pSrc->viaCoroutine
120214 && !pSrc->notIndexed
120215 && HasRowid(pTab)
@@ -121758,10 +121990,20 @@
121990 if( pLevel->addrSkip ){
121991 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
121992 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
121993 sqlite3VdbeJumpHere(v, pLevel->addrSkip);
121994 sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
121995 }
121996 if( pLevel->addrLikeRep ){
121997 int op;
121998 if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){
121999 op = OP_DecrJumpZero;
122000 }else{
122001 op = OP_JumpZeroIncr;
122002 }
122003 sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep);
122004 VdbeCoverage(v);
122005 }
122006 if( pLevel->iLeftJoin ){
122007 addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
122008 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
122009 || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
@@ -126982,30 +127224,32 @@
127224 /* Mutex configuration options are only available in a threadsafe
127225 ** compile.
127226 */
127227 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-54466-46756 */
127228 case SQLITE_CONFIG_SINGLETHREAD: {
127229 /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to
127230 ** Single-thread. */
127231 sqlite3GlobalConfig.bCoreMutex = 0; /* Disable mutex on core */
127232 sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
127233 break;
127234 }
127235 #endif
127236 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */
127237 case SQLITE_CONFIG_MULTITHREAD: {
127238 /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to
127239 ** Multi-thread. */
127240 sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
127241 sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
127242 break;
127243 }
127244 #endif
127245 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */
127246 case SQLITE_CONFIG_SERIALIZED: {
127247 /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to
127248 ** Serialized. */
127249 sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
127250 sqlite3GlobalConfig.bFullMutex = 1; /* Enable mutex on connections */
127251 break;
127252 }
127253 #endif
127254 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */
127255 case SQLITE_CONFIG_MUTEX: {
@@ -127113,11 +127357,12 @@
127357 ** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */
127358 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
127359 case SQLITE_CONFIG_HEAP: {
127360 /* EVIDENCE-OF: R-19854-42126 There are three arguments to
127361 ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the
127362 ** number of bytes in the memory buffer, and the minimum allocation size.
127363 */
127364 sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
127365 sqlite3GlobalConfig.nHeap = va_arg(ap, int);
127366 sqlite3GlobalConfig.mnReq = va_arg(ap, int);
127367
127368 if( sqlite3GlobalConfig.mnReq<1 ){
@@ -127218,11 +127463,13 @@
127463 ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
127464 ** silently truncated if necessary so that it does not exceed the
127465 ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE
127466 ** compile-time option.
127467 */
127468 if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){
127469 mxMmap = SQLITE_MAX_MMAP_SIZE;
127470 }
127471 if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
127472 if( szMmap>mxMmap) szMmap = mxMmap;
127473 sqlite3GlobalConfig.mxMmap = mxMmap;
127474 sqlite3GlobalConfig.szMmap = szMmap;
127475 break;
@@ -129062,11 +129309,23 @@
129309 for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
129310 zFile = sqlite3_malloc(nByte);
129311 if( !zFile ) return SQLITE_NOMEM;
129312
129313 iIn = 5;
129314 #ifdef SQLITE_ALLOW_URI_AUTHORITY
129315 if( strncmp(zUri+5, "///", 3)==0 ){
129316 iIn = 7;
129317 /* The following condition causes URIs with five leading / characters
129318 ** like file://///host/path to be converted into UNCs like //host/path.
129319 ** The correct URI for that UNC has only two or four leading / characters
129320 ** file://host/path or file:////host/path. But 5 leading slashes is a
129321 ** common error, we are told, so we handle it as a special case. */
129322 if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; }
129323 }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){
129324 iIn = 16;
129325 }
129326 #else
129327 /* Discard the scheme and authority segments of the URI. */
129328 if( zUri[5]=='/' && zUri[6]=='/' ){
129329 iIn = 7;
129330 while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;
129331 if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){
@@ -129505,11 +129764,12 @@
129764 sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
129765
129766 opendb_out:
129767 sqlite3_free(zOpen);
129768 if( db ){
129769 assert( db->mutex!=0 || isThreadsafe==0
129770 || sqlite3GlobalConfig.bFullMutex==0 );
129771 sqlite3_mutex_leave(db->mutex);
129772 }
129773 rc = sqlite3_errcode(db);
129774 assert( db!=0 || rc==SQLITE_NOMEM );
129775 if( rc==SQLITE_NOMEM ){
@@ -130250,21 +130510,21 @@
130510 case SQLITE_TESTCTRL_ISINIT: {
130511 if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
130512 break;
130513 }
130514
130515 /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);
130516 **
130517 ** This test control is used to create imposter tables. "db" is a pointer
130518 ** to the database connection. dbName is the database name (ex: "main" or
130519 ** "temp") which will receive the imposter. "onOff" turns imposter mode on
130520 ** or off. "tnum" is the root page of the b-tree to which the imposter
130521 ** table should connect.
130522 **
130523 ** Enable imposter mode only when the schema has already been parsed. Then
130524 ** run a single CREATE TABLE statement to construct the imposter table in
130525 ** the parsed schema. Then turn imposter mode back off again.
130526 **
130527 ** If onOff==0 and tnum>0 then reset the schema for all databases, causing
130528 ** the schema to be reparsed the next time it is needed. This has the
130529 ** effect of erasing all imposter tables.
130530 */
130531
+33 -32
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105105
**
106106
** See also: [sqlite3_libversion()],
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110
-#define SQLITE_VERSION "3.8.8"
111
-#define SQLITE_VERSION_NUMBER 3008008
112
-#define SQLITE_SOURCE_ID "2015-02-25 14:25:31 6d132e7a224ee68b5cefe9222944aac5760ffc20"
110
+#define SQLITE_VERSION "3.8.9"
111
+#define SQLITE_VERSION_NUMBER 3008009
112
+#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -754,18 +754,20 @@
754754
**
755755
** These integer constants are opcodes for the xFileControl method
756756
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
757757
** interface.
758758
**
759
+** <ul>
760
+** <li>[[SQLITE_FCNTL_LOCKSTATE]]
759761
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
760762
** opcode causes the xFileControl method to write the current state of
761763
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
762764
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
763765
** into an integer that the pArg argument points to. This capability
764
-** is used during testing and only needs to be supported when SQLITE_TEST
765
-** is defined.
766
-** <ul>
766
+** is used during testing and is only available when the SQLITE_TEST
767
+** compile-time option is used.
768
+**
767769
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
768770
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
769771
** layer a hint of how large the database file will grow to be during the
770772
** current transaction. This hint is not guaranteed to be accurate but it
771773
** is often close. The underlying VFS might choose to preallocate database
@@ -886,11 +888,13 @@
886888
** the error message if the pragma fails. ^If the
887889
** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
888890
** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
889891
** file control returns [SQLITE_OK], then the parser assumes that the
890892
** VFS has handled the PRAGMA itself and the parser generates a no-op
891
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
893
+** prepared statement if result string is NULL, or that returns a copy
894
+** of the result string if the string is non-NULL.
895
+** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
892896
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
893897
** that the VFS encountered an error while handling the [PRAGMA] and the
894898
** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
895899
** file control occurs at the beginning of pragma statement analysis and so
896900
** it is able to override built-in [PRAGMA] statements.
@@ -1745,11 +1749,10 @@
17451749
** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
17461750
** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
17471751
** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
17481752
** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
17491753
** that specifies the maximum size of the created heap.
1750
-** </dl>
17511754
**
17521755
** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
17531756
** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
17541757
** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
17551758
** is a pointer to an integer and writes into that integer the number of extra
@@ -3185,20 +3188,18 @@
31853188
** The second argument, "zSql", is the statement to be compiled, encoded
31863189
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
31873190
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
31883191
** use UTF-16.
31893192
**
3190
-** ^If the nByte argument is less than zero, then zSql is read up to the
3191
-** first zero terminator. ^If nByte is non-negative, then it is the maximum
3192
-** number of bytes read from zSql. ^When nByte is non-negative, the
3193
-** zSql string ends at either the first '\000' or '\u0000' character or
3194
-** the nByte-th byte, whichever comes first. If the caller knows
3195
-** that the supplied string is nul-terminated, then there is a small
3196
-** performance advantage to be gained by passing an nByte parameter that
3197
-** is equal to the number of bytes in the input string <i>including</i>
3198
-** the nul-terminator bytes as this saves SQLite from having to
3199
-** make a copy of the input string.
3193
+** ^If the nByte argument is negative, then zSql is read up to the
3194
+** first zero terminator. ^If nByte is positive, then it is the
3195
+** number of bytes read from zSql. ^If nByte is zero, then no prepared
3196
+** statement is generated.
3197
+** If the caller knows that the supplied string is nul-terminated, then
3198
+** there is a small performance advantage to passing an nByte parameter that
3199
+** is the number of bytes in the input string <i>including</i>
3200
+** the nul-terminator.
32003201
**
32013202
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
32023203
** past the end of the first SQL statement in zSql. These routines only
32033204
** compile the first statement in zSql, so *pzTail is left pointing to
32043205
** what remains uncompiled.
@@ -4223,12 +4224,12 @@
42234224
** DEPRECATED
42244225
**
42254226
** These functions are [deprecated]. In order to maintain
42264227
** backwards compatibility with older code, these functions continue
42274228
** to be supported. However, new applications should avoid
4228
-** the use of these functions. To help encourage people to avoid
4229
-** using these functions, we are not going to tell you what they do.
4229
+** the use of these functions. To encourage programmers to avoid
4230
+** these functions, we will not explain what they do.
42304231
*/
42314232
#ifndef SQLITE_OMIT_DEPRECATED
42324233
SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
42334234
SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
42344235
SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -6986,24 +6987,24 @@
69866987
**
69876988
** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
69886989
** is not a permanent error and does not affect the return value of
69896990
** sqlite3_backup_finish().
69906991
**
6991
-** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
6992
+** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
69926993
** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
69936994
**
6994
-** ^Each call to sqlite3_backup_step() sets two values inside
6995
-** the [sqlite3_backup] object: the number of pages still to be backed
6996
-** up and the total number of pages in the source database file.
6997
-** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
6998
-** retrieve these two values, respectively.
6999
-**
7000
-** ^The values returned by these functions are only updated by
7001
-** sqlite3_backup_step(). ^If the source database is modified during a backup
7002
-** operation, then the values are not updated to account for any extra
7003
-** pages that need to be updated or the size of the source database file
7004
-** changing.
6995
+** ^The sqlite3_backup_remaining() routine returns the number of pages still
6996
+** to be backed up at the conclusion of the most recent sqlite3_backup_step().
6997
+** ^The sqlite3_backup_pagecount() routine returns the total number of pages
6998
+** in the source database at the conclusion of the most recent
6999
+** sqlite3_backup_step().
7000
+** ^(The values returned by these functions are only updated by
7001
+** sqlite3_backup_step(). If the source database is modified in a way that
7002
+** changes the size of the source database or the number of pages remaining,
7003
+** those changes are not reflected in the output of sqlite3_backup_pagecount()
7004
+** and sqlite3_backup_remaining() until after the next
7005
+** sqlite3_backup_step().)^
70057006
**
70067007
** <b>Concurrent Usage of Database Handles</b>
70077008
**
70087009
** ^The source [database connection] may be used by the application for other
70097010
** purposes while a backup operation is underway or being initialized.
70107011
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.8"
111 #define SQLITE_VERSION_NUMBER 3008008
112 #define SQLITE_SOURCE_ID "2015-02-25 14:25:31 6d132e7a224ee68b5cefe9222944aac5760ffc20"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -754,18 +754,20 @@
754 **
755 ** These integer constants are opcodes for the xFileControl method
756 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
757 ** interface.
758 **
 
 
759 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
760 ** opcode causes the xFileControl method to write the current state of
761 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
762 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
763 ** into an integer that the pArg argument points to. This capability
764 ** is used during testing and only needs to be supported when SQLITE_TEST
765 ** is defined.
766 ** <ul>
767 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
768 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
769 ** layer a hint of how large the database file will grow to be during the
770 ** current transaction. This hint is not guaranteed to be accurate but it
771 ** is often close. The underlying VFS might choose to preallocate database
@@ -886,11 +888,13 @@
886 ** the error message if the pragma fails. ^If the
887 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
888 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
889 ** file control returns [SQLITE_OK], then the parser assumes that the
890 ** VFS has handled the PRAGMA itself and the parser generates a no-op
891 ** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
 
 
892 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
893 ** that the VFS encountered an error while handling the [PRAGMA] and the
894 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
895 ** file control occurs at the beginning of pragma statement analysis and so
896 ** it is able to override built-in [PRAGMA] statements.
@@ -1745,11 +1749,10 @@
1745 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1746 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
1747 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
1748 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1749 ** that specifies the maximum size of the created heap.
1750 ** </dl>
1751 **
1752 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
1753 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
1754 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
1755 ** is a pointer to an integer and writes into that integer the number of extra
@@ -3185,20 +3188,18 @@
3185 ** The second argument, "zSql", is the statement to be compiled, encoded
3186 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3187 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3188 ** use UTF-16.
3189 **
3190 ** ^If the nByte argument is less than zero, then zSql is read up to the
3191 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
3192 ** number of bytes read from zSql. ^When nByte is non-negative, the
3193 ** zSql string ends at either the first '\000' or '\u0000' character or
3194 ** the nByte-th byte, whichever comes first. If the caller knows
3195 ** that the supplied string is nul-terminated, then there is a small
3196 ** performance advantage to be gained by passing an nByte parameter that
3197 ** is equal to the number of bytes in the input string <i>including</i>
3198 ** the nul-terminator bytes as this saves SQLite from having to
3199 ** make a copy of the input string.
3200 **
3201 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
3202 ** past the end of the first SQL statement in zSql. These routines only
3203 ** compile the first statement in zSql, so *pzTail is left pointing to
3204 ** what remains uncompiled.
@@ -4223,12 +4224,12 @@
4223 ** DEPRECATED
4224 **
4225 ** These functions are [deprecated]. In order to maintain
4226 ** backwards compatibility with older code, these functions continue
4227 ** to be supported. However, new applications should avoid
4228 ** the use of these functions. To help encourage people to avoid
4229 ** using these functions, we are not going to tell you what they do.
4230 */
4231 #ifndef SQLITE_OMIT_DEPRECATED
4232 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4233 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4234 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -6986,24 +6987,24 @@
6986 **
6987 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
6988 ** is not a permanent error and does not affect the return value of
6989 ** sqlite3_backup_finish().
6990 **
6991 ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
6992 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
6993 **
6994 ** ^Each call to sqlite3_backup_step() sets two values inside
6995 ** the [sqlite3_backup] object: the number of pages still to be backed
6996 ** up and the total number of pages in the source database file.
6997 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
6998 ** retrieve these two values, respectively.
6999 **
7000 ** ^The values returned by these functions are only updated by
7001 ** sqlite3_backup_step(). ^If the source database is modified during a backup
7002 ** operation, then the values are not updated to account for any extra
7003 ** pages that need to be updated or the size of the source database file
7004 ** changing.
7005 **
7006 ** <b>Concurrent Usage of Database Handles</b>
7007 **
7008 ** ^The source [database connection] may be used by the application for other
7009 ** purposes while a backup operation is underway or being initialized.
7010
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.9"
111 #define SQLITE_VERSION_NUMBER 3008009
112 #define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -754,18 +754,20 @@
754 **
755 ** These integer constants are opcodes for the xFileControl method
756 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
757 ** interface.
758 **
759 ** <ul>
760 ** <li>[[SQLITE_FCNTL_LOCKSTATE]]
761 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
762 ** opcode causes the xFileControl method to write the current state of
763 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
764 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
765 ** into an integer that the pArg argument points to. This capability
766 ** is used during testing and is only available when the SQLITE_TEST
767 ** compile-time option is used.
768 **
769 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
770 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
771 ** layer a hint of how large the database file will grow to be during the
772 ** current transaction. This hint is not guaranteed to be accurate but it
773 ** is often close. The underlying VFS might choose to preallocate database
@@ -886,11 +888,13 @@
888 ** the error message if the pragma fails. ^If the
889 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
890 ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
891 ** file control returns [SQLITE_OK], then the parser assumes that the
892 ** VFS has handled the PRAGMA itself and the parser generates a no-op
893 ** prepared statement if result string is NULL, or that returns a copy
894 ** of the result string if the string is non-NULL.
895 ** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
896 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
897 ** that the VFS encountered an error while handling the [PRAGMA] and the
898 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
899 ** file control occurs at the beginning of pragma statement analysis and so
900 ** it is able to override built-in [PRAGMA] statements.
@@ -1745,11 +1749,10 @@
1749 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1750 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
1751 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
1752 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1753 ** that specifies the maximum size of the created heap.
 
1754 **
1755 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
1756 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
1757 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
1758 ** is a pointer to an integer and writes into that integer the number of extra
@@ -3185,20 +3188,18 @@
3188 ** The second argument, "zSql", is the statement to be compiled, encoded
3189 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3190 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3191 ** use UTF-16.
3192 **
3193 ** ^If the nByte argument is negative, then zSql is read up to the
3194 ** first zero terminator. ^If nByte is positive, then it is the
3195 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3196 ** statement is generated.
3197 ** If the caller knows that the supplied string is nul-terminated, then
3198 ** there is a small performance advantage to passing an nByte parameter that
3199 ** is the number of bytes in the input string <i>including</i>
3200 ** the nul-terminator.
 
 
3201 **
3202 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
3203 ** past the end of the first SQL statement in zSql. These routines only
3204 ** compile the first statement in zSql, so *pzTail is left pointing to
3205 ** what remains uncompiled.
@@ -4223,12 +4224,12 @@
4224 ** DEPRECATED
4225 **
4226 ** These functions are [deprecated]. In order to maintain
4227 ** backwards compatibility with older code, these functions continue
4228 ** to be supported. However, new applications should avoid
4229 ** the use of these functions. To encourage programmers to avoid
4230 ** these functions, we will not explain what they do.
4231 */
4232 #ifndef SQLITE_OMIT_DEPRECATED
4233 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4234 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4235 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
@@ -6986,24 +6987,24 @@
6987 **
6988 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
6989 ** is not a permanent error and does not affect the return value of
6990 ** sqlite3_backup_finish().
6991 **
6992 ** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
6993 ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
6994 **
6995 ** ^The sqlite3_backup_remaining() routine returns the number of pages still
6996 ** to be backed up at the conclusion of the most recent sqlite3_backup_step().
6997 ** ^The sqlite3_backup_pagecount() routine returns the total number of pages
6998 ** in the source database at the conclusion of the most recent
6999 ** sqlite3_backup_step().
7000 ** ^(The values returned by these functions are only updated by
7001 ** sqlite3_backup_step(). If the source database is modified in a way that
7002 ** changes the size of the source database or the number of pages remaining,
7003 ** those changes are not reflected in the output of sqlite3_backup_pagecount()
7004 ** and sqlite3_backup_remaining() until after the next
7005 ** sqlite3_backup_step().)^
7006 **
7007 ** <b>Concurrent Usage of Database Handles</b>
7008 **
7009 ** ^The source [database connection] may be used by the application for other
7010 ** purposes while a backup operation is underway or being initialized.
7011

Keyboard Shortcuts

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