Fossil SCM

Update to the latest 3.8.0 alpha version of SQLite.

drh 2013-07-09 11:52 trunk
Commit 5ea03d389d4507567b1b0436d76a4057f50f088c
3 files changed +3 -3 +36 -20 +1 -1
+3 -3
--- src/shell.c
+++ src/shell.c
@@ -1736,15 +1736,15 @@
17361736
p->cTerm = EOF;
17371737
break;
17381738
}
17391739
csv_append_char(p, c);
17401740
pc = c;
1741
- }
1741
+ }
17421742
}else{
1743
- csv_append_char(p, c);
1744
- while( (c = fgetc(p->in))!=EOF && c!=cSep && c!='\n' ){
1743
+ while( c!=EOF && c!=cSep && c!='\n' ){
17451744
csv_append_char(p, c);
1745
+ c = fgetc(p->in);
17461746
}
17471747
if( c=='\n' ){
17481748
p->nLine++;
17491749
if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--;
17501750
}
17511751
--- src/shell.c
+++ src/shell.c
@@ -1736,15 +1736,15 @@
1736 p->cTerm = EOF;
1737 break;
1738 }
1739 csv_append_char(p, c);
1740 pc = c;
1741 }
1742 }else{
1743 csv_append_char(p, c);
1744 while( (c = fgetc(p->in))!=EOF && c!=cSep && c!='\n' ){
1745 csv_append_char(p, c);
 
1746 }
1747 if( c=='\n' ){
1748 p->nLine++;
1749 if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--;
1750 }
1751
--- src/shell.c
+++ src/shell.c
@@ -1736,15 +1736,15 @@
1736 p->cTerm = EOF;
1737 break;
1738 }
1739 csv_append_char(p, c);
1740 pc = c;
1741 }
1742 }else{
1743 while( c!=EOF && c!=cSep && c!='\n' ){
 
1744 csv_append_char(p, c);
1745 c = fgetc(p->in);
1746 }
1747 if( c=='\n' ){
1748 p->nLine++;
1749 if( p->n>1 && p->z[p->n-1]=='\r' ) p->n--;
1750 }
1751
+36 -20
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670670
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671671
** [sqlite_version()] and [sqlite_source_id()].
672672
*/
673673
#define SQLITE_VERSION "3.8.0"
674674
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
675
+#define SQLITE_SOURCE_ID "2013-07-09 03:04:32 52a49cbc1621094b2fe2b021209b768d29e0426b"
676676
677677
/*
678678
** CAPI3REF: Run-Time Library Version Numbers
679679
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680680
**
@@ -19954,12 +19954,12 @@
1995419954
if( xtype==etEXP ){
1995519955
e2 = 0;
1995619956
}else{
1995719957
e2 = exp;
1995819958
}
19959
- if( e2+precision+width > etBUFSIZE - 15 ){
19960
- bufpt = zExtra = sqlite3Malloc( e2+precision+width+15 );
19959
+ if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
19960
+ bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
1996119961
if( bufpt==0 ){
1996219962
pAccum->mallocFailed = 1;
1996319963
return;
1996419964
}
1996519965
}
@@ -40075,10 +40075,11 @@
4007540075
assert( !MEMDB );
4007640076
pager_reset(pPager);
4007740077
pPager->changeCountDone = pPager->tempFile;
4007840078
pPager->eState = PAGER_OPEN;
4007940079
pPager->errCode = SQLITE_OK;
40080
+ if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);
4008040081
}
4008140082
4008240083
pPager->journalOff = 0;
4008340084
pPager->journalHdr = 0;
4008440085
pPager->setMaster = 0;
@@ -41641,14 +41642,14 @@
4164141642
** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.
4164241643
*/
4164341644
static void pagerFixMaplimit(Pager *pPager){
4164441645
#if SQLITE_MAX_MMAP_SIZE>0
4164541646
sqlite3_file *fd = pPager->fd;
41646
- if( isOpen(fd) ){
41647
+ if( isOpen(fd) && fd->pMethods->iVersion>=3 ){
4164741648
sqlite3_int64 sz;
41648
- pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->szMmap>0;
4164941649
sz = pPager->szMmap;
41650
+ pPager->bUseFetch = (sz>0);
4165041651
sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);
4165141652
}
4165241653
#endif
4165341654
}
4165441655
@@ -60297,11 +60298,11 @@
6029760298
p->bIsReader = 1;
6029860299
}else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
6029960300
p->bIsReader = 1;
6030060301
}else if( opcode==OP_Vacuum
6030160302
|| opcode==OP_JournalMode
60302
-#ifndef SQLITE_OMIT_VIRTUALTABLE
60303
+#ifndef SQLITE_OMIT_WAL
6030360304
|| opcode==OP_Checkpoint
6030460305
#endif
6030560306
){
6030660307
p->readOnly = 0;
6030760308
p->bIsReader = 1;
@@ -104504,11 +104505,11 @@
104504104505
104505104506
/*
104506104507
** Each instance of this object holds a sequence of WhereLoop objects
104507104508
** that implement some or all of a query plan.
104508104509
**
104509
-** Think of each WhereLoop objects as a node in a graph, which arcs
104510
+** Think of each WhereLoop object as a node in a graph with arcs
104510104511
** showing dependences and costs for travelling between nodes. (That is
104511104512
** not a completely accurate description because WhereLoop costs are a
104512104513
** vector, not a scalar, and because dependences are many-to-one, not
104513104514
** one-to-one as are graph nodes. But it is a useful visualization aid.)
104514104515
** Then a WherePath object is a path through the graph that visits some
@@ -104774,11 +104775,11 @@
104774104775
/*
104775104776
** These are definitions of bits in the WhereLoop.wsFlags field.
104776104777
** The particular combination of bits in each WhereLoop help to
104777104778
** determine the algorithm that WhereLoop represents.
104778104779
*/
104779
-#define WHERE_COLUMN_EQ 0x00000001 /* x=EXPR or x IN (...) or x IS NULL */
104780
+#define WHERE_COLUMN_EQ 0x00000001 /* x=EXPR */
104780104781
#define WHERE_COLUMN_RANGE 0x00000002 /* x<EXPR and/or x>EXPR */
104781104782
#define WHERE_COLUMN_IN 0x00000004 /* x IN (...) */
104782104783
#define WHERE_COLUMN_NULL 0x00000008 /* x IS NULL */
104783104784
#define WHERE_CONSTRAINT 0x0000000f /* Any of the WHERE_COLUMN_xxx values */
104784104785
#define WHERE_TOP_LIMIT 0x00000010 /* x<EXPR or x<=EXPR constraint */
@@ -105167,11 +105168,11 @@
105167105168
/*
105168105169
** Advance to the next WhereTerm that matches according to the criteria
105169105170
** established when the pScan object was initialized by whereScanInit().
105170105171
** Return NULL if there are no more matching WhereTerms.
105171105172
*/
105172
-WhereTerm *whereScanNext(WhereScan *pScan){
105173
+static WhereTerm *whereScanNext(WhereScan *pScan){
105173105174
int iCur; /* The cursor on the LHS of the term */
105174105175
int iColumn; /* The column on the LHS of the term. -1 for IPK */
105175105176
Expr *pX; /* An expression being tested */
105176105177
WhereClause *pWC; /* Shorthand for pScan->pWC */
105177105178
WhereTerm *pTerm; /* The term being tested */
@@ -105254,11 +105255,11 @@
105254105255
** but is enough to handle most commonly occurring SQL statements.
105255105256
**
105256105257
** If X is not the INTEGER PRIMARY KEY then X must be compatible with
105257105258
** index pIdx.
105258105259
*/
105259
-WhereTerm *whereScanInit(
105260
+static WhereTerm *whereScanInit(
105260105261
WhereScan *pScan, /* The WhereScan object being initialized */
105261105262
WhereClause *pWC, /* The WHERE clause to be scanned */
105262105263
int iCur, /* Cursor to scan for */
105263105264
int iColumn, /* Column to scan for */
105264105265
u32 opMask, /* Operator(s) to scan for */
@@ -107680,14 +107681,15 @@
107680107681
};
107681107682
assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107682107683
assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107683107684
assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107684107685
107686
+ assert( (pStart->wtFlags & TERM_VNULL)==0 );
107685107687
testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107686107688
pX = pStart->pExpr;
107687107689
assert( pX!=0 );
107688
- assert( pStart->leftCursor==iCur );
107690
+ testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107689107691
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107690107692
sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
107691107693
VdbeComment((v, "pk"));
107692107694
sqlite3ExprCacheAffinityChange(pParse, r1, 1);
107693107695
sqlite3ReleaseTempReg(pParse, rTemp);
@@ -107697,11 +107699,12 @@
107697107699
}
107698107700
if( pEnd ){
107699107701
Expr *pX;
107700107702
pX = pEnd->pExpr;
107701107703
assert( pX!=0 );
107702
- assert( pEnd->leftCursor==iCur );
107704
+ assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107705
+ testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107703107706
testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107704107707
memEndValue = ++pParse->nMem;
107705107708
sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107706107709
if( pX->op==TK_LT || pX->op==TK_GT ){
107707107710
testOp = bRev ? OP_Le : OP_Ge;
@@ -108232,10 +108235,11 @@
108232108235
WhereTerm *pAlt;
108233108236
Expr sEq;
108234108237
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108235108238
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108236108239
if( pTerm->leftCursor!=iCur ) continue;
108240
+ if( pLevel->iLeftJoin ) continue;
108237108241
pE = pTerm->pExpr;
108238108242
assert( !ExprHasProperty(pE, EP_FromJoin) );
108239108243
assert( (pTerm->prereqRight & newNotReady)!=0 );
108240108244
pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0);
108241108245
if( pAlt==0 ) continue;
@@ -108626,10 +108630,15 @@
108626108630
pNew->rSetup = 0;
108627108631
rLogSize = estLog(whereCost(pProbe->aiRowEst[0]));
108628108632
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
108629108633
int nIn = 0;
108630108634
if( pTerm->prereqRight & pNew->maskSelf ) continue;
108635
+#ifdef SQLITE_ENABLE_STAT3
108636
+ if( (pTerm->wtFlags & TERM_VNULL)!=0 && pSrc->pTab->aCol[iCol].notNull ){
108637
+ continue; /* skip IS NOT NULL constraints on a NOT NULL column */
108638
+ }
108639
+#endif
108631108640
pNew->wsFlags = saved_wsFlags;
108632108641
pNew->u.btree.nEq = saved_nEq;
108633108642
pNew->nLTerm = saved_nLTerm;
108634108643
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
108635108644
pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -108773,11 +108782,11 @@
108773108782
return m;
108774108783
}
108775108784
108776108785
108777108786
/*
108778
-** Add all WhereLoop objects a single table of the join were the table
108787
+** Add all WhereLoop objects for a single table of the join where the table
108779108788
** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
108780108789
** a b-tree table, not a virtual table.
108781108790
*/
108782108791
static int whereLoopAddBtree(
108783108792
WhereLoopBuilder *pBuilder, /* WHERE clause information */
@@ -109237,16 +109246,23 @@
109237109246
}
109238109247
109239109248
/*
109240109249
** Examine a WherePath (with the addition of the extra WhereLoop of the 5th
109241109250
** parameters) to see if it outputs rows in the requested ORDER BY
109242
-** (or GROUP BY) without requiring a separate source operation. Return:
109251
+** (or GROUP BY) without requiring a separate sort operation. Return:
109243109252
**
109244109253
** 0: ORDER BY is not satisfied. Sorting required
109245109254
** 1: ORDER BY is satisfied. Omit sorting
109246109255
** -1: Unknown at this time
109247109256
**
109257
+** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as
109258
+** strict. With GROUP BY and DISTINCT the only requirement is that
109259
+** equivalent rows appear immediately adjacent to one another. GROUP BY
109260
+** and DISTINT do not require rows to appear in any particular order as long
109261
+** as equivelent rows are grouped together. Thus for GROUP BY and DISTINCT
109262
+** the pOrderBy terms can be matched in any order. With ORDER BY, the
109263
+** pOrderBy terms must be matched in strict left-to-right order.
109248109264
*/
109249109265
static int wherePathSatisfiesOrderBy(
109250109266
WhereInfo *pWInfo, /* The WHERE clause */
109251109267
ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
109252109268
WherePath *pPath, /* The WherePath to check */
@@ -109490,11 +109506,11 @@
109490109506
}
109491109507
#endif
109492109508
109493109509
109494109510
/*
109495
-** Given the list of WhereLoop objects on pWInfo->pLoops, this routine
109511
+** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
109496109512
** attempts to find the lowest cost path that visits each WhereLoop
109497109513
** once. This path is then loaded into the pWInfo->a[].pWLoop fields.
109498109514
**
109499109515
** Assume that the total number of output rows that will need to be sorted
109500109516
** will be nRowEst (in the 10*log2 representation). Or, ignore sorting
@@ -109907,11 +109923,12 @@
109907109923
** fi
109908109924
** end
109909109925
**
109910109926
** ORDER BY CLAUSE PROCESSING
109911109927
**
109912
-** pOrderBy is a pointer to the ORDER BY clause of a SELECT statement,
109928
+** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause
109929
+** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
109913109930
** if there is one. If there is no ORDER BY clause or if this routine
109914109931
** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
109915109932
*/
109916109933
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
109917109934
Parse *pParse, /* The parser context */
@@ -109999,10 +110016,11 @@
109999110016
*/
110000110017
initMaskSet(pMaskSet);
110001110018
whereClauseInit(&pWInfo->sWC, pWInfo);
110002110019
sqlite3ExprCodeConstants(pParse, pWhere);
110003110020
whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110021
+ sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110004110022
110005110023
/* Special case: a WHERE clause that is constant. Evaluate the
110006110024
** expression and either jump over all of the code or fall thru.
110007110025
*/
110008110026
if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
@@ -110193,17 +110211,15 @@
110193110211
}
110194110212
110195110213
/* Open all tables in the pTabList and any indices selected for
110196110214
** searching those tables.
110197110215
*/
110198
- sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110199110216
notReady = ~(Bitmask)0;
110200110217
for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){
110201110218
Table *pTab; /* Table to open */
110202110219
int iDb; /* Index of database containing table/index */
110203110220
struct SrcList_item *pTabItem;
110204
- WhereLoop *pLoop;
110205110221
110206110222
pTabItem = &pTabList->a[pLevel->iFrom];
110207110223
pTab = pTabItem->pTab;
110208110224
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
110209110225
pLoop = pLevel->pWLoop;
@@ -120698,11 +120714,11 @@
120698120714
nName = (int)strlen(argv[2]) + 1;
120699120715
120700120716
nByte = sizeof(const char *) * (argc-2);
120701120717
aCol = (const char **)sqlite3_malloc(nByte);
120702120718
if( aCol ){
120703
- memset(aCol, 0, nByte);
120719
+ memset((void*)aCol, 0, nByte);
120704120720
azNotindexed = (char **)sqlite3_malloc(nByte);
120705120721
}
120706120722
if( azNotindexed ){
120707120723
memset(azNotindexed, 0, nByte);
120708120724
}
@@ -120949,11 +120965,11 @@
120949120965
assert( zCsr <= &((char *)p)[nByte] );
120950120966
}
120951120967
120952120968
/* Fill in the abNotindexed array */
120953120969
for(iCol=0; iCol<nCol; iCol++){
120954
- int n = strlen(p->azColumn[iCol]);
120970
+ int n = (int)strlen(p->azColumn[iCol]);
120955120971
for(i=0; i<nNotindexed; i++){
120956120972
char *zNot = azNotindexed[i];
120957120973
if( zNot && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) ){
120958120974
p->abNotindexed[iCol] = 1;
120959120975
sqlite3_free(zNot);
120960120976
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -19954,12 +19954,12 @@
19954 if( xtype==etEXP ){
19955 e2 = 0;
19956 }else{
19957 e2 = exp;
19958 }
19959 if( e2+precision+width > etBUFSIZE - 15 ){
19960 bufpt = zExtra = sqlite3Malloc( e2+precision+width+15 );
19961 if( bufpt==0 ){
19962 pAccum->mallocFailed = 1;
19963 return;
19964 }
19965 }
@@ -40075,10 +40075,11 @@
40075 assert( !MEMDB );
40076 pager_reset(pPager);
40077 pPager->changeCountDone = pPager->tempFile;
40078 pPager->eState = PAGER_OPEN;
40079 pPager->errCode = SQLITE_OK;
 
40080 }
40081
40082 pPager->journalOff = 0;
40083 pPager->journalHdr = 0;
40084 pPager->setMaster = 0;
@@ -41641,14 +41642,14 @@
41641 ** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.
41642 */
41643 static void pagerFixMaplimit(Pager *pPager){
41644 #if SQLITE_MAX_MMAP_SIZE>0
41645 sqlite3_file *fd = pPager->fd;
41646 if( isOpen(fd) ){
41647 sqlite3_int64 sz;
41648 pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->szMmap>0;
41649 sz = pPager->szMmap;
 
41650 sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);
41651 }
41652 #endif
41653 }
41654
@@ -60297,11 +60298,11 @@
60297 p->bIsReader = 1;
60298 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60299 p->bIsReader = 1;
60300 }else if( opcode==OP_Vacuum
60301 || opcode==OP_JournalMode
60302 #ifndef SQLITE_OMIT_VIRTUALTABLE
60303 || opcode==OP_Checkpoint
60304 #endif
60305 ){
60306 p->readOnly = 0;
60307 p->bIsReader = 1;
@@ -104504,11 +104505,11 @@
104504
104505 /*
104506 ** Each instance of this object holds a sequence of WhereLoop objects
104507 ** that implement some or all of a query plan.
104508 **
104509 ** Think of each WhereLoop objects as a node in a graph, which arcs
104510 ** showing dependences and costs for travelling between nodes. (That is
104511 ** not a completely accurate description because WhereLoop costs are a
104512 ** vector, not a scalar, and because dependences are many-to-one, not
104513 ** one-to-one as are graph nodes. But it is a useful visualization aid.)
104514 ** Then a WherePath object is a path through the graph that visits some
@@ -104774,11 +104775,11 @@
104774 /*
104775 ** These are definitions of bits in the WhereLoop.wsFlags field.
104776 ** The particular combination of bits in each WhereLoop help to
104777 ** determine the algorithm that WhereLoop represents.
104778 */
104779 #define WHERE_COLUMN_EQ 0x00000001 /* x=EXPR or x IN (...) or x IS NULL */
104780 #define WHERE_COLUMN_RANGE 0x00000002 /* x<EXPR and/or x>EXPR */
104781 #define WHERE_COLUMN_IN 0x00000004 /* x IN (...) */
104782 #define WHERE_COLUMN_NULL 0x00000008 /* x IS NULL */
104783 #define WHERE_CONSTRAINT 0x0000000f /* Any of the WHERE_COLUMN_xxx values */
104784 #define WHERE_TOP_LIMIT 0x00000010 /* x<EXPR or x<=EXPR constraint */
@@ -105167,11 +105168,11 @@
105167 /*
105168 ** Advance to the next WhereTerm that matches according to the criteria
105169 ** established when the pScan object was initialized by whereScanInit().
105170 ** Return NULL if there are no more matching WhereTerms.
105171 */
105172 WhereTerm *whereScanNext(WhereScan *pScan){
105173 int iCur; /* The cursor on the LHS of the term */
105174 int iColumn; /* The column on the LHS of the term. -1 for IPK */
105175 Expr *pX; /* An expression being tested */
105176 WhereClause *pWC; /* Shorthand for pScan->pWC */
105177 WhereTerm *pTerm; /* The term being tested */
@@ -105254,11 +105255,11 @@
105254 ** but is enough to handle most commonly occurring SQL statements.
105255 **
105256 ** If X is not the INTEGER PRIMARY KEY then X must be compatible with
105257 ** index pIdx.
105258 */
105259 WhereTerm *whereScanInit(
105260 WhereScan *pScan, /* The WhereScan object being initialized */
105261 WhereClause *pWC, /* The WHERE clause to be scanned */
105262 int iCur, /* Cursor to scan for */
105263 int iColumn, /* Column to scan for */
105264 u32 opMask, /* Operator(s) to scan for */
@@ -107680,14 +107681,15 @@
107680 };
107681 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107682 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107683 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107684
 
107685 testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107686 pX = pStart->pExpr;
107687 assert( pX!=0 );
107688 assert( pStart->leftCursor==iCur );
107689 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107690 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
107691 VdbeComment((v, "pk"));
107692 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
107693 sqlite3ReleaseTempReg(pParse, rTemp);
@@ -107697,11 +107699,12 @@
107697 }
107698 if( pEnd ){
107699 Expr *pX;
107700 pX = pEnd->pExpr;
107701 assert( pX!=0 );
107702 assert( pEnd->leftCursor==iCur );
 
107703 testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107704 memEndValue = ++pParse->nMem;
107705 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107706 if( pX->op==TK_LT || pX->op==TK_GT ){
107707 testOp = bRev ? OP_Le : OP_Ge;
@@ -108232,10 +108235,11 @@
108232 WhereTerm *pAlt;
108233 Expr sEq;
108234 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108235 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108236 if( pTerm->leftCursor!=iCur ) continue;
 
108237 pE = pTerm->pExpr;
108238 assert( !ExprHasProperty(pE, EP_FromJoin) );
108239 assert( (pTerm->prereqRight & newNotReady)!=0 );
108240 pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0);
108241 if( pAlt==0 ) continue;
@@ -108626,10 +108630,15 @@
108626 pNew->rSetup = 0;
108627 rLogSize = estLog(whereCost(pProbe->aiRowEst[0]));
108628 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
108629 int nIn = 0;
108630 if( pTerm->prereqRight & pNew->maskSelf ) continue;
 
 
 
 
 
108631 pNew->wsFlags = saved_wsFlags;
108632 pNew->u.btree.nEq = saved_nEq;
108633 pNew->nLTerm = saved_nLTerm;
108634 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
108635 pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -108773,11 +108782,11 @@
108773 return m;
108774 }
108775
108776
108777 /*
108778 ** Add all WhereLoop objects a single table of the join were the table
108779 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
108780 ** a b-tree table, not a virtual table.
108781 */
108782 static int whereLoopAddBtree(
108783 WhereLoopBuilder *pBuilder, /* WHERE clause information */
@@ -109237,16 +109246,23 @@
109237 }
109238
109239 /*
109240 ** Examine a WherePath (with the addition of the extra WhereLoop of the 5th
109241 ** parameters) to see if it outputs rows in the requested ORDER BY
109242 ** (or GROUP BY) without requiring a separate source operation. Return:
109243 **
109244 ** 0: ORDER BY is not satisfied. Sorting required
109245 ** 1: ORDER BY is satisfied. Omit sorting
109246 ** -1: Unknown at this time
109247 **
 
 
 
 
 
 
 
109248 */
109249 static int wherePathSatisfiesOrderBy(
109250 WhereInfo *pWInfo, /* The WHERE clause */
109251 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
109252 WherePath *pPath, /* The WherePath to check */
@@ -109490,11 +109506,11 @@
109490 }
109491 #endif
109492
109493
109494 /*
109495 ** Given the list of WhereLoop objects on pWInfo->pLoops, this routine
109496 ** attempts to find the lowest cost path that visits each WhereLoop
109497 ** once. This path is then loaded into the pWInfo->a[].pWLoop fields.
109498 **
109499 ** Assume that the total number of output rows that will need to be sorted
109500 ** will be nRowEst (in the 10*log2 representation). Or, ignore sorting
@@ -109907,11 +109923,12 @@
109907 ** fi
109908 ** end
109909 **
109910 ** ORDER BY CLAUSE PROCESSING
109911 **
109912 ** pOrderBy is a pointer to the ORDER BY clause of a SELECT statement,
 
109913 ** if there is one. If there is no ORDER BY clause or if this routine
109914 ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
109915 */
109916 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
109917 Parse *pParse, /* The parser context */
@@ -109999,10 +110016,11 @@
109999 */
110000 initMaskSet(pMaskSet);
110001 whereClauseInit(&pWInfo->sWC, pWInfo);
110002 sqlite3ExprCodeConstants(pParse, pWhere);
110003 whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
 
110004
110005 /* Special case: a WHERE clause that is constant. Evaluate the
110006 ** expression and either jump over all of the code or fall thru.
110007 */
110008 if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
@@ -110193,17 +110211,15 @@
110193 }
110194
110195 /* Open all tables in the pTabList and any indices selected for
110196 ** searching those tables.
110197 */
110198 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110199 notReady = ~(Bitmask)0;
110200 for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){
110201 Table *pTab; /* Table to open */
110202 int iDb; /* Index of database containing table/index */
110203 struct SrcList_item *pTabItem;
110204 WhereLoop *pLoop;
110205
110206 pTabItem = &pTabList->a[pLevel->iFrom];
110207 pTab = pTabItem->pTab;
110208 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
110209 pLoop = pLevel->pWLoop;
@@ -120698,11 +120714,11 @@
120698 nName = (int)strlen(argv[2]) + 1;
120699
120700 nByte = sizeof(const char *) * (argc-2);
120701 aCol = (const char **)sqlite3_malloc(nByte);
120702 if( aCol ){
120703 memset(aCol, 0, nByte);
120704 azNotindexed = (char **)sqlite3_malloc(nByte);
120705 }
120706 if( azNotindexed ){
120707 memset(azNotindexed, 0, nByte);
120708 }
@@ -120949,11 +120965,11 @@
120949 assert( zCsr <= &((char *)p)[nByte] );
120950 }
120951
120952 /* Fill in the abNotindexed array */
120953 for(iCol=0; iCol<nCol; iCol++){
120954 int n = strlen(p->azColumn[iCol]);
120955 for(i=0; i<nNotindexed; i++){
120956 char *zNot = azNotindexed[i];
120957 if( zNot && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) ){
120958 p->abNotindexed[iCol] = 1;
120959 sqlite3_free(zNot);
120960
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-09 03:04:32 52a49cbc1621094b2fe2b021209b768d29e0426b"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -19954,12 +19954,12 @@
19954 if( xtype==etEXP ){
19955 e2 = 0;
19956 }else{
19957 e2 = exp;
19958 }
19959 if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
19960 bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
19961 if( bufpt==0 ){
19962 pAccum->mallocFailed = 1;
19963 return;
19964 }
19965 }
@@ -40075,10 +40075,11 @@
40075 assert( !MEMDB );
40076 pager_reset(pPager);
40077 pPager->changeCountDone = pPager->tempFile;
40078 pPager->eState = PAGER_OPEN;
40079 pPager->errCode = SQLITE_OK;
40080 if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);
40081 }
40082
40083 pPager->journalOff = 0;
40084 pPager->journalHdr = 0;
40085 pPager->setMaster = 0;
@@ -41641,14 +41642,14 @@
41642 ** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.
41643 */
41644 static void pagerFixMaplimit(Pager *pPager){
41645 #if SQLITE_MAX_MMAP_SIZE>0
41646 sqlite3_file *fd = pPager->fd;
41647 if( isOpen(fd) && fd->pMethods->iVersion>=3 ){
41648 sqlite3_int64 sz;
 
41649 sz = pPager->szMmap;
41650 pPager->bUseFetch = (sz>0);
41651 sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);
41652 }
41653 #endif
41654 }
41655
@@ -60297,11 +60298,11 @@
60298 p->bIsReader = 1;
60299 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60300 p->bIsReader = 1;
60301 }else if( opcode==OP_Vacuum
60302 || opcode==OP_JournalMode
60303 #ifndef SQLITE_OMIT_WAL
60304 || opcode==OP_Checkpoint
60305 #endif
60306 ){
60307 p->readOnly = 0;
60308 p->bIsReader = 1;
@@ -104504,11 +104505,11 @@
104505
104506 /*
104507 ** Each instance of this object holds a sequence of WhereLoop objects
104508 ** that implement some or all of a query plan.
104509 **
104510 ** Think of each WhereLoop object as a node in a graph with arcs
104511 ** showing dependences and costs for travelling between nodes. (That is
104512 ** not a completely accurate description because WhereLoop costs are a
104513 ** vector, not a scalar, and because dependences are many-to-one, not
104514 ** one-to-one as are graph nodes. But it is a useful visualization aid.)
104515 ** Then a WherePath object is a path through the graph that visits some
@@ -104774,11 +104775,11 @@
104775 /*
104776 ** These are definitions of bits in the WhereLoop.wsFlags field.
104777 ** The particular combination of bits in each WhereLoop help to
104778 ** determine the algorithm that WhereLoop represents.
104779 */
104780 #define WHERE_COLUMN_EQ 0x00000001 /* x=EXPR */
104781 #define WHERE_COLUMN_RANGE 0x00000002 /* x<EXPR and/or x>EXPR */
104782 #define WHERE_COLUMN_IN 0x00000004 /* x IN (...) */
104783 #define WHERE_COLUMN_NULL 0x00000008 /* x IS NULL */
104784 #define WHERE_CONSTRAINT 0x0000000f /* Any of the WHERE_COLUMN_xxx values */
104785 #define WHERE_TOP_LIMIT 0x00000010 /* x<EXPR or x<=EXPR constraint */
@@ -105167,11 +105168,11 @@
105168 /*
105169 ** Advance to the next WhereTerm that matches according to the criteria
105170 ** established when the pScan object was initialized by whereScanInit().
105171 ** Return NULL if there are no more matching WhereTerms.
105172 */
105173 static WhereTerm *whereScanNext(WhereScan *pScan){
105174 int iCur; /* The cursor on the LHS of the term */
105175 int iColumn; /* The column on the LHS of the term. -1 for IPK */
105176 Expr *pX; /* An expression being tested */
105177 WhereClause *pWC; /* Shorthand for pScan->pWC */
105178 WhereTerm *pTerm; /* The term being tested */
@@ -105254,11 +105255,11 @@
105255 ** but is enough to handle most commonly occurring SQL statements.
105256 **
105257 ** If X is not the INTEGER PRIMARY KEY then X must be compatible with
105258 ** index pIdx.
105259 */
105260 static WhereTerm *whereScanInit(
105261 WhereScan *pScan, /* The WhereScan object being initialized */
105262 WhereClause *pWC, /* The WHERE clause to be scanned */
105263 int iCur, /* Cursor to scan for */
105264 int iColumn, /* Column to scan for */
105265 u32 opMask, /* Operator(s) to scan for */
@@ -107680,14 +107681,15 @@
107681 };
107682 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107683 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107684 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107685
107686 assert( (pStart->wtFlags & TERM_VNULL)==0 );
107687 testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107688 pX = pStart->pExpr;
107689 assert( pX!=0 );
107690 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107691 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107692 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
107693 VdbeComment((v, "pk"));
107694 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
107695 sqlite3ReleaseTempReg(pParse, rTemp);
@@ -107697,11 +107699,12 @@
107699 }
107700 if( pEnd ){
107701 Expr *pX;
107702 pX = pEnd->pExpr;
107703 assert( pX!=0 );
107704 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107705 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107706 testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107707 memEndValue = ++pParse->nMem;
107708 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107709 if( pX->op==TK_LT || pX->op==TK_GT ){
107710 testOp = bRev ? OP_Le : OP_Ge;
@@ -108232,10 +108235,11 @@
108235 WhereTerm *pAlt;
108236 Expr sEq;
108237 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108238 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108239 if( pTerm->leftCursor!=iCur ) continue;
108240 if( pLevel->iLeftJoin ) continue;
108241 pE = pTerm->pExpr;
108242 assert( !ExprHasProperty(pE, EP_FromJoin) );
108243 assert( (pTerm->prereqRight & newNotReady)!=0 );
108244 pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0);
108245 if( pAlt==0 ) continue;
@@ -108626,10 +108630,15 @@
108630 pNew->rSetup = 0;
108631 rLogSize = estLog(whereCost(pProbe->aiRowEst[0]));
108632 for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
108633 int nIn = 0;
108634 if( pTerm->prereqRight & pNew->maskSelf ) continue;
108635 #ifdef SQLITE_ENABLE_STAT3
108636 if( (pTerm->wtFlags & TERM_VNULL)!=0 && pSrc->pTab->aCol[iCol].notNull ){
108637 continue; /* skip IS NOT NULL constraints on a NOT NULL column */
108638 }
108639 #endif
108640 pNew->wsFlags = saved_wsFlags;
108641 pNew->u.btree.nEq = saved_nEq;
108642 pNew->nLTerm = saved_nLTerm;
108643 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
108644 pNew->aLTerm[pNew->nLTerm++] = pTerm;
@@ -108773,11 +108782,11 @@
108782 return m;
108783 }
108784
108785
108786 /*
108787 ** Add all WhereLoop objects for a single table of the join where the table
108788 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
108789 ** a b-tree table, not a virtual table.
108790 */
108791 static int whereLoopAddBtree(
108792 WhereLoopBuilder *pBuilder, /* WHERE clause information */
@@ -109237,16 +109246,23 @@
109246 }
109247
109248 /*
109249 ** Examine a WherePath (with the addition of the extra WhereLoop of the 5th
109250 ** parameters) to see if it outputs rows in the requested ORDER BY
109251 ** (or GROUP BY) without requiring a separate sort operation. Return:
109252 **
109253 ** 0: ORDER BY is not satisfied. Sorting required
109254 ** 1: ORDER BY is satisfied. Omit sorting
109255 ** -1: Unknown at this time
109256 **
109257 ** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as
109258 ** strict. With GROUP BY and DISTINCT the only requirement is that
109259 ** equivalent rows appear immediately adjacent to one another. GROUP BY
109260 ** and DISTINT do not require rows to appear in any particular order as long
109261 ** as equivelent rows are grouped together. Thus for GROUP BY and DISTINCT
109262 ** the pOrderBy terms can be matched in any order. With ORDER BY, the
109263 ** pOrderBy terms must be matched in strict left-to-right order.
109264 */
109265 static int wherePathSatisfiesOrderBy(
109266 WhereInfo *pWInfo, /* The WHERE clause */
109267 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
109268 WherePath *pPath, /* The WherePath to check */
@@ -109490,11 +109506,11 @@
109506 }
109507 #endif
109508
109509
109510 /*
109511 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
109512 ** attempts to find the lowest cost path that visits each WhereLoop
109513 ** once. This path is then loaded into the pWInfo->a[].pWLoop fields.
109514 **
109515 ** Assume that the total number of output rows that will need to be sorted
109516 ** will be nRowEst (in the 10*log2 representation). Or, ignore sorting
@@ -109907,11 +109923,12 @@
109923 ** fi
109924 ** end
109925 **
109926 ** ORDER BY CLAUSE PROCESSING
109927 **
109928 ** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause
109929 ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
109930 ** if there is one. If there is no ORDER BY clause or if this routine
109931 ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
109932 */
109933 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
109934 Parse *pParse, /* The parser context */
@@ -109999,10 +110016,11 @@
110016 */
110017 initMaskSet(pMaskSet);
110018 whereClauseInit(&pWInfo->sWC, pWInfo);
110019 sqlite3ExprCodeConstants(pParse, pWhere);
110020 whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110021 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110022
110023 /* Special case: a WHERE clause that is constant. Evaluate the
110024 ** expression and either jump over all of the code or fall thru.
110025 */
110026 if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
@@ -110193,17 +110211,15 @@
110211 }
110212
110213 /* Open all tables in the pTabList and any indices selected for
110214 ** searching those tables.
110215 */
 
110216 notReady = ~(Bitmask)0;
110217 for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){
110218 Table *pTab; /* Table to open */
110219 int iDb; /* Index of database containing table/index */
110220 struct SrcList_item *pTabItem;
 
110221
110222 pTabItem = &pTabList->a[pLevel->iFrom];
110223 pTab = pTabItem->pTab;
110224 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
110225 pLoop = pLevel->pWLoop;
@@ -120698,11 +120714,11 @@
120714 nName = (int)strlen(argv[2]) + 1;
120715
120716 nByte = sizeof(const char *) * (argc-2);
120717 aCol = (const char **)sqlite3_malloc(nByte);
120718 if( aCol ){
120719 memset((void*)aCol, 0, nByte);
120720 azNotindexed = (char **)sqlite3_malloc(nByte);
120721 }
120722 if( azNotindexed ){
120723 memset(azNotindexed, 0, nByte);
120724 }
@@ -120949,11 +120965,11 @@
120965 assert( zCsr <= &((char *)p)[nByte] );
120966 }
120967
120968 /* Fill in the abNotindexed array */
120969 for(iCol=0; iCol<nCol; iCol++){
120970 int n = (int)strlen(p->azColumn[iCol]);
120971 for(i=0; i<nNotindexed; i++){
120972 char *zNot = azNotindexed[i];
120973 if( zNot && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) ){
120974 p->abNotindexed[iCol] = 1;
120975 sqlite3_free(zNot);
120976
+1 -1
--- 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.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
112
+#define SQLITE_SOURCE_ID "2013-07-09 03:04:32 52a49cbc1621094b2fe2b021209b768d29e0426b"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- 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.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- 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.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-09 03:04:32 52a49cbc1621094b2fe2b021209b768d29e0426b"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

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