/ Check-in [9ef69d18]
Login

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

Overview
Comment:Experimental change to apply affinity before running CHECK constraints on an INSERT. Note that in the CHECK constraints, REAL affinity really is REAL affinity, and not numeric affinity. This causes failures in some tests that are assuming affinity is applied after CHECK constraints.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | apply-affinity-first
Files: files | file ages | folders
SHA3-256: 9ef69d183927a26b293907e09d2e1d03c4125315178801d839cc64a50d1877af
User & Date: drh 2019-03-20 20:27:20
Context
2019-03-20
20:27
Experimental change to apply affinity before running CHECK constraints on an INSERT. Note that in the CHECK constraints, REAL affinity really is REAL affinity, and not numeric affinity. This causes failures in some tests that are assuming affinity is applied after CHECK constraints. Leaf check-in: 9ef69d18 user: drh tags: apply-affinity-first
18:22
In the CLI, give better error messages if something goes wrong with the ".dbinfo" command. check-in: 3649a77b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

  1392   1392     }
  1393   1393   
  1394   1394     /* Test all CHECK constraints
  1395   1395     */
  1396   1396   #ifndef SQLITE_OMIT_CHECK
  1397   1397     if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
  1398   1398       ExprList *pCheck = pTab->pCheck;
         1399  +    VdbeOp *pOp;
  1399   1400       pParse->iSelfTab = -(regNewData+1);
  1400   1401       onError = overrideError!=OE_Default ? overrideError : OE_Abort;
         1402  +    sqlite3TableAffinity(v, pTab, regNewData+1);
         1403  +    pOp = sqlite3VdbeGetOp(v, -1);
         1404  +    if( pOp->opcode==OP_Affinity && pOp->p4.z!=0 ){
         1405  +      const char *zAff = pOp->p4.z;
         1406  +      for(i=0; zAff[i]; i++){
         1407  +        if( zAff[i]=='E' ) sqlite3VdbeAddOp1(v,OP_RealAffinity,regNewData+i+1);
         1408  +      }
         1409  +    }
  1401   1410       for(i=0; i<pCheck->nExpr; i++){
  1402   1411         int allOk;
  1403   1412         Expr *pExpr = pCheck->a[i].pExpr;
  1404   1413         if( aiChng
  1405   1414          && !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng)
  1406   1415         ){
  1407   1416           /* The check constraints do not reference any of the columns being