/ Check-in [c2c776ab]
Login

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

Overview
Comment:Fix a problem with shared-cache mode and CHECK constraints causing one db handle to invoke a collation sequence function registered with another.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | shared-cache-fix
Files: files | file ages | folders
SHA1:c2c776ab73828374836af008aa320cc670c081b5
User & Date: dan 2012-10-05 16:30:10
Context
2012-10-05
17:18
Add a test for the collation-sequence/CHECK constraint problem fixed by the previous commit. Closed-Leaf check-in: 82b6aa77 user: dan tags: shared-cache-fix
16:30
Fix a problem with shared-cache mode and CHECK constraints causing one db handle to invoke a collation sequence function registered with another. check-in: c2c776ab user: dan tags: shared-cache-fix
2012-10-04
19:33
Shared-cache mode fixes for views and virtual tables. check-in: 2b370dea user: dan tags: shared-cache-fix
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         -      sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
         1277  +      Expr *pDup = sqlite3ExprDup(db, pCheck->a[i].pExpr, 0);
         1278  +      if( pDup==0 ) break;
         1279  +      sqlite3ExprIfTrue(pParse, pDup, allOk, SQLITE_JUMPIFNULL);
  1278   1280         if( onError==OE_Ignore ){
  1279   1281           sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
  1280   1282         }else{
  1281   1283           char *zConsName = pCheck->a[i].zName;
  1282   1284           if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
  1283   1285           if( zConsName ){
  1284   1286             zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
  1285   1287           }else{
  1286   1288             zConsName = 0;
  1287   1289           }
  1288   1290           sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
  1289   1291         }
  1290   1292         sqlite3VdbeResolveLabel(v, allOk);
         1293  +      sqlite3ExprDelete(db, pDup);
  1291   1294       }
  1292   1295     }
  1293   1296   #endif /* !defined(SQLITE_OMIT_CHECK) */
  1294   1297   
  1295   1298     /* If we have an INTEGER PRIMARY KEY, make sure the primary key
  1296   1299     ** of the new record does not previously exist.  Except, if this
  1297   1300     ** is an UPDATE and the primary key is not changing, that is OK.