aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pager.c5
-rw-r--r--src/printf.c4
-rw-r--r--src/test_vfs.c36
-rw-r--r--src/vdbeaux.c2
-rw-r--r--src/where.c17
5 files changed, 49 insertions, 15 deletions
diff --git a/src/pager.c b/src/pager.c
index 645cc3d9a..b20822896 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -1812,6 +1812,7 @@ static void pager_unlock(Pager *pPager){
pPager->changeCountDone = pPager->tempFile;
pPager->eState = PAGER_OPEN;
pPager->errCode = SQLITE_OK;
+ if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);
}
pPager->journalOff = 0;
@@ -3378,10 +3379,10 @@ void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
static void pagerFixMaplimit(Pager *pPager){
#if SQLITE_MAX_MMAP_SIZE>0
sqlite3_file *fd = pPager->fd;
- if( isOpen(fd) ){
+ if( isOpen(fd) && fd->pMethods->iVersion>=3 ){
sqlite3_int64 sz;
- pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->szMmap>0;
sz = pPager->szMmap;
+ pPager->bUseFetch = (sz>0);
sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);
}
#endif
diff --git a/src/printf.c b/src/printf.c
index 8d37d633b..67649b269 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -468,8 +468,8 @@ void sqlite3VXPrintf(
}else{
e2 = exp;
}
- if( e2+precision+width > etBUFSIZE - 15 ){
- bufpt = zExtra = sqlite3Malloc( e2+precision+width+15 );
+ if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
+ bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
if( bufpt==0 ){
pAccum->mallocFailed = 1;
return;
diff --git a/src/test_vfs.c b/src/test_vfs.c
index fcd577439..8b6b530bb 100644
--- a/src/test_vfs.c
+++ b/src/test_vfs.c
@@ -190,8 +190,11 @@ static int tvfsShmMap(sqlite3_file*,int,int,int, void volatile **);
static void tvfsShmBarrier(sqlite3_file*);
static int tvfsShmUnmap(sqlite3_file*, int);
+static int tvfsFetch(sqlite3_file*, sqlite3_int64, int, void**);
+static int tvfsUnfetch(sqlite3_file*, sqlite3_int64, void*);
+
static sqlite3_io_methods tvfs_io_methods = {
- 2, /* iVersion */
+ 3, /* iVersion */
tvfsClose, /* xClose */
tvfsRead, /* xRead */
tvfsWrite, /* xWrite */
@@ -207,7 +210,9 @@ static sqlite3_io_methods tvfs_io_methods = {
tvfsShmMap, /* xShmMap */
tvfsShmLock, /* xShmLock */
tvfsShmBarrier, /* xShmBarrier */
- tvfsShmUnmap /* xShmUnmap */
+ tvfsShmUnmap, /* xShmUnmap */
+ tvfsFetch,
+ tvfsUnfetch
};
static int tvfsResultCode(Testvfs *p, int *pRc){
@@ -618,7 +623,10 @@ static int tvfsOpen(
pMethods = (sqlite3_io_methods *)ckalloc(nByte);
memcpy(pMethods, &tvfs_io_methods, nByte);
- pMethods->iVersion = pVfs->iVersion;
+ pMethods->iVersion = pFd->pReal->pMethods->iVersion;
+ if( pMethods->iVersion>pVfs->iVersion ){
+ pMethods->iVersion = pVfs->iVersion;
+ }
if( pVfs->iVersion>1 && ((Testvfs *)pVfs->pAppData)->isNoshm ){
pMethods->xShmUnmap = 0;
pMethods->xShmLock = 0;
@@ -993,6 +1001,21 @@ static int tvfsShmUnmap(
return rc;
}
+static int tvfsFetch(
+ sqlite3_file *pFile,
+ sqlite3_int64 iOfst,
+ int iAmt,
+ void **pp
+){
+ TestvfsFd *pFd = tvfsGetFd(pFile);
+ return sqlite3OsFetch(pFd->pReal, iOfst, iAmt, pp);
+}
+
+static int tvfsUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *p){
+ TestvfsFd *pFd = tvfsGetFd(pFile);
+ return sqlite3OsUnfetch(pFd->pReal, iOfst, p);
+}
+
static int testvfs_obj_cmd(
ClientData cd,
Tcl_Interp *interp,
@@ -1343,7 +1366,7 @@ static int testvfs_cmd(
Tcl_Obj *CONST objv[]
){
static sqlite3_vfs tvfs_vfs = {
- 2, /* iVersion */
+ 3, /* iVersion */
0, /* szOsFile */
0, /* mxPathname */
0, /* pNext */
@@ -1369,6 +1392,9 @@ static int testvfs_cmd(
tvfsCurrentTime, /* xCurrentTime */
0, /* xGetLastError */
0, /* xCurrentTimeInt64 */
+ 0, /* xSetSystemCall */
+ 0, /* xGetSystemCall */
+ 0, /* xNextSystemCall */
};
Testvfs *p; /* New object */
@@ -1382,7 +1408,7 @@ static int testvfs_cmd(
int isDefault = 0; /* True if -default is passed */
int szOsFile = 0; /* Value passed to -szosfile */
int mxPathname = -1; /* Value passed to -mxpathname */
- int iVersion = 2; /* Value passed to -iversion */
+ int iVersion = 3; /* Value passed to -iversion */
if( objc<2 || 0!=(objc%2) ) goto bad_args;
for(i=2; i<objc; i += 2){
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index b65b121ee..fb8294a25 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -417,7 +417,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
p->bIsReader = 1;
}else if( opcode==OP_Vacuum
|| opcode==OP_JournalMode
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+#ifndef SQLITE_OMIT_WAL
|| opcode==OP_Checkpoint
#endif
){
diff --git a/src/where.c b/src/where.c
index f00a5eb81..e18e88623 100644
--- a/src/where.c
+++ b/src/where.c
@@ -822,7 +822,7 @@ static u16 operatorMask(int op){
** established when the pScan object was initialized by whereScanInit().
** Return NULL if there are no more matching WhereTerms.
*/
-WhereTerm *whereScanNext(WhereScan *pScan){
+static WhereTerm *whereScanNext(WhereScan *pScan){
int iCur; /* The cursor on the LHS of the term */
int iColumn; /* The column on the LHS of the term. -1 for IPK */
Expr *pX; /* An expression being tested */
@@ -909,7 +909,7 @@ WhereTerm *whereScanNext(WhereScan *pScan){
** If X is not the INTEGER PRIMARY KEY then X must be compatible with
** index pIdx.
*/
-WhereTerm *whereScanInit(
+static WhereTerm *whereScanInit(
WhereScan *pScan, /* The WhereScan object being initialized */
WhereClause *pWC, /* The WHERE clause to be scanned */
int iCur, /* Cursor to scan for */
@@ -3335,10 +3335,11 @@ static Bitmask codeOneLoopStart(
assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
+ assert( (pStart->wtFlags & TERM_VNULL)==0 );
testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
pX = pStart->pExpr;
assert( pX!=0 );
- assert( pStart->leftCursor==iCur );
+ testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
VdbeComment((v, "pk"));
@@ -3352,7 +3353,8 @@ static Bitmask codeOneLoopStart(
Expr *pX;
pX = pEnd->pExpr;
assert( pX!=0 );
- assert( pEnd->leftCursor==iCur );
+ assert( (pEnd->wtFlags & TERM_VNULL)==0 );
+ testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
memEndValue = ++pParse->nMem;
sqlite3ExprCode(pParse, pX->pRight, memEndValue);
@@ -4282,6 +4284,11 @@ static int whereLoopAddBtreeIndex(
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
int nIn = 0;
if( pTerm->prereqRight & pNew->maskSelf ) continue;
+#ifdef SQLITE_ENABLE_STAT3
+ if( (pTerm->wtFlags & TERM_VNULL)!=0 && pSrc->pTab->aCol[iCol].notNull ){
+ continue; /* skip IS NOT NULL constraints on a NOT NULL column */
+ }
+#endif
pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq;
pNew->nLTerm = saved_nLTerm;
@@ -5663,6 +5670,7 @@ WhereInfo *sqlite3WhereBegin(
whereClauseInit(&pWInfo->sWC, pWInfo);
sqlite3ExprCodeConstants(pParse, pWhere);
whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
+ sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
/* Special case: a WHERE clause that is constant. Evaluate the
** expression and either jump over all of the code or fall thru.
@@ -5857,7 +5865,6 @@ WhereInfo *sqlite3WhereBegin(
/* Open all tables in the pTabList and any indices selected for
** searching those tables.
*/
- sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
notReady = ~(Bitmask)0;
for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){
Table *pTab; /* Table to open */