diff options
author | drh <drh@noemail.net> | 2016-02-10 19:10:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-02-10 19:10:50 +0000 |
commit | 05723a9e3c44b26d8dae814848fc142af8cb74b1 (patch) | |
tree | c77f078290430302ea224606929586eeb61f6fa9 /src/insert.c | |
parent | 98bfa16db247c4887f4c090269413a0c2248b390 (diff) | |
download | sqlite-05723a9e3c44b26d8dae814848fc142af8cb74b1.tar.gz sqlite-05723a9e3c44b26d8dae814848fc142af8cb74b1.zip |
Add testcase() macros to the CHECK constraint avoidance logic. Avoid creating
an unused VDBE label during CHECK constraint code generation.
FossilOrigin-Name: 970881befd5da6cc837c474d6e917de0bf029350
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/insert.c b/src/insert.c index 8cb26a54a..7ff884b8c 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1119,7 +1119,14 @@ static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){ w.xExprCallback = checkConstraintExprNode; w.u.aiCol = aiChng; sqlite3WalkExpr(&w, pExpr); - if( !chngRowid ) w.eCode &= ~CKCNSTRNT_ROWID; + if( !chngRowid ){ + testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 ); + w.eCode &= ~CKCNSTRNT_ROWID; + } + testcase( w.eCode==0 ); + testcase( w.eCode==CKCNSTRNT_COLUMN ); + testcase( w.eCode==CKCNSTRNT_ROWID ); + testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) ); return !w.eCode; } @@ -1320,9 +1327,10 @@ void sqlite3GenerateConstraintChecks( pParse->ckBase = regNewData+1; onError = overrideError!=OE_Default ? overrideError : OE_Abort; for(i=0; i<pCheck->nExpr; i++){ - int allOk = sqlite3VdbeMakeLabel(v); + int allOk; Expr *pExpr = pCheck->a[i].pExpr; if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue; + allOk = sqlite3VdbeMakeLabel(v); sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL); if( onError==OE_Ignore ){ sqlite3VdbeGoto(v, ignoreDest); |