Merge all the latest changes from trunk.
FossilOrigin-Name: b86590043e17705ada90562cf30f69b3e3ef65a4
This commit is contained in:
+39
-21
@@ -130,7 +130,7 @@ static int growOpArray(Vdbe *v, int nOp){
|
||||
p->nOpAlloc = p->szOpAlloc/sizeof(Op);
|
||||
v->aOp = pNew;
|
||||
}
|
||||
return (pNew ? SQLITE_OK : SQLITE_NOMEM);
|
||||
return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
@@ -1489,6 +1489,7 @@ void sqlite3VdbeFrameDelete(VdbeFrame *p){
|
||||
sqlite3VdbeFreeCursor(p->v, apCsr[i]);
|
||||
}
|
||||
releaseMemArray(aMem, p->nChildMem);
|
||||
sqlite3VdbeDeleteAuxData(p->v->db, &p->pAuxData, -1, 0);
|
||||
sqlite3DbFree(p->v->db, p);
|
||||
}
|
||||
|
||||
@@ -1531,7 +1532,7 @@ int sqlite3VdbeList(
|
||||
releaseMemArray(pMem, 8);
|
||||
p->pResultSet = 0;
|
||||
|
||||
if( p->rc==SQLITE_NOMEM ){
|
||||
if( p->rc==SQLITE_NOMEM_BKPT ){
|
||||
/* This happens if a malloc() inside a call to sqlite3_column_text() or
|
||||
** sqlite3_column_text16() failed. */
|
||||
sqlite3OomFault(db);
|
||||
@@ -2017,6 +2018,9 @@ int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
|
||||
v->db->lastRowid = pFrame->lastRowid;
|
||||
v->nChange = pFrame->nChange;
|
||||
v->db->nChange = pFrame->nDbChange;
|
||||
sqlite3VdbeDeleteAuxData(v->db, &v->pAuxData, -1, 0);
|
||||
v->pAuxData = pFrame->pAuxData;
|
||||
pFrame->pAuxData = 0;
|
||||
return pFrame->pc;
|
||||
}
|
||||
|
||||
@@ -2048,7 +2052,7 @@ static void closeAllCursors(Vdbe *p){
|
||||
}
|
||||
|
||||
/* Delete any auxdata allocations made by the VM */
|
||||
if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p, -1, 0);
|
||||
if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p->db, &p->pAuxData, -1, 0);
|
||||
assert( p->pAuxData==0 );
|
||||
}
|
||||
|
||||
@@ -2120,7 +2124,7 @@ int sqlite3VdbeSetColName(
|
||||
assert( var<COLNAME_N );
|
||||
if( p->db->mallocFailed ){
|
||||
assert( !zName || xDel!=SQLITE_DYNAMIC );
|
||||
return SQLITE_NOMEM;
|
||||
return SQLITE_NOMEM_BKPT;
|
||||
}
|
||||
assert( p->aColName!=0 );
|
||||
pColName = &(p->aColName[idx+var*p->nResColumn]);
|
||||
@@ -2137,7 +2141,9 @@ int sqlite3VdbeSetColName(
|
||||
*/
|
||||
static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
int i;
|
||||
int nTrans = 0; /* Number of databases with an active write-transaction */
|
||||
int nTrans = 0; /* Number of databases with an active write-transaction
|
||||
** that are candidates for a two-phase commit using a
|
||||
** master-journal */
|
||||
int rc = SQLITE_OK;
|
||||
int needXcommit = 0;
|
||||
|
||||
@@ -2165,10 +2171,28 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
if( sqlite3BtreeIsInTrans(pBt) ){
|
||||
/* Whether or not a database might need a master journal depends upon
|
||||
** its journal mode (among other things). This matrix determines which
|
||||
** journal modes use a master journal and which do not */
|
||||
static const u8 aMJNeeded[] = {
|
||||
/* DELETE */ 1,
|
||||
/* PERSIST */ 1,
|
||||
/* OFF */ 0,
|
||||
/* TRUNCATE */ 1,
|
||||
/* MEMORY */ 0,
|
||||
/* WAL */ 0
|
||||
};
|
||||
Pager *pPager; /* Pager associated with pBt */
|
||||
needXcommit = 1;
|
||||
if( i!=1 ) nTrans++;
|
||||
sqlite3BtreeEnter(pBt);
|
||||
rc = sqlite3PagerExclusiveLock(sqlite3BtreePager(pBt));
|
||||
pPager = sqlite3BtreePager(pBt);
|
||||
if( db->aDb[i].safety_level!=PAGER_SYNCHRONOUS_OFF
|
||||
&& aMJNeeded[sqlite3PagerGetJournalMode(pPager)]
|
||||
){
|
||||
assert( i!=1 );
|
||||
nTrans++;
|
||||
}
|
||||
rc = sqlite3PagerExclusiveLock(pPager);
|
||||
sqlite3BtreeLeave(pBt);
|
||||
}
|
||||
}
|
||||
@@ -2226,7 +2250,6 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
else{
|
||||
sqlite3_vfs *pVfs = db->pVfs;
|
||||
int needSync = 0;
|
||||
char *zMaster = 0; /* File-name for the master journal */
|
||||
char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);
|
||||
sqlite3_file *pMaster = 0;
|
||||
@@ -2238,7 +2261,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
/* Select a master journal file name */
|
||||
nMainFile = sqlite3Strlen30(zMainFile);
|
||||
zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile);
|
||||
if( zMaster==0 ) return SQLITE_NOMEM;
|
||||
if( zMaster==0 ) return SQLITE_NOMEM_BKPT;
|
||||
do {
|
||||
u32 iRandom;
|
||||
if( retryCount ){
|
||||
@@ -2286,9 +2309,6 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
continue; /* Ignore TEMP and :memory: databases */
|
||||
}
|
||||
assert( zFile[0]!=0 );
|
||||
if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
|
||||
needSync = 1;
|
||||
}
|
||||
rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
|
||||
offset += sqlite3Strlen30(zFile)+1;
|
||||
if( rc!=SQLITE_OK ){
|
||||
@@ -2303,8 +2323,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
/* Sync the master journal file. If the IOCAP_SEQUENTIAL device
|
||||
** flag is set this is not required.
|
||||
*/
|
||||
if( needSync
|
||||
&& 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
|
||||
if( 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
|
||||
&& SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))
|
||||
){
|
||||
sqlite3OsCloseFree(pMaster);
|
||||
@@ -2340,7 +2359,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
** doing this the directory is synced again before any individual
|
||||
** transaction files are deleted.
|
||||
*/
|
||||
rc = sqlite3OsDelete(pVfs, zMaster, needSync);
|
||||
rc = sqlite3OsDelete(pVfs, zMaster, 1);
|
||||
sqlite3DbFree(db, zMaster);
|
||||
zMaster = 0;
|
||||
if( rc ){
|
||||
@@ -2528,7 +2547,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
*/
|
||||
|
||||
if( db->mallocFailed ){
|
||||
p->rc = SQLITE_NOMEM;
|
||||
p->rc = SQLITE_NOMEM_BKPT;
|
||||
}
|
||||
if( p->aOnceFlag ) memset(p->aOnceFlag, 0, p->nOnceFlag);
|
||||
closeAllCursors(p);
|
||||
@@ -2689,7 +2708,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
p->magic = VDBE_MAGIC_HALT;
|
||||
checkActiveVdbeCnt(db);
|
||||
if( db->mallocFailed ){
|
||||
p->rc = SQLITE_NOMEM;
|
||||
p->rc = SQLITE_NOMEM_BKPT;
|
||||
}
|
||||
|
||||
/* If the auto-commit flag is set to true, then any locks that were held
|
||||
@@ -2876,8 +2895,7 @@ int sqlite3VdbeFinalize(Vdbe *p){
|
||||
** * the corresponding bit in argument mask is clear (where the first
|
||||
** function parameter corresponds to bit 0 etc.).
|
||||
*/
|
||||
void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
|
||||
AuxData **pp = &pVdbe->pAuxData;
|
||||
void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){
|
||||
while( *pp ){
|
||||
AuxData *pAux = *pp;
|
||||
if( (iOp<0)
|
||||
@@ -2888,7 +2906,7 @@ void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
|
||||
pAux->xDelete(pAux->pAux);
|
||||
}
|
||||
*pp = pAux->pNext;
|
||||
sqlite3DbFree(pVdbe->db, pAux);
|
||||
sqlite3DbFree(db, pAux);
|
||||
}else{
|
||||
pp= &pAux->pNext;
|
||||
}
|
||||
@@ -3668,7 +3686,7 @@ static int vdbeCompareMemString(
|
||||
v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
|
||||
n2 = v2==0 ? 0 : c2.n;
|
||||
rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
|
||||
if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM;
|
||||
if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
|
||||
sqlite3VdbeMemRelease(&c1);
|
||||
sqlite3VdbeMemRelease(&c2);
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user