Fossil SCM

Bring in the latest SQLite 3.8.1 beta for the purpose of pre-release testing of SQLite.

drh 2013-10-14 13:30 trunk
Commit 089dad49e24d195bc3d8145acc538f6abe2e3f11
3 files changed +1 -1 +126 -60 +14 -14
+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
+126 -60
--- 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 13:21:00 1660efbe46439734c7dc1674994ceb86a9b41d1a"
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 */
@@ -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
@@ -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
@@ -108909,10 +108972,13 @@
108909108972
int iMin = 0; /* Smallest sample not yet tested */
108910108973
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108911108974
int iTest; /* Next sample to test */
108912108975
int res; /* Result of comparison operation */
108913108976
108977
+#ifndef SQLITE_DEBUG
108978
+ UNUSED_PARAMETER( pParse );
108979
+#endif
108914108980
assert( pRec!=0 || pParse->db->mallocFailed );
108915108981
if( pRec==0 ) return;
108916108982
iCol = pRec->nField - 1;
108917108983
assert( pIdx->nSample>0 );
108918108984
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109092,15 @@
109026109092
WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109027109093
WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109028109094
){
109029109095
int rc = SQLITE_OK;
109030109096
int nOut = pLoop->nOut;
109031
- int nEq = pLoop->u.btree.nEq;
109032109097
LogEst nNew;
109033109098
109034109099
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109035109100
Index *p = pLoop->u.btree.pIndex;
109101
+ int nEq = pLoop->u.btree.nEq;
109036109102
109037109103
if( p->nSample>0
109038109104
&& nEq==pBuilder->nRecValid
109039109105
&& nEq<p->nSampleCol
109040109106
&& OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110820,11 @@
110754110820
**
110755110821
** In the current implementation, the first extra WHERE clause term reduces
110756110822
** the number of output rows by a factor of 10 and each additional term
110757110823
** reduces the number of output rows by sqrt(2).
110758110824
*/
110759
-static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){
110825
+static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110760110826
WhereTerm *pTerm, *pX;
110761110827
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110762110828
int i, j;
110763110829
110764110830
if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +110995,12 @@
110929110995
&& !ExprHasProperty(pExpr, EP_xIsSelect) ){
110930110996
rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110931110997
}
110932110998
assert( nOut==0 || rc==SQLITE_OK );
110933110999
if( nOut ){
110934
- nOut = sqlite3LogEst(nOut);
110935
- pNew->nOut = MIN(nOut, saved_nOut);
111000
+ pNew->nOut = sqlite3LogEst(nOut);
111001
+ if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
110936111002
}
110937111003
}
110938111004
#endif
110939111005
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
110940111006
/* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111007,11 @@
110941111007
** the main table */
110942111008
pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
110943111009
}
110944111010
/* Step cost for each output row */
110945111011
pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
110946
- whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor);
111012
+ whereLoopOutputAdjust(pBuilder->pWC, pNew);
110947111013
rc = whereLoopInsert(pBuilder, pNew);
110948111014
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
110949111015
&& pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
110950111016
){
110951111017
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111211,11 @@
111145111211
pNew->iSortIdx = b ? iSortIdx : 0;
111146111212
/* TUNING: Cost of full table scan is 3*(N + log2(N)).
111147111213
** + The extra 3 factor is to encourage the use of indexed lookups
111148111214
** over full scans. FIXME */
111149111215
pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111150
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111216
+ whereLoopOutputAdjust(pWC, pNew);
111151111217
rc = whereLoopInsert(pBuilder, pNew);
111152111218
pNew->nOut = rSize;
111153111219
if( rc ) break;
111154111220
}else{
111155111221
Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111244,11 @@
111178111244
assert( b!=0 );
111179111245
/* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111180111246
** which we will simplify to just N*log2(N) */
111181111247
pNew->rRun = rSize + rLogSize;
111182111248
}
111183
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111249
+ whereLoopOutputAdjust(pWC, pNew);
111184111250
rc = whereLoopInsert(pBuilder, pNew);
111185111251
pNew->nOut = rSize;
111186111252
if( rc ) break;
111187111253
}
111188111254
}
@@ -126258,11 +126324,11 @@
126258126324
assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126259126325
assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126260126326
126261126327
while( bEof==0 ){
126262126328
int bMaxSet = 0;
126263
- sqlite3_int64 iMax; /* Largest docid for all iterators */
126329
+ sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126264126330
int i; /* Used to iterate through tokens */
126265126331
126266126332
/* Advance the iterator for each token in the phrase once. */
126267126333
for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126268126334
rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
@@ -126301,11 +126367,11 @@
126301126367
char *pR = aDoclist;
126302126368
char *pOut = aDoclist;
126303126369
int nDist = p->nToken-1-i;
126304126370
int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126305126371
if( res==0 ) break;
126306
- nList = (pOut - aDoclist);
126372
+ nList = (int)(pOut - aDoclist);
126307126373
}
126308126374
}
126309126375
if( i==(p->nToken-1) ){
126310126376
pDL->iDocid = iMax;
126311126377
pDL->pList = aDoclist;
126312126378
--- 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 */
@@ -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
@@ -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
@@ -108909,10 +108972,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 +109092,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 +110820,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 +110995,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 +111007,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 +111211,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 +111244,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,11 +126324,11 @@
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);
@@ -126301,11 +126367,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 13:21:00 1660efbe46439734c7dc1674994ceb86a9b41d1a"
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 */
@@ -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
@@ -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
@@ -108909,10 +108972,13 @@
108972 int iMin = 0; /* Smallest sample not yet tested */
108973 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108974 int iTest; /* Next sample to test */
108975 int res; /* Result of comparison operation */
108976
108977 #ifndef SQLITE_DEBUG
108978 UNUSED_PARAMETER( pParse );
108979 #endif
108980 assert( pRec!=0 || pParse->db->mallocFailed );
108981 if( pRec==0 ) return;
108982 iCol = pRec->nField - 1;
108983 assert( pIdx->nSample>0 );
108984 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109092,15 @@
109092 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109093 WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109094 ){
109095 int rc = SQLITE_OK;
109096 int nOut = pLoop->nOut;
 
109097 LogEst nNew;
109098
109099 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109100 Index *p = pLoop->u.btree.pIndex;
109101 int nEq = pLoop->u.btree.nEq;
109102
109103 if( p->nSample>0
109104 && nEq==pBuilder->nRecValid
109105 && nEq<p->nSampleCol
109106 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110820,11 @@
110820 **
110821 ** In the current implementation, the first extra WHERE clause term reduces
110822 ** the number of output rows by a factor of 10 and each additional term
110823 ** reduces the number of output rows by sqrt(2).
110824 */
110825 static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110826 WhereTerm *pTerm, *pX;
110827 Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110828 int i, j;
110829
110830 if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +110995,12 @@
110995 && !ExprHasProperty(pExpr, EP_xIsSelect) ){
110996 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110997 }
110998 assert( nOut==0 || rc==SQLITE_OK );
110999 if( nOut ){
111000 pNew->nOut = sqlite3LogEst(nOut);
111001 if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
111002 }
111003 }
111004 #endif
111005 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
111006 /* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111007,11 @@
111007 ** the main table */
111008 pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
111009 }
111010 /* Step cost for each output row */
111011 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
111012 whereLoopOutputAdjust(pBuilder->pWC, pNew);
111013 rc = whereLoopInsert(pBuilder, pNew);
111014 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
111015 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
111016 ){
111017 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111211,11 @@
111211 pNew->iSortIdx = b ? iSortIdx : 0;
111212 /* TUNING: Cost of full table scan is 3*(N + log2(N)).
111213 ** + The extra 3 factor is to encourage the use of indexed lookups
111214 ** over full scans. FIXME */
111215 pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111216 whereLoopOutputAdjust(pWC, pNew);
111217 rc = whereLoopInsert(pBuilder, pNew);
111218 pNew->nOut = rSize;
111219 if( rc ) break;
111220 }else{
111221 Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111244,11 @@
111244 assert( b!=0 );
111245 /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111246 ** which we will simplify to just N*log2(N) */
111247 pNew->rRun = rSize + rLogSize;
111248 }
111249 whereLoopOutputAdjust(pWC, pNew);
111250 rc = whereLoopInsert(pBuilder, pNew);
111251 pNew->nOut = rSize;
111252 if( rc ) break;
111253 }
111254 }
@@ -126258,11 +126324,11 @@
126324 assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126325 assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126326
126327 while( bEof==0 ){
126328 int bMaxSet = 0;
126329 sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126330 int i; /* Used to iterate through tokens */
126331
126332 /* Advance the iterator for each token in the phrase once. */
126333 for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126334 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
@@ -126301,11 +126367,11 @@
126367 char *pR = aDoclist;
126368 char *pOut = aDoclist;
126369 int nDist = p->nToken-1-i;
126370 int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126371 if( res==0 ) break;
126372 nList = (int)(pOut - aDoclist);
126373 }
126374 }
126375 if( i==(p->nToken-1) ){
126376 pDL->iDocid = iMax;
126377 pDL->pList = aDoclist;
126378
+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 13:21:00 1660efbe46439734c7dc1674994ceb86a9b41d1a"
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 13:21:00 1660efbe46439734c7dc1674994ceb86a9b41d1a"
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

Keyboard Shortcuts

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