1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 22:28:47 -04:00

updated SQLite to 3.12.2

This commit is contained in:
Kenichi Ishigaki 2016-04-19 12:18:33 +09:00
parent c91398e2e0
commit 67c5927214
3 changed files with 122 additions and 73 deletions

View file

@ -977,7 +977,7 @@ are limited by the typeless nature of the SQLite database.
=head1 SQLITE VERSION =head1 SQLITE VERSION
DBD::SQLite is usually compiled with a bundled SQLite library DBD::SQLite is usually compiled with a bundled SQLite library
(SQLite version S<3.12.0> as of this release) for consistency. (SQLite version S<3.12.2> as of this release) for consistency.
However, a different version of SQLite may sometimes be used for However, a different version of SQLite may sometimes be used for
some reasons like security, or some new experimental features. some reasons like security, or some new experimental features.

145
sqlite3.c
View file

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite ** This file is an amalgamation of many separate C source files from SQLite
** version 3.12.0. By combining all the individual C code files into this ** version 3.12.2. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation ** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be ** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements ** possible if the files were compiled separately. Performance improvements
@ -336,9 +336,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.12.0" #define SQLITE_VERSION "3.12.2"
#define SQLITE_VERSION_NUMBER 3012000 #define SQLITE_VERSION_NUMBER 3012002
#define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" #define SQLITE_SOURCE_ID "2016-04-18 17:30:31 92dc59fd5ad66f646666042eb04195e3a61a9e8e"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -14393,6 +14393,7 @@ SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*); SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int); SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
@ -63940,6 +63941,28 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
pPage = pCur->apPage[iCellDepth]; pPage = pCur->apPage[iCellDepth];
pCell = findCell(pPage, iCellIdx); pCell = findCell(pPage, iCellIdx);
/* If the bPreserve flag is set to true, then the cursor position must
** be preserved following this delete operation. If the current delete
** will cause a b-tree rebalance, then this is done by saving the cursor
** key and leaving the cursor in CURSOR_REQUIRESEEK state before
** returning.
**
** Or, if the current delete will not cause a rebalance, then the cursor
** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately
** before or after the deleted entry. In this case set bSkipnext to true. */
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
){
/* A b-tree rebalance will be required after deleting this entry.
** Save the cursor key. */
rc = saveCursorKey(pCur);
if( rc ) return rc;
}else{
bSkipnext = 1;
}
}
/* If the page containing the entry to delete is not a leaf page, move /* If the page containing the entry to delete is not a leaf page, move
** the cursor to the largest entry in the tree that is smaller than ** the cursor to the largest entry in the tree that is smaller than
** the entry being deleted. This cell will replace the cell being deleted ** the entry being deleted. This cell will replace the cell being deleted
@ -63966,28 +63989,6 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
invalidateIncrblobCursors(p, pCur->info.nKey, 0); invalidateIncrblobCursors(p, pCur->info.nKey, 0);
} }
/* If the bPreserve flag is set to true, then the cursor position must
** be preserved following this delete operation. If the current delete
** will cause a b-tree rebalance, then this is done by saving the cursor
** key and leaving the cursor in CURSOR_REQUIRESEEK state before
** returning.
**
** Or, if the current delete will not cause a rebalance, then the cursor
** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately
** before or after the deleted entry. In this case set bSkipnext to true. */
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
){
/* A b-tree rebalance will be required after deleting this entry.
** Save the cursor key. */
rc = saveCursorKey(pCur);
if( rc ) return rc;
}else{
bSkipnext = 1;
}
}
/* Make the page containing the entry to be deleted writable. Then free any /* Make the page containing the entry to be deleted writable. Then free any
** overflow pages associated with the entry and finally remove the cell ** overflow pages associated with the entry and finally remove the cell
** itself from within the page. */ ** itself from within the page. */
@ -82768,7 +82769,6 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
){ ){
int pgsz; /* Page size of main database */ int pgsz; /* Page size of main database */
int i; /* Used to iterate through aTask[] */ int i; /* Used to iterate through aTask[] */
int mxCache; /* Cache size */
VdbeSorter *pSorter; /* The new sorter */ VdbeSorter *pSorter; /* The new sorter */
KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */ KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */
int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */ int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
@ -82825,11 +82825,20 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
} }
if( !sqlite3TempInMemory(db) ){ if( !sqlite3TempInMemory(db) ){
i64 mxCache; /* Cache size in bytes*/
u32 szPma = sqlite3GlobalConfig.szPma; u32 szPma = sqlite3GlobalConfig.szPma;
pSorter->mnPmaSize = szPma * pgsz; pSorter->mnPmaSize = szPma * pgsz;
mxCache = db->aDb[0].pSchema->cache_size; mxCache = db->aDb[0].pSchema->cache_size;
if( mxCache<(int)szPma ) mxCache = (int)szPma; if( mxCache<0 ){
pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_PMASZ); /* A negative cache-size value C indicates that the cache is abs(C)
** KiB in size. */
mxCache = mxCache * -1024;
}else{
mxCache = mxCache * pgsz;
}
mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);
pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);
/* EVIDENCE-OF: R-26747-61719 When the application provides any amount of /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
@ -84674,6 +84683,7 @@ static int memjrnlRead(
#endif #endif
assert( (iAmt+iOfst)<=p->endpoint.iOffset ); assert( (iAmt+iOfst)<=p->endpoint.iOffset );
assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){ if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
sqlite3_int64 iOff = 0; sqlite3_int64 iOff = 0;
for(pChunk=p->pFirst; for(pChunk=p->pFirst;
@ -84684,6 +84694,7 @@ static int memjrnlRead(
} }
}else{ }else{
pChunk = p->readpoint.pChunk; pChunk = p->readpoint.pChunk;
assert( pChunk!=0 );
} }
iChunkOffset = (int)(iOfst%p->nChunkSize); iChunkOffset = (int)(iOfst%p->nChunkSize);
@ -84695,7 +84706,7 @@ static int memjrnlRead(
nRead -= iSpace; nRead -= iSpace;
iChunkOffset = 0; iChunkOffset = 0;
} while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 ); } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
p->readpoint.iOffset = iOfst+iAmt; p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;
p->readpoint.pChunk = pChunk; p->readpoint.pChunk = pChunk;
return SQLITE_OK; return SQLITE_OK;
@ -95560,6 +95571,7 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
zType = z + sqlite3Strlen30(z) + 1; zType = z + sqlite3Strlen30(z) + 1;
memcpy(zType, pType->z, pType->n); memcpy(zType, pType->z, pType->n);
zType[pType->n] = 0; zType[pType->n] = 0;
sqlite3Dequote(zType);
pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst); pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
pCol->colFlags |= COLFLAG_HASTYPE; pCol->colFlags |= COLFLAG_HASTYPE;
} }
@ -96650,12 +96662,6 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
** statement that defines the view. ** statement that defines the view.
*/ */
assert( pTable->pSelect ); assert( pTable->pSelect );
if( pTable->pCheck ){
db->lookaside.bDisable++;
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
db->lookaside.bDisable--;
}else{
pSel = sqlite3SelectDup(db, pTable->pSelect, 0); pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
if( pSel ){ if( pSel ){
n = pParse->nTab; n = pParse->nTab;
@ -96670,25 +96676,42 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
#else #else
pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
#endif #endif
db->lookaside.bDisable--;
pParse->nTab = n; pParse->nTab = n;
if( pSelTab ){ if( pTable->pCheck ){
/* CREATE VIEW name(arglist) AS ...
** The names of the columns in the table are taken from
** arglist which is stored in pTable->pCheck. The pCheck field
** normally holds CHECK constraints on an ordinary table, but for
** a VIEW it holds the list of column names.
*/
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
if( db->mallocFailed==0
&& pParse->nErr==0
&& pTable->nCol==pSel->pEList->nExpr
){
sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);
}
}else if( pSelTab ){
/* CREATE VIEW name AS... without an argument list. Construct
** the column names from the SELECT statement that defines the view.
*/
assert( pTable->aCol==0 ); assert( pTable->aCol==0 );
pTable->nCol = pSelTab->nCol; pTable->nCol = pSelTab->nCol;
pTable->aCol = pSelTab->aCol; pTable->aCol = pSelTab->aCol;
pSelTab->nCol = 0; pSelTab->nCol = 0;
pSelTab->aCol = 0; pSelTab->aCol = 0;
sqlite3DeleteTable(db, pSelTab);
assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
}else{ }else{
pTable->nCol = 0; pTable->nCol = 0;
nErr++; nErr++;
} }
if( pSelTab ) sqlite3DeleteTable(db, pSelTab);
sqlite3SelectDelete(db, pSel); sqlite3SelectDelete(db, pSel);
db->lookaside.bDisable--;
} else { } else {
nErr++; nErr++;
} }
}
pTable->pSchema->schemaFlags |= DB_UnresetViews; pTable->pSchema->schemaFlags |= DB_UnresetViews;
#endif /* SQLITE_OMIT_VIEW */ #endif /* SQLITE_OMIT_VIEW */
return nErr; return nErr;
@ -112193,7 +112216,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
** This routine requires that all identifiers in the SELECT ** This routine requires that all identifiers in the SELECT
** statement be resolved. ** statement be resolved.
*/ */
static void selectAddColumnTypeAndCollation( SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(
Parse *pParse, /* Parsing contexts */ Parse *pParse, /* Parsing contexts */
Table *pTab, /* Add column type information to this table */ Table *pTab, /* Add column type information to this table */
Select *pSelect /* SELECT used to determine types and collations */ Select *pSelect /* SELECT used to determine types and collations */
@ -112215,10 +112238,20 @@ static void selectAddColumnTypeAndCollation(
sNC.pSrcList = pSelect->pSrc; sNC.pSrcList = pSelect->pSrc;
a = pSelect->pEList->a; a = pSelect->pEList->a;
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
const char *zType;
int n, m;
p = a[i].pExpr; p = a[i].pExpr;
columnType(&sNC, p, 0, 0, 0, &pCol->szEst); zType = columnType(&sNC, p, 0, 0, 0, &pCol->szEst);
szAll += pCol->szEst; szAll += pCol->szEst;
pCol->affinity = sqlite3ExprAffinity(p); pCol->affinity = sqlite3ExprAffinity(p);
if( zType && (m = sqlite3Strlen30(zType))>0 ){
n = sqlite3Strlen30(pCol->zName);
pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);
if( pCol->zName ){
memcpy(&pCol->zName[n+1], zType, m+1);
pCol->colFlags |= COLFLAG_HASTYPE;
}
}
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB; if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;
pColl = sqlite3ExprCollSeq(pParse, p); pColl = sqlite3ExprCollSeq(pParse, p);
if( pColl && pCol->zColl==0 ){ if( pColl && pCol->zColl==0 ){
@ -112255,7 +112288,7 @@ SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
pTab->zName = 0; pTab->zName = 0;
pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol); sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
selectAddColumnTypeAndCollation(pParse, pTab, pSelect); sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);
pTab->iPKey = -1; pTab->iPKey = -1;
if( db->mallocFailed ){ if( db->mallocFailed ){
sqlite3DeleteTable(db, pTab); sqlite3DeleteTable(db, pTab);
@ -115039,7 +115072,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
Select *pSel = pFrom->pSelect; Select *pSel = pFrom->pSelect;
if( pSel ){ if( pSel ){
while( pSel->pPrior ) pSel = pSel->pPrior; while( pSel->pPrior ) pSel = pSel->pPrior;
selectAddColumnTypeAndCollation(pParse, pTab, pSel); sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);
} }
} }
} }
@ -121336,7 +121369,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
} }
} }
} }
sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); /* These registers need to be preserved in case there is an IN operator
** loop. So we could deallocate the registers here (and potentially
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
** simpler and safer to simply not reuse the registers.
**
** sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
*/
sqlite3ExprCachePop(pParse); sqlite3ExprCachePop(pParse);
}else }else
#endif /* SQLITE_OMIT_VIRTUALTABLE */ #endif /* SQLITE_OMIT_VIRTUALTABLE */
@ -125728,8 +125767,6 @@ static int whereLoopAddBtreeIndex(
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
if( pNew->wsFlags & WHERE_BTM_LIMIT ){ if( pNew->wsFlags & WHERE_BTM_LIMIT ){
opMask = WO_LT|WO_LE; opMask = WO_LT|WO_LE;
}else if( /*pProbe->tnum<=0 ||*/ (pSrc->fg.jointype & JT_LEFT)!=0 ){
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE;
}else{ }else{
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
} }
@ -125767,6 +125804,18 @@ static int whereLoopAddBtreeIndex(
** to mix with a lower range bound from some other source */ ** to mix with a lower range bound from some other source */
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
/* Do not allow IS constraints from the WHERE clause to be used by the
** right table of a LEFT JOIN. Only constraints in the ON clause are
** allowed */
if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
&& (eOp & (WO_IS|WO_ISNULL))!=0
){
testcase( eOp & WO_IS );
testcase( eOp & WO_ISNULL );
continue;
}
pNew->wsFlags = saved_wsFlags; pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq; pNew->u.btree.nEq = saved_nEq;
pNew->nLTerm = saved_nLTerm; pNew->nLTerm = saved_nLTerm;
@ -185424,7 +185473,7 @@ static void fts5SourceIdFunc(
){ ){
assert( nArg==0 ); assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused); UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b", -1, SQLITE_TRANSIENT); sqlite3_result_text(pCtx, "fts5: 2016-04-18 17:30:31 92dc59fd5ad66f646666042eb04195e3a61a9e8e", -1, SQLITE_TRANSIENT);
} }
static int fts5Init(sqlite3 *db){ static int fts5Init(sqlite3 *db){

View file

@ -111,9 +111,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.12.0" #define SQLITE_VERSION "3.12.2"
#define SQLITE_VERSION_NUMBER 3012000 #define SQLITE_VERSION_NUMBER 3012002
#define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" #define SQLITE_SOURCE_ID "2016-04-18 17:30:31 92dc59fd5ad66f646666042eb04195e3a61a9e8e"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers