aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/func.c2
-rw-r--r--src/pager.c14
-rw-r--r--src/pragma.c6
-rw-r--r--src/trigger.c2
-rw-r--r--src/vdbe.h2
-rw-r--r--src/vdbeblob.c2
-rw-r--r--src/where.c3
7 files changed, 19 insertions, 12 deletions
diff --git a/src/func.c b/src/func.c
index e657558ba..6be963580 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1017,7 +1017,7 @@ static void charFunc(
){
unsigned char *z, *zOut;
int i;
- zOut = z = sqlite3_malloc( argc*4 );
+ zOut = z = sqlite3_malloc( argc*4+1 );
if( z==0 ){
sqlite3_result_error_nomem(context);
return;
diff --git a/src/pager.c b/src/pager.c
index e2486caa0..c6485a4d4 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -4889,14 +4889,16 @@ static int hasHotJournal(Pager *pPager, int *pExists){
if( rc==SQLITE_OK && !locked ){
Pgno nPage; /* Number of pages in database file */
- /* Check the size of the database file. If it consists of 0 pages
- ** and the journal is not being persisted, then delete the journal
- ** file. See the header comment above for the reasoning here.
- ** Delete the obsolete journal file under a RESERVED lock to avoid
- ** race conditions and to avoid violating [H33020].
- */
rc = pagerPagecount(pPager, &nPage);
if( rc==SQLITE_OK ){
+ /* If the database is zero pages in size, that means that either (1) the
+ ** journal is a remnant from a prior database with the same name where
+ ** the database file but not the journal was deleted, or (2) the initial
+ ** transaction that populates a new database is being rolled back.
+ ** In either case, the journal file can be deleted. However, take care
+ ** not to delete the journal file if it is already open due to
+ ** journal_mode=PERSIST.
+ */
if( nPage==0 && !jrnlOpen ){
sqlite3BeginBenignMalloc();
if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){
diff --git a/src/pragma.c b/src/pragma.c
index a211633f2..fcecad269 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -824,7 +824,7 @@ void sqlite3Pragma(
** size of historical compatibility.
*/
case PragTyp_DEFAULT_CACHE_SIZE: {
- static const int iLn = __LINE__+2;
+ static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList getCacheSize[] = {
{ OP_Transaction, 0, 0, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */
@@ -1087,7 +1087,7 @@ void sqlite3Pragma(
** file. Before writing to meta[6], check that meta[3] indicates
** that this really is an auto-vacuum capable database.
*/
- static const int iLn = __LINE__+2;
+ static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList setMeta6[] = {
{ OP_Transaction, 0, 1, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE},
@@ -1790,7 +1790,7 @@ void sqlite3Pragma(
** messages have been generated, output OK. Otherwise output the
** error message
*/
- static const int iLn = __LINE__+2;
+ static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList endCode[] = {
{ OP_AddImm, 1, 0, 0}, /* 0 */
{ OP_IfNeg, 1, 0, 0}, /* 1 */
diff --git a/src/trigger.c b/src/trigger.c
index dcbaf5d33..01f7b21f7 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -566,7 +566,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
assert( pTable!=0 );
if( (v = sqlite3GetVdbe(pParse))!=0 ){
int base;
- static const int iLn = __LINE__+2;
+ static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList dropTrigger[] = {
{ OP_Rewind, 0, ADDR(9), 0},
{ OP_String8, 0, 1, 0}, /* 1 */
diff --git a/src/vdbe.h b/src/vdbe.h
index 075a63a4d..5892c5def 100644
--- a/src/vdbe.h
+++ b/src/vdbe.h
@@ -274,11 +274,13 @@ void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
# define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);
# define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);
+# define VDBE_OFFSET_LINENO(x) (__LINE__+x)
#else
# define VdbeCoverage(v)
# define VdbeCoverageIf(v,x)
# define VdbeCoverageAlwaysTaken(v)
# define VdbeCoverageNeverTaken(v)
+# define VDBE_OFFSET_LINENO(x) 0
#endif
#endif
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index 43ec130b3..d1262fa54 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -135,7 +135,7 @@ int sqlite3_blob_open(
** which closes the b-tree cursor and (possibly) commits the
** transaction.
*/
- static const int iLn = __LINE__+4;
+ static const int iLn = VDBE_OFFSET_LINENO(4);
static const VdbeOpList openBlob[] = {
/* {OP_Transaction, 0, 0, 0}, // 0: Inserted separately */
{OP_TableLock, 0, 0, 0}, /* 1: Acquire a read or write lock */
diff --git a/src/where.c b/src/where.c
index 963878d00..6cd9c167a 100644
--- a/src/where.c
+++ b/src/where.c
@@ -3974,7 +3974,10 @@ static int whereLoopAddBtreeIndex(
pNew->aLTerm[pNew->nLTerm++] = 0;
pNew->wsFlags |= WHERE_SKIPSCAN;
nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);
+ pNew->rRun = rLogSize + nIter;
+ pNew->nOut += nIter;
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter);
+ pNew->nOut = saved_nOut;
}
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
int nIn = 0;