1
1
/******************************************************************************
2
2
** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.12.0 . By combining all the individual C code files into this
3
+ ** version 3.12.1 . By combining all the individual C code files into this
4
4
** single large file, the entire code can be compiled as a single translation
5
5
** unit. This allows many compilers to do optimizations that would not be
6
6
** possible if the files were compiled separately. Performance improvements
@@ -336,9 +336,9 @@ extern "C" {
336
336
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
337
337
** [sqlite_version()] and [sqlite_source_id()].
338
338
*/
339
- #define SQLITE_VERSION "3.12.0 "
340
- #define SQLITE_VERSION_NUMBER 3012000
341
- #define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b "
339
+ #define SQLITE_VERSION "3.12.1 "
340
+ #define SQLITE_VERSION_NUMBER 3012001
341
+ #define SQLITE_SOURCE_ID "2016-04-08 15:09:49 fe7d3b75fe1bde41511b323925af8ae1b910bc4d "
342
342
343
343
/*
344
344
** CAPI3REF: Run-Time Library Version Numbers
@@ -14393,6 +14393,7 @@ SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
14393
14393
SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
14394
14394
SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
14395
14395
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
14396
+ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
14396
14397
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
14397
14398
SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
14398
14399
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
@@ -84674,6 +84675,7 @@ static int memjrnlRead(
84674
84675
#endif
84675
84676
84676
84677
assert( (iAmt+iOfst)<=p->endpoint.iOffset );
84678
+ assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
84677
84679
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
84678
84680
sqlite3_int64 iOff = 0;
84679
84681
for(pChunk=p->pFirst;
@@ -84684,6 +84686,7 @@ static int memjrnlRead(
84684
84686
}
84685
84687
}else{
84686
84688
pChunk = p->readpoint.pChunk;
84689
+ assert( pChunk!=0 );
84687
84690
}
84688
84691
84689
84692
iChunkOffset = (int)(iOfst%p->nChunkSize);
@@ -84695,7 +84698,7 @@ static int memjrnlRead(
84695
84698
nRead -= iSpace;
84696
84699
iChunkOffset = 0;
84697
84700
} while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
84698
- p->readpoint.iOffset = iOfst+iAmt;
84701
+ p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0 ;
84699
84702
p->readpoint.pChunk = pChunk;
84700
84703
84701
84704
return SQLITE_OK;
@@ -96650,44 +96653,55 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
96650
96653
** statement that defines the view.
96651
96654
*/
96652
96655
assert( pTable->pSelect );
96653
- if( pTable->pCheck ){
96656
+ pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
96657
+ if( pSel ){
96658
+ n = pParse->nTab;
96659
+ sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
96660
+ pTable->nCol = -1;
96654
96661
db->lookaside.bDisable++;
96655
- sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
96656
- &pTable->nCol, &pTable->aCol);
96657
- db->lookaside.bDisable--;
96658
- }else{
96659
- pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
96660
- if( pSel ){
96661
- n = pParse->nTab;
96662
- sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
96663
- pTable->nCol = -1;
96664
- db->lookaside.bDisable++;
96665
96662
#ifndef SQLITE_OMIT_AUTHORIZATION
96666
- xAuth = db->xAuth;
96667
- db->xAuth = 0;
96668
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
96669
- db->xAuth = xAuth;
96663
+ xAuth = db->xAuth;
96664
+ db->xAuth = 0;
96665
+ pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
96666
+ db->xAuth = xAuth;
96670
96667
#else
96671
- pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
96672
- #endif
96673
- db->lookaside.bDisable--;
96674
- pParse->nTab = n;
96675
- if( pSelTab ){
96676
- assert( pTable->aCol==0 );
96677
- pTable->nCol = pSelTab->nCol;
96678
- pTable->aCol = pSelTab->aCol;
96679
- pSelTab->nCol = 0;
96680
- pSelTab->aCol = 0;
96681
- sqlite3DeleteTable(db, pSelTab);
96682
- assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
96683
- }else{
96684
- pTable->nCol = 0;
96685
- nErr++;
96668
+ pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
96669
+ #endif
96670
+ pParse->nTab = n;
96671
+ if( pTable->pCheck ){
96672
+ /* CREATE VIEW name(arglist) AS ...
96673
+ ** The names of the columns in the table are taken from
96674
+ ** arglist which is stored in pTable->pCheck. The pCheck field
96675
+ ** normally holds CHECK constraints on an ordinary table, but for
96676
+ ** a VIEW it holds the list of column names.
96677
+ */
96678
+ sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
96679
+ &pTable->nCol, &pTable->aCol);
96680
+ if( db->mallocFailed==0
96681
+ && pParse->nErr==0
96682
+ && pTable->nCol==pSel->pEList->nExpr
96683
+ ){
96684
+ sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);
96686
96685
}
96687
- sqlite3SelectDelete(db, pSel);
96688
- } else {
96686
+ }else if( pSelTab ){
96687
+ /* CREATE VIEW name AS... without an argument list. Construct
96688
+ ** the column names from the SELECT statement that defines the view.
96689
+ */
96690
+ assert( pTable->aCol==0 );
96691
+ pTable->nCol = pSelTab->nCol;
96692
+ pTable->aCol = pSelTab->aCol;
96693
+ pSelTab->nCol = 0;
96694
+ pSelTab->aCol = 0;
96695
+ assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
96696
+ }else{
96697
+ pTable->nCol = 0;
96689
96698
nErr++;
96690
96699
}
96700
+ if( pSelTab ) sqlite3DeleteTable(db, pSelTab);
96701
+ sqlite3SelectDelete(db, pSel);
96702
+ db->lookaside.bDisable--;
96703
+ } else {
96704
+ nErr++;
96691
96705
}
96692
96706
pTable->pSchema->schemaFlags |= DB_UnresetViews;
96693
96707
#endif /* SQLITE_OMIT_VIEW */
@@ -112193,7 +112207,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
112193
112207
** This routine requires that all identifiers in the SELECT
112194
112208
** statement be resolved.
112195
112209
*/
112196
- static void selectAddColumnTypeAndCollation (
112210
+ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation (
112197
112211
Parse *pParse, /* Parsing contexts */
112198
112212
Table *pTab, /* Add column type information to this table */
112199
112213
Select *pSelect /* SELECT used to determine types and collations */
@@ -112215,10 +112229,20 @@ static void selectAddColumnTypeAndCollation(
112215
112229
sNC.pSrcList = pSelect->pSrc;
112216
112230
a = pSelect->pEList->a;
112217
112231
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
112232
+ const char *zType;
112233
+ int n, m;
112218
112234
p = a[i].pExpr;
112219
- columnType(&sNC, p, 0, 0, 0, &pCol->szEst);
112235
+ zType = columnType(&sNC, p, 0, 0, 0, &pCol->szEst);
112220
112236
szAll += pCol->szEst;
112221
112237
pCol->affinity = sqlite3ExprAffinity(p);
112238
+ if( zType && (m = sqlite3Strlen30(zType))>0 ){
112239
+ n = sqlite3Strlen30(pCol->zName);
112240
+ pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);
112241
+ if( pCol->zName ){
112242
+ memcpy(&pCol->zName[n+1], zType, m+1);
112243
+ pCol->colFlags |= COLFLAG_HASTYPE;
112244
+ }
112245
+ }
112222
112246
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;
112223
112247
pColl = sqlite3ExprCollSeq(pParse, p);
112224
112248
if( pColl && pCol->zColl==0 ){
@@ -112255,7 +112279,7 @@ SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
112255
112279
pTab->zName = 0;
112256
112280
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
112257
112281
sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
112258
- selectAddColumnTypeAndCollation (pParse, pTab, pSelect);
112282
+ sqlite3SelectAddColumnTypeAndCollation (pParse, pTab, pSelect);
112259
112283
pTab->iPKey = -1;
112260
112284
if( db->mallocFailed ){
112261
112285
sqlite3DeleteTable(db, pTab);
@@ -115039,7 +115063,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
115039
115063
Select *pSel = pFrom->pSelect;
115040
115064
if( pSel ){
115041
115065
while( pSel->pPrior ) pSel = pSel->pPrior;
115042
- selectAddColumnTypeAndCollation (pParse, pTab, pSel);
115066
+ sqlite3SelectAddColumnTypeAndCollation (pParse, pTab, pSel);
115043
115067
}
115044
115068
}
115045
115069
}
@@ -125728,8 +125752,6 @@ static int whereLoopAddBtreeIndex(
125728
125752
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
125729
125753
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
125730
125754
opMask = WO_LT|WO_LE;
125731
- }else if( /*pProbe->tnum<=0 ||*/ (pSrc->fg.jointype & JT_LEFT)!=0 ){
125732
- opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE;
125733
125755
}else{
125734
125756
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
125735
125757
}
@@ -125767,6 +125789,18 @@ static int whereLoopAddBtreeIndex(
125767
125789
** to mix with a lower range bound from some other source */
125768
125790
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
125769
125791
125792
+ /* Do not allow IS constraints from the WHERE clause to be used by the
125793
+ ** right table of a LEFT JOIN. Only constraints in the ON clause are
125794
+ ** allowed */
125795
+ if( (pSrc->fg.jointype & JT_LEFT)!=0
125796
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
125797
+ && (eOp & (WO_IS|WO_ISNULL))!=0
125798
+ ){
125799
+ testcase( eOp & WO_IS );
125800
+ testcase( eOp & WO_ISNULL );
125801
+ continue;
125802
+ }
125803
+
125770
125804
pNew->wsFlags = saved_wsFlags;
125771
125805
pNew->u.btree.nEq = saved_nEq;
125772
125806
pNew->nLTerm = saved_nLTerm;
@@ -185424,7 +185458,7 @@ static void fts5SourceIdFunc(
185424
185458
){
185425
185459
assert( nArg==0 );
185426
185460
UNUSED_PARAM2(nArg, apUnused);
185427
- sqlite3_result_text(pCtx, "fts5: 2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b ", -1, SQLITE_TRANSIENT);
185461
+ sqlite3_result_text(pCtx, "fts5: 2016-04-08 15:09:49 fe7d3b75fe1bde41511b323925af8ae1b910bc4d ", -1, SQLITE_TRANSIENT);
185428
185462
}
185429
185463
185430
185464
static int fts5Init(sqlite3 *db){
0 commit comments