Merge enhancements from trunk.
FossilOrigin-Name: a533608cb0de3cbc1e28a794aab99864b8c249f4
This commit is contained in:
+12
-8
@@ -290,7 +290,7 @@ int sqlite3VdbeAddOp4Dup8(
|
||||
const u8 *zP4, /* The P4 operand */
|
||||
int p4type /* P4 operand type */
|
||||
){
|
||||
char *p4copy = sqlite3DbMallocRaw(sqlite3VdbeDb(p), 8);
|
||||
char *p4copy = sqlite3DbMallocRawNN(sqlite3VdbeDb(p), 8);
|
||||
if( p4copy ) memcpy(p4copy, zP4, 8);
|
||||
return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);
|
||||
}
|
||||
@@ -647,6 +647,9 @@ VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){
|
||||
/*
|
||||
** Add a whole list of operations to the operation stack. Return a
|
||||
** pointer to the first operation inserted.
|
||||
**
|
||||
** Non-zero P2 arguments to jump instructions are automatically adjusted
|
||||
** so that the jump target is relative to the first operation inserted.
|
||||
*/
|
||||
VdbeOp *sqlite3VdbeAddOpList(
|
||||
Vdbe *p, /* Add opcodes to the prepared statement */
|
||||
@@ -667,6 +670,9 @@ VdbeOp *sqlite3VdbeAddOpList(
|
||||
pOut->p1 = aOp->p1;
|
||||
pOut->p2 = aOp->p2;
|
||||
assert( aOp->p2>=0 );
|
||||
if( (sqlite3OpcodeProperty[aOp->opcode] & OPFLG_JUMP)!=0 && aOp->p2>0 ){
|
||||
pOut->p2 += p->nOp;
|
||||
}
|
||||
pOut->p3 = aOp->p3;
|
||||
pOut->p4type = P4_NOTUSED;
|
||||
pOut->p4.p = 0;
|
||||
@@ -1418,7 +1424,6 @@ static void releaseMemArray(Mem *p, int N){
|
||||
if( p && N ){
|
||||
Mem *pEnd = &p[N];
|
||||
sqlite3 *db = p->db;
|
||||
u8 malloc_failed = db->mallocFailed;
|
||||
if( db->pnBytesFreed ){
|
||||
do{
|
||||
if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
|
||||
@@ -1454,7 +1459,6 @@ static void releaseMemArray(Mem *p, int N){
|
||||
|
||||
p->flags = MEM_Undefined;
|
||||
}while( (++p)<pEnd );
|
||||
db->mallocFailed = malloc_failed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1515,7 +1519,7 @@ int sqlite3VdbeList(
|
||||
if( p->rc==SQLITE_NOMEM ){
|
||||
/* This happens if a malloc() inside a call to sqlite3_column_text() or
|
||||
** sqlite3_column_text16() failed. */
|
||||
db->mallocFailed = 1;
|
||||
sqlite3OomFault(db);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
@@ -2508,7 +2512,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
** one, or the complete transaction if there is no statement transaction.
|
||||
*/
|
||||
|
||||
if( p->db->mallocFailed ){
|
||||
if( db->mallocFailed ){
|
||||
p->rc = SQLITE_NOMEM;
|
||||
}
|
||||
if( p->aOnceFlag ) memset(p->aOnceFlag, 0, p->nOnceFlag);
|
||||
@@ -2669,7 +2673,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
}
|
||||
p->magic = VDBE_MAGIC_HALT;
|
||||
checkActiveVdbeCnt(db);
|
||||
if( p->db->mallocFailed ){
|
||||
if( db->mallocFailed ){
|
||||
p->rc = SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
@@ -2706,12 +2710,12 @@ int sqlite3VdbeTransferError(Vdbe *p){
|
||||
sqlite3 *db = p->db;
|
||||
int rc = p->rc;
|
||||
if( p->zErrMsg ){
|
||||
u8 mallocFailed = db->mallocFailed;
|
||||
db->bBenignMalloc++;
|
||||
sqlite3BeginBenignMalloc();
|
||||
if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);
|
||||
sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
|
||||
sqlite3EndBenignMalloc();
|
||||
db->mallocFailed = mallocFailed;
|
||||
db->bBenignMalloc--;
|
||||
db->errCode = rc;
|
||||
}else{
|
||||
sqlite3Error(db, rc);
|
||||
|
||||
Reference in New Issue
Block a user