/ Check-in [1a9db8dc]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Duplicating check constraint expressions prior to code generation is no longer required, and so it is removed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ticket-71e333e7
Files: files | file ages | folders
SHA1: 1a9db8dc2f3c5cb089801d56122cdf5c3a618163
User & Date: drh 2012-12-08 04:10:44
Context
2012-12-08
13:26
Fix the header comment on the OP_Compare operator. check-in: 2722f407 user: drh tags: ticket-71e333e7
04:10
Duplicating check constraint expressions prior to code generation is no longer required, and so it is removed. check-in: 1a9db8dc user: drh tags: ticket-71e333e7
03:34
Veryquick passes all tests now. check-in: 7b96115e user: drh tags: ticket-71e333e7
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

  1270   1270   #ifndef SQLITE_OMIT_CHECK
  1271   1271     if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
  1272   1272       ExprList *pCheck = pTab->pCheck;
  1273   1273       pParse->ckBase = regData;
  1274   1274       onError = overrideError!=OE_Default ? overrideError : OE_Abort;
  1275   1275       for(i=0; i<pCheck->nExpr; i++){
  1276   1276         int allOk = sqlite3VdbeMakeLabel(v);
  1277         -      Expr *pDup = sqlite3ExprDup(db, pCheck->a[i].pExpr, 0);
  1278         -      if( !db->mallocFailed ){
  1279         -        assert( pDup!=0 );
  1280         -        sqlite3ExprIfTrue(pParse, pDup, allOk, SQLITE_JUMPIFNULL);
  1281         -        if( onError==OE_Ignore ){
  1282         -          sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
         1277  +      sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
         1278  +      if( onError==OE_Ignore ){
         1279  +        sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
         1280  +      }else{
         1281  +        char *zConsName = pCheck->a[i].zName;
         1282  +        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
         1283  +        if( zConsName ){
         1284  +          zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
  1283   1285           }else{
  1284         -          char *zConsName = pCheck->a[i].zName;
  1285         -          if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
  1286         -          if( zConsName ){
  1287         -            zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
  1288         -          }else{
  1289         -            zConsName = 0;
  1290         -          }
  1291         -          sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
         1286  +          zConsName = 0;
  1292   1287           }
  1293         -        sqlite3VdbeResolveLabel(v, allOk);
         1288  +        sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
  1294   1289         }
  1295         -      sqlite3ExprDelete(db, pDup);
         1290  +      sqlite3VdbeResolveLabel(v, allOk);
  1296   1291       }
  1297   1292     }
  1298   1293   #endif /* !defined(SQLITE_OMIT_CHECK) */
  1299   1294   
  1300   1295     /* If we have an INTEGER PRIMARY KEY, make sure the primary key
  1301   1296     ** of the new record does not previously exist.  Except, if this
  1302   1297     ** is an UPDATE and the primary key is not changing, that is OK.