diff options
author | drh <drh@noemail.net> | 2012-10-09 14:58:15 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-10-09 14:58:15 +0000 |
commit | d1102b1ec7d50045cbbcf2575eacb2d423361fc7 (patch) | |
tree | a586e444e7362a6cf02fa05c85311851e36abb97 /src/insert.c | |
parent | c4645dacfb435002911b187b474fa0788db9cde0 (diff) | |
parent | 5a55826bcda624f8fa4a3b7cc0c8845a689d8957 (diff) | |
download | sqlite-d1102b1ec7d50045cbbcf2575eacb2d423361fc7.tar.gz sqlite-d1102b1ec7d50045cbbcf2575eacb2d423361fc7.zip |
Merge the latest trunk changes, especially the ORDER BY optimizer enhancements
but also other fixes, onto the sessions branch.
FossilOrigin-Name: f1fbb8c5bfa84e84e0b8e2872d83b06a0c0d5acc
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/insert.c b/src/insert.c index 097b6fcad..3950dbd3b 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1274,20 +1274,25 @@ void sqlite3GenerateConstraintChecks( onError = overrideError!=OE_Default ? overrideError : OE_Abort; for(i=0; i<pCheck->nExpr; i++){ int allOk = sqlite3VdbeMakeLabel(v); - sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL); - if( onError==OE_Ignore ){ - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); - }else{ - char *zConsName = pCheck->a[i].zName; - if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ - if( zConsName ){ - zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName); + Expr *pDup = sqlite3ExprDup(db, pCheck->a[i].pExpr, 0); + if( !db->mallocFailed ){ + assert( pDup!=0 ); + sqlite3ExprIfTrue(pParse, pDup, allOk, SQLITE_JUMPIFNULL); + if( onError==OE_Ignore ){ + sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); }else{ - zConsName = 0; + char *zConsName = pCheck->a[i].zName; + if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ + if( zConsName ){ + zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName); + }else{ + zConsName = 0; + } + sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC); } - sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC); + sqlite3VdbeResolveLabel(v, allOk); } - sqlite3VdbeResolveLabel(v, allOk); + sqlite3ExprDelete(db, pDup); } } #endif /* !defined(SQLITE_OMIT_CHECK) */ @@ -1753,7 +1758,7 @@ static int xferOptimization( ** we have to check the semantics. */ pItem = pSelect->pSrc->a; - pSrc = sqlite3LocateTable(pParse, 0, pItem->zName, pItem->zDatabase); + pSrc = sqlite3LocateTableItem(pParse, 0, pItem); if( pSrc==0 ){ return 0; /* FROM clause does not contain a real table */ } |