diff options
author | drh <drh@noemail.net> | 2020-03-10 18:55:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-03-10 18:55:41 +0000 |
commit | 5cf1b611a20201aa141b258901cbfc2950e2037e (patch) | |
tree | c144ef8ab86cb9237cb8fbb655534f2069005ee4 /src | |
parent | 24e399038bfb59823ea6bf1939c2282eeaf4401a (diff) | |
download | sqlite-5cf1b611a20201aa141b258901cbfc2950e2037e.tar.gz sqlite-5cf1b611a20201aa141b258901cbfc2950e2037e.zip |
Further changes to ensure that expressions held in table and index definitions
do not get passed down into code generator logic where they might be modified.
FossilOrigin-Name: f45f5de000834da5b23cdcf12c3f0e3073287756afe06bdb77b95fb65b250258
Diffstat (limited to 'src')
-rw-r--r-- | src/insert.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/insert.c b/src/insert.c index 43d2f11c1..f4049fb3d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1606,7 +1606,7 @@ void sqlite3GenerateConstraintChecks( VdbeCoverage(v); assert( (pCol->colFlags & COLFLAG_GENERATED)==0 ); nSeenReplace++; - sqlite3ExprCode(pParse, pCol->pDflt, iReg); + sqlite3ExprCodeCopy(pParse, pCol->pDflt, iReg); sqlite3VdbeJumpHere(v, addr1); break; } @@ -1661,6 +1661,7 @@ void sqlite3GenerateConstraintChecks( onError = overrideError!=OE_Default ? overrideError : OE_Abort; for(i=0; i<pCheck->nExpr; i++){ int allOk; + Expr *pCopy; Expr *pExpr = pCheck->a[i].pExpr; if( aiChng && !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng) @@ -1675,7 +1676,11 @@ void sqlite3GenerateConstraintChecks( } allOk = sqlite3VdbeMakeLabel(pParse); sqlite3VdbeVerifyAbortable(v, onError); - sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL); + pCopy = sqlite3ExprDup(db, pExpr, 0); + if( !db->mallocFailed ){ + sqlite3ExprIfTrue(pParse, pCopy, allOk, SQLITE_JUMPIFNULL); + } + sqlite3ExprDelete(db, pCopy); if( onError==OE_Ignore ){ sqlite3VdbeGoto(v, ignoreDest); }else{ |