Fossil SCM

merge trunk

jan.nijtmans 2013-10-15 06:51 UTC tkt-change-hook merge
Commit 837c85bae5fb6148439cf2ad6137a90e89b672e8
+2 -2
--- src/cgi.c
+++ src/cgi.c
@@ -1323,12 +1323,12 @@
13231323
*/
13241324
void cgi_handle_ssh_http_request(const char *zIpAddr){
13251325
static int nCycles = 0;
13261326
static char *zCmd = 0;
13271327
char *z, *zToken;
1328
- const char *zType;
1329
- int i, content_length;
1328
+ const char *zType = 0;
1329
+ int i, content_length = 0;
13301330
char zLine[2000]; /* A single line of input. */
13311331
13321332
if( zIpAddr ){
13331333
if( nCycles==0 ){
13341334
cgi_setenv("REMOTE_ADDR", zIpAddr);
13351335
--- src/cgi.c
+++ src/cgi.c
@@ -1323,12 +1323,12 @@
1323 */
1324 void cgi_handle_ssh_http_request(const char *zIpAddr){
1325 static int nCycles = 0;
1326 static char *zCmd = 0;
1327 char *z, *zToken;
1328 const char *zType;
1329 int i, content_length;
1330 char zLine[2000]; /* A single line of input. */
1331
1332 if( zIpAddr ){
1333 if( nCycles==0 ){
1334 cgi_setenv("REMOTE_ADDR", zIpAddr);
1335
--- src/cgi.c
+++ src/cgi.c
@@ -1323,12 +1323,12 @@
1323 */
1324 void cgi_handle_ssh_http_request(const char *zIpAddr){
1325 static int nCycles = 0;
1326 static char *zCmd = 0;
1327 char *z, *zToken;
1328 const char *zType = 0;
1329 int i, content_length = 0;
1330 char zLine[2000]; /* A single line of input. */
1331
1332 if( zIpAddr ){
1333 if( nCycles==0 ){
1334 cgi_setenv("REMOTE_ADDR", zIpAddr);
1335
+1 -1
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
12021202
}
12031203
do{
12041204
/* extract the data and data types */
12051205
for(i=0; i<nCol; i++){
12061206
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207
- if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){
1207
+ if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){
12081208
azVals[i] = "";
12091209
}else{
12101210
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
12111211
}
12121212
if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
12131213
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
1202 }
1203 do{
1204 /* extract the data and data types */
1205 for(i=0; i<nCol; i++){
1206 aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207 if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){
1208 azVals[i] = "";
1209 }else{
1210 azVals[i] = (char*)sqlite3_column_text(pStmt, i);
1211 }
1212 if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
1213
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
1202 }
1203 do{
1204 /* extract the data and data types */
1205 for(i=0; i<nCol; i++){
1206 aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207 if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){
1208 azVals[i] = "";
1209 }else{
1210 azVals[i] = (char*)sqlite3_column_text(pStmt, i);
1211 }
1212 if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
1213
+153 -83
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135135
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136136
** [sqlite_version()] and [sqlite_source_id()].
137137
*/
138138
#define SQLITE_VERSION "3.8.1"
139139
#define SQLITE_VERSION_NUMBER 3008001
140
-#define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
140
+#define SQLITE_SOURCE_ID "2013-10-14 21:14:42 9f66dd7e3790c04f0ab724419f5381bd21f9ebad"
141141
142142
/*
143143
** CAPI3REF: Run-Time Library Version Numbers
144144
** KEYWORDS: sqlite3_version, sqlite3_sourceid
145145
**
@@ -1643,31 +1643,31 @@
16431643
** supplied by the application must not invoke any SQLite interface.
16441644
** In a multi-threaded application, the application-defined logger
16451645
** function must be threadsafe. </dd>
16461646
**
16471647
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648
-** <dd> This option takes a single argument of type int. If non-zero, then
1648
+** <dd>^(This option takes a single argument of type int. If non-zero, then
16491649
** URI handling is globally enabled. If the parameter is zero, then URI handling
1650
-** is globally disabled. If URI handling is globally enabled, all filenames
1650
+** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
16511651
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
16521652
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
16531653
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654
-** connection is opened. If it is globally disabled, filenames are
1654
+** connection is opened. ^If it is globally disabled, filenames are
16551655
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656
-** database connection is opened. By default, URI handling is globally
1656
+** database connection is opened. ^(By default, URI handling is globally
16571657
** disabled. The default value may be changed by compiling with the
1658
-** [SQLITE_USE_URI] symbol defined.
1658
+** [SQLITE_USE_URI] symbol defined.)^
16591659
**
16601660
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661
-** <dd> This option takes a single integer argument which is interpreted as
1661
+** <dd>^This option takes a single integer argument which is interpreted as
16621662
** a boolean in order to enable or disable the use of covering indices for
1663
-** full table scans in the query optimizer. The default setting is determined
1663
+** full table scans in the query optimizer. ^The default setting is determined
16641664
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
16651665
** if that compile-time option is omitted.
16661666
** The ability to disable the use of covering indices for full table scans
16671667
** is because some incorrectly coded legacy applications might malfunction
1668
-** malfunction when the optimization is enabled. Providing the ability to
1668
+** when the optimization is enabled. Providing the ability to
16691669
** disable the optimization allows the older, buggy application code to work
16701670
** without change even with newer versions of SQLite.
16711671
**
16721672
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
16731673
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
16921692
** configuration option can be seen in the "test_sqllog.c" source file in
16931693
** the canonical SQLite source tree.</dd>
16941694
**
16951695
** [[SQLITE_CONFIG_MMAP_SIZE]]
16961696
** <dt>SQLITE_CONFIG_MMAP_SIZE
1697
-** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1697
+** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
16981698
** that are the default mmap size limit (the default setting for
16991699
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700
-** The default setting can be overridden by each database connection using
1700
+** ^The default setting can be overridden by each database connection using
17011701
** either the [PRAGMA mmap_size] command, or by using the
1702
-** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1702
+** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
17031703
** cannot be changed at run-time. Nor may the maximum allowed mmap size
17041704
** exceed the compile-time maximum mmap size set by the
1705
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1706
-** If either argument to this option is negative, then that argument is
1705
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1706
+** ^If either argument to this option is negative, then that argument is
17071707
** changed to its compile-time default.
17081708
** </dl>
17091709
*/
17101710
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
17111711
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
1246812468
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
1246912469
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
1247012470
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
1247112471
#else
1247212472
#define sqlite3FkActions(a,b,c,d,e,f)
12473
- #define sqlite3FkCheck(a,b,c,d)
12473
+ #define sqlite3FkCheck(a,b,c,d,e,f)
1247412474
#define sqlite3FkDropTable(a,b,c)
12475
- #define sqlite3FkOldmask(a,b) 0
12476
- #define sqlite3FkRequired(a,b,c,d,e,f) 0
12475
+ #define sqlite3FkOldmask(a,b) 0
12476
+ #define sqlite3FkRequired(a,b,c,d) 0
1247712477
#endif
1247812478
#ifndef SQLITE_OMIT_FOREIGN_KEY
1247912479
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
1248012480
SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
1248112481
#else
@@ -14430,10 +14430,14 @@
1443014430
** is available. This routine returns 0 on success and
1443114431
** non-zero on any kind of error.
1443214432
**
1443314433
** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
1443414434
** routine will always fail.
14435
+**
14436
+** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
14437
+** library function localtime_r() is used to assist in the calculation of
14438
+** local time.
1443514439
*/
1443614440
static int osLocaltime(time_t *t, struct tm *pTm){
1443714441
int rc;
1443814442
#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
1443914443
&& (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
1448614490
memset(&sLocal, 0, sizeof(sLocal));
1448714491
1448814492
x = *p;
1448914493
computeYMD_HMS(&x);
1449014494
if( x.Y<1971 || x.Y>=2038 ){
14495
+ /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
14496
+ ** works for years between 1970 and 2037. For dates outside this range,
14497
+ ** SQLite attempts to map the year into an equivalent year within this
14498
+ ** range, do the calculation, then map the year back.
14499
+ */
1449114500
x.Y = 2000;
1449214501
x.M = 1;
1449314502
x.D = 1;
1449414503
x.h = 0;
1449514504
x.m = 0;
@@ -60299,11 +60308,13 @@
6029960308
}
6030060309
6030160310
pRec->nField = p->iVal+1;
6030260311
return &pRec->aMem[p->iVal];
6030360312
}
60304
-#endif
60313
+#else
60314
+ UNUSED_PARAMETER(p);
60315
+#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
6030560316
return sqlite3ValueNew(db);
6030660317
}
6030760318
6030860319
/*
6030960320
** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60324,11 @@
6031360324
** If pCtx is NULL and an error occurs after the sqlite3_value object
6031460325
** has been allocated, it is freed before returning. Or, if pCtx is not
6031560326
** NULL, it is assumed that the caller will free any allocated object
6031660327
** in all cases.
6031760328
*/
60318
-int valueFromExpr(
60329
+static int valueFromExpr(
6031960330
sqlite3 *db, /* The database connection */
6032060331
Expr *pExpr, /* The expression to evaluate */
6032160332
u8 enc, /* Encoding to use */
6032260333
u8 affinity, /* Affinity to use */
6032360334
sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60481,11 @@
6047060481
int nVal; /* Bytes of space required for argv[0] */
6047160482
int nRet;
6047260483
sqlite3 *db;
6047360484
u8 *aRet;
6047460485
60486
+ UNUSED_PARAMETER( argc );
6047560487
iSerial = sqlite3VdbeSerialType(argv[0], file_format);
6047660488
nSerial = sqlite3VarintLen(iSerial);
6047760489
nVal = sqlite3VdbeSerialTypeLen(iSerial);
6047860490
db = sqlite3_context_db_handle(context);
6047960491
@@ -75410,10 +75422,14 @@
7541075422
sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
7541175423
"constant between 0.0 and 1.0");
7541275424
pNC->nErr++;
7541375425
}
7541475426
}else{
75427
+ /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
75428
+ ** likelihood(X, 0.0625).
75429
+ ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for
75430
+ ** likelihood(X,0.0625). */
7541575431
pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
7541675432
}
7541775433
}
7541875434
}
7541975435
#ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81300,11 @@
8128481300
** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
8128581301
** created and used by SQLite versions 3.7.9 and later and with
8128681302
** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
8128781303
** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
8128881304
** version of sqlite_stat3 and is only available when compiled with
81289
-** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
81305
+** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
8129081306
** not possible to enable both STAT3 and STAT4 at the same time. If they
8129181307
** are both enabled, then STAT4 takes precedence.
8129281308
**
8129381309
** For most applications, sqlite_stat1 provides all the statisics required
8129481310
** for the query planner to make good choices.
@@ -81360,16 +81376,16 @@
8136081376
**
8136181377
** The sqlite_stat4 table contains multiple entries for each index.
8136281378
** The idx column names the index and the tbl column is the table of the
8136381379
** index. If the idx and tbl columns are the same, then the sample is
8136481380
** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81365
-** binary encoding of a key from the index, with the trailing rowid
81366
-** omitted. The nEq column is a list of integers. The first integer
81367
-** is the approximate number of entries in the index whose left-most
81368
-** column exactly matches the left-most column of the sample. The second
81369
-** integer in nEq is the approximate number of entries in the index where
81370
-** the first two columns match the first two columns of the sample.
81381
+** binary encoding of a key from the index. The nEq column is a
81382
+** list of integers. The first integer is the approximate number
81383
+** of entries in the index whose left-most column exactly matches
81384
+** the left-most column of the sample. The second integer in nEq
81385
+** is the approximate number of entries in the index where the
81386
+** first two columns match the first two columns of the sample.
8137181387
** And so forth. nLt is another list of integers that show the approximate
8137281388
** number of entries that are strictly less than the sample. The first
8137381389
** integer in nLt contains the number of entries in the index where the
8137481390
** left-most column is less than the left-most column of the sample.
8137581391
** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81712,11 @@
8169681712
}
8169781713
8169881714
/*
8169981715
** Copy the contents of object (*pFrom) into (*pTo).
8170081716
*/
81701
-void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81717
+static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
8170281718
pTo->iRowid = pFrom->iRowid;
8170381719
pTo->isPSample = pFrom->isPSample;
8170481720
pTo->iCol = pFrom->iCol;
8170581721
pTo->iHash = pFrom->iHash;
8170681722
memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81857,15 @@
8184181857
){
8184281858
sampleInsert(p, &p->current, 0);
8184381859
}
8184481860
}
8184581861
#endif
81862
+
81863
+#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
81864
+ UNUSED_PARAMETER( p );
81865
+ UNUSED_PARAMETER( iChng );
81866
+#endif
8184681867
}
8184781868
8184881869
/*
8184981870
** Implementation of the stat_push SQL function: stat_push(P,R,C)
8185081871
** Arguments:
@@ -81866,10 +81887,12 @@
8186681887
8186781888
/* The three function arguments */
8186881889
Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
8186981890
int iChng = sqlite3_value_int(argv[1]);
8187081891
81892
+ UNUSED_PARAMETER( argc );
81893
+ UNUSED_PARAMETER( context );
8187181894
assert( p->nCol>1 ); /* Includes rowid field */
8187281895
assert( iChng<p->nCol );
8187381896
8187481897
if( p->nRow==0 ){
8187581898
/* This is the first call to this function. Do initialization. */
@@ -82051,10 +82074,13 @@
8205182074
sqlite3_result_text(context, zRet, -1, sqlite3_free);
8205282075
}
8205382076
}
8205482077
}
8205582078
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
82079
+#ifndef SQLITE_DEBUG
82080
+ UNUSED_PARAMETER( argc );
82081
+#endif
8205682082
}
8205782083
static const FuncDef statGetFuncdef = {
8205882084
1+IsStat34, /* nArg */
8205982085
SQLITE_UTF8, /* funcFlags */
8206082086
0, /* pUserData */
@@ -82069,12 +82095,14 @@
8206982095
8207082096
static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
8207182097
assert( regOut!=regStat4 && regOut!=regStat4+1 );
8207282098
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
8207382099
sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82074
-#else
82100
+#elif SQLITE_DEBUG
8207582101
assert( iParam==STAT_GET_STAT1 );
82102
+#else
82103
+ UNUSED_PARAMETER( iParam );
8207682104
#endif
8207782105
sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
8207882106
sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
8207982107
sqlite3VdbeChangeP5(v, 1 + IsStat34);
8208082108
}
@@ -84833,11 +84861,11 @@
8483384861
*pszEst = 1; /* default size is approx 4 bytes */
8483484862
if( aff<=SQLITE_AFF_NONE ){
8483584863
if( zChar ){
8483684864
while( zChar[0] ){
8483784865
if( sqlite3Isdigit(zChar[0]) ){
84838
- int v;
84866
+ int v = 0;
8483984867
sqlite3GetInt32(zChar, &v);
8484084868
v = v/4 + 1;
8484184869
if( v>255 ) v = 255;
8484284870
*pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
8484384871
break;
@@ -91144,11 +91172,11 @@
9114491172
** generating any VDBE code. If one can be found, then jump over
9114591173
** the entire DELETE if there are no outstanding deferred constraints
9114691174
** when this statement is run. */
9114791175
FKey *p;
9114891176
for(p=pTab->pFKey; p; p=p->pNextFrom){
91149
- if( p->isDeferred ) break;
91177
+ if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
9115091178
}
9115191179
if( !p ) return;
9115291180
iSkip = sqlite3VdbeMakeLabel(v);
9115391181
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
9115491182
}
@@ -91158,15 +91186,22 @@
9115891186
pParse->disableTriggers = 0;
9115991187
9116091188
/* If the DELETE has generated immediate foreign key constraint
9116191189
** violations, halt the VDBE and return an error at this point, before
9116291190
** any modifications to the schema are made. This is because statement
91163
- ** transactions are not able to rollback schema changes. */
91164
- sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91165
- sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91166
- OE_Abort, "foreign key constraint failed", P4_STATIC
91167
- );
91191
+ ** transactions are not able to rollback schema changes.
91192
+ **
91193
+ ** If the SQLITE_DeferFKs flag is set, then this is not required, as
91194
+ ** the statement transaction will not be rolled back even if FK
91195
+ ** constraints are violated.
91196
+ */
91197
+ if( (db->flags & SQLITE_DeferFKs)==0 ){
91198
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91199
+ sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91200
+ OE_Abort, "foreign key constraint failed", P4_STATIC
91201
+ );
91202
+ }
9116891203
9116991204
if( iSkip ){
9117091205
sqlite3VdbeResolveLabel(v, iSkip);
9117191206
}
9117291207
}
@@ -95164,22 +95199,23 @@
9516495199
#define PragTyp_MMAP_SIZE 23
9516595200
#define PragTyp_PAGE_SIZE 24
9516695201
#define PragTyp_SECURE_DELETE 25
9516795202
#define PragTyp_SHRINK_MEMORY 26
9516895203
#define PragTyp_SOFT_HEAP_LIMIT 27
95169
-#define PragTyp_SYNCHRONOUS 28
95170
-#define PragTyp_TABLE_INFO 29
95171
-#define PragTyp_TEMP_STORE 30
95172
-#define PragTyp_TEMP_STORE_DIRECTORY 31
95173
-#define PragTyp_WAL_AUTOCHECKPOINT 32
95174
-#define PragTyp_WAL_CHECKPOINT 33
95175
-#define PragTyp_ACTIVATE_EXTENSIONS 34
95176
-#define PragTyp_HEXKEY 35
95177
-#define PragTyp_KEY 36
95178
-#define PragTyp_REKEY 37
95179
-#define PragTyp_LOCK_STATUS 38
95180
-#define PragTyp_PARSER_TRACE 39
95204
+#define PragTyp_STATS 28
95205
+#define PragTyp_SYNCHRONOUS 29
95206
+#define PragTyp_TABLE_INFO 30
95207
+#define PragTyp_TEMP_STORE 31
95208
+#define PragTyp_TEMP_STORE_DIRECTORY 32
95209
+#define PragTyp_WAL_AUTOCHECKPOINT 33
95210
+#define PragTyp_WAL_CHECKPOINT 34
95211
+#define PragTyp_ACTIVATE_EXTENSIONS 35
95212
+#define PragTyp_HEXKEY 36
95213
+#define PragTyp_KEY 37
95214
+#define PragTyp_REKEY 38
95215
+#define PragTyp_LOCK_STATUS 39
95216
+#define PragTyp_PARSER_TRACE 40
9518195217
#define PragFlag_NeedSchema 0x01
9518295218
static const struct sPragmaNames {
9518395219
const char *const zName; /* Name of pragma */
9518495220
u8 ePragTyp; /* PragTyp_XXX value */
9518595221
u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95502,16 @@
9546695502
#if defined(SQLITE_DEBUG)
9546795503
{ /* zName: */ "sql_trace",
9546895504
/* ePragTyp: */ PragTyp_FLAG,
9546995505
/* ePragFlag: */ 0,
9547095506
/* iArg: */ SQLITE_SqlTrace },
95507
+#endif
95508
+#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
95509
+ { /* zName: */ "stats",
95510
+ /* ePragTyp: */ PragTyp_STATS,
95511
+ /* ePragFlag: */ PragFlag_NeedSchema,
95512
+ /* iArg: */ 0 },
9547195513
#endif
9547295514
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
9547395515
{ /* zName: */ "synchronous",
9547495516
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
9547595517
/* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95570,11 @@
9552895570
{ /* zName: */ "writable_schema",
9552995571
/* ePragTyp: */ PragTyp_FLAG,
9553095572
/* ePragFlag: */ 0,
9553195573
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
9553295574
};
95533
-/* Number of pragmas: 55 on by default, 67 total. */
95575
+/* Number of pragmas: 56 on by default, 68 total. */
9553495576
/* End of the automatically generated pragma table.
9553595577
***************************************************************************/
9553695578
9553795579
/*
9553895580
** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96574,40 @@
9653296574
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
9653396575
}
9653496576
}
9653596577
}
9653696578
break;
96579
+
96580
+ case PragTyp_STATS: {
96581
+ Index *pIdx;
96582
+ HashElem *i;
96583
+ v = sqlite3GetVdbe(pParse);
96584
+ sqlite3VdbeSetNumCols(v, 4);
96585
+ pParse->nMem = 4;
96586
+ sqlite3CodeVerifySchema(pParse, iDb);
96587
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC);
96588
+ sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC);
96589
+ sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC);
96590
+ sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC);
96591
+ for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
96592
+ Table *pTab = sqliteHashData(i);
96593
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
96594
+ sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96595
+ sqlite3VdbeAddOp2(v, OP_Integer,
96596
+ (int)sqlite3LogEstToInt(pTab->szTabRow), 3);
96597
+ sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4);
96598
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96599
+ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
96600
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96601
+ sqlite3VdbeAddOp2(v, OP_Integer,
96602
+ (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
96603
+ sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4);
96604
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96605
+ }
96606
+ }
96607
+ }
96608
+ break;
9653796609
9653896610
case PragTyp_INDEX_INFO: if( zRight ){
9653996611
Index *pIdx;
9654096612
Table *pTab;
9654196613
pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96637,21 @@
9656596637
Table *pTab;
9656696638
int i;
9656796639
pTab = sqlite3FindTable(db, zRight, zDb);
9656896640
if( pTab ){
9656996641
v = sqlite3GetVdbe(pParse);
96570
- sqlite3VdbeSetNumCols(v, 4);
96571
- pParse->nMem = 4;
96642
+ sqlite3VdbeSetNumCols(v, 3);
96643
+ pParse->nMem = 3;
9657296644
sqlite3CodeVerifySchema(pParse, iDb);
9657396645
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
9657496646
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
9657596647
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96576
- sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC);
96577
- sqlite3VdbeAddOp2(v, OP_Integer, 0, 1);
96578
- sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96579
- sqlite3VdbeAddOp2(v, OP_Integer, 1, 3);
96580
- sqlite3VdbeAddOp2(v, OP_Integer,
96581
- (int)sqlite3LogEstToInt(pTab->szTabRow), 4);
96582
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96583
- for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){
96648
+ for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
9658496649
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
9658596650
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
9658696651
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96587
- sqlite3VdbeAddOp2(v, OP_Integer,
96588
- (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4);
96589
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96652
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
9659096653
}
9659196654
}
9659296655
}
9659396656
break;
9659496657
@@ -96718,12 +96781,12 @@
9671896781
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
9671996782
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
9672096783
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
9672196784
P4_TRANSIENT);
9672296785
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96723
- pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96724
- if( pParent==0 ) break;
96786
+ pParent = sqlite3FindTable(db, pFK->zTo, zDb);
96787
+ if( pParent==0 ) continue;
9672596788
pIdx = 0;
9672696789
sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
9672796790
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
9672896791
if( x==0 ){
9672996792
if( pIdx==0 ){
@@ -96736,22 +96799,24 @@
9673696799
}else{
9673796800
k = 0;
9673896801
break;
9673996802
}
9674096803
}
96804
+ assert( pParse->nErr>0 || pFK==0 );
9674196805
if( pFK ) break;
9674296806
if( pParse->nTab<i ) pParse->nTab = i;
9674396807
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
9674496808
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96745
- pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96746
- assert( pParent!=0 );
96809
+ pParent = sqlite3FindTable(db, pFK->zTo, zDb);
9674796810
pIdx = 0;
9674896811
aiCols = 0;
96749
- x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96750
- assert( x==0 );
96812
+ if( pParent ){
96813
+ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96814
+ assert( x==0 );
96815
+ }
9675196816
addrOk = sqlite3VdbeMakeLabel(v);
96752
- if( pIdx==0 ){
96817
+ if( pParent && pIdx==0 ){
9675396818
int iKey = pFK->aCol[0].iFrom;
9675496819
assert( iKey>=0 && iKey<pTab->nCol );
9675596820
if( iKey!=pTab->iPKey ){
9675696821
sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
9675796822
sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96830,19 @@
9676596830
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
9676696831
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
9676796832
}else{
9676896833
for(j=0; j<pFK->nCol; j++){
9676996834
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96770
- aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);
96835
+ aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j);
9677196836
sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
9677296837
}
96773
- sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96774
- sqlite3VdbeChangeP4(v, -1,
96775
- sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96776
- sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96838
+ if( pParent ){
96839
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96840
+ sqlite3VdbeChangeP4(v, -1,
96841
+ sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96842
+ sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96843
+ }
9677796844
}
9677896845
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
9677996846
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
9678096847
pFK->zTo, P4_TRANSIENT);
9678196848
sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108976,13 @@
108909108976
int iMin = 0; /* Smallest sample not yet tested */
108910108977
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108911108978
int iTest; /* Next sample to test */
108912108979
int res; /* Result of comparison operation */
108913108980
108981
+#ifndef SQLITE_DEBUG
108982
+ UNUSED_PARAMETER( pParse );
108983
+#endif
108914108984
assert( pRec!=0 || pParse->db->mallocFailed );
108915108985
if( pRec==0 ) return;
108916108986
iCol = pRec->nField - 1;
108917108987
assert( pIdx->nSample>0 );
108918108988
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109096,15 @@
109026109096
WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109027109097
WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109028109098
){
109029109099
int rc = SQLITE_OK;
109030109100
int nOut = pLoop->nOut;
109031
- int nEq = pLoop->u.btree.nEq;
109032109101
LogEst nNew;
109033109102
109034109103
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109035109104
Index *p = pLoop->u.btree.pIndex;
109105
+ int nEq = pLoop->u.btree.nEq;
109036109106
109037109107
if( p->nSample>0
109038109108
&& nEq==pBuilder->nRecValid
109039109109
&& nEq<p->nSampleCol
109040109110
&& OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110824,11 @@
110754110824
**
110755110825
** In the current implementation, the first extra WHERE clause term reduces
110756110826
** the number of output rows by a factor of 10 and each additional term
110757110827
** reduces the number of output rows by sqrt(2).
110758110828
*/
110759
-static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){
110829
+static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110760110830
WhereTerm *pTerm, *pX;
110761110831
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110762110832
int i, j;
110763110833
110764110834
if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +110999,12 @@
110929110999
&& !ExprHasProperty(pExpr, EP_xIsSelect) ){
110930111000
rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110931111001
}
110932111002
assert( nOut==0 || rc==SQLITE_OK );
110933111003
if( nOut ){
110934
- nOut = sqlite3LogEst(nOut);
110935
- pNew->nOut = MIN(nOut, saved_nOut);
111004
+ pNew->nOut = sqlite3LogEst(nOut);
111005
+ if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
110936111006
}
110937111007
}
110938111008
#endif
110939111009
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
110940111010
/* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111011,11 @@
110941111011
** the main table */
110942111012
pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
110943111013
}
110944111014
/* Step cost for each output row */
110945111015
pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
110946
- whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor);
111016
+ whereLoopOutputAdjust(pBuilder->pWC, pNew);
110947111017
rc = whereLoopInsert(pBuilder, pNew);
110948111018
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
110949111019
&& pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
110950111020
){
110951111021
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111215,11 @@
111145111215
pNew->iSortIdx = b ? iSortIdx : 0;
111146111216
/* TUNING: Cost of full table scan is 3*(N + log2(N)).
111147111217
** + The extra 3 factor is to encourage the use of indexed lookups
111148111218
** over full scans. FIXME */
111149111219
pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111150
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111220
+ whereLoopOutputAdjust(pWC, pNew);
111151111221
rc = whereLoopInsert(pBuilder, pNew);
111152111222
pNew->nOut = rSize;
111153111223
if( rc ) break;
111154111224
}else{
111155111225
Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111248,11 @@
111178111248
assert( b!=0 );
111179111249
/* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111180111250
** which we will simplify to just N*log2(N) */
111181111251
pNew->rRun = rSize + rLogSize;
111182111252
}
111183
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111253
+ whereLoopOutputAdjust(pWC, pNew);
111184111254
rc = whereLoopInsert(pBuilder, pNew);
111185111255
pNew->nOut = rSize;
111186111256
if( rc ) break;
111187111257
}
111188111258
}
@@ -126258,15 +126328,15 @@
126258126328
assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126259126329
assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126260126330
126261126331
while( bEof==0 ){
126262126332
int bMaxSet = 0;
126263
- sqlite3_int64 iMax; /* Largest docid for all iterators */
126333
+ sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126264126334
int i; /* Used to iterate through tokens */
126265126335
126266126336
/* Advance the iterator for each token in the phrase once. */
126267
- for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126337
+ for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
126268126338
rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126269126339
if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126270126340
iMax = a[i].iDocid;
126271126341
bMaxSet = 1;
126272126342
}
@@ -126301,11 +126371,11 @@
126301126371
char *pR = aDoclist;
126302126372
char *pOut = aDoclist;
126303126373
int nDist = p->nToken-1-i;
126304126374
int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126305126375
if( res==0 ) break;
126306
- nList = (pOut - aDoclist);
126376
+ nList = (int)(pOut - aDoclist);
126307126377
}
126308126378
}
126309126379
if( i==(p->nToken-1) ){
126310126380
pDL->iDocid = iMax;
126311126381
pDL->pList = aDoclist;
126312126382
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.1"
139 #define SQLITE_VERSION_NUMBER 3008001
140 #define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -1643,31 +1643,31 @@
1643 ** supplied by the application must not invoke any SQLite interface.
1644 ** In a multi-threaded application, the application-defined logger
1645 ** function must be threadsafe. </dd>
1646 **
1647 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648 ** <dd> This option takes a single argument of type int. If non-zero, then
1649 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1650 ** is globally disabled. If URI handling is globally enabled, all filenames
1651 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1652 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1653 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654 ** connection is opened. If it is globally disabled, filenames are
1655 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656 ** database connection is opened. By default, URI handling is globally
1657 ** disabled. The default value may be changed by compiling with the
1658 ** [SQLITE_USE_URI] symbol defined.
1659 **
1660 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661 ** <dd> This option takes a single integer argument which is interpreted as
1662 ** a boolean in order to enable or disable the use of covering indices for
1663 ** full table scans in the query optimizer. The default setting is determined
1664 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1665 ** if that compile-time option is omitted.
1666 ** The ability to disable the use of covering indices for full table scans
1667 ** is because some incorrectly coded legacy applications might malfunction
1668 ** malfunction when the optimization is enabled. Providing the ability to
1669 ** disable the optimization allows the older, buggy application code to work
1670 ** without change even with newer versions of SQLite.
1671 **
1672 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1673 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
1692 ** configuration option can be seen in the "test_sqllog.c" source file in
1693 ** the canonical SQLite source tree.</dd>
1694 **
1695 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1696 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1697 ** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1698 ** that are the default mmap size limit (the default setting for
1699 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700 ** The default setting can be overridden by each database connection using
1701 ** either the [PRAGMA mmap_size] command, or by using the
1702 ** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1703 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1704 ** exceed the compile-time maximum mmap size set by the
1705 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1706 ** If either argument to this option is negative, then that argument is
1707 ** changed to its compile-time default.
1708 ** </dl>
1709 */
1710 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1711 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
12468 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
12469 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
12470 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
12471 #else
12472 #define sqlite3FkActions(a,b,c,d,e,f)
12473 #define sqlite3FkCheck(a,b,c,d)
12474 #define sqlite3FkDropTable(a,b,c)
12475 #define sqlite3FkOldmask(a,b) 0
12476 #define sqlite3FkRequired(a,b,c,d,e,f) 0
12477 #endif
12478 #ifndef SQLITE_OMIT_FOREIGN_KEY
12479 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
12480 SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
12481 #else
@@ -14430,10 +14430,14 @@
14430 ** is available. This routine returns 0 on success and
14431 ** non-zero on any kind of error.
14432 **
14433 ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
14434 ** routine will always fail.
 
 
 
 
14435 */
14436 static int osLocaltime(time_t *t, struct tm *pTm){
14437 int rc;
14438 #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
14439 && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
14486 memset(&sLocal, 0, sizeof(sLocal));
14487
14488 x = *p;
14489 computeYMD_HMS(&x);
14490 if( x.Y<1971 || x.Y>=2038 ){
 
 
 
 
 
14491 x.Y = 2000;
14492 x.M = 1;
14493 x.D = 1;
14494 x.h = 0;
14495 x.m = 0;
@@ -60299,11 +60308,13 @@
60299 }
60300
60301 pRec->nField = p->iVal+1;
60302 return &pRec->aMem[p->iVal];
60303 }
60304 #endif
 
 
60305 return sqlite3ValueNew(db);
60306 }
60307
60308 /*
60309 ** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60324,11 @@
60313 ** If pCtx is NULL and an error occurs after the sqlite3_value object
60314 ** has been allocated, it is freed before returning. Or, if pCtx is not
60315 ** NULL, it is assumed that the caller will free any allocated object
60316 ** in all cases.
60317 */
60318 int valueFromExpr(
60319 sqlite3 *db, /* The database connection */
60320 Expr *pExpr, /* The expression to evaluate */
60321 u8 enc, /* Encoding to use */
60322 u8 affinity, /* Affinity to use */
60323 sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60481,11 @@
60470 int nVal; /* Bytes of space required for argv[0] */
60471 int nRet;
60472 sqlite3 *db;
60473 u8 *aRet;
60474
 
60475 iSerial = sqlite3VdbeSerialType(argv[0], file_format);
60476 nSerial = sqlite3VarintLen(iSerial);
60477 nVal = sqlite3VdbeSerialTypeLen(iSerial);
60478 db = sqlite3_context_db_handle(context);
60479
@@ -75410,10 +75422,14 @@
75410 sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
75411 "constant between 0.0 and 1.0");
75412 pNC->nErr++;
75413 }
75414 }else{
 
 
 
 
75415 pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
75416 }
75417 }
75418 }
75419 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81300,11 @@
81284 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
81285 ** created and used by SQLite versions 3.7.9 and later and with
81286 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
81287 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
81288 ** version of sqlite_stat3 and is only available when compiled with
81289 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
81290 ** not possible to enable both STAT3 and STAT4 at the same time. If they
81291 ** are both enabled, then STAT4 takes precedence.
81292 **
81293 ** For most applications, sqlite_stat1 provides all the statisics required
81294 ** for the query planner to make good choices.
@@ -81360,16 +81376,16 @@
81360 **
81361 ** The sqlite_stat4 table contains multiple entries for each index.
81362 ** The idx column names the index and the tbl column is the table of the
81363 ** index. If the idx and tbl columns are the same, then the sample is
81364 ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81365 ** binary encoding of a key from the index, with the trailing rowid
81366 ** omitted. The nEq column is a list of integers. The first integer
81367 ** is the approximate number of entries in the index whose left-most
81368 ** column exactly matches the left-most column of the sample. The second
81369 ** integer in nEq is the approximate number of entries in the index where
81370 ** the first two columns match the first two columns of the sample.
81371 ** And so forth. nLt is another list of integers that show the approximate
81372 ** number of entries that are strictly less than the sample. The first
81373 ** integer in nLt contains the number of entries in the index where the
81374 ** left-most column is less than the left-most column of the sample.
81375 ** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81712,11 @@
81696 }
81697
81698 /*
81699 ** Copy the contents of object (*pFrom) into (*pTo).
81700 */
81701 void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81702 pTo->iRowid = pFrom->iRowid;
81703 pTo->isPSample = pFrom->isPSample;
81704 pTo->iCol = pFrom->iCol;
81705 pTo->iHash = pFrom->iHash;
81706 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81857,15 @@
81841 ){
81842 sampleInsert(p, &p->current, 0);
81843 }
81844 }
81845 #endif
 
 
 
 
 
81846 }
81847
81848 /*
81849 ** Implementation of the stat_push SQL function: stat_push(P,R,C)
81850 ** Arguments:
@@ -81866,10 +81887,12 @@
81866
81867 /* The three function arguments */
81868 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
81869 int iChng = sqlite3_value_int(argv[1]);
81870
 
 
81871 assert( p->nCol>1 ); /* Includes rowid field */
81872 assert( iChng<p->nCol );
81873
81874 if( p->nRow==0 ){
81875 /* This is the first call to this function. Do initialization. */
@@ -82051,10 +82074,13 @@
82051 sqlite3_result_text(context, zRet, -1, sqlite3_free);
82052 }
82053 }
82054 }
82055 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
 
 
 
82056 }
82057 static const FuncDef statGetFuncdef = {
82058 1+IsStat34, /* nArg */
82059 SQLITE_UTF8, /* funcFlags */
82060 0, /* pUserData */
@@ -82069,12 +82095,14 @@
82069
82070 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
82071 assert( regOut!=regStat4 && regOut!=regStat4+1 );
82072 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82073 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82074 #else
82075 assert( iParam==STAT_GET_STAT1 );
 
 
82076 #endif
82077 sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
82078 sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
82079 sqlite3VdbeChangeP5(v, 1 + IsStat34);
82080 }
@@ -84833,11 +84861,11 @@
84833 *pszEst = 1; /* default size is approx 4 bytes */
84834 if( aff<=SQLITE_AFF_NONE ){
84835 if( zChar ){
84836 while( zChar[0] ){
84837 if( sqlite3Isdigit(zChar[0]) ){
84838 int v;
84839 sqlite3GetInt32(zChar, &v);
84840 v = v/4 + 1;
84841 if( v>255 ) v = 255;
84842 *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
84843 break;
@@ -91144,11 +91172,11 @@
91144 ** generating any VDBE code. If one can be found, then jump over
91145 ** the entire DELETE if there are no outstanding deferred constraints
91146 ** when this statement is run. */
91147 FKey *p;
91148 for(p=pTab->pFKey; p; p=p->pNextFrom){
91149 if( p->isDeferred ) break;
91150 }
91151 if( !p ) return;
91152 iSkip = sqlite3VdbeMakeLabel(v);
91153 sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
91154 }
@@ -91158,15 +91186,22 @@
91158 pParse->disableTriggers = 0;
91159
91160 /* If the DELETE has generated immediate foreign key constraint
91161 ** violations, halt the VDBE and return an error at this point, before
91162 ** any modifications to the schema are made. This is because statement
91163 ** transactions are not able to rollback schema changes. */
91164 sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91165 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91166 OE_Abort, "foreign key constraint failed", P4_STATIC
91167 );
 
 
 
 
 
 
 
91168
91169 if( iSkip ){
91170 sqlite3VdbeResolveLabel(v, iSkip);
91171 }
91172 }
@@ -95164,22 +95199,23 @@
95164 #define PragTyp_MMAP_SIZE 23
95165 #define PragTyp_PAGE_SIZE 24
95166 #define PragTyp_SECURE_DELETE 25
95167 #define PragTyp_SHRINK_MEMORY 26
95168 #define PragTyp_SOFT_HEAP_LIMIT 27
95169 #define PragTyp_SYNCHRONOUS 28
95170 #define PragTyp_TABLE_INFO 29
95171 #define PragTyp_TEMP_STORE 30
95172 #define PragTyp_TEMP_STORE_DIRECTORY 31
95173 #define PragTyp_WAL_AUTOCHECKPOINT 32
95174 #define PragTyp_WAL_CHECKPOINT 33
95175 #define PragTyp_ACTIVATE_EXTENSIONS 34
95176 #define PragTyp_HEXKEY 35
95177 #define PragTyp_KEY 36
95178 #define PragTyp_REKEY 37
95179 #define PragTyp_LOCK_STATUS 38
95180 #define PragTyp_PARSER_TRACE 39
 
95181 #define PragFlag_NeedSchema 0x01
95182 static const struct sPragmaNames {
95183 const char *const zName; /* Name of pragma */
95184 u8 ePragTyp; /* PragTyp_XXX value */
95185 u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95502,16 @@
95466 #if defined(SQLITE_DEBUG)
95467 { /* zName: */ "sql_trace",
95468 /* ePragTyp: */ PragTyp_FLAG,
95469 /* ePragFlag: */ 0,
95470 /* iArg: */ SQLITE_SqlTrace },
 
 
 
 
 
 
95471 #endif
95472 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
95473 { /* zName: */ "synchronous",
95474 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
95475 /* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95570,11 @@
95528 { /* zName: */ "writable_schema",
95529 /* ePragTyp: */ PragTyp_FLAG,
95530 /* ePragFlag: */ 0,
95531 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
95532 };
95533 /* Number of pragmas: 55 on by default, 67 total. */
95534 /* End of the automatically generated pragma table.
95535 ***************************************************************************/
95536
95537 /*
95538 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96574,40 @@
96532 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
96533 }
96534 }
96535 }
96536 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96537
96538 case PragTyp_INDEX_INFO: if( zRight ){
96539 Index *pIdx;
96540 Table *pTab;
96541 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96637,21 @@
96565 Table *pTab;
96566 int i;
96567 pTab = sqlite3FindTable(db, zRight, zDb);
96568 if( pTab ){
96569 v = sqlite3GetVdbe(pParse);
96570 sqlite3VdbeSetNumCols(v, 4);
96571 pParse->nMem = 4;
96572 sqlite3CodeVerifySchema(pParse, iDb);
96573 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
96574 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
96575 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96576 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC);
96577 sqlite3VdbeAddOp2(v, OP_Integer, 0, 1);
96578 sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96579 sqlite3VdbeAddOp2(v, OP_Integer, 1, 3);
96580 sqlite3VdbeAddOp2(v, OP_Integer,
96581 (int)sqlite3LogEstToInt(pTab->szTabRow), 4);
96582 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96583 for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){
96584 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
96585 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96586 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96587 sqlite3VdbeAddOp2(v, OP_Integer,
96588 (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4);
96589 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96590 }
96591 }
96592 }
96593 break;
96594
@@ -96718,12 +96781,12 @@
96718 if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
96719 sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
96720 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
96721 P4_TRANSIENT);
96722 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96723 pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96724 if( pParent==0 ) break;
96725 pIdx = 0;
96726 sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
96727 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
96728 if( x==0 ){
96729 if( pIdx==0 ){
@@ -96736,22 +96799,24 @@
96736 }else{
96737 k = 0;
96738 break;
96739 }
96740 }
 
96741 if( pFK ) break;
96742 if( pParse->nTab<i ) pParse->nTab = i;
96743 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
96744 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96745 pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96746 assert( pParent!=0 );
96747 pIdx = 0;
96748 aiCols = 0;
96749 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96750 assert( x==0 );
 
 
96751 addrOk = sqlite3VdbeMakeLabel(v);
96752 if( pIdx==0 ){
96753 int iKey = pFK->aCol[0].iFrom;
96754 assert( iKey>=0 && iKey<pTab->nCol );
96755 if( iKey!=pTab->iPKey ){
96756 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
96757 sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96830,19 @@
96765 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
96766 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
96767 }else{
96768 for(j=0; j<pFK->nCol; j++){
96769 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96770 aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);
96771 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
96772 }
96773 sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96774 sqlite3VdbeChangeP4(v, -1,
96775 sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96776 sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
 
 
96777 }
96778 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
96779 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
96780 pFK->zTo, P4_TRANSIENT);
96781 sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108976,13 @@
108909 int iMin = 0; /* Smallest sample not yet tested */
108910 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108911 int iTest; /* Next sample to test */
108912 int res; /* Result of comparison operation */
108913
 
 
 
108914 assert( pRec!=0 || pParse->db->mallocFailed );
108915 if( pRec==0 ) return;
108916 iCol = pRec->nField - 1;
108917 assert( pIdx->nSample>0 );
108918 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109096,15 @@
109026 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109027 WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109028 ){
109029 int rc = SQLITE_OK;
109030 int nOut = pLoop->nOut;
109031 int nEq = pLoop->u.btree.nEq;
109032 LogEst nNew;
109033
109034 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109035 Index *p = pLoop->u.btree.pIndex;
 
109036
109037 if( p->nSample>0
109038 && nEq==pBuilder->nRecValid
109039 && nEq<p->nSampleCol
109040 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110824,11 @@
110754 **
110755 ** In the current implementation, the first extra WHERE clause term reduces
110756 ** the number of output rows by a factor of 10 and each additional term
110757 ** reduces the number of output rows by sqrt(2).
110758 */
110759 static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){
110760 WhereTerm *pTerm, *pX;
110761 Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110762 int i, j;
110763
110764 if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +110999,12 @@
110929 && !ExprHasProperty(pExpr, EP_xIsSelect) ){
110930 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110931 }
110932 assert( nOut==0 || rc==SQLITE_OK );
110933 if( nOut ){
110934 nOut = sqlite3LogEst(nOut);
110935 pNew->nOut = MIN(nOut, saved_nOut);
110936 }
110937 }
110938 #endif
110939 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
110940 /* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111011,11 @@
110941 ** the main table */
110942 pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
110943 }
110944 /* Step cost for each output row */
110945 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
110946 whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor);
110947 rc = whereLoopInsert(pBuilder, pNew);
110948 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
110949 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
110950 ){
110951 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111215,11 @@
111145 pNew->iSortIdx = b ? iSortIdx : 0;
111146 /* TUNING: Cost of full table scan is 3*(N + log2(N)).
111147 ** + The extra 3 factor is to encourage the use of indexed lookups
111148 ** over full scans. FIXME */
111149 pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111150 whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111151 rc = whereLoopInsert(pBuilder, pNew);
111152 pNew->nOut = rSize;
111153 if( rc ) break;
111154 }else{
111155 Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111248,11 @@
111178 assert( b!=0 );
111179 /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111180 ** which we will simplify to just N*log2(N) */
111181 pNew->rRun = rSize + rLogSize;
111182 }
111183 whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111184 rc = whereLoopInsert(pBuilder, pNew);
111185 pNew->nOut = rSize;
111186 if( rc ) break;
111187 }
111188 }
@@ -126258,15 +126328,15 @@
126258 assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126259 assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126260
126261 while( bEof==0 ){
126262 int bMaxSet = 0;
126263 sqlite3_int64 iMax; /* Largest docid for all iterators */
126264 int i; /* Used to iterate through tokens */
126265
126266 /* Advance the iterator for each token in the phrase once. */
126267 for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126268 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126269 if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126270 iMax = a[i].iDocid;
126271 bMaxSet = 1;
126272 }
@@ -126301,11 +126371,11 @@
126301 char *pR = aDoclist;
126302 char *pOut = aDoclist;
126303 int nDist = p->nToken-1-i;
126304 int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126305 if( res==0 ) break;
126306 nList = (pOut - aDoclist);
126307 }
126308 }
126309 if( i==(p->nToken-1) ){
126310 pDL->iDocid = iMax;
126311 pDL->pList = aDoclist;
126312
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.1"
139 #define SQLITE_VERSION_NUMBER 3008001
140 #define SQLITE_SOURCE_ID "2013-10-14 21:14:42 9f66dd7e3790c04f0ab724419f5381bd21f9ebad"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -1643,31 +1643,31 @@
1643 ** supplied by the application must not invoke any SQLite interface.
1644 ** In a multi-threaded application, the application-defined logger
1645 ** function must be threadsafe. </dd>
1646 **
1647 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648 ** <dd>^(This option takes a single argument of type int. If non-zero, then
1649 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1650 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
1651 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1652 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1653 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654 ** connection is opened. ^If it is globally disabled, filenames are
1655 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656 ** database connection is opened. ^(By default, URI handling is globally
1657 ** disabled. The default value may be changed by compiling with the
1658 ** [SQLITE_USE_URI] symbol defined.)^
1659 **
1660 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661 ** <dd>^This option takes a single integer argument which is interpreted as
1662 ** a boolean in order to enable or disable the use of covering indices for
1663 ** full table scans in the query optimizer. ^The default setting is determined
1664 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1665 ** if that compile-time option is omitted.
1666 ** The ability to disable the use of covering indices for full table scans
1667 ** is because some incorrectly coded legacy applications might malfunction
1668 ** when the optimization is enabled. Providing the ability to
1669 ** disable the optimization allows the older, buggy application code to work
1670 ** without change even with newer versions of SQLite.
1671 **
1672 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1673 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
1692 ** configuration option can be seen in the "test_sqllog.c" source file in
1693 ** the canonical SQLite source tree.</dd>
1694 **
1695 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1696 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1697 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1698 ** that are the default mmap size limit (the default setting for
1699 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700 ** ^The default setting can be overridden by each database connection using
1701 ** either the [PRAGMA mmap_size] command, or by using the
1702 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1703 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1704 ** exceed the compile-time maximum mmap size set by the
1705 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1706 ** ^If either argument to this option is negative, then that argument is
1707 ** changed to its compile-time default.
1708 ** </dl>
1709 */
1710 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1711 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
12468 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
12469 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
12470 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
12471 #else
12472 #define sqlite3FkActions(a,b,c,d,e,f)
12473 #define sqlite3FkCheck(a,b,c,d,e,f)
12474 #define sqlite3FkDropTable(a,b,c)
12475 #define sqlite3FkOldmask(a,b) 0
12476 #define sqlite3FkRequired(a,b,c,d) 0
12477 #endif
12478 #ifndef SQLITE_OMIT_FOREIGN_KEY
12479 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
12480 SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
12481 #else
@@ -14430,10 +14430,14 @@
14430 ** is available. This routine returns 0 on success and
14431 ** non-zero on any kind of error.
14432 **
14433 ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
14434 ** routine will always fail.
14435 **
14436 ** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
14437 ** library function localtime_r() is used to assist in the calculation of
14438 ** local time.
14439 */
14440 static int osLocaltime(time_t *t, struct tm *pTm){
14441 int rc;
14442 #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
14443 && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
14490 memset(&sLocal, 0, sizeof(sLocal));
14491
14492 x = *p;
14493 computeYMD_HMS(&x);
14494 if( x.Y<1971 || x.Y>=2038 ){
14495 /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
14496 ** works for years between 1970 and 2037. For dates outside this range,
14497 ** SQLite attempts to map the year into an equivalent year within this
14498 ** range, do the calculation, then map the year back.
14499 */
14500 x.Y = 2000;
14501 x.M = 1;
14502 x.D = 1;
14503 x.h = 0;
14504 x.m = 0;
@@ -60299,11 +60308,13 @@
60308 }
60309
60310 pRec->nField = p->iVal+1;
60311 return &pRec->aMem[p->iVal];
60312 }
60313 #else
60314 UNUSED_PARAMETER(p);
60315 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
60316 return sqlite3ValueNew(db);
60317 }
60318
60319 /*
60320 ** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60324,11 @@
60324 ** If pCtx is NULL and an error occurs after the sqlite3_value object
60325 ** has been allocated, it is freed before returning. Or, if pCtx is not
60326 ** NULL, it is assumed that the caller will free any allocated object
60327 ** in all cases.
60328 */
60329 static int valueFromExpr(
60330 sqlite3 *db, /* The database connection */
60331 Expr *pExpr, /* The expression to evaluate */
60332 u8 enc, /* Encoding to use */
60333 u8 affinity, /* Affinity to use */
60334 sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60481,11 @@
60481 int nVal; /* Bytes of space required for argv[0] */
60482 int nRet;
60483 sqlite3 *db;
60484 u8 *aRet;
60485
60486 UNUSED_PARAMETER( argc );
60487 iSerial = sqlite3VdbeSerialType(argv[0], file_format);
60488 nSerial = sqlite3VarintLen(iSerial);
60489 nVal = sqlite3VdbeSerialTypeLen(iSerial);
60490 db = sqlite3_context_db_handle(context);
60491
@@ -75410,10 +75422,14 @@
75422 sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
75423 "constant between 0.0 and 1.0");
75424 pNC->nErr++;
75425 }
75426 }else{
75427 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
75428 ** likelihood(X, 0.0625).
75429 ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for
75430 ** likelihood(X,0.0625). */
75431 pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
75432 }
75433 }
75434 }
75435 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81300,11 @@
81300 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
81301 ** created and used by SQLite versions 3.7.9 and later and with
81302 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
81303 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
81304 ** version of sqlite_stat3 and is only available when compiled with
81305 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
81306 ** not possible to enable both STAT3 and STAT4 at the same time. If they
81307 ** are both enabled, then STAT4 takes precedence.
81308 **
81309 ** For most applications, sqlite_stat1 provides all the statisics required
81310 ** for the query planner to make good choices.
@@ -81360,16 +81376,16 @@
81376 **
81377 ** The sqlite_stat4 table contains multiple entries for each index.
81378 ** The idx column names the index and the tbl column is the table of the
81379 ** index. If the idx and tbl columns are the same, then the sample is
81380 ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81381 ** binary encoding of a key from the index. The nEq column is a
81382 ** list of integers. The first integer is the approximate number
81383 ** of entries in the index whose left-most column exactly matches
81384 ** the left-most column of the sample. The second integer in nEq
81385 ** is the approximate number of entries in the index where the
81386 ** first two columns match the first two columns of the sample.
81387 ** And so forth. nLt is another list of integers that show the approximate
81388 ** number of entries that are strictly less than the sample. The first
81389 ** integer in nLt contains the number of entries in the index where the
81390 ** left-most column is less than the left-most column of the sample.
81391 ** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81712,11 @@
81712 }
81713
81714 /*
81715 ** Copy the contents of object (*pFrom) into (*pTo).
81716 */
81717 static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81718 pTo->iRowid = pFrom->iRowid;
81719 pTo->isPSample = pFrom->isPSample;
81720 pTo->iCol = pFrom->iCol;
81721 pTo->iHash = pFrom->iHash;
81722 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81857,15 @@
81857 ){
81858 sampleInsert(p, &p->current, 0);
81859 }
81860 }
81861 #endif
81862
81863 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
81864 UNUSED_PARAMETER( p );
81865 UNUSED_PARAMETER( iChng );
81866 #endif
81867 }
81868
81869 /*
81870 ** Implementation of the stat_push SQL function: stat_push(P,R,C)
81871 ** Arguments:
@@ -81866,10 +81887,12 @@
81887
81888 /* The three function arguments */
81889 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
81890 int iChng = sqlite3_value_int(argv[1]);
81891
81892 UNUSED_PARAMETER( argc );
81893 UNUSED_PARAMETER( context );
81894 assert( p->nCol>1 ); /* Includes rowid field */
81895 assert( iChng<p->nCol );
81896
81897 if( p->nRow==0 ){
81898 /* This is the first call to this function. Do initialization. */
@@ -82051,10 +82074,13 @@
82074 sqlite3_result_text(context, zRet, -1, sqlite3_free);
82075 }
82076 }
82077 }
82078 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
82079 #ifndef SQLITE_DEBUG
82080 UNUSED_PARAMETER( argc );
82081 #endif
82082 }
82083 static const FuncDef statGetFuncdef = {
82084 1+IsStat34, /* nArg */
82085 SQLITE_UTF8, /* funcFlags */
82086 0, /* pUserData */
@@ -82069,12 +82095,14 @@
82095
82096 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
82097 assert( regOut!=regStat4 && regOut!=regStat4+1 );
82098 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82099 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82100 #elif SQLITE_DEBUG
82101 assert( iParam==STAT_GET_STAT1 );
82102 #else
82103 UNUSED_PARAMETER( iParam );
82104 #endif
82105 sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
82106 sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
82107 sqlite3VdbeChangeP5(v, 1 + IsStat34);
82108 }
@@ -84833,11 +84861,11 @@
84861 *pszEst = 1; /* default size is approx 4 bytes */
84862 if( aff<=SQLITE_AFF_NONE ){
84863 if( zChar ){
84864 while( zChar[0] ){
84865 if( sqlite3Isdigit(zChar[0]) ){
84866 int v = 0;
84867 sqlite3GetInt32(zChar, &v);
84868 v = v/4 + 1;
84869 if( v>255 ) v = 255;
84870 *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
84871 break;
@@ -91144,11 +91172,11 @@
91172 ** generating any VDBE code. If one can be found, then jump over
91173 ** the entire DELETE if there are no outstanding deferred constraints
91174 ** when this statement is run. */
91175 FKey *p;
91176 for(p=pTab->pFKey; p; p=p->pNextFrom){
91177 if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
91178 }
91179 if( !p ) return;
91180 iSkip = sqlite3VdbeMakeLabel(v);
91181 sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
91182 }
@@ -91158,15 +91186,22 @@
91186 pParse->disableTriggers = 0;
91187
91188 /* If the DELETE has generated immediate foreign key constraint
91189 ** violations, halt the VDBE and return an error at this point, before
91190 ** any modifications to the schema are made. This is because statement
91191 ** transactions are not able to rollback schema changes.
91192 **
91193 ** If the SQLITE_DeferFKs flag is set, then this is not required, as
91194 ** the statement transaction will not be rolled back even if FK
91195 ** constraints are violated.
91196 */
91197 if( (db->flags & SQLITE_DeferFKs)==0 ){
91198 sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91199 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91200 OE_Abort, "foreign key constraint failed", P4_STATIC
91201 );
91202 }
91203
91204 if( iSkip ){
91205 sqlite3VdbeResolveLabel(v, iSkip);
91206 }
91207 }
@@ -95164,22 +95199,23 @@
95199 #define PragTyp_MMAP_SIZE 23
95200 #define PragTyp_PAGE_SIZE 24
95201 #define PragTyp_SECURE_DELETE 25
95202 #define PragTyp_SHRINK_MEMORY 26
95203 #define PragTyp_SOFT_HEAP_LIMIT 27
95204 #define PragTyp_STATS 28
95205 #define PragTyp_SYNCHRONOUS 29
95206 #define PragTyp_TABLE_INFO 30
95207 #define PragTyp_TEMP_STORE 31
95208 #define PragTyp_TEMP_STORE_DIRECTORY 32
95209 #define PragTyp_WAL_AUTOCHECKPOINT 33
95210 #define PragTyp_WAL_CHECKPOINT 34
95211 #define PragTyp_ACTIVATE_EXTENSIONS 35
95212 #define PragTyp_HEXKEY 36
95213 #define PragTyp_KEY 37
95214 #define PragTyp_REKEY 38
95215 #define PragTyp_LOCK_STATUS 39
95216 #define PragTyp_PARSER_TRACE 40
95217 #define PragFlag_NeedSchema 0x01
95218 static const struct sPragmaNames {
95219 const char *const zName; /* Name of pragma */
95220 u8 ePragTyp; /* PragTyp_XXX value */
95221 u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95502,16 @@
95502 #if defined(SQLITE_DEBUG)
95503 { /* zName: */ "sql_trace",
95504 /* ePragTyp: */ PragTyp_FLAG,
95505 /* ePragFlag: */ 0,
95506 /* iArg: */ SQLITE_SqlTrace },
95507 #endif
95508 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
95509 { /* zName: */ "stats",
95510 /* ePragTyp: */ PragTyp_STATS,
95511 /* ePragFlag: */ PragFlag_NeedSchema,
95512 /* iArg: */ 0 },
95513 #endif
95514 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
95515 { /* zName: */ "synchronous",
95516 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
95517 /* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95570,11 @@
95570 { /* zName: */ "writable_schema",
95571 /* ePragTyp: */ PragTyp_FLAG,
95572 /* ePragFlag: */ 0,
95573 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
95574 };
95575 /* Number of pragmas: 56 on by default, 68 total. */
95576 /* End of the automatically generated pragma table.
95577 ***************************************************************************/
95578
95579 /*
95580 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96574,40 @@
96574 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
96575 }
96576 }
96577 }
96578 break;
96579
96580 case PragTyp_STATS: {
96581 Index *pIdx;
96582 HashElem *i;
96583 v = sqlite3GetVdbe(pParse);
96584 sqlite3VdbeSetNumCols(v, 4);
96585 pParse->nMem = 4;
96586 sqlite3CodeVerifySchema(pParse, iDb);
96587 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC);
96588 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC);
96589 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC);
96590 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC);
96591 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
96592 Table *pTab = sqliteHashData(i);
96593 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
96594 sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96595 sqlite3VdbeAddOp2(v, OP_Integer,
96596 (int)sqlite3LogEstToInt(pTab->szTabRow), 3);
96597 sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4);
96598 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96599 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
96600 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96601 sqlite3VdbeAddOp2(v, OP_Integer,
96602 (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
96603 sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4);
96604 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96605 }
96606 }
96607 }
96608 break;
96609
96610 case PragTyp_INDEX_INFO: if( zRight ){
96611 Index *pIdx;
96612 Table *pTab;
96613 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96637,21 @@
96637 Table *pTab;
96638 int i;
96639 pTab = sqlite3FindTable(db, zRight, zDb);
96640 if( pTab ){
96641 v = sqlite3GetVdbe(pParse);
96642 sqlite3VdbeSetNumCols(v, 3);
96643 pParse->nMem = 3;
96644 sqlite3CodeVerifySchema(pParse, iDb);
96645 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
96646 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
96647 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96648 for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
 
 
 
 
 
 
 
96649 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
96650 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96651 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96652 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
 
 
96653 }
96654 }
96655 }
96656 break;
96657
@@ -96718,12 +96781,12 @@
96781 if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
96782 sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
96783 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
96784 P4_TRANSIENT);
96785 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96786 pParent = sqlite3FindTable(db, pFK->zTo, zDb);
96787 if( pParent==0 ) continue;
96788 pIdx = 0;
96789 sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
96790 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
96791 if( x==0 ){
96792 if( pIdx==0 ){
@@ -96736,22 +96799,24 @@
96799 }else{
96800 k = 0;
96801 break;
96802 }
96803 }
96804 assert( pParse->nErr>0 || pFK==0 );
96805 if( pFK ) break;
96806 if( pParse->nTab<i ) pParse->nTab = i;
96807 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
96808 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96809 pParent = sqlite3FindTable(db, pFK->zTo, zDb);
 
96810 pIdx = 0;
96811 aiCols = 0;
96812 if( pParent ){
96813 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96814 assert( x==0 );
96815 }
96816 addrOk = sqlite3VdbeMakeLabel(v);
96817 if( pParent && pIdx==0 ){
96818 int iKey = pFK->aCol[0].iFrom;
96819 assert( iKey>=0 && iKey<pTab->nCol );
96820 if( iKey!=pTab->iPKey ){
96821 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
96822 sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96830,19 @@
96830 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
96831 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
96832 }else{
96833 for(j=0; j<pFK->nCol; j++){
96834 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96835 aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j);
96836 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
96837 }
96838 if( pParent ){
96839 sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96840 sqlite3VdbeChangeP4(v, -1,
96841 sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96842 sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96843 }
96844 }
96845 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
96846 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
96847 pFK->zTo, P4_TRANSIENT);
96848 sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108976,13 @@
108976 int iMin = 0; /* Smallest sample not yet tested */
108977 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108978 int iTest; /* Next sample to test */
108979 int res; /* Result of comparison operation */
108980
108981 #ifndef SQLITE_DEBUG
108982 UNUSED_PARAMETER( pParse );
108983 #endif
108984 assert( pRec!=0 || pParse->db->mallocFailed );
108985 if( pRec==0 ) return;
108986 iCol = pRec->nField - 1;
108987 assert( pIdx->nSample>0 );
108988 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109096,15 @@
109096 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109097 WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109098 ){
109099 int rc = SQLITE_OK;
109100 int nOut = pLoop->nOut;
 
109101 LogEst nNew;
109102
109103 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109104 Index *p = pLoop->u.btree.pIndex;
109105 int nEq = pLoop->u.btree.nEq;
109106
109107 if( p->nSample>0
109108 && nEq==pBuilder->nRecValid
109109 && nEq<p->nSampleCol
109110 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110824,11 @@
110824 **
110825 ** In the current implementation, the first extra WHERE clause term reduces
110826 ** the number of output rows by a factor of 10 and each additional term
110827 ** reduces the number of output rows by sqrt(2).
110828 */
110829 static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110830 WhereTerm *pTerm, *pX;
110831 Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110832 int i, j;
110833
110834 if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +110999,12 @@
110999 && !ExprHasProperty(pExpr, EP_xIsSelect) ){
111000 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
111001 }
111002 assert( nOut==0 || rc==SQLITE_OK );
111003 if( nOut ){
111004 pNew->nOut = sqlite3LogEst(nOut);
111005 if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
111006 }
111007 }
111008 #endif
111009 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
111010 /* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111011,11 @@
111011 ** the main table */
111012 pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
111013 }
111014 /* Step cost for each output row */
111015 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
111016 whereLoopOutputAdjust(pBuilder->pWC, pNew);
111017 rc = whereLoopInsert(pBuilder, pNew);
111018 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
111019 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
111020 ){
111021 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111215,11 @@
111215 pNew->iSortIdx = b ? iSortIdx : 0;
111216 /* TUNING: Cost of full table scan is 3*(N + log2(N)).
111217 ** + The extra 3 factor is to encourage the use of indexed lookups
111218 ** over full scans. FIXME */
111219 pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111220 whereLoopOutputAdjust(pWC, pNew);
111221 rc = whereLoopInsert(pBuilder, pNew);
111222 pNew->nOut = rSize;
111223 if( rc ) break;
111224 }else{
111225 Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111248,11 @@
111248 assert( b!=0 );
111249 /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111250 ** which we will simplify to just N*log2(N) */
111251 pNew->rRun = rSize + rLogSize;
111252 }
111253 whereLoopOutputAdjust(pWC, pNew);
111254 rc = whereLoopInsert(pBuilder, pNew);
111255 pNew->nOut = rSize;
111256 if( rc ) break;
111257 }
111258 }
@@ -126258,15 +126328,15 @@
126328 assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126329 assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126330
126331 while( bEof==0 ){
126332 int bMaxSet = 0;
126333 sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126334 int i; /* Used to iterate through tokens */
126335
126336 /* Advance the iterator for each token in the phrase once. */
126337 for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
126338 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126339 if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126340 iMax = a[i].iDocid;
126341 bMaxSet = 1;
126342 }
@@ -126301,11 +126371,11 @@
126371 char *pR = aDoclist;
126372 char *pOut = aDoclist;
126373 int nDist = p->nToken-1-i;
126374 int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126375 if( res==0 ) break;
126376 nList = (int)(pOut - aDoclist);
126377 }
126378 }
126379 if( i==(p->nToken-1) ){
126380 pDL->iDocid = iMax;
126381 pDL->pList = aDoclist;
126382
+14 -14
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.1"
111111
#define SQLITE_VERSION_NUMBER 3008001
112
-#define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
112
+#define SQLITE_SOURCE_ID "2013-10-14 21:14:42 9f66dd7e3790c04f0ab724419f5381bd21f9ebad"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -1615,31 +1615,31 @@
16151615
** supplied by the application must not invoke any SQLite interface.
16161616
** In a multi-threaded application, the application-defined logger
16171617
** function must be threadsafe. </dd>
16181618
**
16191619
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620
-** <dd> This option takes a single argument of type int. If non-zero, then
1620
+** <dd>^(This option takes a single argument of type int. If non-zero, then
16211621
** URI handling is globally enabled. If the parameter is zero, then URI handling
1622
-** is globally disabled. If URI handling is globally enabled, all filenames
1622
+** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
16231623
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
16241624
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
16251625
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626
-** connection is opened. If it is globally disabled, filenames are
1626
+** connection is opened. ^If it is globally disabled, filenames are
16271627
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628
-** database connection is opened. By default, URI handling is globally
1628
+** database connection is opened. ^(By default, URI handling is globally
16291629
** disabled. The default value may be changed by compiling with the
1630
-** [SQLITE_USE_URI] symbol defined.
1630
+** [SQLITE_USE_URI] symbol defined.)^
16311631
**
16321632
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633
-** <dd> This option takes a single integer argument which is interpreted as
1633
+** <dd>^This option takes a single integer argument which is interpreted as
16341634
** a boolean in order to enable or disable the use of covering indices for
1635
-** full table scans in the query optimizer. The default setting is determined
1635
+** full table scans in the query optimizer. ^The default setting is determined
16361636
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
16371637
** if that compile-time option is omitted.
16381638
** The ability to disable the use of covering indices for full table scans
16391639
** is because some incorrectly coded legacy applications might malfunction
1640
-** malfunction when the optimization is enabled. Providing the ability to
1640
+** when the optimization is enabled. Providing the ability to
16411641
** disable the optimization allows the older, buggy application code to work
16421642
** without change even with newer versions of SQLite.
16431643
**
16441644
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
16451645
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
16641664
** configuration option can be seen in the "test_sqllog.c" source file in
16651665
** the canonical SQLite source tree.</dd>
16661666
**
16671667
** [[SQLITE_CONFIG_MMAP_SIZE]]
16681668
** <dt>SQLITE_CONFIG_MMAP_SIZE
1669
-** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1669
+** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
16701670
** that are the default mmap size limit (the default setting for
16711671
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672
-** The default setting can be overridden by each database connection using
1672
+** ^The default setting can be overridden by each database connection using
16731673
** either the [PRAGMA mmap_size] command, or by using the
1674
-** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1674
+** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
16751675
** cannot be changed at run-time. Nor may the maximum allowed mmap size
16761676
** exceed the compile-time maximum mmap size set by the
1677
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1678
-** If either argument to this option is negative, then that argument is
1677
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1678
+** ^If either argument to this option is negative, then that argument is
16791679
** changed to its compile-time default.
16801680
** </dl>
16811681
*/
16821682
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
16831683
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
16841684
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.1"
111 #define SQLITE_VERSION_NUMBER 3008001
112 #define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1615,31 +1615,31 @@
1615 ** supplied by the application must not invoke any SQLite interface.
1616 ** In a multi-threaded application, the application-defined logger
1617 ** function must be threadsafe. </dd>
1618 **
1619 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620 ** <dd> This option takes a single argument of type int. If non-zero, then
1621 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1622 ** is globally disabled. If URI handling is globally enabled, all filenames
1623 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1624 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1625 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626 ** connection is opened. If it is globally disabled, filenames are
1627 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628 ** database connection is opened. By default, URI handling is globally
1629 ** disabled. The default value may be changed by compiling with the
1630 ** [SQLITE_USE_URI] symbol defined.
1631 **
1632 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633 ** <dd> This option takes a single integer argument which is interpreted as
1634 ** a boolean in order to enable or disable the use of covering indices for
1635 ** full table scans in the query optimizer. The default setting is determined
1636 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1637 ** if that compile-time option is omitted.
1638 ** The ability to disable the use of covering indices for full table scans
1639 ** is because some incorrectly coded legacy applications might malfunction
1640 ** malfunction when the optimization is enabled. Providing the ability to
1641 ** disable the optimization allows the older, buggy application code to work
1642 ** without change even with newer versions of SQLite.
1643 **
1644 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1645 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
1664 ** configuration option can be seen in the "test_sqllog.c" source file in
1665 ** the canonical SQLite source tree.</dd>
1666 **
1667 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1668 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1669 ** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1670 ** that are the default mmap size limit (the default setting for
1671 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672 ** The default setting can be overridden by each database connection using
1673 ** either the [PRAGMA mmap_size] command, or by using the
1674 ** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1675 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1676 ** exceed the compile-time maximum mmap size set by the
1677 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1678 ** If either argument to this option is negative, then that argument is
1679 ** changed to its compile-time default.
1680 ** </dl>
1681 */
1682 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1683 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1684
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.1"
111 #define SQLITE_VERSION_NUMBER 3008001
112 #define SQLITE_SOURCE_ID "2013-10-14 21:14:42 9f66dd7e3790c04f0ab724419f5381bd21f9ebad"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1615,31 +1615,31 @@
1615 ** supplied by the application must not invoke any SQLite interface.
1616 ** In a multi-threaded application, the application-defined logger
1617 ** function must be threadsafe. </dd>
1618 **
1619 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620 ** <dd>^(This option takes a single argument of type int. If non-zero, then
1621 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1622 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
1623 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1624 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1625 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626 ** connection is opened. ^If it is globally disabled, filenames are
1627 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628 ** database connection is opened. ^(By default, URI handling is globally
1629 ** disabled. The default value may be changed by compiling with the
1630 ** [SQLITE_USE_URI] symbol defined.)^
1631 **
1632 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633 ** <dd>^This option takes a single integer argument which is interpreted as
1634 ** a boolean in order to enable or disable the use of covering indices for
1635 ** full table scans in the query optimizer. ^The default setting is determined
1636 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1637 ** if that compile-time option is omitted.
1638 ** The ability to disable the use of covering indices for full table scans
1639 ** is because some incorrectly coded legacy applications might malfunction
1640 ** when the optimization is enabled. Providing the ability to
1641 ** disable the optimization allows the older, buggy application code to work
1642 ** without change even with newer versions of SQLite.
1643 **
1644 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1645 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
1664 ** configuration option can be seen in the "test_sqllog.c" source file in
1665 ** the canonical SQLite source tree.</dd>
1666 **
1667 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1668 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1669 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1670 ** that are the default mmap size limit (the default setting for
1671 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672 ** ^The default setting can be overridden by each database connection using
1673 ** either the [PRAGMA mmap_size] command, or by using the
1674 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1675 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1676 ** exceed the compile-time maximum mmap size set by the
1677 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1678 ** ^If either argument to this option is negative, then that argument is
1679 ** changed to its compile-time default.
1680 ** </dl>
1681 */
1682 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1683 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1684
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
5555
<b>fossil clone</b> <i>URL repository-filename</i>
5656
</blockquote>
5757
5858
<p>The <i>URL</i> above is the http URL for the fossil repository
5959
you want to clone, and it may include a "user:password" part, e.g.
60
- <tt>http://drh:[email protected]/fossil</tt>. You can
60
+ <tt>http://user:[email protected]/fossil</tt>. You can
6161
call the new repository anything you want - there are no naming
6262
restrictions. As an example, you can clone the fossil repository
6363
this way:</p>
6464
6565
<blockquote>
6666
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
55 <b>fossil clone</b> <i>URL repository-filename</i>
56 </blockquote>
57
58 <p>The <i>URL</i> above is the http URL for the fossil repository
59 you want to clone, and it may include a "user:password" part, e.g.
60 <tt>http://drh:[email protected]/fossil</tt>. You can
61 call the new repository anything you want - there are no naming
62 restrictions. As an example, you can clone the fossil repository
63 this way:</p>
64
65 <blockquote>
66
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
55 <b>fossil clone</b> <i>URL repository-filename</i>
56 </blockquote>
57
58 <p>The <i>URL</i> above is the http URL for the fossil repository
59 you want to clone, and it may include a "user:password" part, e.g.
60 <tt>http://user:[email protected]/fossil</tt>. You can
61 call the new repository anything you want - there are no naming
62 restrictions. As an example, you can clone the fossil repository
63 this way:</p>
64
65 <blockquote>
66

Keyboard Shortcuts

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