/ Check-in [54b22192]
Login

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

Overview
Comment:Standardize the error messages generated by constraint failures to a format of "$TYPE constraint failed: $DETAIL". This involves many changes to the expected output of test cases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-rowid
Files: files | file ages | folders
SHA1: 54b221929744b1bcdbcc2030fef2e510618afd41
User & Date: drh 2013-11-05 13:33:55
Context
2013-11-05
14:19
Add tests for updates of without-rowid tables that use non-BINARY collation sequences for the primary key columns. And a minor bugfix to the same. check-in: 99b1fa4b user: dan tags: omit-rowid
13:33
Standardize the error messages generated by constraint failures to a format of "$TYPE constraint failed: $DETAIL". This involves many changes to the expected output of test cases. check-in: 54b22192 user: drh tags: omit-rowid
01:59
Add the conflict2.test script. Fix issues discovered by this script. check-in: 294ed337 user: drh tags: omit-rowid
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2679   2679     assert( pKey!=0 || db->mallocFailed || pParse->nErr );
  2680   2680     if( pIndex->onError!=OE_None && pKey!=0 ){
  2681   2681       int j2 = sqlite3VdbeCurrentAddr(v) + 3;
  2682   2682       sqlite3VdbeAddOp2(v, OP_Goto, 0, j2);
  2683   2683       addr2 = sqlite3VdbeCurrentAddr(v);
  2684   2684       sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
  2685   2685                            pKey->nField - pIndex->nKeyCol);
  2686         -    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE,
  2687         -        OE_Abort, "indexed columns are not unique", P4_STATIC
  2688         -    );
         2686  +    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
  2689   2687     }else{
  2690   2688       addr2 = sqlite3VdbeCurrentAddr(v);
  2691   2689     }
  2692   2690     sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord);
  2693   2691     sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
  2694   2692     sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  2695   2693     sqlite3ReleaseTempReg(pParse, regRecord);
................................................................................
  3945   3943   ** and/or current transaction is rolled back.
  3946   3944   */
  3947   3945   void sqlite3HaltConstraint(
  3948   3946     Parse *pParse,    /* Parsing context */
  3949   3947     int errCode,      /* extended error code */
  3950   3948     int onError,      /* Constraint type */
  3951   3949     char *p4,         /* Error message */
  3952         -  int p4type        /* P4_STATIC or P4_TRANSIENT */
         3950  +  i8 p4type,        /* P4_STATIC or P4_TRANSIENT */
         3951  +  u8 p5Errmsg       /* P5_ErrMsg type */
  3953   3952   ){
  3954   3953     Vdbe *v = sqlite3GetVdbe(pParse);
  3955   3954     assert( (errCode&0xff)==SQLITE_CONSTRAINT );
  3956   3955     if( onError==OE_Abort ){
  3957   3956       sqlite3MayAbort(pParse);
  3958   3957     }
  3959   3958     sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);
         3959  +  if( p5Errmsg ) sqlite3VdbeChangeP5(v, p5Errmsg);
         3960  +}
         3961  +
         3962  +/*
         3963  +** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.
         3964  +*/
         3965  +void sqlite3UniqueConstraint(
         3966  +  Parse *pParse,    /* Parsing context */
         3967  +  int onError,      /* Constraint type */
         3968  +  Index *pIdx       /* The index that triggers the constraint */
         3969  +){
         3970  +  char *zErr;
         3971  +  int j;
         3972  +  StrAccum errMsg;
         3973  +  Table *pTab = pIdx->pTable;
         3974  +
         3975  +  sqlite3StrAccumInit(&errMsg, 0, 0, 200);
         3976  +  errMsg.db = pParse->db;
         3977  +  for(j=0; j<pIdx->nKeyCol; j++){
         3978  +    char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
         3979  +    if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
         3980  +    sqlite3StrAccumAppend(&errMsg, pTab->zName, -1);
         3981  +    sqlite3StrAccumAppend(&errMsg, ".", 1);
         3982  +    sqlite3StrAccumAppend(&errMsg, zCol, -1);
         3983  +  }
         3984  +  zErr = sqlite3StrAccumFinish(&errMsg);
         3985  +  sqlite3HaltConstraint(pParse, 
         3986  +    (pIdx->autoIndex==2)?SQLITE_CONSTRAINT_PRIMARYKEY:SQLITE_CONSTRAINT_UNIQUE,
         3987  +    onError, zErr, 0, P5_ConstraintUnique);
         3988  +  sqlite3DbFree(errMsg.db, zErr);
         3989  +}
         3990  +
         3991  +
         3992  +/*
         3993  +** Code an OP_Halt due to non-unique rowid.
         3994  +*/
         3995  +void sqlite3RowidConstraint(
         3996  +  Parse *pParse,    /* Parsing context */
         3997  +  int onError,      /* Conflict resolution algorithm */
         3998  +  Table *pTab       /* The table with the non-unique rowid */ 
         3999  +){
         4000  +  char *zMsg;
         4001  +  int rc;
         4002  +  if( pTab->iPKey>=0 ){
         4003  +    zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName,
         4004  +                          pTab->aCol[pTab->iPKey].zName);
         4005  +    rc = SQLITE_CONSTRAINT_PRIMARYKEY;
         4006  +  }else{
         4007  +    zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName);
         4008  +    rc = SQLITE_CONSTRAINT_ROWID;
         4009  +  }
         4010  +  sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,
         4011  +                        P5_ConstraintUnique);
  3960   4012   }
  3961   4013   
  3962   4014   /*
  3963   4015   ** Check to see if pIndex uses the collating sequence pColl.  Return
  3964   4016   ** true if it does and false if it does not.
  3965   4017   */
  3966   4018   #ifndef SQLITE_OMIT_REINDEX

Changes to src/expr.c.

  2968   2968         }
  2969   2969         assert( !ExprHasProperty(pExpr, EP_IntValue) );
  2970   2970         if( pExpr->affinity==OE_Ignore ){
  2971   2971           sqlite3VdbeAddOp4(
  2972   2972               v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
  2973   2973         }else{
  2974   2974           sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,
  2975         -                              pExpr->affinity, pExpr->u.zToken, 0);
         2975  +                              pExpr->affinity, pExpr->u.zToken, 0, 0);
  2976   2976         }
  2977   2977   
  2978   2978         break;
  2979   2979       }
  2980   2980   #endif
  2981   2981     }
  2982   2982     sqlite3ReleaseTempReg(pParse, regFree1);

Changes to src/fkey.c.

   428    428     ){
   429    429       /* Special case: If this is an INSERT statement that will insert exactly
   430    430       ** one row into the table, raise a constraint immediately instead of
   431    431       ** incrementing a counter. This is necessary as the VM code is being
   432    432       ** generated for will not open a statement transaction.  */
   433    433       assert( nIncr==1 );
   434    434       sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
   435         -        OE_Abort, "foreign key constraint failed", P4_STATIC
   436         -    );
          435  +        OE_Abort, 0, P4_STATIC, P5_ConstraintFK);
   437    436     }else{
   438    437       if( nIncr>0 && pFKey->isDeferred==0 ){
   439    438         sqlite3ParseToplevel(pParse)->mayAbort = 1;
   440    439       }
   441    440       sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
   442    441     }
   443    442   
................................................................................
   512    511   ** table that correspond to the parent table row being deleted or inserted.
   513    512   ** For each child row found, one of the following actions is taken:
   514    513   **
   515    514   **   Operation | FK type   | Action taken
   516    515   **   --------------------------------------------------------------------------
   517    516   **   DELETE      immediate   Increment the "immediate constraint counter".
   518    517   **                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,
   519         -**                           throw a "foreign key constraint failed" exception.
          518  +**                           throw a "FOREIGN KEY constraint failed" exception.
   520    519   **
   521    520   **   INSERT      immediate   Decrement the "immediate constraint counter".
   522    521   **
   523    522   **   DELETE      deferred    Increment the "deferred constraint counter".
   524    523   **                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,
   525         -**                           throw a "foreign key constraint failed" exception.
          524  +**                           throw a "FOREIGN KEY constraint failed" exception.
   526    525   **
   527    526   **   INSERT      deferred    Decrement the "deferred constraint counter".
   528    527   **
   529    528   ** These operations are identified in the comment at the top of this file 
   530    529   ** (fkey.c) as "I.2" and "D.2".
   531    530   */
   532    531   static void fkScanChildren(
................................................................................
   730    729       ** If the SQLITE_DeferFKs flag is set, then this is not required, as
   731    730       ** the statement transaction will not be rolled back even if FK
   732    731       ** constraints are violated.
   733    732       */
   734    733       if( (db->flags & SQLITE_DeferFKs)==0 ){
   735    734         sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
   736    735         sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
   737         -          OE_Abort, "foreign key constraint failed", P4_STATIC
   738         -      );
          736  +          OE_Abort, 0, P4_STATIC, P5_ConstraintFK);
   739    737       }
   740    738   
   741    739       if( iSkip ){
   742    740         sqlite3VdbeResolveLabel(v, iSkip);
   743    741       }
   744    742     }
   745    743   }
................................................................................
  1209   1207   
  1210   1208       if( action==OE_Restrict ){
  1211   1209         Token tFrom;
  1212   1210         Expr *pRaise; 
  1213   1211   
  1214   1212         tFrom.z = zFrom;
  1215   1213         tFrom.n = nFrom;
  1216         -      pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed");
         1214  +      pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed");
  1217   1215         if( pRaise ){
  1218   1216           pRaise->affinity = OE_Abort;
  1219   1217         }
  1220   1218         pSelect = sqlite3SelectNew(pParse, 
  1221   1219             sqlite3ExprListAppend(pParse, 0, pRaise),
  1222   1220             sqlite3SrcListAppend(db, 0, &tFrom, 0),
  1223   1221             pWhere,

Changes to src/insert.c.

  1274   1274           || onError==OE_Ignore || onError==OE_Replace );
  1275   1275       switch( onError ){
  1276   1276         case OE_Abort:
  1277   1277           sqlite3MayAbort(pParse);
  1278   1278           /* Fall through */
  1279   1279         case OE_Rollback:
  1280   1280         case OE_Fail: {
  1281         -        char *zMsg;
  1282         -        sqlite3VdbeAddOp3(v, OP_HaltIfNull,
  1283         -                          SQLITE_CONSTRAINT_NOTNULL, onError, regNewData+1+i);
  1284         -        zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL",
  1285         -                              pTab->zName, pTab->aCol[i].zName);
  1286         -        sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
         1281  +        char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
         1282  +                                    pTab->aCol[i].zName);
         1283  +        sqlite3VdbeAddOp4(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,
         1284  +                          regNewData+1+i, zMsg, P4_DYNAMIC);
         1285  +        sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
  1287   1286           break;
  1288   1287         }
  1289   1288         case OE_Ignore: {
  1290   1289           sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
  1291   1290           break;
  1292   1291         }
  1293   1292         default: {
................................................................................
  1309   1308       onError = overrideError!=OE_Default ? overrideError : OE_Abort;
  1310   1309       for(i=0; i<pCheck->nExpr; i++){
  1311   1310         int allOk = sqlite3VdbeMakeLabel(v);
  1312   1311         sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
  1313   1312         if( onError==OE_Ignore ){
  1314   1313           sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
  1315   1314         }else{
  1316         -        char *zConsName = pCheck->a[i].zName;
         1315  +        char *zName = pCheck->a[i].zName;
         1316  +        if( zName==0 ) zName = pTab->zName;
  1317   1317           if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
  1318         -        if( zConsName ){
  1319         -          zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
  1320         -        }else{
  1321         -          zConsName = 0;
  1322         -        }
  1323   1318           sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,
  1324         -                              onError, zConsName, P4_DYNAMIC);
         1319  +                              onError, zName, P4_TRANSIENT,
         1320  +                              P5_ConstraintCheck);
  1325   1321         }
  1326   1322         sqlite3VdbeResolveLabel(v, allOk);
  1327   1323       }
  1328   1324     }
  1329   1325   #endif /* !defined(SQLITE_OMIT_CHECK) */
  1330   1326   
  1331   1327     /* If rowid is changing, make sure the new rowid does not previously
................................................................................
  1358   1354         default: {
  1359   1355           onError = OE_Abort;
  1360   1356           /* Fall thru into the next case */
  1361   1357         }
  1362   1358         case OE_Rollback:
  1363   1359         case OE_Abort:
  1364   1360         case OE_Fail: {
  1365         -        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY,
  1366         -           onError, "PRIMARY KEY must be unique", P4_STATIC);
         1361  +        sqlite3RowidConstraint(pParse, onError, pTab);
  1367   1362           break;
  1368   1363         }
  1369   1364         case OE_Replace: {
  1370   1365           /* If there are DELETE triggers on this table and the
  1371   1366           ** recursive-triggers flag is set, call GenerateRowDelete() to
  1372   1367           ** remove the conflicting row from the table. This will fire
  1373   1368           ** the triggers and remove both the table and index b-tree entries.
................................................................................
  1542   1537       /* Generate code that executes if the new index entry is not unique */
  1543   1538       assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
  1544   1539           || onError==OE_Ignore || onError==OE_Replace );
  1545   1540       switch( onError ){
  1546   1541         case OE_Rollback:
  1547   1542         case OE_Abort:
  1548   1543         case OE_Fail: {
  1549         -        if( pIdx->autoIndex==2 ){
  1550         -          sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY,
  1551         -                                onError, "PRIMARY KEY must be unique", 0);
  1552         -        }else{
  1553         -          int j;
  1554         -          StrAccum errMsg;
  1555         -          const char *zSep;
  1556         -          char *zErr;
  1557         -
  1558         -          sqlite3StrAccumInit(&errMsg, 0, 0, 200);
  1559         -          errMsg.db = db;
  1560         -          zSep = pIdx->nKeyCol>1 ? "columns " : "column ";
  1561         -          for(j=0; j<pIdx->nKeyCol; j++){
  1562         -            char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
  1563         -            sqlite3StrAccumAppend(&errMsg, zSep, -1);
  1564         -            zSep = ", ";
  1565         -            sqlite3StrAccumAppend(&errMsg, zCol, -1);
  1566         -          }
  1567         -          sqlite3StrAccumAppend(&errMsg,
  1568         -              pIdx->nKeyCol>1 ? " are not unique" : " is not unique", -1);
  1569         -          zErr = sqlite3StrAccumFinish(&errMsg);
  1570         -          sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE,
  1571         -                               onError, zErr, 0);
  1572         -          sqlite3DbFree(errMsg.db, zErr);
  1573         -        }
         1544  +        sqlite3UniqueConstraint(pParse, onError, pIdx);
  1574   1545           break;
  1575   1546         }
  1576   1547         case OE_Ignore: {
  1577   1548           assert( seenReplace==0 );
  1578   1549           sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
  1579   1550           break;
  1580   1551         }
................................................................................
  2015   1986         emptyDestTest = 0;
  2016   1987       }
  2017   1988       sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);
  2018   1989       emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0);
  2019   1990       if( pDest->iPKey>=0 ){
  2020   1991         addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
  2021   1992         addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);
  2022         -      sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY,
  2023         -          onError, "PRIMARY KEY must be unique", P4_STATIC);
         1993  +      sqlite3RowidConstraint(pParse, onError, pDest);
  2024   1994         sqlite3VdbeJumpHere(v, addr2);
  2025   1995         autoIncStep(pParse, regAutoinc, regRowid);
  2026   1996       }else if( pDest->pIndex==0 ){
  2027   1997         addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);
  2028   1998       }else{
  2029   1999         addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
  2030   2000         assert( (pDest->tabFlags & TF_Autoincrement)==0 );

Changes to src/main.c.

  1131   1131                                   zName = "SQLITE_CONSTRAINT_PRIMARYKEY";   break;
  1132   1132         case SQLITE_CONSTRAINT_NOTNULL: zName = "SQLITE_CONSTRAINT_NOTNULL";break;
  1133   1133         case SQLITE_CONSTRAINT_COMMITHOOK:
  1134   1134                                   zName = "SQLITE_CONSTRAINT_COMMITHOOK";   break;
  1135   1135         case SQLITE_CONSTRAINT_VTAB:    zName = "SQLITE_CONSTRAINT_VTAB";   break;
  1136   1136         case SQLITE_CONSTRAINT_FUNCTION:
  1137   1137                                   zName = "SQLITE_CONSTRAINT_FUNCTION";     break;
         1138  +      case SQLITE_CONSTRAINT_ROWID:   zName = "SQLITE_CONSTRAINT_ROWID";  break;
  1138   1139         case SQLITE_MISMATCH:           zName = "SQLITE_MISMATCH";          break;
  1139   1140         case SQLITE_MISUSE:             zName = "SQLITE_MISUSE";            break;
  1140   1141         case SQLITE_NOLFS:              zName = "SQLITE_NOLFS";             break;
  1141   1142         case SQLITE_AUTH:               zName = "SQLITE_AUTH";              break;
  1142   1143         case SQLITE_FORMAT:             zName = "SQLITE_FORMAT";            break;
  1143   1144         case SQLITE_RANGE:              zName = "SQLITE_RANGE";             break;
  1144   1145         case SQLITE_NOTADB:             zName = "SQLITE_NOTADB";            break;

Changes to src/sqlite.h.in.

   492    492   #define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))
   493    493   #define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))
   494    494   #define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))
   495    495   #define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))
   496    496   #define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
   497    497   #define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
   498    498   #define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
          499  +#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
   499    500   #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   500    501   #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   501    502   #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   502    503   
   503    504   /*
   504    505   ** CAPI3REF: Flags For File Open Operations
   505    506   **

Changes to src/sqliteInt.h.

  2934   2934   void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
  2935   2935                                        u8,u8,int,int*);
  2936   2936   void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
  2937   2937   int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, int*, int*);
  2938   2938   void sqlite3BeginWriteOperation(Parse*, int, int);
  2939   2939   void sqlite3MultiWrite(Parse*);
  2940   2940   void sqlite3MayAbort(Parse*);
  2941         -void sqlite3HaltConstraint(Parse*, int, int, char*, int);
         2941  +void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);
         2942  +void sqlite3UniqueConstraint(Parse*, int, Index*);
         2943  +void sqlite3RowidConstraint(Parse*, int, Table*);
  2942   2944   Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
  2943   2945   ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
  2944   2946   SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
  2945   2947   IdList *sqlite3IdListDup(sqlite3*,IdList*);
  2946   2948   Select *sqlite3SelectDup(sqlite3*,Select*,int);
  2947   2949   void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
  2948   2950   FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8);

Changes to src/vdbe.c.

   800    800     pcDest = (int)pIn1->u.i;
   801    801     pIn1->u.i = pc;
   802    802     REGISTER_TRACE(pOp->p1, pIn1);
   803    803     pc = pcDest;
   804    804     break;
   805    805   }
   806    806   
   807         -/* Opcode:  HaltIfNull  P1 P2 P3 P4 *
          807  +/* Opcode:  HaltIfNull  P1 P2 P3 P4 P5
   808    808   ** Synopsis:  if r[P3] null then halt
   809    809   **
   810    810   ** Check the value in register P3.  If it is NULL then Halt using
   811    811   ** parameter P1, P2, and P4 as if this were a Halt instruction.  If the
   812    812   ** value in register P3 is not NULL, then this routine is a no-op.
          813  +** The P5 parameter should be 1.
   813    814   */
   814    815   case OP_HaltIfNull: {      /* in3 */
   815    816     pIn3 = &aMem[pOp->p3];
   816    817     if( (pIn3->flags & MEM_Null)==0 ) break;
   817    818     /* Fall through into OP_Halt */
   818    819   }
   819    820   
   820         -/* Opcode:  Halt P1 P2 * P4 *
          821  +/* Opcode:  Halt P1 P2 * P4 P5
   821    822   **
   822    823   ** Exit immediately.  All open cursors, etc are closed
   823    824   ** automatically.
   824    825   **
   825    826   ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),
   826    827   ** or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).
   827    828   ** For errors, it can be some other value.  If P1!=0 then P2 will determine
   828    829   ** whether or not to rollback the current transaction.  Do not rollback
   829    830   ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,
   830    831   ** then back out all changes that have occurred during this execution of the
   831    832   ** VDBE, but do not rollback the transaction. 
   832    833   **
   833    834   ** If P4 is not null then it is an error message string.
          835  +**
          836  +** P5 is a value between 0 and 4, inclusive, that modifies the P4 string.
          837  +**
          838  +**    0:  (no change)
          839  +**    1:  NOT NULL contraint failed: P4
          840  +**    2:  UNIQUE constraint failed: P4
          841  +**    3:  CHECK constraint failed: P4
          842  +**    4:  FOREIGN KEY constraint failed: P4
          843  +**
          844  +** If P5 is not zero and P4 is NULL, then everything after the ":" is
          845  +** omitted.
   834    846   **
   835    847   ** There is an implied "Halt 0 0 0" instruction inserted at the very end of
   836    848   ** every program.  So a jump past the last instruction of the program
   837    849   ** is the same as executing Halt.
   838    850   */
   839    851   case OP_Halt: {
          852  +  const char *zType;
          853  +  const char *zLogFmt;
          854  +
   840    855     if( pOp->p1==SQLITE_OK && p->pFrame ){
   841    856       /* Halt the sub-program. Return control to the parent frame. */
   842    857       VdbeFrame *pFrame = p->pFrame;
   843    858       p->pFrame = pFrame->pParent;
   844    859       p->nFrame--;
   845    860       sqlite3VdbeSetChanges(db, p->nChange);
   846    861       pc = sqlite3VdbeFrameRestore(pFrame);
................................................................................
   853    868         ** as the p2 of the calling OP_Program.  */
   854    869         pc = p->aOp[pc].p2-1;
   855    870       }
   856    871       aOp = p->aOp;
   857    872       aMem = p->aMem;
   858    873       break;
   859    874     }
   860         -
          875  +  if( pOp->p5 ){
          876  +    static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK",
          877  +                                           "FOREIGN KEY" };
          878  +    assert( pOp->p5>=1 && pOp->p5<=4 );
          879  +    testcase( pOp->p5==1 );
          880  +    testcase( pOp->p5==2 );
          881  +    testcase( pOp->p5==3 );
          882  +    testcase( pOp->p5==4 );
          883  +    zType = azType[pOp->p5-1];
          884  +  }else{
          885  +    zType = 0;
          886  +  }
   861    887     p->rc = pOp->p1;
   862    888     p->errorAction = (u8)pOp->p2;
   863    889     p->pc = pc;
   864         -  if( pOp->p4.z ){
   865         -    assert( p->rc!=SQLITE_OK );
   866         -    sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
   867         -    testcase( sqlite3GlobalConfig.xLog!=0 );
   868         -    sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pc, p->zSql, pOp->p4.z);
   869         -  }else if( p->rc ){
   870         -    testcase( sqlite3GlobalConfig.xLog!=0 );
   871         -    sqlite3_log(pOp->p1, "constraint failed at %d in [%s]", pc, p->zSql);
          890  +  if( p->rc ){
          891  +    zLogFmt = "abort at %d in [%s]: %s";
          892  +    if( zType && pOp->p4.z ){
          893  +      sqlite3SetString(&p->zErrMsg, db, "%s constraint failed: %s", 
          894  +                       zType, pOp->p4.z);
          895  +    }else if( pOp->p4.z ){
          896  +      sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
          897  +    }else if( zType ){
          898  +      sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType);
          899  +    }else{
          900  +      zLogFmt = "abort at %d in [%s]";
          901  +    }
          902  +    sqlite3_log(pOp->p1, zLogFmt, pc, p->zSql, p->zErrMsg);
   872    903     }
   873    904     rc = sqlite3VdbeHalt(p);
   874    905     assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
   875    906     if( rc==SQLITE_BUSY ){
   876    907       p->rc = rc = SQLITE_BUSY;
   877    908     }else{
   878    909       assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );

Changes to src/vdbe.h.

   122    122   ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used.  It still
   123    123   ** gets freed when the Vdbe is finalized so it still should be obtained
   124    124   ** from a single sqliteMalloc().  But no copy is made and the calling
   125    125   ** function should *not* try to free the KeyInfo.
   126    126   */
   127    127   #define P4_KEYINFO_HANDOFF (-16)
   128    128   #define P4_KEYINFO_STATIC  (-17)
          129  +
          130  +/* Error message codes for OP_Halt */
          131  +#define P5_ConstraintNotNull 1
          132  +#define P5_ConstraintUnique  2
          133  +#define P5_ConstraintCheck   3
          134  +#define P5_ConstraintFK      4
   129    135   
   130    136   /*
   131    137   ** The Vdbe.aColName array contains 5n Mem structures, where n is the 
   132    138   ** number of columns of data returned by the statement.
   133    139   */
   134    140   #define COLNAME_NAME     0
   135    141   #define COLNAME_DECLTYPE 1

Changes to src/vdbeaux.c.

  2194   2194   int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
  2195   2195     sqlite3 *db = p->db;
  2196   2196     if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) 
  2197   2197      || (!deferred && p->nFkConstraint>0) 
  2198   2198     ){
  2199   2199       p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
  2200   2200       p->errorAction = OE_Abort;
  2201         -    sqlite3SetString(&p->zErrMsg, db, "foreign key constraint failed");
         2201  +    sqlite3SetString(&p->zErrMsg, db, "FOREIGN KEY constraint failed");
  2202   2202       return SQLITE_ERROR;
  2203   2203     }
  2204   2204     return SQLITE_OK;
  2205   2205   }
  2206   2206   #endif
  2207   2207   
  2208   2208   /*

Changes to test/autovacuum.test.

   522    522       SELECT sum(a) FROM av1;
   523    523     }
   524    524   } {5049}
   525    525   do_test autovacuum-4.2 {
   526    526     catchsql {
   527    527       CREATE UNIQUE INDEX av1_i ON av1(a);
   528    528     }
   529         -} {1 {indexed columns are not unique}}
          529  +} {1 {UNIQUE constraint failed: av1.a}}
   530    530   do_test autovacuum-4.3 {
   531    531     execsql {
   532    532       SELECT sum(a) FROM av1;
   533    533     }
   534    534   } {5049}
   535    535   do_test autovacuum-4.4 {
   536    536     execsql {

Changes to test/capi2.test.

   233    233   # (Test result changes from 0 to 1).  (Later:) change counter updates occur
   234    234   # when sqlite3_step returns, not at finalize time.
   235    235   do_test capi2-3.13b {db changes} {0}
   236    236   
   237    237   do_test capi2-3.14 {
   238    238     list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \
   239    239          [sqlite3_extended_errcode $DB]
   240         -} {SQLITE_CONSTRAINT {column a is not unique} SQLITE_CONSTRAINT_UNIQUE}
          240  +} {SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.a} SQLITE_CONSTRAINT_UNIQUE}
   241    241   do_test capi2-3.15 {
   242    242     set VM [sqlite3_prepare $DB {CREATE TABLE t2(a NOT NULL, b)} -1 TAIL]
   243    243     set TAIL
   244    244   } {}
   245    245   do_test capi2-3.16 {
   246    246     list [sqlite3_step $VM] \
   247    247          [sqlite3_column_count $VM] \
................................................................................
   257    257          [sqlite3_column_count $VM] \
   258    258          [get_row_values $VM] \
   259    259          [get_column_names $VM]
   260    260   } {SQLITE_ERROR 0 {} {}}
   261    261   do_test capi2-3.19 {
   262    262     list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \
   263    263          [sqlite3_extended_errcode $DB]
   264         -} {SQLITE_CONSTRAINT {t2.a may not be NULL} SQLITE_CONSTRAINT_NOTNULL}
          264  +} {SQLITE_CONSTRAINT {NOT NULL constraint failed: t2.a} SQLITE_CONSTRAINT_NOTNULL}
   265    265   
   266    266   do_test capi2-3.20 {
   267    267     execsql {
   268    268       CREATE TABLE a1(message_id, name , UNIQUE(message_id, name) );
   269    269       INSERT INTO a1 VALUES(1, 1);
   270    270     }
   271    271   } {}
................................................................................
   551    551          [get_column_names $VM1]
   552    552   } {SQLITE_ROW 1 12 {x counter}}
   553    553   do_test capi2-6.27 {
   554    554     catchsql {
   555    555       INSERT INTO t1 VALUES(2,4,5);
   556    556       SELECT * FROM t1;
   557    557     }
   558         -} {1 {column a is not unique}}
          558  +} {1 {UNIQUE constraint failed: t1.a}}
   559    559   do_test capi2-6.28 {
   560    560     list [sqlite3_step $VM1] \
   561    561          [sqlite3_column_count $VM1] \
   562    562          [get_row_values $VM1] \
   563    563          [get_column_names $VM1]
   564    564   } {SQLITE_ROW 1 13 {x counter}}
   565    565   do_test capi2-6.99 {

Changes to test/check.test.

    37     37       SELECT * FROM t1;
    38     38     }  
    39     39   } {3 4.0}
    40     40   do_test check-1.3 {
    41     41     catchsql {
    42     42       INSERT INTO t1 VALUES(6,7);
    43     43     }
    44         -} {1 {constraint failed}}
           44  +} {1 {CHECK constraint failed: t1}}
    45     45   do_test check-1.4 {
    46     46     execsql {
    47     47       SELECT * FROM t1;
    48     48     }  
    49     49   } {3 4.0}
    50     50   do_test check-1.5 {
    51     51     catchsql {
    52     52       INSERT INTO t1 VALUES(4,3);
    53     53     }
    54         -} {1 {constraint failed}}
           54  +} {1 {CHECK constraint failed: t1}}
    55     55   do_test check-1.6 {
    56     56     execsql {
    57     57       SELECT * FROM t1;
    58     58     }  
    59     59   } {3 4.0}
    60     60   do_test check-1.7 {
    61     61     catchsql {
................................................................................
    84     84       SELECT * FROM t1;
    85     85     }
    86     86   } {2 4.0}
    87     87   do_test check-1.12 {
    88     88     catchsql {
    89     89       UPDATE t1 SET x=7 WHERE x==2
    90     90     }
    91         -} {1 {constraint failed}}
           91  +} {1 {CHECK constraint failed: t1}}
    92     92   do_test check-1.13 {
    93     93     execsql {
    94     94       SELECT * FROM t1;
    95     95     }
    96     96   } {2 4.0}
    97     97   do_test check-1.14 {
    98     98     catchsql {
    99     99       UPDATE t1 SET x=5 WHERE x==2
   100    100     }
   101         -} {1 {constraint failed}}
          101  +} {1 {CHECK constraint failed: t1}}
   102    102   do_test check-1.15 {
   103    103     execsql {
   104    104       SELECT * FROM t1;
   105    105     }
   106    106   } {2 4.0}
   107    107   do_test check-1.16 {
   108    108     catchsql {
................................................................................
   138    138       SELECT * FROM t2;
   139    139     }
   140    140   } {1 2.2 three {} {} {}}
   141    141   do_test check-2.4 {
   142    142     catchsql {
   143    143       INSERT INTO t2 VALUES(1.1, NULL, NULL);
   144    144     }
   145         -} {1 {constraint one failed}}
          145  +} {1 {CHECK constraint failed: one}}
   146    146   do_test check-2.5 {
   147    147     catchsql {
   148    148       INSERT INTO t2 VALUES(NULL, 5, NULL);
   149    149     }
   150         -} {1 {constraint two failed}}
          150  +} {1 {CHECK constraint failed: two}}
   151    151   do_test check-2.6 {
   152    152     catchsql {
   153    153       INSERT INTO t2 VALUES(NULL, NULL, 3.14159);
   154    154     }
   155         -} {1 {constraint three failed}}
          155  +} {1 {CHECK constraint failed: three}}
   156    156   
   157    157   # Undocumented behavior:  The CONSTRAINT name clause can follow a constraint.
   158    158   # Such a clause is ignored.  But the parser must accept it for backwards
   159    159   # compatibility.
   160    160   #
   161    161   do_test check-2.10 {
   162    162     execsql {
................................................................................
   168    168       );
   169    169     }
   170    170   } {}
   171    171   do_test check-2.11 {
   172    172     catchsql {
   173    173       INSERT INTO t2b VALUES('xyzzy','hi',5);
   174    174     }
   175         -} {1 {constraint failed}}
          175  +} {1 {CHECK constraint failed: t2b}}
   176    176   do_test check-2.12 {
   177    177     execsql {
   178    178       CREATE TABLE t2c(
   179    179         x INTEGER CONSTRAINT x_one CONSTRAINT x_two
   180    180             CHECK( typeof(coalesce(x,0))=='integer' )
   181    181             CONSTRAINT x_two CONSTRAINT x_three,
   182    182         y INTEGER, z INTEGER,
................................................................................
   184    184       );
   185    185     }
   186    186   } {}
   187    187   do_test check-2.13 {
   188    188     catchsql {
   189    189       INSERT INTO t2c VALUES('xyzzy',7,8);
   190    190     }
   191         -} {1 {constraint x_two failed}}
          191  +} {1 {CHECK constraint failed: x_two}}
   192    192   do_test check-2.cleanup {
   193    193     execsql {
   194    194       DROP TABLE IF EXISTS t2b;
   195    195       DROP TABLE IF EXISTS t2c;
   196    196     }
   197    197   } {}
   198    198   
................................................................................
   252    252       SELECT * FROM t3;
   253    253     }
   254    254   } {1 2 3}
   255    255   do_test check-3.9 {
   256    256     catchsql {
   257    257       INSERT INTO t3 VALUES(111,222,333);
   258    258     }
   259         -} {1 {constraint failed}}
          259  +} {1 {CHECK constraint failed: t3}}
   260    260   
   261    261   do_test check-4.1 {
   262    262     execsql {
   263    263       CREATE TABLE t4(x, y,
   264    264         CHECK (
   265    265              x+y==11
   266    266           OR x*y==12
................................................................................
   294    294       SELECT * FROM t4
   295    295     }
   296    296   } {12 -22}
   297    297   do_test check-4.6 {
   298    298     catchsql {
   299    299       UPDATE t4 SET x=0, y=1;
   300    300     }
   301         -} {1 {constraint failed}}
          301  +} {1 {CHECK constraint failed: t4}}
   302    302   do_test check-4.7 {
   303    303     execsql {
   304    304       SELECT * FROM t4;
   305    305     }
   306    306   } {12 -22}
   307    307   do_test check-4.8 {
   308    308     execsql {
................................................................................
   312    312     }
   313    313   } {0 1}
   314    314   do_test check-4.9 {
   315    315     catchsql {
   316    316       PRAGMA ignore_check_constraints=OFF;
   317    317       UPDATE t4 SET x=0, y=2;
   318    318     }
   319         -} {1 {constraint failed}}
          319  +} {1 {CHECK constraint failed: t4}}
   320    320   ifcapable vacuum {
   321    321     do_test check_4.10 {
   322    322       catchsql {
   323    323         VACUUM
   324    324       }
   325    325     } {0 {}}
   326    326   }
................................................................................
   363    363       SELECT * FROM t1;
   364    364     }
   365    365   } {4 11.0 2 20.0}
   366    366   do_test check-6.5 {
   367    367     catchsql {
   368    368       UPDATE OR FAIL t1 SET x=7-x, y=y+1;
   369    369     }
   370         -} {1 {constraint failed}}
          370  +} {1 {CHECK constraint failed: t1}}
   371    371   do_test check-6.6 {
   372    372     execsql {
   373    373       SELECT * FROM t1;
   374    374     }
   375    375   } {3 12.0 2 20.0}
   376    376   do_test check-6.7 {
   377    377     catchsql {
   378    378       BEGIN;
   379    379       INSERT INTO t1 VALUES(1,30.0);
   380    380       INSERT OR ROLLBACK INTO t1 VALUES(8,40.0);
   381    381     }
   382         -} {1 {constraint failed}}
          382  +} {1 {CHECK constraint failed: t1}}
   383    383   do_test check-6.8 {
   384    384     catchsql {
   385    385       COMMIT;
   386    386     }
   387    387   } {1 {cannot commit - no transaction is active}}
   388    388   do_test check-6.9 {
   389    389     execsql {
................................................................................
   394    394   do_test check-6.11 {
   395    395     execsql {SELECT * FROM t1}
   396    396   } {3 12.0 2 20.0}
   397    397   do_test check-6.12 {
   398    398     catchsql {
   399    399       REPLACE INTO t1 VALUES(6,7);
   400    400     }
   401         -} {1 {constraint failed}}
          401  +} {1 {CHECK constraint failed: t1}}
   402    402   do_test check-6.13 {
   403    403     execsql {SELECT * FROM t1}
   404    404   } {3 12.0 2 20.0}
   405    405   do_test check-6.14 {
   406    406     catchsql {
   407    407       INSERT OR IGNORE INTO t1 VALUES(6,7);
   408    408     }
................................................................................
   422    422   #
   423    423   reset_db
   424    424   proc myfunc {x} {expr $x < 10}
   425    425   db func myfunc myfunc
   426    426   
   427    427   do_execsql_test  7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) }
   428    428   do_execsql_test  7.2 { INSERT INTO t6 VALUES(9)  }
   429         -do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } {1 {constraint failed}}
          429  +do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } \
          430  +          {1 {CHECK constraint failed: t6}}
   430    431   
   431    432   do_test 7.4 {
   432    433     sqlite3 db2 test.db
   433    434     execsql { SELECT * FROM t6 } db2 
   434    435   } {9}
   435    436   
   436    437   do_test 7.5 {
................................................................................
   445    446     db2 func myfunc myfunc
   446    447     execsql { INSERT INTO t6 VALUES(8) } db2
   447    448   } {}
   448    449   
   449    450   do_test 7.8 {
   450    451     db2 func myfunc myfunc
   451    452     catchsql { INSERT INTO t6 VALUES(12) } db2
   452         -} {1 {constraint failed}}
          453  +} {1 {CHECK constraint failed: t6}}
   453    454   
   454    455   # 2013-08-02:  Silently ignore database name qualifiers in CHECK constraints.
   455    456   #
   456    457   do_execsql_test 8.1 {
   457    458     CREATE TABLE t810(a, CHECK( main.t810.a>0 ));
   458    459     CREATE TABLE t811(b, CHECK( xyzzy.t811.b BETWEEN 5 AND 10 ));
   459    460   } {}
   460    461   
   461    462   finish_test

Changes to test/collate4.test.

   469    469     }
   470    470   } {}
   471    471   do_test collate4-3.1 {
   472    472     catchsql {
   473    473       INSERT INTO collate4t1 VALUES('abc');
   474    474       INSERT INTO collate4t1 VALUES('ABC');
   475    475     }
   476         -} {1 {PRIMARY KEY must be unique}}
          476  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   477    477   do_test collate4-3.2 {
   478    478     execsql {
   479    479       SELECT * FROM collate4t1;
   480    480     }
   481    481   } {abc}
   482    482   do_test collate4-3.3 {
   483    483     catchsql {
   484    484       INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
   485    485     }
   486         -} {1 {PRIMARY KEY must be unique}}
          486  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   487    487   do_test collate4-3.4 {
   488    488     catchsql {
   489    489       INSERT INTO collate4t1 VALUES(1);
   490    490       UPDATE collate4t1 SET a = 'abc';
   491    491     }
   492         -} {1 {PRIMARY KEY must be unique}}
          492  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   493    493   do_test collate4-3.5 {
   494    494     execsql {
   495    495       DROP TABLE collate4t1;
   496    496       CREATE TABLE collate4t1(a COLLATE NOCASE UNIQUE);
   497    497     }
   498    498   } {}
   499    499   do_test collate4-3.6 {
   500    500     catchsql {
   501    501       INSERT INTO collate4t1 VALUES('abc');
   502    502       INSERT INTO collate4t1 VALUES('ABC');
   503    503     }
   504         -} {1 {column a is not unique}}
          504  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   505    505   do_test collate4-3.7 {
   506    506     execsql {
   507    507       SELECT * FROM collate4t1;
   508    508     }
   509    509   } {abc}
   510    510   do_test collate4-3.8 {
   511    511     catchsql {
   512    512       INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
   513    513     }
   514         -} {1 {column a is not unique}}
          514  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   515    515   do_test collate4-3.9 {
   516    516     catchsql {
   517    517       INSERT INTO collate4t1 VALUES(1);
   518    518       UPDATE collate4t1 SET a = 'abc';
   519    519     }
   520         -} {1 {column a is not unique}}
          520  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   521    521   do_test collate4-3.10 {
   522    522     execsql {
   523    523       DROP TABLE collate4t1;
   524    524       CREATE TABLE collate4t1(a);
   525    525       CREATE UNIQUE INDEX collate4i1 ON collate4t1(a COLLATE NOCASE);
   526    526     }
   527    527   } {}
   528    528   do_test collate4-3.11 {
   529    529     catchsql {
   530    530       INSERT INTO collate4t1 VALUES('abc');
   531    531       INSERT INTO collate4t1 VALUES('ABC');
   532    532     }
   533         -} {1 {column a is not unique}}
          533  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   534    534   do_test collate4-3.12 {
   535    535     execsql {
   536    536       SELECT * FROM collate4t1;
   537    537     }
   538    538   } {abc}
   539    539   do_test collate4-3.13 {
   540    540     catchsql {
   541    541       INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;
   542    542     }
   543         -} {1 {column a is not unique}}
          543  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   544    544   do_test collate4-3.14 {
   545    545     catchsql {
   546    546       INSERT INTO collate4t1 VALUES(1);
   547    547       UPDATE collate4t1 SET a = 'abc';
   548    548     }
   549         -} {1 {column a is not unique}}
          549  +} {1 {UNIQUE constraint failed: collate4t1.a}}
   550    550   
   551    551   do_test collate4-3.15 {
   552    552     execsql {
   553    553       DROP TABLE collate4t1;
   554    554     }
   555    555   } {}
   556    556   

Changes to test/conflict.test.

   238    238    11 ROLLBACK {INSERT OR IGNORE}      0 {}  1
   239    239    12 {}       {INSERT OR IGNORE}      0 {}  1
   240    240    13 {}       {INSERT OR REPLACE}     0 5   1
   241    241    14 {}       {INSERT OR FAIL}        1 {}  1
   242    242    15 {}       {INSERT OR ABORT}       1 {}  1
   243    243    16 {}       {INSERT OR ROLLBACK}    1 {}  {}
   244    244   } {
   245         -  if {$t0} {set t1 {t1.c may not be NULL}}
          245  +  if {$t0} {set t1 {NOT NULL constraint failed: t1.c}}
   246    246     do_test conflict-5.$i {
   247    247       if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
   248    248       set r0 [catch {execsql [subst {
   249    249         DROP TABLE t1;
   250    250         CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
   251    251         DELETE FROM t2;
   252    252         BEGIN;
................................................................................
   302    302    11 ROLLBACK {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   303    303    12 {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   304    304    13 {}       {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0
   305    305    14 {}       {UPDATE OR FAIL}        1 {6 7 3 4}  1 0 0
   306    306    15 {}       {UPDATE OR ABORT}       1 {1 2 3 4}  1 0 1
   307    307    16 {}       {UPDATE OR ROLLBACK}    1 {1 2 3 4}  0 0 0
   308    308   } {
   309         -  if {$t0} {set t1 {column a is not unique}}
          309  +  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
   310    310     if {[info exists TEMP_STORE] && $TEMP_STORE==3} {
   311    311       set t3 0
   312    312     } else {
   313    313       set t3 [expr {$t3+$t4}]
   314    314     }
   315    315     do_test conflict-6.$i {
   316    316       db close
................................................................................
   489    489     }
   490    490   } {0 {1 1 1 1 1 2 2 2 2 2}}
   491    491   do_test conflict-9.5 {
   492    492     catchsql {
   493    493       INSERT INTO t2 VALUES(3,1,3,3,3);
   494    494       SELECT * FROM t2;
   495    495     }
   496         -} {1 {column b is not unique}}
          496  +} {1 {UNIQUE constraint failed: t2.b}}
   497    497   do_test conflict-9.6 {
   498    498     catchsql {
   499    499       UPDATE t2 SET b=b+1 WHERE b=1;
   500    500       SELECT * FROM t2;
   501    501     }
   502         -} {1 {column b is not unique}}
          502  +} {1 {UNIQUE constraint failed: t2.b}}
   503    503   do_test conflict-9.7 {
   504    504     catchsql {
   505    505       BEGIN;
   506    506       UPDATE t3 SET x=x+1;
   507    507       INSERT INTO t2 VALUES(3,1,3,3,3);
   508    508       SELECT * FROM t2;
   509    509     }
   510         -} {1 {column b is not unique}}
          510  +} {1 {UNIQUE constraint failed: t2.b}}
   511    511   do_test conflict-9.8 {
   512    512     execsql {COMMIT}
   513    513     execsql {SELECT * FROM t3}
   514    514   } {2}
   515    515   do_test conflict-9.9 {
   516    516     catchsql {
   517    517       BEGIN;
   518    518       UPDATE t3 SET x=x+1;
   519    519       UPDATE t2 SET b=b+1 WHERE b=1;
   520    520       SELECT * FROM t2;
   521    521     }
   522         -} {1 {column b is not unique}}
          522  +} {1 {UNIQUE constraint failed: t2.b}}
   523    523   do_test conflict-9.10 {
   524    524     execsql {COMMIT}
   525    525     execsql {SELECT * FROM t3}
   526    526   } {3}
   527    527   do_test conflict-9.11 {
   528    528     catchsql {
   529    529       INSERT INTO t2 VALUES(3,3,3,1,3);
   530    530       SELECT * FROM t2;
   531    531     }
   532         -} {1 {column d is not unique}}
          532  +} {1 {UNIQUE constraint failed: t2.d}}
   533    533   do_test conflict-9.12 {
   534    534     catchsql {
   535    535       UPDATE t2 SET d=d+1 WHERE d=1;
   536    536       SELECT * FROM t2;
   537    537     }
   538         -} {1 {column d is not unique}}
          538  +} {1 {UNIQUE constraint failed: t2.d}}
   539    539   do_test conflict-9.13 {
   540    540     catchsql {
   541    541       BEGIN;
   542    542       UPDATE t3 SET x=x+1;
   543    543       INSERT INTO t2 VALUES(3,3,3,1,3);
   544    544       SELECT * FROM t2;
   545    545     }
   546         -} {1 {column d is not unique}}
          546  +} {1 {UNIQUE constraint failed: t2.d}}
   547    547   do_test conflict-9.14 {
   548    548     execsql {COMMIT}
   549    549     execsql {SELECT * FROM t3}
   550    550   } {4}
   551    551   do_test conflict-9.15 {
   552    552     catchsql {
   553    553       BEGIN;
   554    554       UPDATE t3 SET x=x+1;
   555    555       UPDATE t2 SET d=d+1 WHERE d=1;
   556    556       SELECT * FROM t2;
   557    557     }
   558         -} {1 {column d is not unique}}
          558  +} {1 {UNIQUE constraint failed: t2.d}}
   559    559   do_test conflict-9.16 {
   560    560     execsql {COMMIT}
   561    561     execsql {SELECT * FROM t3}
   562    562   } {5}
   563    563   do_test conflict-9.17 {
   564    564     catchsql {
   565    565       INSERT INTO t2 VALUES(3,3,3,3,1);
   566    566       SELECT * FROM t2;
   567    567     }
   568         -} {1 {column e is not unique}}
          568  +} {1 {UNIQUE constraint failed: t2.e}}
   569    569   do_test conflict-9.18 {
   570    570     catchsql {
   571    571       UPDATE t2 SET e=e+1 WHERE e=1;
   572    572       SELECT * FROM t2;
   573    573     }
   574         -} {1 {column e is not unique}}
          574  +} {1 {UNIQUE constraint failed: t2.e}}
   575    575   do_test conflict-9.19 {
   576    576     catchsql {
   577    577       BEGIN;
   578    578       UPDATE t3 SET x=x+1;
   579    579       INSERT INTO t2 VALUES(3,3,3,3,1);
   580    580       SELECT * FROM t2;
   581    581     }
   582         -} {1 {column e is not unique}}
          582  +} {1 {UNIQUE constraint failed: t2.e}}
   583    583   verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE
   584    584   do_test conflict-9.20 {
   585    585     catch {execsql {COMMIT}}
   586    586     execsql {SELECT * FROM t3}
   587    587   } {5}
   588    588   do_test conflict-9.21 {
   589    589     catchsql {
   590    590       BEGIN;
   591    591       UPDATE t3 SET x=x+1;
   592    592       UPDATE t2 SET e=e+1 WHERE e=1;
   593    593       SELECT * FROM t2;
   594    594     }
   595         -} {1 {column e is not unique}}
          595  +} {1 {UNIQUE constraint failed: t2.e}}
   596    596   verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE
   597    597   do_test conflict-9.22 {
   598    598     catch {execsql {COMMIT}}
   599    599     execsql {SELECT * FROM t3}
   600    600   } {5}
   601    601   do_test conflict-9.23 {
   602    602     catchsql {
................................................................................
   778    778       SELECT * FROM t5;
   779    779     }
   780    780   } {1 one 2 two}
   781    781   do_test conflict-12.3 {
   782    782     catchsql {
   783    783       UPDATE t5 SET a=a+1 WHERE a=1;
   784    784     }
   785         -} {1 {PRIMARY KEY must be unique}}
          785  +} {1 {UNIQUE constraint failed: t5.a}}
   786    786   verify_ex_errcode conflict-12.3b SQLITE_CONSTRAINT_PRIMARYKEY
   787    787   do_test conflict-12.4 {
   788    788     execsql {
   789    789       UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;
   790    790       SELECT * FROM t5;
   791    791     }
   792    792   } {2 one}
          793  +do_test conflict-12.5 {
          794  +  catchsql {
          795  +    CREATE TABLE t5b(x);
          796  +    INSERT INTO t5b(rowid, x) VALUES(1,10),(2,11);
          797  +    UPDATE t5b SET rowid=rowid+1 WHERE x=10;
          798  +  }
          799  +} {1 {UNIQUE constraint failed: t5b.rowid}}
          800  +verify_ex_errcode conflict-12.5b SQLITE_CONSTRAINT_ROWID
   793    801   
   794    802   
   795    803   # Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]
   796    804   # REPLACE works like ABORT on a CHECK constraint.
   797    805   #
   798    806   do_test conflict-13.1 {
   799    807     execsql {
................................................................................
   800    808       CREATE TABLE t13(a CHECK(a!=2));
   801    809       BEGIN;
   802    810       REPLACE INTO t13 VALUES(1);
   803    811     }
   804    812     catchsql {
   805    813       REPLACE INTO t13 VALUES(2);
   806    814     }
   807         -} {1 {constraint failed}}
          815  +} {1 {CHECK constraint failed: t13}}
   808    816   verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK
   809    817   do_test conflict-13.2 {
   810    818     execsql {
   811    819       REPLACE INTO t13 VALUES(3);
   812    820       COMMIT;
   813    821       SELECT * FROM t13;
   814    822     }
   815    823   } {1 3}
   816    824   
   817    825   
   818    826   finish_test

Changes to test/conflict2.test.

   237    237    11 ROLLBACK {INSERT OR IGNORE}      0 {}  1
   238    238    12 {}       {INSERT OR IGNORE}      0 {}  1
   239    239    13 {}       {INSERT OR REPLACE}     0 5   1
   240    240    14 {}       {INSERT OR FAIL}        1 {}  1
   241    241    15 {}       {INSERT OR ABORT}       1 {}  1
   242    242    16 {}       {INSERT OR ROLLBACK}    1 {}  {}
   243    243   } {
   244         -  if {$t0} {set t1 {t1.c may not be NULL}}
          244  +  if {$t0} {set t1 {NOT NULL constraint failed: t1.c}}
   245    245     do_test conflict2-5.$i {
   246    246       if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
   247    247       set r0 [catch {execsql [subst {
   248    248         DROP TABLE t1;
   249    249         CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
   250    250         DELETE FROM t2;
   251    251         BEGIN;
................................................................................
   301    301    11 ROLLBACK {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   302    302    12 {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   303    303    13 {}       {UPDATE OR REPLACE}     0 {7 6 9}    1 0 1
   304    304    14 {}       {UPDATE OR FAIL}        1 {6 7 3 4}  1 0 0
   305    305    15 {}       {UPDATE OR ABORT}       1 {1 2 3 4}  1 0 1
   306    306    16 {}       {UPDATE OR ROLLBACK}    1 {1 2 3 4}  0 0 0
   307    307   } {
   308         -  if {$t0} {set t1 {PRIMARY KEY must be unique}}
          308  +  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
   309    309     if {[info exists TEMP_STORE] && $TEMP_STORE==3} {
   310    310       set t3 0
   311    311     } else {
   312    312       set t3 [expr {$t3+$t4}]
   313    313     }
   314    314     do_test conflict2-6.$i {
   315    315       db close
................................................................................
   487    487       SELECT * FROM t2;
   488    488     }
   489    489   } {0 {1 1 1 1 1 2 2 2 2 2}}
   490    490   do_test conflict2-9.5 {
   491    491     catchsql {
   492    492       INSERT INTO t2 VALUES(3,1,3,3,3);
   493    493     }
   494         -} {1 {column b is not unique}}
          494  +} {1 {UNIQUE constraint failed: t2.b}}
   495    495   do_test conflict2-9.5b {
   496    496     db eval {SELECT * FROM t2;}
   497    497   } {1 1 1 1 1 2 2 2 2 2}
   498    498   do_test conflict2-9.6 {
   499    499     catchsql {
   500    500       UPDATE t2 SET b=b+1 WHERE b=1;
   501    501       SELECT * FROM t2;
   502    502     }
   503         -} {1 {column b is not unique}}
          503  +} {1 {UNIQUE constraint failed: t2.b}}
   504    504   do_test conflict2-9.6b {
   505    505     db eval {SELECT * FROM t2;}
   506    506   } {1 1 1 1 1 2 2 2 2 2}
   507    507   do_test conflict2-9.7 {
   508    508     catchsql {
   509    509       BEGIN;
   510    510       UPDATE t3 SET x=x+1;
   511    511       INSERT INTO t2 VALUES(3,1,3,3,3);
   512    512       SELECT * FROM t2;
   513    513     }
   514         -} {1 {column b is not unique}}
          514  +} {1 {UNIQUE constraint failed: t2.b}}
   515    515   do_test conflict2-9.8 {
   516    516     execsql {COMMIT}
   517    517     execsql {SELECT * FROM t3}
   518    518   } {2}
   519    519   do_test conflict2-9.9 {
   520    520     catchsql {
   521    521       BEGIN;
   522    522       UPDATE t3 SET x=x+1;
   523    523       UPDATE t2 SET b=b+1 WHERE b=1;
   524    524       SELECT * FROM t2;
   525    525     }
   526         -} {1 {column b is not unique}}
          526  +} {1 {UNIQUE constraint failed: t2.b}}
   527    527   do_test conflict2-9.10 {
   528    528     execsql {COMMIT}
   529    529     execsql {SELECT * FROM t3}
   530    530   } {3}
   531    531   do_test conflict2-9.11 {
   532    532     catchsql {
   533    533       INSERT INTO t2 VALUES(3,3,3,1,3);
   534    534       SELECT * FROM t2;
   535    535     }
   536         -} {1 {column d is not unique}}
          536  +} {1 {UNIQUE constraint failed: t2.d}}
   537    537   do_test conflict2-9.12 {
   538    538     catchsql {
   539    539       UPDATE t2 SET d=d+1 WHERE d=1;
   540    540       SELECT * FROM t2;
   541    541     }
   542         -} {1 {column d is not unique}}
          542  +} {1 {UNIQUE constraint failed: t2.d}}
   543    543   do_test conflict2-9.13 {
   544    544     catchsql {
   545    545       BEGIN;
   546    546       UPDATE t3 SET x=x+1;
   547    547       INSERT INTO t2 VALUES(3,3,3,1,3);
   548    548       SELECT * FROM t2;
   549    549     }
   550         -} {1 {column d is not unique}}
          550  +} {1 {UNIQUE constraint failed: t2.d}}
   551    551   do_test conflict2-9.14 {
   552    552     execsql {COMMIT}
   553    553     execsql {SELECT * FROM t3}
   554    554   } {4}
   555    555   do_test conflict2-9.15 {
   556    556     catchsql {
   557    557       BEGIN;
   558    558       UPDATE t3 SET x=x+1;
   559    559       UPDATE t2 SET d=d+1 WHERE d=1;
   560    560       SELECT * FROM t2;
   561    561     }
   562         -} {1 {column d is not unique}}
          562  +} {1 {UNIQUE constraint failed: t2.d}}
   563    563   do_test conflict2-9.16 {
   564    564     execsql {COMMIT}
   565    565     execsql {SELECT * FROM t3}
   566    566   } {5}
   567    567   do_test conflict2-9.17 {
   568    568     catchsql {
   569    569       INSERT INTO t2 VALUES(3,3,3,3,1);
   570    570       SELECT * FROM t2;
   571    571     }
   572         -} {1 {column e is not unique}}
          572  +} {1 {UNIQUE constraint failed: t2.e}}
   573    573   do_test conflict2-9.18 {
   574    574     catchsql {
   575    575       UPDATE t2 SET e=e+1 WHERE e=1;
   576    576       SELECT * FROM t2;
   577    577     }
   578         -} {1 {column e is not unique}}
          578  +} {1 {UNIQUE constraint failed: t2.e}}
   579    579   do_test conflict2-9.19 {
   580    580     catchsql {
   581    581       BEGIN;
   582    582       UPDATE t3 SET x=x+1;
   583    583       INSERT INTO t2 VALUES(3,3,3,3,1);
   584    584       SELECT * FROM t2;
   585    585     }
   586         -} {1 {column e is not unique}}
          586  +} {1 {UNIQUE constraint failed: t2.e}}
   587    587   verify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE
   588    588   do_test conflict2-9.20 {
   589    589     catch {execsql {COMMIT}}
   590    590     execsql {SELECT * FROM t3}
   591    591   } {5}
   592    592   do_test conflict2-9.21 {
   593    593     catchsql {
   594    594       BEGIN;
   595    595       UPDATE t3 SET x=x+1;
   596    596       UPDATE t2 SET e=e+1 WHERE e=1;
   597    597       SELECT * FROM t2;
   598    598     }
   599         -} {1 {column e is not unique}}
          599  +} {1 {UNIQUE constraint failed: t2.e}}
   600    600   verify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE
   601    601   do_test conflict2-9.22 {
   602    602     catch {execsql {COMMIT}}
   603    603     execsql {SELECT * FROM t3}
   604    604   } {5}
   605    605   do_test conflict2-9.23 {
   606    606     catchsql {
................................................................................
   782    782       SELECT * FROM t5;
   783    783     }
   784    784   } {1 one 2 two}
   785    785   do_test conflict2-12.3 {
   786    786     catchsql {
   787    787       UPDATE t5 SET a=a+1 WHERE a=1;
   788    788     }
   789         -} {1 {PRIMARY KEY must be unique}}
          789  +} {1 {UNIQUE constraint failed: t5.a}}
   790    790   verify_ex_errcode conflict2-12.3b SQLITE_CONSTRAINT_PRIMARYKEY
   791    791   do_test conflict2-12.4 {
   792    792     execsql {
   793    793       UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;
   794    794       SELECT * FROM t5;
   795    795     }
   796    796   } {2 one}
................................................................................
   804    804       CREATE TABLE t13(a PRIMARY KEY CHECK(a!=2)) WITHOUT rowid;
   805    805       BEGIN;
   806    806       REPLACE INTO t13 VALUES(1);
   807    807     }
   808    808     catchsql {
   809    809       REPLACE INTO t13 VALUES(2);
   810    810     }
   811         -} {1 {constraint failed}}
          811  +} {1 {CHECK constraint failed: t13}}
   812    812   verify_ex_errcode conflict2-13.1b SQLITE_CONSTRAINT_CHECK
   813    813   do_test conflict2-13.2 {
   814    814     execsql {
   815    815       REPLACE INTO t13 VALUES(3);
   816    816       COMMIT;
   817    817       SELECT * FROM t13;
   818    818     }
   819    819   } {1 3}
   820    820   
   821    821   
   822    822   finish_test

Changes to test/e_createtable.test.

  1178   1178     CREATE TABLE t2(x, y, PRIMARY KEY(x, y));
  1179   1179     INSERT INTO t2 VALUES(0,          'zero');
  1180   1180     INSERT INTO t2 VALUES(45.5,       'one');
  1181   1181     INSERT INTO t2 VALUES('brambles', 'two');
  1182   1182     INSERT INTO t2 VALUES(X'ABCDEF',  'three');
  1183   1183   } {}
  1184   1184   
  1185         -do_createtable_tests 4.3.1 -error {PRIMARY KEY must be unique} {
         1185  +do_createtable_tests 4.3.1 -error {UNIQUE constraint failed: t1.x} {
  1186   1186     1    "INSERT INTO t1 VALUES(0, 0)"                 {"column x is"}
  1187   1187     2    "INSERT INTO t1 VALUES(45.5, 'abc')"          {"column x is"}
  1188   1188     3    "INSERT INTO t1 VALUES(0.0, 'abc')"           {"column x is"}
  1189   1189     4    "INSERT INTO t1 VALUES('brambles', 'abc')"    {"column x is"}
  1190   1190     5    "INSERT INTO t1 VALUES(X'ABCDEF', 'abc')"     {"column x is"}
  1191         -
         1191  +}
         1192  +do_createtable_tests 4.3.1 -error {UNIQUE constraint failed: t2.x, t2.y} {
  1192   1193     6    "INSERT INTO t2 VALUES(0, 'zero')"            {"columns x, y are"}
  1193   1194     7    "INSERT INTO t2 VALUES(45.5, 'one')"          {"columns x, y are"}
  1194   1195     8    "INSERT INTO t2 VALUES(0.0, 'zero')"          {"columns x, y are"}
  1195   1196     9    "INSERT INTO t2 VALUES('brambles', 'two')"    {"columns x, y are"}
  1196   1197     10   "INSERT INTO t2 VALUES(X'ABCDEF', 'three')"   {"columns x, y are"}
  1197   1198   }
  1198   1199   do_createtable_tests 4.3.2 {
................................................................................
  1204   1205   
  1205   1206     6    "INSERT INTO t2 VALUES(0, 0)"                 {}
  1206   1207     7    "INSERT INTO t2 VALUES(45.5, 'abc')"          {}
  1207   1208     8    "INSERT INTO t2 VALUES(0.0, 'abc')"           {}
  1208   1209     9    "INSERT INTO t2 VALUES('brambles', 'abc')"    {}
  1209   1210     10   "INSERT INTO t2 VALUES(X'ABCDEF', 'abc')"     {}
  1210   1211   }
  1211         -do_createtable_tests 4.3.3 -error {PRIMARY KEY must be unique} {
         1212  +do_createtable_tests 4.3.3 -error {UNIQUE constraint failed: t1.x} {
  1212   1213     1    "UPDATE t1 SET x=0           WHERE y='two'"    {"column x is"}
  1213   1214     2    "UPDATE t1 SET x='brambles'  WHERE y='three'"  {"column x is"}
  1214   1215     3    "UPDATE t1 SET x=45.5        WHERE y='zero'"   {"column x is"}
  1215   1216     4    "UPDATE t1 SET x=X'ABCDEF'   WHERE y='one'"    {"column x is"}
  1216   1217     5    "UPDATE t1 SET x=0.0         WHERE y='three'"  {"column x is"}
  1217         -
         1218  +}
         1219  +do_createtable_tests 4.3.3 -error {UNIQUE constraint failed: t2.x, t2.y} {
  1218   1220     6    "UPDATE t2 SET x=0, y='zero' WHERE y='two'"    {"columns x, y are"}
  1219   1221     7    "UPDATE t2 SET x='brambles', y='two' WHERE y='three'"  
  1220   1222          {"columns x, y are"}
  1221   1223     8    "UPDATE t2 SET x=45.5, y='one' WHERE y='zero'" {"columns x, y are"}
  1222   1224     9    "UPDATE t2 SET x=X'ABCDEF', y='three' WHERE y='one'" 
  1223   1225          {"columns x, y are"}
  1224   1226     10   "UPDATE t2 SET x=0.0, y='zero'        WHERE y='three'"  
................................................................................
  1301   1303     INSERT INTO t1 VALUES('reveal', 'variableness');
  1302   1304     INSERT INTO t1 VALUES(X'123456', X'654321');
  1303   1305   
  1304   1306     INSERT INTO t4 VALUES('xyx', 1, 1);
  1305   1307     INSERT INTO t4 VALUES('xyx', 2, 1);
  1306   1308     INSERT INTO t4 VALUES('uvw', 1, 1);
  1307   1309   }
  1308         -do_createtable_tests 4.7.1 -error { %s not unique } {
  1309         -  1    "INSERT INTO t1 VALUES(1, 'one')"             {{column a is}}
  1310         -  2    "INSERT INTO t1 VALUES(4.3, 'two')"           {{column a is}}
  1311         -  3    "INSERT INTO t1 VALUES('reveal', 'three')"    {{column a is}}
  1312         -  4    "INSERT INTO t1 VALUES(X'123456', 'four')"    {{column a is}}
         1310  +do_createtable_tests 4.7.1 -error {UNIQUE constraint failed: %s} {
         1311  +  1    "INSERT INTO t1 VALUES(1, 'one')"             {{t1.a}}
         1312  +  2    "INSERT INTO t1 VALUES(4.3, 'two')"           {{t1.a}}
         1313  +  3    "INSERT INTO t1 VALUES('reveal', 'three')"    {{t1.a}}
         1314  +  4    "INSERT INTO t1 VALUES(X'123456', 'four')"    {{t1.a}}
  1313   1315   
  1314         -  5    "UPDATE t1 SET a = 1 WHERE rowid=2"           {{column a is}}
  1315         -  6    "UPDATE t1 SET a = 4.3 WHERE rowid=3"         {{column a is}}
  1316         -  7    "UPDATE t1 SET a = 'reveal' WHERE rowid=4"    {{column a is}}
  1317         -  8    "UPDATE t1 SET a = X'123456' WHERE rowid=1"   {{column a is}}
         1316  +  5    "UPDATE t1 SET a = 1 WHERE rowid=2"           {{t1.a}}
         1317  +  6    "UPDATE t1 SET a = 4.3 WHERE rowid=3"         {{t1.a}}
         1318  +  7    "UPDATE t1 SET a = 'reveal' WHERE rowid=4"    {{t1.a}}
         1319  +  8    "UPDATE t1 SET a = X'123456' WHERE rowid=1"   {{t1.a}}
  1318   1320   
  1319         -  9    "INSERT INTO t4 VALUES('xyx', 1, 1)"          {{columns a, b, c are}}
  1320         -  10   "INSERT INTO t4 VALUES('xyx', 2, 1)"          {{columns a, b, c are}}
  1321         -  11   "INSERT INTO t4 VALUES('uvw', 1, 1)"          {{columns a, b, c are}}
         1321  +  9    "INSERT INTO t4 VALUES('xyx', 1, 1)"          {{t4.a, t4.b, t4.c}}
         1322  +  10   "INSERT INTO t4 VALUES('xyx', 2, 1)"          {{t4.a, t4.b, t4.c}}
         1323  +  11   "INSERT INTO t4 VALUES('uvw', 1, 1)"          {{t4.a, t4.b, t4.c}}
  1322   1324   
  1323         -  12   "UPDATE t4 SET a='xyx' WHERE rowid=3"         {{columns a, b, c are}}
  1324         -  13   "UPDATE t4 SET b=1 WHERE rowid=2"             {{columns a, b, c are}}
  1325         -  14   "UPDATE t4 SET a=0, b=0, c=0"                 {{columns a, b, c are}}
         1325  +  12   "UPDATE t4 SET a='xyx' WHERE rowid=3"         {{t4.a, t4.b, t4.c}}
         1326  +  13   "UPDATE t4 SET b=1 WHERE rowid=2"             {{t4.a, t4.b, t4.c}}
         1327  +  14   "UPDATE t4 SET a=0, b=0, c=0"                 {{t4.a, t4.b, t4.c}}
  1326   1328   }
  1327   1329   
  1328   1330   # EVIDENCE-OF: R-21289-11559 As with PRIMARY KEY constraints, for the
  1329   1331   # purposes of UNIQUE constraints NULL values are considered distinct
  1330   1332   # from all other values (including other NULLs).
  1331   1333   #
  1332   1334   do_createtable_tests 4.8 {
................................................................................
  1400   1402     CREATE TABLE x2(a CHECK( a||b ), b);
  1401   1403     CREATE TABLE t2(a, b, CHECK( a||b ));
  1402   1404     INSERT INTO x2 VALUES(1, 'xx');
  1403   1405     INSERT INTO x2 VALUES(1, 'yy');
  1404   1406     INSERT INTO t2 SELECT * FROM x2;
  1405   1407   }
  1406   1408   
  1407         -do_createtable_tests 4.11 -error {constraint failed} {
  1408         -  1a    "INSERT INTO x1 VALUES('one', 0)"       {}
  1409         -  1b    "INSERT INTO t1 VALUES('one', -4.0)"    {}
         1409  +do_createtable_tests 4.11 -error {CHECK constraint failed: %s} {
         1410  +  1a    "INSERT INTO x1 VALUES('one', 0)"       {x1}
         1411  +  1b    "INSERT INTO t1 VALUES('one', -4.0)"    {t1}
  1410   1412   
  1411         -  2a    "INSERT INTO x2 VALUES('abc', 1)"       {}
  1412         -  2b    "INSERT INTO t2 VALUES('abc', 1)"       {}
         1413  +  2a    "INSERT INTO x2 VALUES('abc', 1)"       {x2}
         1414  +  2b    "INSERT INTO t2 VALUES('abc', 1)"       {t2}
  1413   1415   
  1414         -  3a    "INSERT INTO x2 VALUES(0, 'abc')"       {}
  1415         -  3b    "INSERT INTO t2 VALUES(0, 'abc')"       {}
         1416  +  3a    "INSERT INTO x2 VALUES(0, 'abc')"       {x2}
         1417  +  3b    "INSERT INTO t2 VALUES(0, 'abc')"       {t2}
  1416   1418   
  1417         -  4a    "UPDATE t1 SET b=-1 WHERE rowid=1"      {}
  1418         -  4b    "UPDATE x1 SET b=-1 WHERE rowid=1"      {}
         1419  +  4a    "UPDATE t1 SET b=-1 WHERE rowid=1"      {t1}
         1420  +  4b    "UPDATE x1 SET b=-1 WHERE rowid=1"      {x1}
  1419   1421   
  1420         -  4a    "UPDATE x2 SET a='' WHERE rowid=1"      {}
  1421         -  4b    "UPDATE t2 SET a='' WHERE rowid=1"      {}
         1422  +  4a    "UPDATE x2 SET a='' WHERE rowid=1"      {x2}
         1423  +  4b    "UPDATE t2 SET a='' WHERE rowid=1"      {t2}
  1422   1424   }
  1423   1425   
  1424   1426   # EVIDENCE-OF: R-34109-39108 If the CHECK expression evaluates to NULL,
  1425   1427   # or any other non-zero value, it is not a constraint violation.
  1426   1428   #
  1427   1429   do_createtable_tests 4.12 {
  1428   1430     1a    "INSERT INTO x1 VALUES('one', NULL)"    {}
................................................................................
  1465   1467   
  1466   1468     INSERT INTO t2 VALUES('x', 'y');
  1467   1469     INSERT INTO t2 VALUES('z', NULL);
  1468   1470   
  1469   1471     INSERT INTO t3 VALUES('x', 'y', 'z');
  1470   1472     INSERT INTO t3 VALUES(1, 2, 3);
  1471   1473   }
  1472         -do_createtable_tests 4.14 -error {
  1473         -  %s may not be NULL
  1474         -} {
         1474  +do_createtable_tests 4.14 -error {NOT NULL constraint failed: %s} {
  1475   1475     1    "INSERT INTO t1 VALUES(NULL, 'a')"         {t1.a}
  1476   1476     2    "INSERT INTO t2 VALUES(NULL, 'b')"         {t2.a}
  1477   1477     3    "INSERT INTO t3 VALUES('c', 'd', NULL)"    {t3.c}
  1478   1478     4    "INSERT INTO t3 VALUES('e', NULL, 'f')"    {t3.b}
  1479   1479     5    "INSERT INTO t3 VALUES(NULL, 'g', 'h')"    {t3.a}
  1480   1480   }
  1481   1481   
................................................................................
  1533   1533     INSERT INTO t3_ig SELECT * FROM t3_ab;
  1534   1534     INSERT INTO t3_fa SELECT * FROM t3_ab;
  1535   1535     INSERT INTO t3_re SELECT * FROM t3_ab;
  1536   1536     INSERT INTO t3_xx SELECT * FROM t3_ab;
  1537   1537   }
  1538   1538   
  1539   1539   foreach {tn tbl res ac data} {
  1540         -  1   t1_ab    {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three}
  1541         -  2   t1_ro    {1 {PRIMARY KEY must be unique}} 1 {1 one 2 two}
  1542         -  3   t1_fa    {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three 4 string}
         1540  +  1   t1_ab    {1 {UNIQUE constraint failed: t1_ab.a}} 0 {1 one 2 two 3 three}
         1541  +  2   t1_ro    {1 {UNIQUE constraint failed: t1_ro.a}} 1 {1 one 2 two}
         1542  +  3   t1_fa    {1 {UNIQUE constraint failed: t1_fa.a}} 0 {1 one 2 two 3 three 4 string}
  1543   1543     4   t1_ig    {0 {}} 0 {1 one 2 two 3 three 4 string 6 string}
  1544   1544     5   t1_re    {0 {}} 0 {1 one 2 two 4 string 3 string 6 string}
  1545         -  6   t1_xx    {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three}
         1545  +  6   t1_xx    {1 {UNIQUE constraint failed: t1_xx.a}} 0 {1 one 2 two 3 three}
  1546   1546   } {
  1547   1547     catchsql COMMIT
  1548   1548     do_execsql_test  4.15.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
  1549   1549   
  1550   1550     do_catchsql_test 4.15.$tn.2 " 
  1551   1551       INSERT INTO $tbl SELECT ((a%2)*a+3), 'string' FROM $tbl;
  1552   1552     " $res
  1553   1553   
  1554   1554     do_test e_createtable-4.15.$tn.3 { sqlite3_get_autocommit db } $ac
  1555   1555     do_execsql_test 4.15.$tn.4 "SELECT * FROM $tbl" $data
  1556   1556   }
  1557   1557   foreach {tn tbl res ac data} {
  1558         -  1   t2_ab    {1 {t2_ab.b may not be NULL}} 0 {1 one 2 two 3 three}
  1559         -  2   t2_ro    {1 {t2_ro.b may not be NULL}} 1 {1 one 2 two}
  1560         -  3   t2_fa    {1 {t2_fa.b may not be NULL}} 0 {1 one 2 two 3 three 4 xx}
         1558  +  1   t2_ab    {1 {NOT NULL constraint failed: t2_ab.b}} 0 {1 one 2 two 3 three}
         1559  +  2   t2_ro    {1 {NOT NULL constraint failed: t2_ro.b}} 1 {1 one 2 two}
         1560  +  3   t2_fa    {1 {NOT NULL constraint failed: t2_fa.b}} 0 {1 one 2 two 3 three 4 xx}
  1561   1561     4   t2_ig    {0 {}} 0 {1 one 2 two 3 three 4 xx 6 xx}
  1562         -  5   t2_re    {1 {t2_re.b may not be NULL}} 0 {1 one 2 two 3 three}
  1563         -  6   t2_xx    {1 {t2_xx.b may not be NULL}} 0 {1 one 2 two 3 three}
         1562  +  5   t2_re    {1 {NOT NULL constraint failed: t2_re.b}} 0 {1 one 2 two 3 three}
         1563  +  6   t2_xx    {1 {NOT NULL constraint failed: t2_xx.b}} 0 {1 one 2 two 3 three}
  1564   1564   } {
  1565   1565     catchsql COMMIT
  1566   1566     do_execsql_test  4.16.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
  1567   1567   
  1568   1568     do_catchsql_test 4.16.$tn.2 " 
  1569   1569       INSERT INTO $tbl SELECT a+3, CASE a WHEN 2 THEN NULL ELSE 'xx' END FROM $tbl
  1570   1570     " $res
  1571   1571   
  1572   1572     do_test e_createtable-4.16.$tn.3 { sqlite3_get_autocommit db } $ac
  1573   1573     do_execsql_test 4.16.$tn.4 "SELECT * FROM $tbl" $data
  1574   1574   }
  1575   1575   foreach {tn tbl res ac data} {
  1576         -  1   t3_ab    {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three}
  1577         -  2   t3_ro    {1 {columns a, b are not unique}} 1 {1 one 2 two}
  1578         -  3   t3_fa    {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three 4 three}
         1576  +  1   t3_ab    {1 {UNIQUE constraint failed: t3_ab.a, t3_ab.b}}
         1577  +               0 {1 one 2 two 3 three}
         1578  +  2   t3_ro    {1 {UNIQUE constraint failed: t3_ro.a, t3_ro.b}}
         1579  +               1 {1 one 2 two}
         1580  +  3   t3_fa    {1 {UNIQUE constraint failed: t3_fa.a, t3_fa.b}}
         1581  +               0 {1 one 2 two 3 three 4 three}
  1579   1582     4   t3_ig    {0 {}} 0 {1 one 2 two 3 three 4 three 6 three}
  1580   1583     5   t3_re    {0 {}} 0 {1 one 2 two 4 three 3 three 6 three}
  1581         -  6   t3_xx    {1 {columns a, b are not unique}} 0 {1 one 2 two 3 three}
         1584  +  6   t3_xx    {1 {UNIQUE constraint failed: t3_xx.a, t3_xx.b}}
         1585  +               0 {1 one 2 two 3 three}
  1582   1586   } {
  1583   1587     catchsql COMMIT
  1584   1588     do_execsql_test  4.17.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')"
  1585   1589   
  1586   1590     do_catchsql_test 4.17.$tn.2 " 
  1587   1591       INSERT INTO $tbl SELECT ((a%2)*a+3), 'three' FROM $tbl
  1588   1592     " $res
................................................................................
  1605   1609     CREATE TABLE t4(a, b CHECK (b!=10));
  1606   1610     INSERT INTO t4 VALUES(1, 2);
  1607   1611     INSERT INTO t4 VALUES(3, 4);
  1608   1612   }
  1609   1613   do_execsql_test  4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) }
  1610   1614   do_catchsql_test 4.18.3 { 
  1611   1615     INSERT INTO t4 SELECT a+4, b+4 FROM t4
  1612         -} {1 {constraint failed}}
         1616  +} {1 {CHECK constraint failed: t4}}
  1613   1617   do_test e_createtable-4.18.4 { sqlite3_get_autocommit db } 0
  1614   1618   do_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6}
  1615   1619   
  1616   1620   # EVIDENCE-OF: R-19114-56113 Different constraints within the same table
  1617   1621   # may have different default conflict resolution algorithms.
  1618   1622   #
  1619   1623   do_execsql_test 4.19.0 {
  1620   1624     CREATE TABLE t5(a NOT NULL ON CONFLICT IGNORE, b NOT NULL ON CONFLICT ABORT);
  1621   1625   }
  1622   1626   do_catchsql_test 4.19.1 { INSERT INTO t5 VALUES(NULL, 'not null') } {0 {}}
  1623   1627   do_execsql_test  4.19.2 { SELECT * FROM t5 } {}
  1624   1628   do_catchsql_test 4.19.3 { INSERT INTO t5 VALUES('not null', NULL) } \
  1625         -  {1 {t5.b may not be NULL}}
         1629  +  {1 {NOT NULL constraint failed: t5.b}}
  1626   1630   do_execsql_test  4.19.4 { SELECT * FROM t5 } {}
  1627   1631   
  1628   1632   #------------------------------------------------------------------------
  1629   1633   # Tests for INTEGER PRIMARY KEY and rowid related statements.
  1630   1634   #
  1631   1635   
  1632   1636   # EVIDENCE-OF: R-52584-04009 The rowid value can be accessed using one
................................................................................
  1743   1747     SELECT typeof(pk), pk FROM t7;
  1744   1748     SELECT typeof(pk), pk FROM t8;
  1745   1749     SELECT typeof(pk), pk FROM t9;
  1746   1750   } {integer 2 integer 2 integer 2 integer 2}
  1747   1751   
  1748   1752   do_catchsql_test 5.4.4.1 { 
  1749   1753     INSERT INTO t6 VALUES(2) 
  1750         -} {1 {PRIMARY KEY must be unique}}
         1754  +} {1 {UNIQUE constraint failed: t6.pk}}
  1751   1755   do_catchsql_test 5.4.4.2 { 
  1752   1756     INSERT INTO t7 VALUES(2) 
  1753         -} {1 {PRIMARY KEY must be unique}}
         1757  +} {1 {UNIQUE constraint failed: t7.pk}}
  1754   1758   do_catchsql_test 5.4.4.3 { 
  1755   1759     INSERT INTO t8 VALUES(2) 
  1756         -} {1 {PRIMARY KEY must be unique}}
         1760  +} {1 {UNIQUE constraint failed: t8.pk}}
  1757   1761   do_catchsql_test 5.4.4.4 { 
  1758   1762     INSERT INTO t9 VALUES(2) 
  1759         -} {1 {PRIMARY KEY must be unique}}
         1763  +} {1 {UNIQUE constraint failed: t9.pk}}
  1760   1764   
  1761   1765   # EVIDENCE-OF: R-56094-57830 the following three table declarations all
  1762   1766   # cause the column "x" to be an alias for the rowid (an integer primary
  1763   1767   # key): CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z); CREATE TABLE
  1764   1768   # t(x INTEGER, y, z, PRIMARY KEY(x ASC)); CREATE TABLE t(x INTEGER, y,
  1765   1769   # z, PRIMARY KEY(x DESC));
  1766   1770   #

Changes to test/e_fkey.test.

   207    207       INSERT INTO t2 VALUES(2, 1);
   208    208       BEGIN;
   209    209         PRAGMA foreign_keys = OFF;
   210    210     }
   211    211     catchsql {
   212    212         DELETE FROM t1
   213    213     }
   214         -} {1 {foreign key constraint failed}}
          214  +} {1 {FOREIGN KEY constraint failed}}
   215    215   do_test e_fkey-6.2 {
   216    216     execsql { PRAGMA foreign_keys }
   217    217   } {1}
   218    218   do_test e_fkey-6.3 {
   219    219     execsql {
   220    220       COMMIT;
   221    221       PRAGMA foreign_keys = OFF;
................................................................................
   261    261   #-------------------------------------------------------------------------
   262    262   # EVIDENCE-OF: R-61362-32087 Attempting to insert a row into the track
   263    263   # table that does not correspond to any row in the artist table will
   264    264   # fail,
   265    265   #
   266    266   do_test e_fkey-8.1 {
   267    267     catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }
   268         -} {1 {foreign key constraint failed}}
          268  +} {1 {FOREIGN KEY constraint failed}}
   269    269   do_test e_fkey-8.2 {
   270    270     execsql { INSERT INTO artist VALUES(2, 'artist 1') }
   271    271     catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }
   272         -} {1 {foreign key constraint failed}}
          272  +} {1 {FOREIGN KEY constraint failed}}
   273    273   do_test e_fkey-8.2 {
   274    274     execsql { INSERT INTO track VALUES(1, 'track 1', 2) }
   275    275   } {}
   276    276   
   277    277   #-------------------------------------------------------------------------
   278    278   # Attempting to delete a row from the 'artist' table while there are 
   279    279   # dependent rows in the track table also fails.
   280    280   #
   281    281   # EVIDENCE-OF: R-24401-52400 as will attempting to delete a row from the
   282    282   # artist table when there exist dependent rows in the track table
   283    283   #
   284    284   do_test e_fkey-9.1 {
   285    285     catchsql { DELETE FROM artist WHERE artistid = 2 }
   286         -} {1 {foreign key constraint failed}}
          286  +} {1 {FOREIGN KEY constraint failed}}
   287    287   do_test e_fkey-9.2 {
   288    288     execsql { 
   289    289       DELETE FROM track WHERE trackartist = 2;
   290    290       DELETE FROM artist WHERE artistid = 2;
   291    291     }
   292    292   } {}
   293    293   
................................................................................
   307    307   } {}
   308    308   do_test e_fkey-10.2 {
   309    309     execsql { SELECT * FROM artist }
   310    310   } {}
   311    311   do_test e_fkey-10.3 {
   312    312     # Setting the trackid to a non-NULL value fails, of course.
   313    313     catchsql { UPDATE track SET trackartist = 5 WHERE trackid = 1 }
   314         -} {1 {foreign key constraint failed}}
          314  +} {1 {FOREIGN KEY constraint failed}}
   315    315   do_test e_fkey-10.4 {
   316    316     execsql {
   317    317       INSERT INTO artist VALUES(5, 'artist 5');
   318    318       UPDATE track SET trackartist = 5 WHERE trackid = 1;
   319    319     }
   320    320     catchsql { DELETE FROM artist WHERE artistid = 5}
   321         -} {1 {foreign key constraint failed}}
          321  +} {1 {FOREIGN KEY constraint failed}}
   322    322   do_test e_fkey-10.5 {
   323    323     execsql { 
   324    324       UPDATE track SET trackartist = NULL WHERE trackid = 1;
   325    325       DELETE FROM artist WHERE artistid = 5;
   326    326     }
   327    327   } {}
   328    328   
................................................................................
   340    340   # This procedure executes a test case to check that statement 
   341    341   # R-52486-21352 is true after executing the SQL statement passed.
   342    342   # as the second argument.
   343    343   proc test_r52486_21352 {tn sql} {
   344    344     set res [catchsql $sql]
   345    345     set results {
   346    346       {0 {}} 
   347         -    {1 {PRIMARY KEY must be unique}} 
   348         -    {1 {foreign key constraint failed}}
          347  +    {1 {UNIQUE constraint failed: artist.artistid}} 
          348  +    {1 {FOREIGN KEY constraint failed}}
   349    349     }
   350    350     if {[lsearch $results $res]<0} {
   351    351       error $res
   352    352     }
   353    353   
   354    354     do_test e_fkey-11.$tn {
   355    355       execsql {
................................................................................
   405    405         trackartist INTEGER NOT NULL,
   406    406         FOREIGN KEY(trackartist) REFERENCES artist(artistid)
   407    407       );
   408    408     }
   409    409   } {}
   410    410   do_test e_fkey-12.2 {
   411    411     catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }
   412         -} {1 {track.trackartist may not be NULL}}
          412  +} {1 {NOT NULL constraint failed: track.trackartist}}
   413    413   
   414    414   #-------------------------------------------------------------------------
   415    415   # EVIDENCE-OF: R-16127-35442
   416    416   #
   417    417   # Test an example from foreignkeys.html.
   418    418   #
   419    419   drop_all_tables
................................................................................
   434    434       INSERT INTO track VALUES(11, 'That''s Amore', 1);
   435    435       INSERT INTO track VALUES(12, 'Christmas Blues', 1);
   436    436       INSERT INTO track VALUES(13, 'My Way', 2);
   437    437     }
   438    438   } {}
   439    439   do_test e_fkey-13.2 {
   440    440     catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', 3) }
   441         -} {1 {foreign key constraint failed}}
          441  +} {1 {FOREIGN KEY constraint failed}}
   442    442   do_test e_fkey-13.3 {
   443    443     execsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }
   444    444   } {}
   445    445   do_test e_fkey-13.4 {
   446    446     catchsql { 
   447    447       UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';
   448    448     }
   449         -} {1 {foreign key constraint failed}}
          449  +} {1 {FOREIGN KEY constraint failed}}
   450    450   do_test e_fkey-13.5 {
   451    451     execsql {
   452    452       INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
   453    453       UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';
   454    454       INSERT INTO track VALUES(15, 'Boogie Woogie', 3);
   455    455     }
   456    456   } {}
................................................................................
   460    460   #
   461    461   # Test the second example from the first section of foreignkeys.html.
   462    462   #
   463    463   do_test e_fkey-14.1 {
   464    464     catchsql {
   465    465       DELETE FROM artist WHERE artistname = 'Frank Sinatra';
   466    466     }
   467         -} {1 {foreign key constraint failed}}
          467  +} {1 {FOREIGN KEY constraint failed}}
   468    468   do_test e_fkey-14.2 {
   469    469     execsql {
   470    470       DELETE FROM track WHERE trackname = 'My Way';
   471    471       DELETE FROM artist WHERE artistname = 'Frank Sinatra';
   472    472     }
   473    473   } {}
   474    474   do_test e_fkey-14.3 {
   475    475     catchsql {
   476    476       UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';
   477    477     }
   478         -} {1 {foreign key constraint failed}}
          478  +} {1 {FOREIGN KEY constraint failed}}
   479    479   do_test e_fkey-14.4 {
   480    480     execsql {
   481    481       DELETE FROM track WHERE trackname IN('That''s Amore', 'Christmas Blues');
   482    482       UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';
   483    483     }
   484    484   } {}
   485    485   
................................................................................
   509    509       SELECT typeof(p) FROM par;
   510    510     }
   511    511   } {integer text blob}
   512    512   
   513    513   proc test_efkey_45 {tn isError sql} {
   514    514     do_test e_fkey-15.$tn.1 "
   515    515       catchsql {$sql}
   516         -  " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
          516  +  " [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]
   517    517   
   518    518     do_test e_fkey-15.$tn.2 {
   519    519       execsql {
   520    520         SELECT * FROM chi WHERE c IS NOT NULL AND c NOT IN (SELECT p FROM par)
   521    521       }
   522    522     } {}
   523    523   }
................................................................................
   553    553       INSERT INTO t2 VALUES('ONE');
   554    554       UPDATE t2 SET b = 'OnE';
   555    555       UPDATE t1 SET a = 'ONE';
   556    556     }
   557    557   } {}
   558    558   do_test e_fkey-16.3 {
   559    559     catchsql { UPDATE t2 SET b = 'two' WHERE rowid = 1 }
   560         -} {1 {foreign key constraint failed}}
          560  +} {1 {FOREIGN KEY constraint failed}}
   561    561   do_test e_fkey-16.4 {
   562    562     catchsql { DELETE FROM t1 WHERE rowid = 1 }
   563         -} {1 {foreign key constraint failed}}
          563  +} {1 {FOREIGN KEY constraint failed}}
   564    564   
   565    565   #-------------------------------------------------------------------------
   566    566   # Specifically, test that when comparing child and parent key values the
   567    567   # affinity of the parent key column is applied to the child key value
   568    568   # before the comparison takes place.
   569    569   #
   570    570   # EVIDENCE-OF: R-04240-13860 When comparing values, if the parent key
................................................................................
   588    588     }
   589    589   } {2.0 text}
   590    590   do_test e_fkey-17.3 {
   591    591     execsql { SELECT typeof(a) FROM t1 }
   592    592   } {integer integer text}
   593    593   do_test e_fkey-17.4 {
   594    594     catchsql { DELETE FROM t1 WHERE rowid = 2 }
   595         -} {1 {foreign key constraint failed}}
          595  +} {1 {FOREIGN KEY constraint failed}}
   596    596   
   597    597   ###########################################################################
   598    598   ### SECTION 3: Required and Suggested Database Indexes
   599    599   ###########################################################################
   600    600   
   601    601   #-------------------------------------------------------------------------
   602    602   # A parent key must be either a PRIMARY KEY, subject to a UNIQUE 
................................................................................
   892    892       CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES p1);
   893    893       CREATE TABLE c2(a, b REFERENCES p2);
   894    894     }
   895    895   } {}
   896    896   proc test_efkey_60 {tn isError sql} {
   897    897     do_test e_fkey-23.$tn "
   898    898       catchsql {$sql}
   899         -  " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
          899  +  " [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]
   900    900   }
   901    901   
   902    902   test_efkey_60 2 1 "INSERT INTO c1 VALUES(239, 231)"
   903    903   test_efkey_60 3 0 "INSERT INTO p1 VALUES(239, 231)"
   904    904   test_efkey_60 4 0 "INSERT INTO c1 VALUES(239, 231)"
   905    905   test_efkey_60 5 1 "INSERT INTO c2 VALUES(239, 231)"
   906    906   test_efkey_60 6 0 "INSERT INTO p2 VALUES(239, 231)"
................................................................................
   929    929       CREATE INDEX c2i ON c2(a, b);
   930    930       CREATE UNIQUE INDEX c3i ON c2(b, a);
   931    931     }
   932    932   } {}
   933    933   proc test_efkey_61 {tn isError sql} {
   934    934     do_test e_fkey-24.$tn "
   935    935       catchsql {$sql}
   936         -  " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
          936  +  " [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]
   937    937   }
   938    938   foreach {tn c} [list 2 c1 3 c2 4 c3] {
   939    939     test_efkey_61 $tn.1 1 "INSERT INTO $c VALUES(1, 2)"
   940    940     test_efkey_61 $tn.2 0 "INSERT INTO parent VALUES(1, 2)"
   941    941     test_efkey_61 $tn.3 0 "INSERT INTO $c VALUES(1, 2)"
   942    942   
   943    943     execsql "DELETE FROM $c ; DELETE FROM parent"
................................................................................
   994    994     }
   995    995   } {}
   996    996   
   997    997   do_test e_fkey-25.5 {
   998    998     concat \
   999    999       [execsql { SELECT rowid FROM track WHERE trackartist = 5 }]   \
  1000   1000       [catchsql { DELETE FROM artist WHERE artistid = 5 }]
  1001         -} {1 1 {foreign key constraint failed}}
         1001  +} {1 1 {FOREIGN KEY constraint failed}}
  1002   1002   
  1003   1003   do_test e_fkey-25.6 {
  1004   1004     concat \
  1005   1005       [execsql { SELECT rowid FROM track WHERE trackartist = 7 }]   \
  1006   1006       [catchsql { DELETE FROM artist WHERE artistid = 7 }]
  1007   1007   } {0 {}}
  1008   1008   
  1009   1009   do_test e_fkey-25.7 {
  1010   1010     concat \
  1011   1011       [execsql { SELECT rowid FROM track WHERE trackartist = 6 }]   \
  1012   1012       [catchsql { DELETE FROM artist WHERE artistid = 6 }]
  1013         -} {2 1 {foreign key constraint failed}}
         1013  +} {2 1 {FOREIGN KEY constraint failed}}
  1014   1014   
  1015   1015   #-------------------------------------------------------------------------
  1016   1016   # EVIDENCE-OF: R-47936-10044 Or, more generally:
  1017   1017   # SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value
  1018   1018   #
  1019   1019   # Test that when a row is deleted from the parent table of an FK 
  1020   1020   # constraint, the child table is queried for orphaned rows. The
................................................................................
  1195   1195       );
  1196   1196     }
  1197   1197   } {}
  1198   1198   do_test e_fkey-29.3 {
  1199   1199     catchsql {
  1200   1200       INSERT INTO song VALUES(2, 'Elvis Presley', 'Elvis Is Back!', 'Fever');
  1201   1201     }
  1202         -} {1 {foreign key constraint failed}}
         1202  +} {1 {FOREIGN KEY constraint failed}}
  1203   1203   
  1204   1204   
  1205   1205   #-------------------------------------------------------------------------
  1206   1206   # EVIDENCE-OF: R-33626-48418 In SQLite, if any of the child key columns
  1207   1207   # (in this case songartist and songalbum) are NULL, then there is no
  1208   1208   # requirement for a corresponding row in the parent table.
  1209   1209   #
................................................................................
  1236   1236       CREATE TABLE prince(c REFERENCES king, d);
  1237   1237     }
  1238   1238   } {}
  1239   1239   
  1240   1240   do_test e_fkey-31.2 {
  1241   1241     # Execute a statement that violates the immediate FK constraint.
  1242   1242     catchsql { INSERT INTO prince VALUES(1, 2) }
  1243         -} {1 {foreign key constraint failed}}
         1243  +} {1 {FOREIGN KEY constraint failed}}
  1244   1244   
  1245   1245   do_test e_fkey-31.3 {
  1246   1246     # This time, use a trigger to fix the constraint violation before the
  1247   1247     # statement has finished executing. Then execute the same statement as
  1248   1248     # in the previous test case. This time, no error.
  1249   1249     execsql {
  1250   1250       CREATE TRIGGER kt AFTER INSERT ON prince WHEN
................................................................................
  1261   1261   do_test e_fkey-31.4 {
  1262   1262     execsql {
  1263   1263       BEGIN;
  1264   1264       INSERT INTO prince VALUES(2, 3);
  1265   1265       DROP TRIGGER kt;
  1266   1266     }
  1267   1267     catchsql { INSERT INTO prince VALUES(3, 4) }
  1268         -} {1 {foreign key constraint failed}}
         1268  +} {1 {FOREIGN KEY constraint failed}}
  1269   1269   do_test e_fkey-31.5 {
  1270   1270     execsql {
  1271   1271       COMMIT;
  1272   1272       SELECT * FROM king;
  1273   1273     }
  1274   1274   } {1 {} 2 {}}
  1275   1275   
................................................................................
  1292   1292   #
  1293   1293   # EVIDENCE-OF: R-29604-30395 However, COMMIT will fail as long as
  1294   1294   # foreign key constraints remain in violation.
  1295   1295   #
  1296   1296   proc test_efkey_34 {tn isError sql} {
  1297   1297     do_test e_fkey-32.$tn "
  1298   1298       catchsql {$sql}
  1299         -  " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
         1299  +  " [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]
  1300   1300   }
  1301   1301   drop_all_tables
  1302   1302   
  1303   1303   test_efkey_34  1 0 {
  1304   1304     CREATE TABLE ll(k PRIMARY KEY);
  1305   1305     CREATE TABLE kk(c REFERENCES ll DEFERRABLE INITIALLY DEFERRED);
  1306   1306   }
................................................................................
  1323   1323   # executing. In this case deferred constraints behave the same as
  1324   1324   # immediate constraints.
  1325   1325   #
  1326   1326   drop_all_tables
  1327   1327   proc test_efkey_35 {tn isError sql} {
  1328   1328     do_test e_fkey-33.$tn "
  1329   1329       catchsql {$sql}
  1330         -  " [lindex {{0 {}} {1 {foreign key constraint failed}}} $isError]
         1330  +  " [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]
  1331   1331   }
  1332   1332   do_test e_fkey-33.1 {
  1333   1333     execsql {
  1334   1334       CREATE TABLE parent(x, y);
  1335   1335       CREATE UNIQUE INDEX pi ON parent(x, y);
  1336   1336       CREATE TABLE child(a, b,
  1337   1337         FOREIGN KEY(a, b) REFERENCES parent(x, y) DEFERRABLE INITIALLY DEFERRED
................................................................................
  1413   1413       INSERT INTO c6 VALUES('p', 'q', 'r');
  1414   1414       INSERT INTO c7 VALUES('s', 't', 'u');
  1415   1415     }
  1416   1416   } {}
  1417   1417   
  1418   1418   proc test_efkey_29 {tn sql isError} {
  1419   1419     do_test e_fkey-34.$tn "catchsql {$sql}" [
  1420         -    lindex {{0 {}} {1 {foreign key constraint failed}}} $isError
         1420  +    lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError
  1421   1421     ]
  1422   1422   }
  1423   1423   test_efkey_29  2 "BEGIN"                                   0
  1424   1424   test_efkey_29  3 "DELETE FROM parent WHERE x = 'a'"        1
  1425   1425   test_efkey_29  4 "DELETE FROM parent WHERE x = 'd'"        1
  1426   1426   test_efkey_29  5 "DELETE FROM parent WHERE x = 'g'"        1
  1427   1427   test_efkey_29  6 "DELETE FROM parent WHERE x = 'j'"        1
................................................................................
  1487   1487   } {}
  1488   1488   do_test e_fkey-35.2 {
  1489   1489     execsql {
  1490   1490       BEGIN;
  1491   1491         INSERT INTO track VALUES(1, 'White Christmas', 5);
  1492   1492     }
  1493   1493     catchsql COMMIT
  1494         -} {1 {foreign key constraint failed}}
         1494  +} {1 {FOREIGN KEY constraint failed}}
  1495   1495   do_test e_fkey-35.3 {
  1496   1496     execsql {
  1497   1497       INSERT INTO artist VALUES(5, 'Bing Crosby');
  1498   1498       COMMIT;
  1499   1499     }
  1500   1500   } {}
  1501   1501   
................................................................................
  1524   1524         SAVEPOINT one;
  1525   1525           INSERT INTO t1 VALUES(4, 5);
  1526   1526         RELEASE one;
  1527   1527     }
  1528   1528   } {}
  1529   1529   do_test e_fkey-36.3 {
  1530   1530     catchsql COMMIT
  1531         -} {1 {foreign key constraint failed}}
         1531  +} {1 {FOREIGN KEY constraint failed}}
  1532   1532   do_test e_fkey-36.4 {
  1533   1533     execsql {
  1534   1534       UPDATE t1 SET a = 5 WHERE a = 4;
  1535   1535       COMMIT;
  1536   1536     }
  1537   1537   } {}
  1538   1538   
................................................................................
  1554   1554         SAVEPOINT two;
  1555   1555           INSERT INTO t1 VALUES(6, 7);
  1556   1556         RELEASE two;
  1557   1557     }
  1558   1558   } {}
  1559   1559   do_test e_fkey-37.2 {
  1560   1560     catchsql {RELEASE one}
  1561         -} {1 {foreign key constraint failed}}
         1561  +} {1 {FOREIGN KEY constraint failed}}
  1562   1562   do_test e_fkey-37.3 {
  1563   1563     execsql {
  1564   1564         UPDATE t1 SET a = 7 WHERE a = 6;
  1565   1565       RELEASE one;
  1566   1566     }
  1567   1567   } {}
  1568   1568   do_test e_fkey-37.4 {
................................................................................
  1571   1571         SAVEPOINT two;
  1572   1572           INSERT INTO t1 VALUES(9, 10);
  1573   1573         RELEASE two;
  1574   1574     }
  1575   1575   } {}
  1576   1576   do_test e_fkey-37.5 {
  1577   1577     catchsql {RELEASE one}
  1578         -} {1 {foreign key constraint failed}}
         1578  +} {1 {FOREIGN KEY constraint failed}}
  1579   1579   do_test e_fkey-37.6 {
  1580   1580     execsql {ROLLBACK TO one ; RELEASE one}
  1581   1581   } {}
  1582   1582   
  1583   1583   #-------------------------------------------------------------------------
  1584   1584   # Test that if a COMMIT operation fails due to deferred foreign key 
  1585   1585   # constraints, any nested savepoints remain open.
................................................................................
  1602   1602         SAVEPOINT one;
  1603   1603           INSERT INTO t1 VALUES(5, 6);
  1604   1604           SELECT * FROM t1;
  1605   1605     }
  1606   1606   } {1 1 2 2 3 3 4 4 5 6}
  1607   1607   do_test e_fkey-38.3 {
  1608   1608     catchsql COMMIT
  1609         -} {1 {foreign key constraint failed}}
         1609  +} {1 {FOREIGN KEY constraint failed}}
  1610   1610   do_test e_fkey-38.4 {
  1611   1611     execsql {
  1612   1612       ROLLBACK TO one;
  1613   1613       COMMIT;
  1614   1614       SELECT * FROM t1;
  1615   1615     }
  1616   1616   } {1 1 2 2 3 3 4 4}
................................................................................
  1623   1623           INSERT INTO t1 VALUES(6, 7);
  1624   1624           SAVEPOINT c;
  1625   1625             INSERT INTO t1 VALUES(7, 8);
  1626   1626     }
  1627   1627   } {}
  1628   1628   do_test e_fkey-38.6 {
  1629   1629     catchsql {RELEASE a}
  1630         -} {1 {foreign key constraint failed}}
         1630  +} {1 {FOREIGN KEY constraint failed}}
  1631   1631   do_test e_fkey-38.7 {
  1632   1632     execsql  {ROLLBACK TO c}
  1633   1633     catchsql {RELEASE a}
  1634         -} {1 {foreign key constraint failed}}
         1634  +} {1 {FOREIGN KEY constraint failed}}
  1635   1635   do_test e_fkey-38.8 {
  1636   1636     execsql  {
  1637   1637       ROLLBACK TO b;
  1638   1638       RELEASE a;
  1639   1639       SELECT * FROM t1;
  1640   1640     }
  1641   1641   } {1 1 2 2 3 3 4 4 5 5}
................................................................................
  1778   1778         UPDATE parent SET p1='k' WHERE p1='j';
  1779   1779         DELETE FROM parent WHERE p1='l';
  1780   1780         SELECT * FROM child;
  1781   1781     }
  1782   1782   } {j k l m}
  1783   1783   do_test e_fkey-41.3 {
  1784   1784     catchsql COMMIT
  1785         -} {1 {foreign key constraint failed}}
         1785  +} {1 {FOREIGN KEY constraint failed}}
  1786   1786   do_test e_fkey-41.4 {
  1787   1787     execsql ROLLBACK
  1788   1788   } {}
  1789   1789   
  1790   1790   #-------------------------------------------------------------------------
  1791   1791   # Test that "RESTRICT" means the application is prohibited from deleting
  1792   1792   # or updating a parent table row when there exists one or more child keys
................................................................................
  1816   1816       INSERT INTO parent VALUES('c', 'd');
  1817   1817       INSERT INTO child1 VALUES('b', 'a');
  1818   1818       INSERT INTO child2 VALUES('d', 'c');
  1819   1819     }
  1820   1820   } {}
  1821   1821   do_test e_fkey-41.3 {
  1822   1822     catchsql { DELETE FROM parent WHERE p1 = 'a' }
  1823         -} {1 {foreign key constraint failed}}
         1823  +} {1 {FOREIGN KEY constraint failed}}
  1824   1824   do_test e_fkey-41.4 {
  1825   1825     catchsql { UPDATE parent SET p2 = 'e' WHERE p1 = 'c' }
  1826         -} {1 {foreign key constraint failed}}
         1826  +} {1 {FOREIGN KEY constraint failed}}
  1827   1827   
  1828   1828   #-------------------------------------------------------------------------
  1829   1829   # Test that RESTRICT is slightly different from NO ACTION for IMMEDIATE
  1830   1830   # constraints, in that it is enforced immediately, not at the end of the 
  1831   1831   # statement.
  1832   1832   #
  1833   1833   # EVIDENCE-OF: R-37997-42187 The difference between the effect of a
................................................................................
  1853   1853         UPDATE child1 set c = new.x WHERE c = old.x;
  1854   1854         UPDATE child2 set c = new.x WHERE c = old.x;
  1855   1855       END;
  1856   1856     }
  1857   1857   } {}
  1858   1858   do_test e_fkey-42.2 {
  1859   1859     catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }
  1860         -} {1 {foreign key constraint failed}}
         1860  +} {1 {FOREIGN KEY constraint failed}}
  1861   1861   do_test e_fkey-42.3 {
  1862   1862     execsql { 
  1863   1863       UPDATE parent SET x = 'key two' WHERE x = 'key2';
  1864   1864       SELECT * FROM child2;
  1865   1865     }
  1866   1866   } {{key two}}
  1867   1867   
................................................................................
  1881   1881         UPDATE child1 SET c = NULL WHERE c = old.x;
  1882   1882         UPDATE child2 SET c = NULL WHERE c = old.x;
  1883   1883       END;
  1884   1884     }
  1885   1885   } {}
  1886   1886   do_test e_fkey-42.5 {
  1887   1887     catchsql { DELETE FROM parent WHERE x = 'key1' }
  1888         -} {1 {foreign key constraint failed}}
         1888  +} {1 {FOREIGN KEY constraint failed}}
  1889   1889   do_test e_fkey-42.6 {
  1890   1890     execsql { 
  1891   1891       DELETE FROM parent WHERE x = 'key2';
  1892   1892       SELECT * FROM child2;
  1893   1893     }
  1894   1894   } {{}}
  1895   1895   
................................................................................
  1904   1904       INSERT INTO parent VALUES('key2');
  1905   1905       INSERT INTO child1 VALUES('key1');
  1906   1906       INSERT INTO child2 VALUES('key2');
  1907   1907     }
  1908   1908   } {}
  1909   1909   do_test e_fkey-42.8 {
  1910   1910     catchsql { REPLACE INTO parent VALUES('key1') }
  1911         -} {1 {foreign key constraint failed}}
         1911  +} {1 {FOREIGN KEY constraint failed}}
  1912   1912   do_test e_fkey-42.9 {
  1913   1913     execsql { 
  1914   1914       REPLACE INTO parent VALUES('key2');
  1915   1915       SELECT * FROM child2;
  1916   1916     }
  1917   1917   } {key2}
  1918   1918   
................................................................................
  1940   1940       INSERT INTO child1 VALUES('key1');
  1941   1941       INSERT INTO child2 VALUES('key2');
  1942   1942       BEGIN;
  1943   1943     }
  1944   1944   } {}
  1945   1945   do_test e_fkey-43.2 {
  1946   1946     catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }
  1947         -} {1 {foreign key constraint failed}}
         1947  +} {1 {FOREIGN KEY constraint failed}}
  1948   1948   do_test e_fkey-43.3 {
  1949   1949     execsql { UPDATE parent SET x = 'key two' WHERE x = 'key2' }
  1950   1950   } {}
  1951   1951   do_test e_fkey-43.4 {
  1952   1952     catchsql COMMIT
  1953         -} {1 {foreign key constraint failed}}
         1953  +} {1 {FOREIGN KEY constraint failed}}
  1954   1954   do_test e_fkey-43.5 {
  1955   1955     execsql {
  1956   1956       UPDATE child2 SET c = 'key two';
  1957   1957       COMMIT;
  1958   1958     }
  1959   1959   } {}
  1960   1960   
................................................................................
  1974   1974       INSERT INTO child1 VALUES('key1');
  1975   1975       INSERT INTO child2 VALUES('key2');
  1976   1976       BEGIN;
  1977   1977     }
  1978   1978   } {}
  1979   1979   do_test e_fkey-43.7 {
  1980   1980     catchsql { DELETE FROM parent WHERE x = 'key1' }
  1981         -} {1 {foreign key constraint failed}}
         1981  +} {1 {FOREIGN KEY constraint failed}}
  1982   1982   do_test e_fkey-43.8 {
  1983   1983     execsql { DELETE FROM parent WHERE x = 'key2' }
  1984   1984   } {}
  1985   1985   do_test e_fkey-43.9 {
  1986   1986     catchsql COMMIT
  1987         -} {1 {foreign key constraint failed}}
         1987  +} {1 {FOREIGN KEY constraint failed}}
  1988   1988   do_test e_fkey-43.10 {
  1989   1989     execsql {
  1990   1990       UPDATE child2 SET c = NULL;
  1991   1991       COMMIT;
  1992   1992     }
  1993   1993   } {}
  1994   1994   
................................................................................
  2236   2236       ROLLBACK;
  2237   2237       DELETE FROM parent WHERE a = 'A';
  2238   2238       SELECT * FROM parent;
  2239   2239     }
  2240   2240   } {ONE two three}
  2241   2241   do_test e_fkey-49.4 {
  2242   2242     catchsql { UPDATE parent SET a = '' WHERE a = 'oNe' }
  2243         -} {1 {foreign key constraint failed}}
         2243  +} {1 {FOREIGN KEY constraint failed}}
  2244   2244   
  2245   2245   
  2246   2246   #-------------------------------------------------------------------------
  2247   2247   # EVIDENCE-OF: R-11856-19836
  2248   2248   #
  2249   2249   # Test an example from the "ON DELETE and ON UPDATE Actions" section 
  2250   2250   # of foreignkeys.html. This example shows that adding an "ON DELETE DEFAULT"
................................................................................
  2271   2271       );
  2272   2272       INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
  2273   2273       INSERT INTO track VALUES(14, 'Mr. Bojangles', 3);
  2274   2274     }
  2275   2275   } {}
  2276   2276   do_test e_fkey-50.2 {
  2277   2277     catchsql { DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.' }
  2278         -} {1 {foreign key constraint failed}}
         2278  +} {1 {FOREIGN KEY constraint failed}}
  2279   2279   do_test e_fkey-50.3 {
  2280   2280     execsql {
  2281   2281       INSERT INTO artist VALUES(0, 'Unknown Artist');
  2282   2282       DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.';
  2283   2283     }
  2284   2284   } {}
  2285   2285   do_test e_fkey-50.4 {
................................................................................
  2635   2635     execsql { 
  2636   2636       DELETE FROM c1;
  2637   2637       DELETE FROM c2;
  2638   2638       DELETE FROM c3;
  2639   2639     }
  2640   2640     execsql { INSERT INTO c5 VALUES('a', 'b') }
  2641   2641     catchsql { DROP TABLE p }
  2642         -} {1 {foreign key constraint failed}}
         2642  +} {1 {FOREIGN KEY constraint failed}}
  2643   2643   do_test e_fkey-58.2 {
  2644   2644     execsql { SELECT * FROM p }
  2645   2645   } {a b}
  2646   2646   do_test e_fkey-58.3 {
  2647   2647     catchsql {
  2648   2648       BEGIN;
  2649   2649         DROP TABLE p;
  2650   2650     }
  2651         -} {1 {foreign key constraint failed}}
         2651  +} {1 {FOREIGN KEY constraint failed}}
  2652   2652   do_test e_fkey-58.4 {
  2653   2653     execsql {
  2654   2654       SELECT * FROM p;
  2655   2655       SELECT * FROM c5;
  2656   2656       ROLLBACK;
  2657   2657     }
  2658   2658   } {a b a b}
................................................................................
  2678   2678     execsql {
  2679   2679       BEGIN;
  2680   2680         DROP TABLE p;
  2681   2681     }
  2682   2682   } {}
  2683   2683   do_test e_fkey-59.3 {
  2684   2684     catchsql COMMIT
  2685         -} {1 {foreign key constraint failed}}
         2685  +} {1 {FOREIGN KEY constraint failed}}
  2686   2686   do_test e_fkey-59.4 {
  2687   2687     execsql { CREATE TABLE p(a, b, PRIMARY KEY(a, b)) }
  2688   2688     catchsql COMMIT
  2689         -} {1 {foreign key constraint failed}}
         2689  +} {1 {FOREIGN KEY constraint failed}}
  2690   2690   do_test e_fkey-59.5 {
  2691   2691     execsql { INSERT INTO p VALUES('a', 'b') }
  2692   2692     execsql COMMIT
  2693   2693   } {}
  2694   2694   
  2695   2695   #-------------------------------------------------------------------------
  2696   2696   # Any "foreign key mismatch" errors encountered while running an implicit
................................................................................
  2845   2845       execsql { INSERT INTO c VALUES('x', 'x', NULL)  }
  2846   2846       execsql { INSERT INTO c VALUES('y', NULL, 'x')  }
  2847   2847       execsql { INSERT INTO c VALUES('z', NULL, NULL) }
  2848   2848   
  2849   2849       # Check that the FK is enforced properly if there are no NULL values 
  2850   2850       # in the child key columns.
  2851   2851       catchsql { INSERT INTO c VALUES('a', 2, 4) }
  2852         -  } {1 {foreign key constraint failed}}
         2852  +  } {1 {FOREIGN KEY constraint failed}}
  2853   2853   }
  2854   2854   
  2855   2855   #-------------------------------------------------------------------------
  2856   2856   # Test that SQLite does not support the SET CONSTRAINT statement. And
  2857   2857   # that it is possible to create both immediate and deferred constraints.
  2858   2858   #
  2859   2859   # EVIDENCE-OF: R-21599-16038 In SQLite, a foreign key constraint is
................................................................................
  2875   2875       CREATE TABLE ci(c, d, 
  2876   2876         FOREIGN KEY(c, d) REFERENCES p DEFERRABLE INITIALLY IMMEDIATE);
  2877   2877       BEGIN;
  2878   2878     }
  2879   2879   } {}
  2880   2880   do_test e_fkey-62.4 {
  2881   2881     catchsql { INSERT INTO ci VALUES('x', 'y') }
  2882         -} {1 {foreign key constraint failed}}
         2882  +} {1 {FOREIGN KEY constraint failed}}
  2883   2883   do_test e_fkey-62.5 {
  2884   2884     catchsql { INSERT INTO cd VALUES('x', 'y') }
  2885   2885   } {0 {}}
  2886   2886   do_test e_fkey-62.6 {
  2887   2887     catchsql { COMMIT }
  2888         -} {1 {foreign key constraint failed}}
         2888  +} {1 {FOREIGN KEY constraint failed}}
  2889   2889   do_test e_fkey-62.7 {
  2890   2890     execsql { 
  2891   2891       DELETE FROM cd;
  2892   2892       COMMIT;
  2893   2893     }
  2894   2894   } {}
  2895   2895   

Changes to test/e_insert.test.

   367    367   #
   368    368   do_execsql_test e_insert-4.1.0 {
   369    369     INSERT INTO a4 VALUES(1, 'a');
   370    370     INSERT INTO a4 VALUES(2, 'a');
   371    371     INSERT INTO a4 VALUES(3, 'a');
   372    372   } {}
   373    373   foreach {tn sql error ac data } {
   374         -  1.1  "INSERT INTO a4 VALUES(2,'b')"  {column c is not unique}  1 {1 a 2 a 3 a}
          374  +  1.1  "INSERT INTO a4 VALUES(2,'b')"  {UNIQUE constraint failed: a4.c}  1 {1 a 2 a 3 a}
   375    375     1.2  "INSERT OR REPLACE INTO a4 VALUES(2, 'b')"            {}  1 {1 a 3 a 2 b}
   376    376     1.3  "INSERT OR IGNORE INTO a4 VALUES(3, 'c')"             {}  1 {1 a 3 a 2 b}
   377    377     1.4  "BEGIN" {} 0 {1 a 3 a 2 b}
   378         -  1.5  "INSERT INTO a4 VALUES(1, 'd')" {column c is not unique}  0 {1 a 3 a 2 b}
          378  +  1.5  "INSERT INTO a4 VALUES(1, 'd')" {UNIQUE constraint failed: a4.c}  0 {1 a 3 a 2 b}
   379    379     1.6  "INSERT OR ABORT INTO a4 VALUES(1, 'd')" 
   380         -        {column c is not unique}  0 {1 a 3 a 2 b}
          380  +        {UNIQUE constraint failed: a4.c}  0 {1 a 3 a 2 b}
   381    381     1.7  "INSERT OR ROLLBACK INTO a4 VALUES(1, 'd')" 
   382         -        {column c is not unique}  1 {1 a 3 a 2 b}
          382  +        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b}
   383    383     1.8  "INSERT INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
   384         -        {column c is not unique}  1 {1 a 3 a 2 b}
          384  +        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b}
   385    385     1.9  "INSERT OR FAIL INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
   386         -        {column c is not unique}  1 {1 a 3 a 2 b 4 e}
          386  +        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b 4 e}
   387    387   
   388    388     2.1  "INSERT INTO a4 VALUES(2,'f')"  
   389         -        {column c is not unique}  1 {1 a 3 a 2 b 4 e}
          389  +        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b 4 e}
   390    390     2.2  "REPLACE INTO a4 VALUES(2, 'f')" {}  1 {1 a 3 a 4 e 2 f}
   391    391   } {
   392    392     do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=""}] $error]
   393    393     do_execsql_test  e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data]
   394    394     do_test          e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac
   395    395   }
   396    396   

Changes to test/e_update.test.

   274    274     INSERT INTO t3 VALUES(1, 'one');
   275    275     INSERT INTO t3 VALUES(2, 'two');
   276    276     INSERT INTO t3 VALUES(3, 'three');
   277    277     INSERT INTO t3 VALUES(4, 'four');
   278    278   } {}
   279    279   foreach {tn sql error ac data } {
   280    280     1  "UPDATE t3 SET b='one' WHERE a=3" 
   281         -     {column b is not unique} 1 {1 one 2 two 3 three 4 four}
          281  +     {UNIQUE constraint failed: t3.b} 1 {1 one 2 two 3 three 4 four}
   282    282   
   283    283     2  "UPDATE OR REPLACE t3 SET b='one' WHERE a=3" 
   284    284        {} 1 {2 two 3 one 4 four}
   285    285   
   286    286     3  "UPDATE OR FAIL t3 SET b='three'"
   287         -     {column b is not unique} 1 {2 three 3 one 4 four}
          287  +     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}
   288    288   
   289    289     4  "UPDATE OR IGNORE t3 SET b='three' WHERE a=3" 
   290    290        {} 1 {2 three 3 one 4 four}
   291    291   
   292    292     5  "UPDATE OR ABORT t3 SET b='three' WHERE a=3" 
   293         -     {column b is not unique} 1 {2 three 3 one 4 four}
          293  +     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}
   294    294   
   295    295     6  "BEGIN" {} 0 {2 three 3 one 4 four}
   296    296   
   297    297     7  "UPDATE t3 SET b='three' WHERE a=3" 
   298         -     {column b is not unique} 0 {2 three 3 one 4 four}
          298  +     {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}
   299    299   
   300    300     8  "UPDATE OR ABORT t3 SET b='three' WHERE a=3" 
   301         -     {column b is not unique} 0 {2 three 3 one 4 four}
          301  +     {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}
   302    302   
   303    303     9  "UPDATE OR FAIL t3 SET b='two'"
   304         -     {column b is not unique} 0 {2 two 3 one 4 four}
          304  +     {UNIQUE constraint failed: t3.b} 0 {2 two 3 one 4 four}
   305    305   
   306    306     10 "UPDATE OR IGNORE t3 SET b='four' WHERE a=3"
   307    307        {} 0 {2 two 3 one 4 four}
   308    308   
   309    309     11 "UPDATE OR REPLACE t3 SET b='four' WHERE a=3"
   310    310        {} 0 {2 two 3 four}
   311    311   
   312    312     12 "UPDATE OR ROLLBACK t3 SET b='four'"
   313         -     {column b is not unique} 1 {2 three 3 one 4 four}
          313  +     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}
   314    314   } {
   315    315     do_catchsql_test e_update-1.8.$tn.1 $sql [list [expr {$error!=""}] $error]
   316    316     do_execsql_test  e_update-1.8.$tn.2 {SELECT * FROM t3} [list {*}$data]
   317    317     do_test          e_update-1.8.$tn.3 {sqlite3_get_autocommit db} $ac
   318    318   }
   319    319   
   320    320   

Changes to test/errmsg.test.

    74     74     CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
    75     75     INSERT INTO t1 VALUES('abc', 'def');
    76     76   }
    77     77   do_test 2.2 {
    78     78     error_messages "INSERT INTO t1 VALUES('ghi', 'def')"
    79     79   } [list {*}{
    80     80       SQLITE_ERROR      {SQL logic error or missing database} 
    81         -    SQLITE_CONSTRAINT {column b is not unique}
           81  +    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
    82     82   }]
    83     83   verify_ex_errcode 2.2b SQLITE_CONSTRAINT_UNIQUE
    84     84   do_test 2.3 {
    85     85     error_messages_v2 "INSERT INTO t1 VALUES('ghi', 'def')"
    86     86   } [list {*}{
    87         -    SQLITE_CONSTRAINT {column b is not unique}
    88         -    SQLITE_CONSTRAINT {column b is not unique}
           87  +    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
           88  +    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
    89     89   }]
    90     90   verify_ex_errcode 2.3b SQLITE_CONSTRAINT_UNIQUE
    91     91   
    92     92   #-------------------------------------------------------------------------
    93     93   # Test SQLITE_SCHEMA errors. And, for _v2(), test that if the schema
    94     94   # change invalidates the SQL statement itself the error message is returned
    95     95   # correctly.

Changes to test/fkey2.test.

   100    100   
   101    101     CREATE TABLE t9(a REFERENCES nosuchtable, b);
   102    102     CREATE TABLE t10(a REFERENCES t9(c) /D/, b);
   103    103   }
   104    104   
   105    105   
   106    106   set FkeySimpleTests {
   107         -  1.1  "INSERT INTO t2 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          107  +  1.1  "INSERT INTO t2 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   108    108     1.2  "INSERT INTO t1 VALUES(1, 2)"      {0 {}}
   109    109     1.3  "INSERT INTO t2 VALUES(1, 3)"      {0 {}}
   110         -  1.4  "INSERT INTO t2 VALUES(2, 4)"      {1 {foreign key constraint failed}}
          110  +  1.4  "INSERT INTO t2 VALUES(2, 4)"      {1 {FOREIGN KEY constraint failed}}
   111    111     1.5  "INSERT INTO t2 VALUES(NULL, 4)"   {0 {}}
   112         -  1.6  "UPDATE t2 SET c=2 WHERE d=4"      {1 {foreign key constraint failed}}
          112  +  1.6  "UPDATE t2 SET c=2 WHERE d=4"      {1 {FOREIGN KEY constraint failed}}
   113    113     1.7  "UPDATE t2 SET c=1 WHERE d=4"      {0 {}}
   114    114     1.9  "UPDATE t2 SET c=1 WHERE d=4"      {0 {}}
   115    115     1.10 "UPDATE t2 SET c=NULL WHERE d=4"   {0 {}}
   116         -  1.11 "DELETE FROM t1 WHERE a=1"         {1 {foreign key constraint failed}}
   117         -  1.12 "UPDATE t1 SET a = 2"              {1 {foreign key constraint failed}}
          116  +  1.11 "DELETE FROM t1 WHERE a=1"         {1 {FOREIGN KEY constraint failed}}
          117  +  1.12 "UPDATE t1 SET a = 2"              {1 {FOREIGN KEY constraint failed}}
   118    118     1.13 "UPDATE t1 SET a = 1"              {0 {}}
   119    119   
   120         -  2.1  "INSERT INTO t4 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          120  +  2.1  "INSERT INTO t4 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   121    121     2.2  "INSERT INTO t3 VALUES(1, 2)"      {0 {}}
   122    122     2.3  "INSERT INTO t4 VALUES(1, 3)"      {0 {}}
   123    123   
   124         -  4.1  "INSERT INTO t8 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          124  +  4.1  "INSERT INTO t8 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   125    125     4.2  "INSERT INTO t7 VALUES(2, 1)"      {0 {}}
   126    126     4.3  "INSERT INTO t8 VALUES(1, 3)"      {0 {}}
   127         -  4.4  "INSERT INTO t8 VALUES(2, 4)"      {1 {foreign key constraint failed}}
          127  +  4.4  "INSERT INTO t8 VALUES(2, 4)"      {1 {FOREIGN KEY constraint failed}}
   128    128     4.5  "INSERT INTO t8 VALUES(NULL, 4)"   {0 {}}
   129         -  4.6  "UPDATE t8 SET c=2 WHERE d=4"      {1 {foreign key constraint failed}}
          129  +  4.6  "UPDATE t8 SET c=2 WHERE d=4"      {1 {FOREIGN KEY constraint failed}}
   130    130     4.7  "UPDATE t8 SET c=1 WHERE d=4"      {0 {}}
   131    131     4.9  "UPDATE t8 SET c=1 WHERE d=4"      {0 {}}
   132    132     4.10 "UPDATE t8 SET c=NULL WHERE d=4"   {0 {}}
   133         -  4.11 "DELETE FROM t7 WHERE b=1"         {1 {foreign key constraint failed}}
   134         -  4.12 "UPDATE t7 SET b = 2"              {1 {foreign key constraint failed}}
          133  +  4.11 "DELETE FROM t7 WHERE b=1"         {1 {FOREIGN KEY constraint failed}}
          134  +  4.12 "UPDATE t7 SET b = 2"              {1 {FOREIGN KEY constraint failed}}
   135    135     4.13 "UPDATE t7 SET b = 1"              {0 {}}
   136         -  4.14 "INSERT INTO t8 VALUES('a', 'b')"  {1 {foreign key constraint failed}}
   137         -  4.15 "UPDATE t7 SET b = 5"              {1 {foreign key constraint failed}}
   138         -  4.16 "UPDATE t7 SET rowid = 5"          {1 {foreign key constraint failed}}
          136  +  4.14 "INSERT INTO t8 VALUES('a', 'b')"  {1 {FOREIGN KEY constraint failed}}
          137  +  4.15 "UPDATE t7 SET b = 5"              {1 {FOREIGN KEY constraint failed}}
          138  +  4.16 "UPDATE t7 SET rowid = 5"          {1 {FOREIGN KEY constraint failed}}
   139    139     4.17 "UPDATE t7 SET a = 10"             {0 {}}
   140    140   
   141    141     5.1  "INSERT INTO t9 VALUES(1, 3)"      {1 {no such table: main.nosuchtable}}
   142    142     5.2  "INSERT INTO t10 VALUES(1, 3)"  
   143    143                               {1 {foreign key mismatch - "t10" referencing "t9"}}
   144    144   }
   145    145   
................................................................................
   211    211       INSERT INTO i VALUES(35);
   212    212       INSERT INTO j VALUES('35.0');
   213    213       SELECT j, typeof(j) FROM j;
   214    214     }
   215    215   } {35.0 text}
   216    216   do_test fkey2-1.5.2 {
   217    217     catchsql { DELETE FROM i }
   218         -} {1 {foreign key constraint failed}}
          218  +} {1 {FOREIGN KEY constraint failed}}
   219    219   
   220    220   # Same test using a regular primary key with integer affinity.
   221    221   drop_all_tables
   222    222   do_test fkey2-1.6.1 {
   223    223     execsql {
   224    224       CREATE TABLE i(i INT UNIQUE);
   225    225       CREATE TABLE j(j REFERENCES i(i));
................................................................................
   227    227       INSERT INTO j VALUES('35.0');
   228    228       SELECT j, typeof(j) FROM j;
   229    229       SELECT i, typeof(i) FROM i;
   230    230     }
   231    231   } {35.0 text 35 integer}
   232    232   do_test fkey2-1.6.2 {
   233    233     catchsql { DELETE FROM i }
   234         -} {1 {foreign key constraint failed}}
          234  +} {1 {FOREIGN KEY constraint failed}}
   235    235   
   236    236   # Use a collation sequence on the parent key.
   237    237   drop_all_tables
   238    238   do_test fkey2-1.7.1 {
   239    239     execsql {
   240    240       CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY);
   241    241       CREATE TABLE j(j TEXT COLLATE binary REFERENCES i(i));
   242    242       INSERT INTO i VALUES('SQLite');
   243    243       INSERT INTO j VALUES('sqlite');
   244    244     }
   245    245     catchsql { DELETE FROM i }
   246         -} {1 {foreign key constraint failed}}
          246  +} {1 {FOREIGN KEY constraint failed}}
   247    247   
   248    248   # Use the parent key collation even if it is default and the child key
   249    249   # has an explicit value.
   250    250   drop_all_tables
   251    251   do_test fkey2-1.7.2 {
   252    252     execsql {
   253    253       CREATE TABLE i(i TEXT PRIMARY KEY);        -- Colseq is "BINARY"
   254    254       CREATE TABLE j(j TEXT COLLATE nocase REFERENCES i(i));
   255    255       INSERT INTO i VALUES('SQLite');
   256    256     }
   257    257     catchsql { INSERT INTO j VALUES('sqlite') }
   258         -} {1 {foreign key constraint failed}}
          258  +} {1 {FOREIGN KEY constraint failed}}
   259    259   do_test fkey2-1.7.3 {
   260    260     execsql {
   261    261       INSERT INTO i VALUES('sqlite');
   262    262       INSERT INTO j VALUES('sqlite');
   263    263       DELETE FROM i WHERE i = 'SQLite';
   264    264     }
   265    265     catchsql { DELETE FROM i WHERE i = 'sqlite' }
   266         -} {1 {foreign key constraint failed}}
          266  +} {1 {FOREIGN KEY constraint failed}}
   267    267   
   268    268   #-------------------------------------------------------------------------
   269    269   # This section (test cases fkey2-2.*) contains tests to check that the
   270    270   # deferred foreign key constraint logic works.
   271    271   #
   272    272   proc fkey2-2-test {tn nocommit sql {res {}}} {
   273    273     if {$res eq "FKV"} {
   274         -    set expected {1 {foreign key constraint failed}}
          274  +    set expected {1 {FOREIGN KEY constraint failed}}
   275    275     } else {
   276    276       set expected [list 0 $res]
   277    277     }
   278    278     do_test fkey2-2.$tn [list catchsql $sql] $expected
   279    279     if {$nocommit} {
   280    280       do_test fkey2-2.${tn}c {
   281    281         catchsql COMMIT
   282         -    } {1 {foreign key constraint failed}}
          282  +    } {1 {FOREIGN KEY constraint failed}}
   283    283     }
   284    284   }
   285    285   
   286    286   fkey2-2-test 1 0 {
   287    287     CREATE TABLE node(
   288    288       nodeid PRIMARY KEY,
   289    289       parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
................................................................................
   371    371   fkey2-2-test 62 0   "DELETE FROM leaf"
   372    372   fkey2-2-test 63 0   "DELETE FROM node"
   373    373   fkey2-2-test 64 1   "INSERT INTO leaf VALUES('a', 1)"
   374    374   fkey2-2-test 65 1   "INSERT INTO leaf VALUES('b', 2)"
   375    375   fkey2-2-test 66 1   "INSERT INTO leaf VALUES('c', 1)"
   376    376   do_test fkey2-2-test-67 {
   377    377     catchsql          "INSERT INTO node SELECT parent, 3 FROM leaf"
   378         -} {1 {PRIMARY KEY must be unique}}
          378  +} {1 {UNIQUE constraint failed: node.nodeid}}
   379    379   fkey2-2-test 68 0 "COMMIT"           FKV
   380    380   fkey2-2-test 69 1   "INSERT INTO node VALUES(1, NULL)"
   381    381   fkey2-2-test 70 0   "INSERT INTO node VALUES(2, NULL)"
   382    382   fkey2-2-test 71 0 "COMMIT"
   383    383   
   384    384   fkey2-2-test 72 0 "BEGIN"
   385    385   fkey2-2-test 73 1   "DELETE FROM node"
................................................................................
   413    413       INSERT INTO ab VALUES(1, 'b');
   414    414       INSERT INTO cd VALUES(1, 'd');
   415    415       INSERT INTO ef VALUES(1, 'e');
   416    416     }
   417    417   } {}
   418    418   do_test fkey2-3.1.3 {
   419    419     catchsql { UPDATE ab SET a = 5 }
   420         -} {1 {constraint failed}}
          420  +} {1 {CHECK constraint failed: ef}}
   421    421   do_test fkey2-3.1.4 {
   422    422     execsql { SELECT * FROM ab }
   423    423   } {1 b}
   424    424   do_test fkey2-3.1.4 {
   425    425     execsql BEGIN;
   426    426     catchsql { UPDATE ab SET a = 5 }
   427         -} {1 {constraint failed}}
          427  +} {1 {CHECK constraint failed: ef}}
   428    428   do_test fkey2-3.1.5 {
   429    429     execsql COMMIT;
   430    430     execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
   431    431   } {1 b 1 d 1 e}
   432    432   
   433    433   do_test fkey2-3.2.1 {
   434    434     execsql BEGIN;
   435    435     catchsql { DELETE FROM ab }
   436         -} {1 {foreign key constraint failed}}
          436  +} {1 {FOREIGN KEY constraint failed}}
   437    437   do_test fkey2-3.2.2 {
   438    438     execsql COMMIT
   439    439     execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
   440    440   } {1 b 1 d 1 e}
   441    441   
   442    442   #-------------------------------------------------------------------------
   443    443   # Test cases fkey2-4.* test that recursive foreign key actions 
................................................................................
   551    551     execsql {
   552    552       CREATE TABLE t1(a PRIMARY KEY, b);
   553    553       CREATE TABLE t2(c INTEGER PRIMARY KEY REFERENCES t1, b);
   554    554     }
   555    555   } {}
   556    556   do_test fkey2-7.2 {
   557    557     catchsql { INSERT INTO t2 VALUES(1, 'A'); }
   558         -} {1 {foreign key constraint failed}}
          558  +} {1 {FOREIGN KEY constraint failed}}
   559    559   do_test fkey2-7.3 {
   560    560     execsql { 
   561    561       INSERT INTO t1 VALUES(1, 2);
   562    562       INSERT INTO t1 VALUES(2, 3);
   563    563       INSERT INTO t2 VALUES(1, 'A');
   564    564     }
   565    565   } {}
   566    566   do_test fkey2-7.4 {
   567    567     execsql { UPDATE t2 SET c = 2 }
   568    568   } {}
   569    569   do_test fkey2-7.5 {
   570    570     catchsql { UPDATE t2 SET c = 3 }
   571         -} {1 {foreign key constraint failed}}
          571  +} {1 {FOREIGN KEY constraint failed}}
   572    572   do_test fkey2-7.6 {
   573    573     catchsql { DELETE FROM t1 WHERE a = 2 }
   574         -} {1 {foreign key constraint failed}}
          574  +} {1 {FOREIGN KEY constraint failed}}
   575    575   do_test fkey2-7.7 {
   576    576     execsql { DELETE FROM t1 WHERE a = 1 }
   577    577   } {}
   578    578   do_test fkey2-7.8 {
   579    579     catchsql { UPDATE t1 SET a = 3 }
   580         -} {1 {foreign key constraint failed}}
          580  +} {1 {FOREIGN KEY constraint failed}}
   581    581   do_test fkey2-7.9 {
   582    582     catchsql { UPDATE t2 SET rowid = 3 }
   583         -} {1 {foreign key constraint failed}}
          583  +} {1 {FOREIGN KEY constraint failed}}
   584    584   
   585    585   #-------------------------------------------------------------------------
   586    586   # Test that it is not possible to enable/disable FK support while a
   587    587   # transaction is open.
   588    588   # 
   589    589   drop_all_tables
   590    590   proc fkey2-8-test {tn zSql value} {
................................................................................
   641    641     }
   642    642   } {1 2}
   643    643   do_test fkey2-9.1.4 {
   644    644     execsql { SELECT * FROM t1 }
   645    645   } {2 two}
   646    646   do_test fkey2-9.1.5 {
   647    647     catchsql { DELETE FROM t1 }
   648         -} {1 {foreign key constraint failed}}
          648  +} {1 {FOREIGN KEY constraint failed}}
   649    649   
   650    650   do_test fkey2-9.2.1 {
   651    651     execsql {
   652    652       CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c));
   653    653       CREATE TABLE cc(d DEFAULT 3, e DEFAULT 1, f DEFAULT 2,
   654    654           FOREIGN KEY(f, d) REFERENCES pp 
   655    655           ON UPDATE SET DEFAULT 
................................................................................
   776    776     execsql "INSERT INTO t2 VALUES('two')"
   777    777   } {}
   778    778   do_test fkey2-12.1.3 { 
   779    779     execsql "UPDATE t1 SET b = 'four' WHERE b = 'one'"
   780    780   } {}
   781    781   do_test fkey2-12.1.4 { 
   782    782     catchsql "UPDATE t1 SET b = 'five' WHERE b = 'two'"
   783         -} {1 {foreign key constraint failed}}
          783  +} {1 {FOREIGN KEY constraint failed}}
   784    784   do_test fkey2-12.1.5 { 
   785    785     execsql "DELETE FROM t1 WHERE b = 'two'"
   786    786   } {}
   787    787   do_test fkey2-12.1.6 { 
   788    788     catchsql "COMMIT"
   789         -} {1 {foreign key constraint failed}}
          789  +} {1 {FOREIGN KEY constraint failed}}
   790    790   do_test fkey2-12.1.7 { 
   791    791     execsql {
   792    792       INSERT INTO t1 VALUES(2, 'two');
   793    793       COMMIT;
   794    794     }
   795    795   } {}
   796    796   
................................................................................
   824    824     execsql {
   825    825       DROP TABLE t2;
   826    826       CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);
   827    827       INSERT INTO t2 VALUES('a');
   828    828       INSERT INTO t2 VALUES('b');
   829    829     }
   830    830     catchsql { DELETE FROM t1 }
   831         -} {1 {foreign key constraint failed}}
          831  +} {1 {FOREIGN KEY constraint failed}}
   832    832   do_test fkey2-12.2.4 {
   833    833     execsql {
   834    834       SELECT * FROM t1;
   835    835       SELECT * FROM t2;
   836    836     }
   837    837   } {A B a b}
   838    838   
................................................................................
   862    862       UPDATE up SET c34 = 'possibly';
   863    863       SELECT c38, c39 FROM down;
   864    864       DELETE FROM down;
   865    865     }
   866    866   } {no possibly}
   867    867   do_test fkey2-12.3.3 {
   868    868     catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }
   869         -} {1 {foreign key constraint failed}}
          869  +} {1 {FOREIGN KEY constraint failed}}
   870    870   do_test fkey2-12.3.4 {
   871    871     execsql { 
   872    872       INSERT INTO up(c34, c35) VALUES('yes', 'no');
   873    873       INSERT INTO down(c39, c38) VALUES('yes', 'no');
   874    874     }
   875    875     catchsql { DELETE FROM up WHERE c34 = 'yes' }
   876         -} {1 {foreign key constraint failed}}
          876  +} {1 {FOREIGN KEY constraint failed}}
   877    877   do_test fkey2-12.3.5 {
   878    878     execsql { 
   879    879       DELETE FROM up WHERE c34 = 'possibly';
   880    880       SELECT c34, c35 FROM up;
   881    881       SELECT c39, c38 FROM down;
   882    882     }
   883    883   } {yes no yes no}
................................................................................
   897    897   } {}
   898    898   foreach {tn stmt} {
   899    899     1   "REPLACE INTO pp VALUES(1, 4, 5)"
   900    900     2   "REPLACE INTO pp(rowid, a, b, c) VALUES(1, 2, 3, 4)"
   901    901   } {
   902    902     do_test fkey2-13.1.$tn.1 {
   903    903       catchsql $stmt
   904         -  } {1 {foreign key constraint failed}}
          904  +  } {1 {FOREIGN KEY constraint failed}}
   905    905     do_test fkey2-13.1.$tn.2 {
   906    906       execsql {
   907    907         SELECT * FROM pp;
   908    908         SELECT * FROM cc;
   909    909       }
   910    910     } {1 2 3 2 3 1}
   911    911     do_test fkey2-13.1.$tn.3 {
   912    912       execsql BEGIN;
   913    913       catchsql $stmt
   914         -  } {1 {foreign key constraint failed}}
          914  +  } {1 {FOREIGN KEY constraint failed}}
   915    915     do_test fkey2-13.1.$tn.4 {
   916    916       execsql {
   917    917         COMMIT;
   918    918         SELECT * FROM pp;
   919    919         SELECT * FROM cc;
   920    920       }
   921    921     } {1 2 3 2 3 1}
................................................................................
  1011   1011     } [list \
  1012   1012       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")}                    \
  1013   1013       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)}     \
  1014   1014       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1015   1015     ]
  1016   1016     do_test fkey2-14.2.2.3 {
  1017   1017       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
  1018         -  } {1 {foreign key constraint failed}}
         1018  +  } {1 {FOREIGN KEY constraint failed}}
  1019   1019     do_test fkey2-14.2.2.4 {
  1020   1020       execsql { INSERT INTO t4 VALUES(1, NULL) }
  1021   1021     } {}
  1022   1022     do_test fkey2-14.2.2.5 {
  1023   1023       catchsql { UPDATE t4 SET b = 5 }
  1024         -  } {1 {foreign key constraint failed}}
         1024  +  } {1 {FOREIGN KEY constraint failed}}
  1025   1025     do_test fkey2-14.2.2.6 {
  1026   1026       catchsql { UPDATE t4 SET b = 1 }
  1027   1027     } {0 {}}
  1028   1028     do_test fkey2-14.2.2.7 {
  1029   1029       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1030   1030     } {}
  1031   1031   
................................................................................
  1092   1092     } [list \
  1093   1093       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")}                    \
  1094   1094       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)}     \
  1095   1095       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1096   1096     ]
  1097   1097     do_test fkey2-14.2tmp.2.3 {
  1098   1098       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
  1099         -  } {1 {foreign key constraint failed}}
         1099  +  } {1 {FOREIGN KEY constraint failed}}
  1100   1100     do_test fkey2-14.2tmp.2.4 {
  1101   1101       execsql { INSERT INTO t4 VALUES(1, NULL) }
  1102   1102     } {}
  1103   1103     do_test fkey2-14.2tmp.2.5 {
  1104   1104       catchsql { UPDATE t4 SET b = 5 }
  1105         -  } {1 {foreign key constraint failed}}
         1105  +  } {1 {FOREIGN KEY constraint failed}}
  1106   1106     do_test fkey2-14.2tmp.2.6 {
  1107   1107       catchsql { UPDATE t4 SET b = 1 }
  1108   1108     } {0 {}}
  1109   1109     do_test fkey2-14.2tmp.2.7 {
  1110   1110       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1111   1111     } {}
  1112   1112   
................................................................................
  1174   1174     } [list \
  1175   1175       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")}                    \
  1176   1176       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)}     \
  1177   1177       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1178   1178     ]
  1179   1179     do_test fkey2-14.2aux.2.3 {
  1180   1180       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
  1181         -  } {1 {foreign key constraint failed}}
         1181  +  } {1 {FOREIGN KEY constraint failed}}
  1182   1182     do_test fkey2-14.2aux.2.4 {
  1183   1183       execsql { INSERT INTO t4 VALUES(1, NULL) }
  1184   1184     } {}
  1185   1185     do_test fkey2-14.2aux.2.5 {
  1186   1186       catchsql { UPDATE t4 SET b = 5 }
  1187         -  } {1 {foreign key constraint failed}}
         1187  +  } {1 {FOREIGN KEY constraint failed}}
  1188   1188     do_test fkey2-14.2aux.2.6 {
  1189   1189       catchsql { UPDATE t4 SET b = 1 }
  1190   1190     } {0 {}}
  1191   1191     do_test fkey2-14.2aux.2.7 {
  1192   1192       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1193   1193     } {}
  1194   1194   }
................................................................................
  1206   1206       INSERT INTO t1 VALUES('a', 1);
  1207   1207       CREATE TABLE t2(x REFERENCES t1);
  1208   1208       INSERT INTO t2 VALUES('a');
  1209   1209     }
  1210   1210   } {}
  1211   1211   do_test fkey-2.14.3.3 {
  1212   1212     catchsql { DROP TABLE t1 }
  1213         -} {1 {foreign key constraint failed}}
         1213  +} {1 {FOREIGN KEY constraint failed}}
  1214   1214   do_test fkey-2.14.3.4 {
  1215   1215     execsql {
  1216   1216       DELETE FROM t2;
  1217   1217       DROP TABLE t1;
  1218   1218     }
  1219   1219   } {}
  1220   1220   do_test fkey-2.14.3.4 {
................................................................................
  1225   1225       CREATE TABLE t1(x PRIMARY KEY);
  1226   1226       INSERT INTO t1 VALUES('x');
  1227   1227     }
  1228   1228     execsql { INSERT INTO t2 VALUES('x') }
  1229   1229   } {}
  1230   1230   do_test fkey-2.14.3.6 {
  1231   1231     catchsql { DROP TABLE t1 }
  1232         -} {1 {foreign key constraint failed}}
         1232  +} {1 {FOREIGN KEY constraint failed}}
  1233   1233   do_test fkey-2.14.3.7 {
  1234   1234     execsql {
  1235   1235       DROP TABLE t2;
  1236   1236       DROP TABLE t1;
  1237   1237     }
  1238   1238   } {}
  1239   1239   do_test fkey-2.14.3.8 {
................................................................................
  1383   1383     } {}
  1384   1384     do_test fkey2-16.1.$tn.2 {
  1385   1385       execsql { UPDATE self SET a = 14, b = 14 }
  1386   1386     } {}
  1387   1387   
  1388   1388     do_test fkey2-16.1.$tn.3 {
  1389   1389       catchsql { UPDATE self SET b = 15 }
  1390         -  } {1 {foreign key constraint failed}}
         1390  +  } {1 {FOREIGN KEY constraint failed}}
  1391   1391   
  1392   1392     do_test fkey2-16.1.$tn.4 {
  1393   1393       catchsql { UPDATE self SET a = 15 }
  1394         -  } {1 {foreign key constraint failed}}
         1394  +  } {1 {FOREIGN KEY constraint failed}}
  1395   1395   
  1396   1396     do_test fkey2-16.1.$tn.5 {
  1397   1397       catchsql { UPDATE self SET a = 15, b = 16 }
  1398         -  } {1 {foreign key constraint failed}}
         1398  +  } {1 {FOREIGN KEY constraint failed}}
  1399   1399   
  1400   1400     do_test fkey2-16.1.$tn.6 {
  1401   1401       catchsql { UPDATE self SET a = 17, b = 17 }
  1402   1402     } {0 {}}
  1403   1403   
  1404   1404     do_test fkey2-16.1.$tn.7 {
  1405   1405       execsql { DELETE FROM self }
  1406   1406     } {}
  1407   1407     do_test fkey2-16.1.$tn.8 {
  1408   1408       catchsql { INSERT INTO self VALUES(20, 21) }
  1409         -  } {1 {foreign key constraint failed}}
         1409  +  } {1 {FOREIGN KEY constraint failed}}
  1410   1410   }
  1411   1411   
  1412   1412   #-------------------------------------------------------------------------
  1413   1413   # This next block of tests, fkey2-17.*, tests that if "PRAGMA count_changes"
  1414   1414   # is turned on statements that violate immediate FK constraints return
  1415   1415   # SQLITE_CONSTRAINT immediately, not after returning a number of rows.
  1416   1416   # Whereas statements that violate deferred FK constraints return the number
................................................................................
  1459   1459   } {1 1 1 1 1}
  1460   1460   do_test fkey2-17.1.6 {
  1461   1461     catchsql {
  1462   1462       BEGIN;
  1463   1463         INSERT INTO one VALUES(0, 0, 0);
  1464   1464         UPDATE two SET e=e+1, f=f+1;
  1465   1465     }
  1466         -} {1 {foreign key constraint failed}}
         1466  +} {1 {FOREIGN KEY constraint failed}}
  1467   1467   do_test fkey2-17.1.7 {
  1468   1468     execsql { SELECT * FROM one }
  1469   1469   } {1 2 3 2 3 4 3 4 5 0 0 0}
  1470   1470   do_test fkey2-17.1.8 {
  1471   1471     execsql { SELECT * FROM two }
  1472   1472   } {1 2 3 2 3 4 3 4 5}
  1473   1473   do_test fkey2-17.1.9 {
................................................................................
  1615   1615     rename auth {}
  1616   1616     proc auth {args} {
  1617   1617       if {[lindex $args 1] == "long"} {return SQLITE_IGNORE}
  1618   1618       return SQLITE_OK
  1619   1619     }
  1620   1620     do_test fkey2-18.8 {
  1621   1621       catchsql { INSERT INTO short VALUES(1, 3, 2) }
  1622         -  } {1 {foreign key constraint failed}}
         1622  +  } {1 {FOREIGN KEY constraint failed}}
  1623   1623     do_test fkey2-18.9 {
  1624   1624       execsql { INSERT INTO short VALUES(1, 3, NULL) }
  1625   1625     } {}
  1626   1626     do_test fkey2-18.10 {
  1627   1627       execsql { SELECT * FROM short }
  1628   1628     } {1 3 2 1 3 {}}
  1629   1629     do_test fkey2-18.11 {
  1630   1630       catchsql { UPDATE short SET f = 2 WHERE f IS NULL }
  1631         -  } {1 {foreign key constraint failed}}
         1631  +  } {1 {FOREIGN KEY constraint failed}}
  1632   1632   
  1633   1633     db auth {}
  1634   1634     unset authargs
  1635   1635   }
  1636   1636   
  1637   1637   
  1638   1638   do_test fkey2-19.1 {
................................................................................
  1676   1676     3 "INSERT OR ABORT"
  1677   1677     4 "INSERT OR ROLLBACK"
  1678   1678     5 "INSERT OR REPLACE"
  1679   1679     6 "INSERT OR FAIL"
  1680   1680   } {
  1681   1681     do_test fkey2-20.2.$tn.1 {
  1682   1682       catchsql "$insert INTO cc VALUES(1, 2)"
  1683         -  } {1 {foreign key constraint failed}}
         1683  +  } {1 {FOREIGN KEY constraint failed}}
  1684   1684     do_test fkey2-20.2.$tn.2 {
  1685   1685       execsql { SELECT * FROM cc }
  1686   1686     } {}
  1687   1687     do_test fkey2-20.2.$tn.3 {
  1688   1688       execsql {
  1689   1689         BEGIN;
  1690   1690           INSERT INTO pp VALUES(2, 'two');
  1691   1691           INSERT INTO cc VALUES(1, 2);
  1692   1692       }
  1693   1693       catchsql "$insert INTO cc VALUES(3, 4)"
  1694         -  } {1 {foreign key constraint failed}}
         1694  +  } {1 {FOREIGN KEY constraint failed}}
  1695   1695     do_test fkey2-20.2.$tn.4 {
  1696   1696       execsql { COMMIT ; SELECT * FROM cc }
  1697   1697     } {1 2}
  1698   1698     do_test fkey2-20.2.$tn.5 {
  1699   1699       execsql { DELETE FROM cc ; DELETE FROM pp }
  1700   1700     } {}
  1701   1701   }
................................................................................
  1712   1712       execsql {
  1713   1713         INSERT INTO pp VALUES(2, 'two');
  1714   1714         INSERT INTO cc VALUES(1, 2);
  1715   1715       }
  1716   1716     } {}
  1717   1717     do_test fkey2-20.3.$tn.2 {
  1718   1718       catchsql "$update pp SET a = 1"
  1719         -  } {1 {foreign key constraint failed}}
         1719  +  } {1 {FOREIGN KEY constraint failed}}
  1720   1720     do_test fkey2-20.3.$tn.3 {
  1721   1721       execsql { SELECT * FROM pp }
  1722   1722     } {2 two}
  1723   1723     do_test fkey2-20.3.$tn.4 {
  1724   1724       catchsql "$update cc SET d = 1"
  1725         -  } {1 {foreign key constraint failed}}
         1725  +  } {1 {FOREIGN KEY constraint failed}}
  1726   1726     do_test fkey2-20.3.$tn.5 {
  1727   1727       execsql { SELECT * FROM cc }
  1728   1728     } {1 2}
  1729   1729     do_test fkey2-20.3.$tn.6 {
  1730   1730       execsql {
  1731   1731         BEGIN;
  1732   1732           INSERT INTO pp VALUES(3, 'three');
  1733   1733       }
  1734   1734       catchsql "$update pp SET a = 1 WHERE a = 2"
  1735         -  } {1 {foreign key constraint failed}}
         1735  +  } {1 {FOREIGN KEY constraint failed}}
  1736   1736     do_test fkey2-20.3.$tn.7 {
  1737   1737       execsql { COMMIT ; SELECT * FROM pp }
  1738   1738     } {2 two 3 three}
  1739   1739     do_test fkey2-20.3.$tn.8 {
  1740   1740       execsql {
  1741   1741         BEGIN;
  1742   1742           INSERT INTO cc VALUES(2, 2);
  1743   1743       }
  1744   1744       catchsql "$update cc SET d = 1 WHERE c = 1"
  1745         -  } {1 {foreign key constraint failed}}
         1745  +  } {1 {FOREIGN KEY constraint failed}}
  1746   1746     do_test fkey2-20.3.$tn.9 {
  1747   1747       execsql { COMMIT ; SELECT * FROM cc }
  1748   1748     } {1 2 2 2}
  1749   1749     do_test fkey2-20.3.$tn.10 {
  1750   1750       execsql { DELETE FROM cc ; DELETE FROM pp }
  1751   1751     } {}
  1752   1752   }
................................................................................
  1764   1764       CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
  1765   1765       CREATE TABLE t2(e REFERENCES t1, f);
  1766   1766       CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));
  1767   1767     }
  1768   1768   } {}
  1769   1769   do_test fkey2-genfkey.1.2 {
  1770   1770     catchsql { INSERT INTO t2 VALUES(1, 2) }
  1771         -} {1 {foreign key constraint failed}}
         1771  +} {1 {FOREIGN KEY constraint failed}}
  1772   1772   do_test fkey2-genfkey.1.3 {
  1773   1773     execsql {
  1774   1774       INSERT INTO t1 VALUES(1, 2, 3);
  1775   1775       INSERT INTO t2 VALUES(1, 2);
  1776   1776     }
  1777   1777   } {}
  1778   1778   do_test fkey2-genfkey.1.4 {
  1779   1779     execsql { INSERT INTO t2 VALUES(NULL, 3) }
  1780   1780   } {}
  1781   1781   do_test fkey2-genfkey.1.5 {
  1782   1782     catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }
  1783         -} {1 {foreign key constraint failed}}
         1783  +} {1 {FOREIGN KEY constraint failed}}
  1784   1784   do_test fkey2-genfkey.1.6 {
  1785   1785     execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }
  1786   1786   } {}
  1787   1787   do_test fkey2-genfkey.1.7 {
  1788   1788     execsql { UPDATE t2 SET e = NULL WHERE f = 3 }
  1789   1789   } {}
  1790   1790   do_test fkey2-genfkey.1.8 {
  1791   1791     catchsql { UPDATE t1 SET a = 10 }
  1792         -} {1 {foreign key constraint failed}}
         1792  +} {1 {FOREIGN KEY constraint failed}}
  1793   1793   do_test fkey2-genfkey.1.9 {
  1794   1794     catchsql { UPDATE t1 SET a = NULL }
  1795   1795   } {1 {datatype mismatch}}
  1796   1796   do_test fkey2-genfkey.1.10 {
  1797   1797     catchsql { DELETE FROM t1 }
  1798         -} {1 {foreign key constraint failed}}
         1798  +} {1 {FOREIGN KEY constraint failed}}
  1799   1799   do_test fkey2-genfkey.1.11 {
  1800   1800     execsql { UPDATE t2 SET e = NULL }
  1801   1801   } {}
  1802   1802   do_test fkey2-genfkey.1.12 {
  1803   1803     execsql { 
  1804   1804       UPDATE t1 SET a = 10;
  1805   1805       DELETE FROM t1;
................................................................................
  1811   1811       INSERT INTO t3 VALUES(1, NULL, NULL);
  1812   1812       INSERT INTO t3 VALUES(1, 2, NULL);
  1813   1813       INSERT INTO t3 VALUES(1, NULL, 3);
  1814   1814     }
  1815   1815   } {}
  1816   1816   do_test fkey2-genfkey.1.14 {
  1817   1817     catchsql { INSERT INTO t3 VALUES(3, 1, 4) }
  1818         -} {1 {foreign key constraint failed}}
         1818  +} {1 {FOREIGN KEY constraint failed}}
  1819   1819   do_test fkey2-genfkey.1.15 {
  1820   1820     execsql { 
  1821   1821       INSERT INTO t1 VALUES(1, 1, 4);
  1822   1822       INSERT INTO t3 VALUES(3, 1, 4);
  1823   1823     }
  1824   1824   } {}
  1825   1825   do_test fkey2-genfkey.1.16 {
  1826   1826     catchsql { DELETE FROM t1 }
  1827         -} {1 {foreign key constraint failed}}
         1827  +} {1 {FOREIGN KEY constraint failed}}
  1828   1828   do_test fkey2-genfkey.1.17 {
  1829   1829     catchsql { UPDATE t1 SET b = 10}
  1830         -} {1 {foreign key constraint failed}}
         1830  +} {1 {FOREIGN KEY constraint failed}}
  1831   1831   do_test fkey2-genfkey.1.18 {
  1832   1832     execsql { UPDATE t1 SET a = 10}
  1833   1833   } {}
  1834   1834   do_test fkey2-genfkey.1.19 {
  1835   1835     catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}
  1836         -} {1 {foreign key constraint failed}}
         1836  +} {1 {FOREIGN KEY constraint failed}}
  1837   1837   
  1838   1838   drop_all_tables
  1839   1839   do_test fkey2-genfkey.2.1 {
  1840   1840     execsql {
  1841   1841       CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
  1842   1842       CREATE TABLE t2(e REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE, f);
  1843   1843       CREATE TABLE t3(g, h, i, 
................................................................................
  1942   1942       INSERT INTO tdd08_b VALUES(100,200,300);
  1943   1943     }
  1944   1944   } {}
  1945   1945   do_test fkey2-dd08e5.1.2 {
  1946   1946     catchsql {
  1947   1947       DELETE FROM tdd08;
  1948   1948     }
  1949         -} {1 {foreign key constraint failed}}
         1949  +} {1 {FOREIGN KEY constraint failed}}
  1950   1950   do_test fkey2-dd08e5.1.3 {
  1951   1951     execsql {
  1952   1952       SELECT * FROM tdd08;
  1953   1953     }
  1954   1954   } {200 300}
  1955   1955   do_test fkey2-dd08e5.1.4 {
  1956   1956     catchsql {
  1957   1957       INSERT INTO tdd08_b VALUES(400,500,300);
  1958   1958     }
  1959         -} {1 {foreign key constraint failed}}
         1959  +} {1 {FOREIGN KEY constraint failed}}
  1960   1960   do_test fkey2-dd08e5.1.5 {
  1961   1961     catchsql {
  1962   1962       UPDATE tdd08_b SET x=x+1;
  1963   1963     }
  1964         -} {1 {foreign key constraint failed}}
         1964  +} {1 {FOREIGN KEY constraint failed}}
  1965   1965   do_test fkey2-dd08e5.1.6 {
  1966   1966     catchsql {
  1967   1967       UPDATE tdd08 SET a=a+1;
  1968   1968     }
  1969         -} {1 {foreign key constraint failed}}
         1969  +} {1 {FOREIGN KEY constraint failed}}
  1970   1970   
  1971   1971   #-------------------------------------------------------------------------
  1972   1972   # Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba
  1973   1973   # fixed.
  1974   1974   #
  1975   1975   do_test fkey2-ce7c13.1.1 {
  1976   1976     execsql {
................................................................................
  1983   1983       SELECT * FROM tce71, tce72;
  1984   1984     }
  1985   1985   } {100 200 300 100 200}
  1986   1986   do_test fkey2-ce7c13.1.2 {
  1987   1987     catchsql {
  1988   1988       UPDATE tce71 set b = 201 where a = 100;
  1989   1989     }
  1990         -} {1 {foreign key constraint failed}}
         1990  +} {1 {FOREIGN KEY constraint failed}}
  1991   1991   do_test fkey2-ce7c13.1.3 {
  1992   1992     catchsql {
  1993   1993       UPDATE tce71 set a = 101 where a = 100;
  1994   1994     }
  1995         -} {1 {foreign key constraint failed}}
         1995  +} {1 {FOREIGN KEY constraint failed}}
  1996   1996   do_test fkey2-ce7c13.1.4 {
  1997   1997     execsql {
  1998   1998       CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b));
  1999   1999       INSERT INTO tce73 VALUES(100,200);
  2000   2000       CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));
  2001   2001       INSERT INTO tce74 VALUES(300,100,200);
  2002   2002       UPDATE tce73 set b = 200 where a = 100;
................................................................................
  2003   2003       SELECT * FROM tce73, tce74;
  2004   2004     }
  2005   2005   } {100 200 300 100 200}
  2006   2006   do_test fkey2-ce7c13.1.5 {
  2007   2007     catchsql {
  2008   2008       UPDATE tce73 set b = 201 where a = 100;
  2009   2009     }
  2010         -} {1 {foreign key constraint failed}}
         2010  +} {1 {FOREIGN KEY constraint failed}}
  2011   2011   do_test fkey2-ce7c13.1.6 {
  2012   2012     catchsql {
  2013   2013       UPDATE tce73 set a = 101 where a = 100;
  2014   2014     }
  2015         -} {1 {foreign key constraint failed}}
         2015  +} {1 {FOREIGN KEY constraint failed}}
  2016   2016   
  2017   2017   finish_test

Changes to test/fkey3.test.

    39     39     }
    40     40   } {1 100 1 101 2 100 2 101}
    41     41   
    42     42   do_test fkey3-1.2 {
    43     43     catchsql {
    44     44       DELETE FROM t1 WHERE x=100;
    45     45     }
    46         -} {1 {foreign key constraint failed}}
           46  +} {1 {FOREIGN KEY constraint failed}}
    47     47   
    48     48   do_test fkey3-1.3 {
    49     49     catchsql {
    50     50       DROP TABLE t1;
    51     51     }
    52         -} {1 {foreign key constraint failed}}
           52  +} {1 {FOREIGN KEY constraint failed}}
    53     53   
    54     54   do_test fkey3-1.4 {
    55     55     execsql {
    56     56       DROP TABLE t2;
    57     57     }
    58     58   } {}
    59     59   
................................................................................
    91     91       UNIQUE(a, b),
    92     92       FOREIGN KEY(c, d) REFERENCES t3(a, b)
    93     93     );
    94     94     INSERT INTO t3 VALUES(1, 2, 1, 2);
    95     95   } {}
    96     96   do_catchsql_test 3.1.2 {
    97     97     INSERT INTO t3 VALUES(NULL, 2, 5, 2);
    98         -} {1 {foreign key constraint failed}}
           98  +} {1 {FOREIGN KEY constraint failed}}
    99     99   do_catchsql_test 3.1.3 {
   100    100     INSERT INTO t3 VALUES(NULL, 3, 5, 2);
   101         -} {1 {foreign key constraint failed}}
          101  +} {1 {FOREIGN KEY constraint failed}}
   102    102   
   103    103   do_execsql_test 3.2.1 {
   104    104     CREATE TABLE t4(a UNIQUE, b REFERENCES t4(a));
   105    105   }
   106    106   do_catchsql_test 3.2.2 {
   107    107     INSERT INTO t4 VALUES(NULL, 1);
   108         -} {1 {foreign key constraint failed}}
          108  +} {1 {FOREIGN KEY constraint failed}}
   109    109   
   110    110   do_execsql_test 3.3.1 {
   111    111     CREATE TABLE t5(a INTEGER PRIMARY KEY, b REFERENCES t5(a));
   112    112     INSERT INTO t5 VALUES(NULL, 1);
   113    113   } {}
   114    114   do_catchsql_test 3.3.2 {
   115    115     INSERT INTO t5 VALUES(NULL, 3);
   116         -} {1 {foreign key constraint failed}}
          116  +} {1 {FOREIGN KEY constraint failed}}
   117    117   
   118    118   do_execsql_test 3.4.1 {
   119    119     CREATE TABLE t6(a INTEGER PRIMARY KEY, b, c, d,
   120    120       FOREIGN KEY(c, d) REFERENCES t6(a, b)
   121    121     );
   122    122     CREATE UNIQUE INDEX t6i ON t6(b, a);
   123    123   }
   124    124   do_execsql_test 3.4.2  { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}
   125    125   do_execsql_test 3.4.3  { INSERT INTO t6 VALUES(2, 'a', 2, 'a');    } {}
   126    126   do_execsql_test 3.4.4  { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}
   127    127   do_execsql_test 3.4.5  { INSERT INTO t6 VALUES(5, 'a', 2, 'a'); } {}
   128    128   do_catchsql_test 3.4.6 { 
   129    129     INSERT INTO t6 VALUES(NULL, 'a', 65, 'a');    
   130         -} {1 {foreign key constraint failed}}
          130  +} {1 {FOREIGN KEY constraint failed}}
   131    131   
   132    132   do_execsql_test 3.4.7 {
   133    133     INSERT INTO t6 VALUES(100, 'one', 100, 'one');
   134    134     DELETE FROM t6 WHERE a = 100;
   135    135   }
   136    136   do_execsql_test 3.4.8 {
   137    137     INSERT INTO t6 VALUES(100, 'one', 100, 'one');
................................................................................
   145    145     );
   146    146     CREATE UNIQUE INDEX t7i ON t7(a, b);
   147    147   }
   148    148   do_execsql_test 3.5.2  { INSERT INTO t7 VALUES('x', 1, 'x', NULL) } {}
   149    149   do_execsql_test 3.5.3  { INSERT INTO t7 VALUES('x', 2, 'x', 2) } {}
   150    150   do_catchsql_test 3.5.4  { 
   151    151     INSERT INTO t7 VALUES('x', 450, 'x', NULL);
   152         -} {1 {foreign key constraint failed}}
          152  +} {1 {FOREIGN KEY constraint failed}}
   153    153   do_catchsql_test 3.5.5  { 
   154    154     INSERT INTO t7 VALUES('x', 450, 'x', 451);
   155         -} {1 {foreign key constraint failed}}
          155  +} {1 {FOREIGN KEY constraint failed}}
   156    156   
   157    157   
   158    158   do_execsql_test 3.6.1 {
   159    159     CREATE TABLE t8(a, b, c, d, e, FOREIGN KEY(c, d) REFERENCES t8(a, b));
   160    160     CREATE UNIQUE INDEX t8i1 ON t8(a, b);
   161    161     CREATE UNIQUE INDEX t8i2 ON t8(c);
   162    162     INSERT INTO t8 VALUES(1, 1, 1, 1, 1);
   163    163   }
   164    164   do_catchsql_test 3.6.2 { 
   165    165     UPDATE t8 SET d = 2; 
   166         -} {1 {foreign key constraint failed}}
          166  +} {1 {FOREIGN KEY constraint failed}}
   167    167   do_execsql_test 3.6.3 { UPDATE t8 SET d = 1; }
   168    168   do_execsql_test 3.6.4 { UPDATE t8 SET e = 2; }
   169    169   
   170    170   do_catchsql_test 3.6.5 {
   171    171     CREATE TABLE TestTable (
   172    172       id INTEGER PRIMARY KEY,
   173    173       name text,
................................................................................
   177    177       foreign key(source_id, parent_id) references TestTable(source_id, id)
   178    178     );
   179    179     CREATE UNIQUE INDEX testindex on TestTable(source_id, id);
   180    180     PRAGMA foreign_keys=1;
   181    181     INSERT INTO TestTable VALUES (1, 'parent', 1, null);
   182    182     INSERT INTO TestTable VALUES (2, 'child', 1, 1);
   183    183     UPDATE TestTable SET parent_id=1000 where id=2;
   184         -} {1 {foreign key constraint failed}}
          184  +} {1 {FOREIGN KEY constraint failed}}
   185    185   
   186    186   finish_test

Changes to test/fkey6.test.

    43     43     CREATE INDEX t3v ON t3(v);
    44     44     INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
    45     45     INSERT INTO t2 VALUES(1,1),(2,2);
    46     46     INSERT INTO t3 VALUES(3,3),(4,4);
    47     47   } {}
    48     48   do_test fkey6-1.2 {
    49     49     catchsql {DELETE FROM t1 WHERE x=2;}
    50         -} {1 {foreign key constraint failed}}
           50  +} {1 {FOREIGN KEY constraint failed}}
    51     51   do_test fkey6-1.3 {
    52     52     sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
    53     53   } {0 0 0}
    54     54   do_test fkey6-1.4 {
    55     55     execsql {
    56     56       BEGIN;
    57     57       DELETE FROM t1 WHERE x=1;
................................................................................
    95     95     PRAGMA defer_foreign_keys;
    96     96     COMMIT;
    97     97     PRAGMA defer_foreign_keys;
    98     98     BEGIN;
    99     99   } {1 0 1 0}
   100    100   do_test fkey6-1.10.2 {
   101    101     catchsql {DELETE FROM t1 WHERE x=3}
   102         -} {1 {foreign key constraint failed}}
          102  +} {1 {FOREIGN KEY constraint failed}}
   103    103   db eval {ROLLBACK}
   104    104   
   105    105   do_test fkey6-1.20 {
   106    106     execsql {
   107    107       BEGIN;
   108    108       DELETE FROM t1 WHERE x=1;
   109    109     }
................................................................................
   169    169       DROP TABLE c1;
   170    170     COMMIT;
   171    171     PRAGMA defer_foreign_keys;
   172    172   } {0}
   173    173   
   174    174   
   175    175   finish_test
   176         -

Changes to test/func4.test.

   377    377         x INTEGER CHECK(tointeger(x) IS NOT NULL)
   378    378       );
   379    379     } {}
   380    380     do_test func4-3.2 {
   381    381       catchsql {
   382    382         INSERT INTO t1 (x) VALUES (NULL);
   383    383       }
   384         -  } {1 {constraint failed}}
          384  +  } {1 {CHECK constraint failed: t1}}
   385    385     do_test func4-3.3 {
   386    386       catchsql {
   387    387         INSERT INTO t1 (x) VALUES (NULL);
   388    388       }
   389         -  } {1 {constraint failed}}
          389  +  } {1 {CHECK constraint failed: t1}}
   390    390     do_test func4-3.4 {
   391    391       catchsql {
   392    392         INSERT INTO t1 (x) VALUES ('');
   393    393       }
   394         -  } {1 {constraint failed}}
          394  +  } {1 {CHECK constraint failed: t1}}
   395    395     do_test func4-3.5 {
   396    396       catchsql {
   397    397         INSERT INTO t1 (x) VALUES ('bad');
   398    398       }
   399         -  } {1 {constraint failed}}
          399  +  } {1 {CHECK constraint failed: t1}}
   400    400     do_test func4-3.6 {
   401    401       catchsql {
   402    402         INSERT INTO t1 (x) VALUES ('1234bad');
   403    403       }
   404         -  } {1 {constraint failed}}
          404  +  } {1 {CHECK constraint failed: t1}}
   405    405     do_test func4-3.7 {
   406    406       catchsql {
   407    407         INSERT INTO t1 (x) VALUES ('1234.56bad');
   408    408       }
   409         -  } {1 {constraint failed}}
          409  +  } {1 {CHECK constraint failed: t1}}
   410    410     do_test func4-3.8 {
   411    411       catchsql {
   412    412         INSERT INTO t1 (x) VALUES (1234);
   413    413       }
   414    414     } {0 {}}
   415    415     do_test func4-3.9 {
   416    416       catchsql {
   417    417         INSERT INTO t1 (x) VALUES (1234.56);
   418    418       }
   419         -  } {1 {constraint failed}}
          419  +  } {1 {CHECK constraint failed: t1}}
   420    420     do_test func4-3.10 {
   421    421       catchsql {
   422    422         INSERT INTO t1 (x) VALUES ('1234');
   423    423       }
   424    424     } {0 {}}
   425    425     do_test func4-3.11 {
   426    426       catchsql {
   427    427         INSERT INTO t1 (x) VALUES ('1234.56');
   428    428       }
   429         -  } {1 {constraint failed}}
          429  +  } {1 {CHECK constraint failed: t1}}
   430    430     do_test func4-3.12 {
   431    431       catchsql {
   432    432         INSERT INTO t1 (x) VALUES (ZEROBLOB(4));
   433    433       }
   434         -  } {1 {constraint failed}}
          434  +  } {1 {CHECK constraint failed: t1}}
   435    435     do_test func4-3.13 {
   436    436       catchsql {
   437    437         INSERT INTO t1 (x) VALUES (X'');
   438    438       }
   439         -  } {1 {constraint failed}}
          439  +  } {1 {CHECK constraint failed: t1}}
   440    440     do_test func4-3.14 {
   441    441       catchsql {
   442    442         INSERT INTO t1 (x) VALUES (X'1234');
   443    443       }
   444         -  } {1 {constraint failed}}
          444  +  } {1 {CHECK constraint failed: t1}}
   445    445     do_test func4-3.15 {
   446    446       catchsql {
   447    447         INSERT INTO t1 (x) VALUES (X'12345678');
   448    448       }
   449         -  } {1 {constraint failed}}
          449  +  } {1 {CHECK constraint failed: t1}}
   450    450     do_test func4-3.16 {
   451    451       catchsql {
   452    452         INSERT INTO t1 (x) VALUES ('1234.00');
   453    453       }
   454         -  } {1 {constraint failed}}
          454  +  } {1 {CHECK constraint failed: t1}}
   455    455     do_test func4-3.17 {
   456    456       catchsql {
   457    457         INSERT INTO t1 (x) VALUES (1234.00);
   458    458       }
   459    459     } {0 {}}
   460    460     do_test func4-3.18 {
   461    461       catchsql {
   462    462         INSERT INTO t1 (x) VALUES ('-9223372036854775809');
   463    463       }
   464         -  } {1 {constraint failed}}
          464  +  } {1 {CHECK constraint failed: t1}}
   465    465     if {$highPrecision(1)} {
   466    466       do_test func4-3.19 {
   467    467         catchsql {
   468    468           INSERT INTO t1 (x) VALUES (9223372036854775808);
   469    469         }
   470         -    } {1 {constraint failed}}
          470  +    } {1 {CHECK constraint failed: t1}}
   471    471     }
   472    472     do_execsql_test func4-3.20 {
   473    473       SELECT x FROM t1 ORDER BY x;
   474    474     } {1234 1234 1234}
   475    475   
   476    476     ifcapable floatingpoint {
   477    477       do_execsql_test func4-4.1 {
................................................................................
   479    479           x REAL CHECK(toreal(x) IS NOT NULL)
   480    480         );
   481    481       } {}
   482    482       do_test func4-4.2 {
   483    483         catchsql {
   484    484           INSERT INTO t2 (x) VALUES (NULL);
   485    485         }
   486         -    } {1 {constraint failed}}
          486  +    } {1 {CHECK constraint failed: t2}}
   487    487       do_test func4-4.3 {
   488    488         catchsql {
   489    489           INSERT INTO t2 (x) VALUES (NULL);
   490    490         }
   491         -    } {1 {constraint failed}}
          491  +    } {1 {CHECK constraint failed: t2}}
   492    492       do_test func4-4.4 {
   493    493         catchsql {
   494    494           INSERT INTO t2 (x) VALUES ('');
   495    495         }
   496         -    } {1 {constraint failed}}
          496  +    } {1 {CHECK constraint failed: t2}}
   497    497       do_test func4-4.5 {
   498    498         catchsql {
   499    499           INSERT INTO t2 (x) VALUES ('bad');
   500    500         }
   501         -    } {1 {constraint failed}}
          501  +    } {1 {CHECK constraint failed: t2}}
   502    502       do_test func4-4.6 {
   503    503         catchsql {
   504    504           INSERT INTO t2 (x) VALUES ('1234bad');
   505    505         }
   506         -    } {1 {constraint failed}}
          506  +    } {1 {CHECK constraint failed: t2}}
   507    507       do_test func4-4.7 {
   508    508         catchsql {
   509    509           INSERT INTO t2 (x) VALUES ('1234.56bad');
   510    510         }
   511         -    } {1 {constraint failed}}
          511  +    } {1 {CHECK constraint failed: t2}}
   512    512       do_test func4-4.8 {
   513    513         catchsql {
   514    514           INSERT INTO t2 (x) VALUES (1234);
   515    515         }
   516    516       } {0 {}}
   517    517       do_test func4-4.9 {
   518    518         catchsql {
................................................................................
   529    529           INSERT INTO t2 (x) VALUES ('1234.56');
   530    530         }
   531    531       } {0 {}}
   532    532       do_test func4-4.12 {
   533    533         catchsql {
   534    534           INSERT INTO t2 (x) VALUES (ZEROBLOB(4));
   535    535         }
   536         -    } {1 {constraint failed}}
          536  +    } {1 {CHECK constraint failed: t2}}
   537    537       do_test func4-4.13 {
   538    538         catchsql {
   539    539           INSERT INTO t2 (x) VALUES (X'');
   540    540         }
   541         -    } {1 {constraint failed}}
          541  +    } {1 {CHECK constraint failed: t2}}
   542    542       do_test func4-4.14 {
   543    543         catchsql {
   544    544           INSERT INTO t2 (x) VALUES (X'1234');
   545    545         }
   546         -    } {1 {constraint failed}}
          546  +    } {1 {CHECK constraint failed: t2}}
   547    547       do_test func4-4.15 {
   548    548         catchsql {
   549    549           INSERT INTO t2 (x) VALUES (X'12345678');
   550    550         }
   551         -    } {1 {constraint failed}}
          551  +    } {1 {CHECK constraint failed: t2}}
   552    552       do_execsql_test func4-4.16 {
   553    553         SELECT x FROM t2 ORDER BY x;
   554    554       } {1234.0 1234.0 1234.56 1234.56}
   555    555     }
   556    556   }
   557    557   
   558    558   ifcapable floatingpoint {

Changes to test/in.test.

   328    328       SELECT * FROM t5;
   329    329     }
   330    330   } {111}
   331    331   do_test in-10.2 {
   332    332     catchsql {
   333    333       INSERT INTO t5 VALUES(4);
   334    334     }
   335         -} {1 {constraint failed}}
          335  +} {1 {CHECK constraint failed: t5}}
   336    336   
   337    337   # Ticket #1821
   338    338   #
   339    339   # Type affinity applied to the right-hand side of an IN operator.
   340    340   #
   341    341   do_test in-11.1 {
   342    342     execsql {

Changes to test/incrblob2.test.

   393    393   do_test incrblob2-8.4 {
   394    394     execsql BEGIN
   395    395     set h [db incrblob t3 b 3]
   396    396     sqlite3_blob_read $h 0 20
   397    397   } {cccccccccccccccccccc}
   398    398   do_test incrblob2-8.5 {
   399    399     catchsql {UPDATE t3 SET a = 6 WHERE a > 3}
   400         -} {1 {column a is not unique}}
          400  +} {1 {UNIQUE constraint failed: t3.a}}
   401    401   do_test incrblob2-8.6 {
   402    402     catchsql {UPDATE t3 SET a = 6 WHERE a > 3}
   403         -} {1 {column a is not unique}}
          403  +} {1 {UNIQUE constraint failed: t3.a}}
   404    404   do_test incrblob2-8.7 {
   405    405     sqlite3_blob_read $h 0 20
   406    406   } {cccccccccccccccccccc}
   407    407   do_test incrblob2-8.8 {
   408    408     catchsql {UPDATE t3 SET a = 6 WHERE a = 3 OR a = 5}
   409         -} {1 {column a is not unique}}
          409  +} {1 {UNIQUE constraint failed: t3.a}}
   410    410   do_test incrblob2-8.9 {
   411    411     set rc [catch {sqlite3_blob_read $h 0 20} msg]
   412    412     list $rc $msg
   413    413   } {1 SQLITE_ABORT}
   414    414   do_test incrblob2-8.X {
   415    415     close $h
   416    416   } {}
   417    417   
   418    418   finish_test

Changes to test/index.test.

   662    662       }
   663    663     } {}
   664    664     do_test index-19.2 {
   665    665       catchsql {
   666    666         BEGIN;
   667    667         INSERT INTO t7 VALUES(1);
   668    668       }
   669         -  } {1 {column a is not unique}}
          669  +  } {1 {UNIQUE constraint failed: t7.a}}
   670    670     do_test index-19.3 {
   671    671       catchsql {
   672    672         BEGIN;
   673    673       }
   674    674     } {1 {cannot start a transaction within a transaction}}
   675    675     do_test index-19.4 {
   676    676       catchsql {
   677    677         INSERT INTO t8 VALUES(1);
   678    678       }
   679         -  } {1 {column a is not unique}}
          679  +  } {1 {UNIQUE constraint failed: t8.a}}
   680    680     do_test index-19.5 {
   681    681       catchsql {
   682    682         BEGIN;
   683    683         COMMIT;
   684    684       }
   685    685     } {0 {}}
   686    686     do_test index-19.6 {

Changes to test/index3.test.

    30     30     }
    31     31   } {1 1}
    32     32   do_test index3-1.2 {
    33     33     catchsql {
    34     34       BEGIN;
    35     35       CREATE UNIQUE INDEX i1 ON t1(a);
    36     36     }
    37         -} {1 {indexed columns are not unique}}
           37  +} {1 {UNIQUE constraint failed: t1.a}}
    38     38   do_test index3-1.3 {
    39     39     catchsql COMMIT;
    40     40   } {0 {}}
    41     41   integrity_check index3-1.4
    42     42   
    43     43   # This test corrupts the database file so it must be the last test
    44     44   # in the series.

Changes to test/index4.test.

   116    116       INSERT INTO t2 VALUES(15);
   117    117       INSERT INTO t2 VALUES(35);
   118    118       INSERT INTO t2 VALUES(16);
   119    119     COMMIT;
   120    120   }
   121    121   do_catchsql_test 2.2 {
   122    122     CREATE UNIQUE INDEX i3 ON t2(x);
   123         -} {1 {indexed columns are not unique}}
          123  +} {1 {UNIQUE constraint failed: t2.x}}
   124    124   
   125    125   
   126    126   finish_test

Changes to test/index6.test.

   216    216     CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;
   217    217   } {}
   218    218   do_test index6-3.2 {
   219    219     # unable to insert a duplicate row a-value that is not 999.
   220    220     catchsql {
   221    221       INSERT INTO t3(a,b) VALUES(150, 'test1');
   222    222     }
   223         -} {1 {column a is not unique}}
          223  +} {1 {UNIQUE constraint failed: t3.a}}
   224    224   do_test index6-3.3 {
   225    225     # can insert multiple rows with a==999 because such rows are not
   226    226     # part of the unique index.
   227    227     catchsql {
   228    228       INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
   229    229     }
   230    230   } {0 {}}

Changes to test/index7.test.

   216    216     CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;
   217    217   } {}
   218    218   do_test index7-3.2 {
   219    219     # unable to insert a duplicate row a-value that is not 999.
   220    220     catchsql {
   221    221       INSERT INTO t3(a,b) VALUES(150, 'test1');
   222    222     }
   223         -} {1 {column a is not unique}}
          223  +} {1 {UNIQUE constraint failed: t3.a}}
   224    224   do_test index7-3.3 {
   225    225     # can insert multiple rows with a==999 because such rows are not
   226    226     # part of the unique index.
   227    227     catchsql {
   228    228       INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
   229    229     }
   230    230   } {0 {}}

Changes to test/insert4.test.

    50     50       DELETE FROM t1;
    51     51       DELETE FROM t2;
    52     52       INSERT INTO t2 VALUES(9,1);
    53     53     }
    54     54     catchsql {
    55     55       INSERT INTO t1 SELECT * FROM t2;
    56     56     }
    57         -} {1 {constraint failed}}
           57  +} {1 {CHECK constraint failed: t1}}
    58     58   xferopt_test insert4-1.2 0
    59     59   do_test insert4-1.3 {
    60     60     execsql {
    61     61       SELECT * FROM t1;
    62     62     }
    63     63   } {}
    64     64   
................................................................................
    97     97   xferopt_test insert4-2.3.2  0
    98     98   do_test insert4-2.3.3 {
    99     99     catchsql {
   100    100       DELETE FROM t1;
   101    101       INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
   102    102       SELECT * FROM t1;
   103    103     }
   104         -} {1 {constraint failed}}
          104  +} {1 {CHECK constraint failed: t1}}
   105    105   xferopt_test insert4-2.3.4 0
   106    106   
   107    107   # Do not run the transfer optimization if there is a DISTINCT
   108    108   #
   109    109   do_test insert4-2.4.1 {
   110    110     execsql {
   111    111       DELETE FROM t3;
................................................................................
   115    115   } {9 1 1 9}
   116    116   xferopt_test insert4-2.4.2 0
   117    117   do_test insert4-2.4.3 {
   118    118     catchsql {
   119    119       DELETE FROM t1;
   120    120       INSERT INTO t1 SELECT DISTINCT * FROM t2;
   121    121     }
   122         -} {1 {constraint failed}}
          122  +} {1 {CHECK constraint failed: t1}}
   123    123   xferopt_test insert4-2.4.4 0
   124    124   
   125    125   # The following procedure constructs two tables then tries to transfer
   126    126   # data from one table to the other.  Checks are made to make sure the
   127    127   # transfer is successful and that the transfer optimization was used or
   128    128   # not, as appropriate.
   129    129   #
................................................................................
   311    311   do_test insert4-6.6 {
   312    312     execsql {
   313    313       CREATE TABLE t6b(x CHECK( x<>'abc' COLLATE nocase ));
   314    314     }
   315    315     catchsql {
   316    316       INSERT INTO t6b SELECT * FROM t6a;
   317    317     }
   318         -} {1 {constraint failed}}
          318  +} {1 {CHECK constraint failed: t6b}}
   319    319   do_test insert4-6.7 {
   320    320     execsql {
   321    321       DROP TABLE t6b;
   322    322       CREATE TABLE t6b(x CHECK( x COLLATE nocase <>'abc' ));
   323    323     }
   324    324     catchsql {
   325    325       INSERT INTO t6b SELECT * FROM t6a;
   326    326     }
   327         -} {1 {constraint failed}}
          327  +} {1 {CHECK constraint failed: t6b}}
   328    328   
   329    329   # Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
   330    330   # Disable the xfer optimization if the destination table contains
   331    331   # a foreign key constraint
   332    332   #
   333    333   ifcapable foreignkey {
   334    334     do_test insert4-7.1 {
................................................................................
   349    349       execsql {
   350    350         DELETE FROM t7b;
   351    351         PRAGMA foreign_keys=ON;
   352    352       }
   353    353       catchsql {
   354    354         INSERT INTO t7b SELECT * FROM t7c;
   355    355       }
   356         -  } {1 {foreign key constraint failed}}
          356  +  } {1 {FOREIGN KEY constraint failed}}
   357    357     do_test insert4-7.4 {
   358    358       execsql {SELECT * FROM t7b}
   359    359     } {}
   360    360     do_test insert4-7.5 {
   361    361       set ::sqlite3_xferopt_count
   362    362     } {0}
   363    363     do_test insert4-7.6 {
................................................................................
   448    448       INSERT INTO t2 VALUES(-99,100);
   449    449       INSERT INTO t2 VALUES(1,3);
   450    450       SELECT * FROM t1;
   451    451     }
   452    452     catchsql {
   453    453       INSERT INTO t1 SELECT * FROM t2;
   454    454     }
   455         -} {1 {PRIMARY KEY must be unique}}
          455  +} {1 {UNIQUE constraint failed: t1.a}}
   456    456   do_test insert4-8.6 {
   457    457     execsql {
   458    458       SELECT * FROM t1;
   459    459     }
   460    460   } {-99 100 1 2} 
   461    461   do_test insert4-8.7 {
   462    462     execsql {
................................................................................
   468    468       INSERT INTO t2 VALUES(-99,100);
   469    469       INSERT INTO t2 VALUES(1,3);
   470    470       SELECT * FROM t1;
   471    471     }
   472    472     catchsql {
   473    473       INSERT INTO t1 SELECT * FROM t2;
   474    474     }
   475         -} {1 {PRIMARY KEY must be unique}}
          475  +} {1 {UNIQUE constraint failed: t1.a}}
   476    476   do_test insert4-8.8 {
   477    477     execsql {
   478    478       SELECT * FROM t1;
   479    479     }
   480    480   } {1 2} 
   481    481   do_test insert4-8.9 {
   482    482     execsql {
................................................................................
   490    490       SELECT * FROM t1;
   491    491     }
   492    492     catchsql {
   493    493       BEGIN;
   494    494       INSERT INTO t1 VALUES(2,3);
   495    495       INSERT INTO t1 SELECT * FROM t2;
   496    496     }
   497         -} {1 {PRIMARY KEY must be unique}}
          497  +} {1 {UNIQUE constraint failed: t1.a}}
   498    498   do_test insert4-8.10 {
   499    499     catchsql {COMMIT}
   500    500   } {1 {cannot commit - no transaction is active}}
   501    501   do_test insert4-8.11 {
   502    502     execsql {
   503    503       SELECT * FROM t1;
   504    504     }

Changes to test/intpkey.test.

    72     72   # failure.
    73     73   #
    74     74   do_test intpkey-1.6 {
    75     75     set r [catch {execsql {
    76     76        INSERT INTO t1 VALUES(5,'second','entry');
    77     77     }} msg]
    78     78     lappend r $msg
    79         -} {1 {PRIMARY KEY must be unique}}
           79  +} {1 {UNIQUE constraint failed: t1.a}}
    80     80   do_test intpkey-1.7 {
    81     81     execsql {
    82     82       SELECT rowid, * FROM t1;
    83     83     }
    84     84   } {5 5 hello world}
    85     85   do_test intpkey-1.8 {
    86     86     set r [catch {execsql {

Changes to test/memdb.test.

   236    236   } {
   237    237     # All tests after test 1 depend on conflict resolution. So end the
   238    238     # loop if that is not available in this build.
   239    239     ifcapable !conflict {
   240    240       if {$i>1} break
   241    241     }
   242    242   
   243         -  if {$t0} {set t1 {column a is not unique}}
          243  +  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
   244    244     do_test memdb-5.$i {
   245    245       if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
   246    246       if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
   247    247       set r0 [catch {execsql "
   248    248         DROP TABLE t1;
   249    249         CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
   250    250         INSERT INTO t1 SELECT * FROM t2;

Changes to test/misc1.test.

   231    231       SELECT * FROM t5 ORDER BY a;
   232    232     }
   233    233   } {1 2 3}
   234    234   do_test misc1-7.4 {
   235    235     catchsql {
   236    236       INSERT INTO t5 VALUES(1,2,4);
   237    237     }
   238         -} {1 {PRIMARY KEY must be unique}}
          238  +} {1 {UNIQUE constraint failed: t5.a, t5.b}}
   239    239   do_test misc1-7.5 {
   240    240     catchsql {
   241    241       INSERT INTO t5 VALUES(0,2,4);
   242    242     }
   243    243   } {0 {}}
   244    244   do_test misc1-7.6 {
   245    245     execsql {

Changes to test/notnull.test.

    43     43   } {0 {1 2 3 4 5}}
    44     44   do_test notnull-1.2 {
    45     45     catchsql {
    46     46       DELETE FROM t1;
    47     47       INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
    48     48       SELECT * FROM t1 order by a;
    49     49     }
    50         -} {1 {t1.a may not be NULL}}
           50  +} {1 {NOT NULL constraint failed: t1.a}}
    51     51   verify_ex_errcode notnull-1.2b SQLITE_CONSTRAINT_NOTNULL
    52     52   do_test notnull-1.3 {
    53     53     catchsql {
    54     54       DELETE FROM t1;
    55     55       INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
    56     56       SELECT * FROM t1 order by a;
    57     57     }
................................................................................
    58     58   } {0 {}}
    59     59   do_test notnull-1.4 {
    60     60     catchsql {
    61     61       DELETE FROM t1;
    62     62       INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
    63     63       SELECT * FROM t1 order by a;
    64     64     }
    65         -} {1 {t1.a may not be NULL}}
           65  +} {1 {NOT NULL constraint failed: t1.a}}
    66     66   verify_ex_errcode notnull-1.4b SQLITE_CONSTRAINT_NOTNULL
    67     67   do_test notnull-1.5 {
    68     68     catchsql {
    69     69       DELETE FROM t1;
    70     70       INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
    71     71       SELECT * FROM t1 order by a;
    72     72     }
    73         -} {1 {t1.a may not be NULL}}
           73  +} {1 {NOT NULL constraint failed: t1.a}}
    74     74   verify_ex_errcode notnull-1.5b SQLITE_CONSTRAINT_NOTNULL
    75     75   do_test notnull-1.6 {
    76     76     catchsql {
    77     77       DELETE FROM t1;
    78     78       INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
    79     79       SELECT * FROM t1 order by a;
    80     80     }
................................................................................
   102    102   } {0 {1 5 3 4 5}}
   103    103   do_test notnull-1.10 {
   104    104     catchsql {
   105    105       DELETE FROM t1;
   106    106       INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   107    107       SELECT * FROM t1 order by a;
   108    108     }
   109         -} {1 {t1.b may not be NULL}}
          109  +} {1 {NOT NULL constraint failed: t1.b}}
   110    110   verify_ex_errcode notnull-1.10b SQLITE_CONSTRAINT_NOTNULL
   111    111   do_test notnull-1.11 {
   112    112     catchsql {
   113    113       DELETE FROM t1;
   114    114       INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   115    115       SELECT * FROM t1 order by a;
   116    116     }
................................................................................
   145    145   } {0 {1 2 6 4 5}}
   146    146   do_test notnull-1.16 {
   147    147     catchsql {
   148    148       DELETE FROM t1;
   149    149       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
   150    150       SELECT * FROM t1 order by a;
   151    151     }
   152         -} {1 {t1.c may not be NULL}}
          152  +} {1 {NOT NULL constraint failed: t1.c}}
   153    153   verify_ex_errcode notnull-1.16b SQLITE_CONSTRAINT_NOTNULL
   154    154   do_test notnull-1.17 {
   155    155     catchsql {
   156    156       DELETE FROM t1;
   157    157       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
   158    158       SELECT * FROM t1 order by a;
   159    159     }
   160         -} {1 {t1.d may not be NULL}}
          160  +} {1 {NOT NULL constraint failed: t1.d}}
   161    161   verify_ex_errcode notnull-1.17b SQLITE_CONSTRAINT_NOTNULL
   162    162   do_test notnull-1.18 {
   163    163     catchsql {
   164    164       DELETE FROM t1;
   165    165       INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
   166    166       SELECT * FROM t1 order by a;
   167    167     }
................................................................................
   175    175   } {0 {1 2 3 4 8}}
   176    176   do_test notnull-1.20 {
   177    177     catchsql {
   178    178       DELETE FROM t1;
   179    179       INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
   180    180       SELECT * FROM t1 order by a;
   181    181     }
   182         -} {1 {t1.e may not be NULL}}
          182  +} {1 {NOT NULL constraint failed: t1.e}}
   183    183   verify_ex_errcode notnull-1.20b SQLITE_CONSTRAINT_NOTNULL
   184    184   do_test notnull-1.21 {
   185    185     catchsql {
   186    186       DELETE FROM t1;
   187    187       INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
   188    188       SELECT * FROM t1 order by a;
   189    189     }
................................................................................
   192    192   do_test notnull-2.1 {
   193    193     catchsql {
   194    194       DELETE FROM t1;
   195    195       INSERT INTO t1 VALUES(1,2,3,4,5);
   196    196       UPDATE t1 SET a=null;
   197    197       SELECT * FROM t1 ORDER BY a;
   198    198     }
   199         -} {1 {t1.a may not be NULL}}
          199  +} {1 {NOT NULL constraint failed: t1.a}}
   200    200   verify_ex_errcode notnull-2.1b SQLITE_CONSTRAINT_NOTNULL
   201    201   do_test notnull-2.2 {
   202    202     catchsql {
   203    203       DELETE FROM t1;
   204    204       INSERT INTO t1 VALUES(1,2,3,4,5);
   205    205       UPDATE OR REPLACE t1 SET a=null;
   206    206       SELECT * FROM t1 ORDER BY a;
   207    207     }
   208         -} {1 {t1.a may not be NULL}}
          208  +} {1 {NOT NULL constraint failed: t1.a}}
   209    209   verify_ex_errcode notnull-2.2b SQLITE_CONSTRAINT_NOTNULL
   210    210   do_test notnull-2.3 {
   211    211     catchsql {
   212    212       DELETE FROM t1;
   213    213       INSERT INTO t1 VALUES(1,2,3,4,5);
   214    214       UPDATE OR IGNORE t1 SET a=null;
   215    215       SELECT * FROM t1 ORDER BY a;
................................................................................
   218    218   do_test notnull-2.4 {
   219    219     catchsql {
   220    220       DELETE FROM t1;
   221    221       INSERT INTO t1 VALUES(1,2,3,4,5);
   222    222       UPDATE OR ABORT t1 SET a=null;
   223    223       SELECT * FROM t1 ORDER BY a;
   224    224     }
   225         -} {1 {t1.a may not be NULL}}
          225  +} {1 {NOT NULL constraint failed: t1.a}}
   226    226   verify_ex_errcode notnull-2.4b SQLITE_CONSTRAINT_NOTNULL
   227    227   do_test notnull-2.5 {
   228    228     catchsql {
   229    229       DELETE FROM t1;
   230    230       INSERT INTO t1 VALUES(1,2,3,4,5);
   231    231       UPDATE t1 SET b=null;
   232    232       SELECT * FROM t1 ORDER BY a;
   233    233     }
   234         -} {1 {t1.b may not be NULL}}
          234  +} {1 {NOT NULL constraint failed: t1.b}}
   235    235   verify_ex_errcode notnull-2.6b SQLITE_CONSTRAINT_NOTNULL
   236    236   do_test notnull-2.6 {
   237    237     catchsql {
   238    238       DELETE FROM t1;
   239    239       INSERT INTO t1 VALUES(1,2,3,4,5);
   240    240       UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
   241    241       SELECT * FROM t1 ORDER BY a;
................................................................................
   268    268   do_test notnull-2.10 {
   269    269     catchsql {
   270    270       DELETE FROM t1;
   271    271       INSERT INTO t1 VALUES(1,2,3,4,5);
   272    272       UPDATE t1 SET e=null, a=b, b=a;
   273    273       SELECT * FROM t1 ORDER BY a;
   274    274     }
   275         -} {1 {t1.e may not be NULL}}
          275  +} {1 {NOT NULL constraint failed: t1.e}}
   276    276   verify_ex_errcode notnull-2.10b SQLITE_CONSTRAINT_NOTNULL
   277    277   
   278    278   do_test notnull-3.0 {
   279    279     execsql {
   280    280       CREATE INDEX t1a ON t1(a);
   281    281       CREATE INDEX t1b ON t1(b);
   282    282       CREATE INDEX t1c ON t1(c);
................................................................................
   294    294   } {0 {1 2 3 4 5}}
   295    295   do_test notnull-3.2 {
   296    296     catchsql {
   297    297       DELETE FROM t1;
   298    298       INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
   299    299       SELECT * FROM t1 order by a;
   300    300     }
   301         -} {1 {t1.a may not be NULL}}
          301  +} {1 {NOT NULL constraint failed: t1.a}}
   302    302   verify_ex_errcode notnull-3.2b SQLITE_CONSTRAINT_NOTNULL
   303    303   do_test notnull-3.3 {
   304    304     catchsql {
   305    305       DELETE FROM t1;
   306    306       INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
   307    307       SELECT * FROM t1 order by a;
   308    308     }
................................................................................
   309    309   } {0 {}}
   310    310   do_test notnull-3.4 {
   311    311     catchsql {
   312    312       DELETE FROM t1;
   313    313       INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
   314    314       SELECT * FROM t1 order by a;
   315    315     }
   316         -} {1 {t1.a may not be NULL}}
          316  +} {1 {NOT NULL constraint failed: t1.a}}
   317    317   verify_ex_errcode notnull-3.4b SQLITE_CONSTRAINT_NOTNULL
   318    318   do_test notnull-3.5 {
   319    319     catchsql {
   320    320       DELETE FROM t1;
   321    321       INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
   322    322       SELECT * FROM t1 order by a;
   323    323     }
   324         -} {1 {t1.a may not be NULL}}
          324  +} {1 {NOT NULL constraint failed: t1.a}}
   325    325   verify_ex_errcode notnull-3.5b SQLITE_CONSTRAINT_NOTNULL
   326    326   do_test notnull-3.6 {
   327    327     catchsql {
   328    328       DELETE FROM t1;
   329    329       INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
   330    330       SELECT * FROM t1 order by a;
   331    331     }
................................................................................
   353    353   } {0 {1 5 3 4 5}}
   354    354   do_test notnull-3.10 {
   355    355     catchsql {
   356    356       DELETE FROM t1;
   357    357       INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   358    358       SELECT * FROM t1 order by a;
   359    359     }
   360         -} {1 {t1.b may not be NULL}}
          360  +} {1 {NOT NULL constraint failed: t1.b}}
   361    361   verify_ex_errcode notnull-3.10b SQLITE_CONSTRAINT_NOTNULL
   362    362   do_test notnull-3.11 {
   363    363     catchsql {
   364    364       DELETE FROM t1;
   365    365       INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   366    366       SELECT * FROM t1 order by a;
   367    367     }
................................................................................
   396    396   } {0 {1 2 6 4 5}}
   397    397   do_test notnull-3.16 {
   398    398     catchsql {
   399    399       DELETE FROM t1;
   400    400       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
   401    401       SELECT * FROM t1 order by a;
   402    402     }
   403         -} {1 {t1.c may not be NULL}}
          403  +} {1 {NOT NULL constraint failed: t1.c}}
   404    404   verify_ex_errcode notnull-3.16b SQLITE_CONSTRAINT_NOTNULL
   405    405   do_test notnull-3.17 {
   406    406     catchsql {
   407    407       DELETE FROM t1;
   408    408       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
   409    409       SELECT * FROM t1 order by a;
   410    410     }
   411         -} {1 {t1.d may not be NULL}}
          411  +} {1 {NOT NULL constraint failed: t1.d}}
   412    412   verify_ex_errcode notnull-3.17b SQLITE_CONSTRAINT_NOTNULL
   413    413   do_test notnull-3.18 {
   414    414     catchsql {
   415    415       DELETE FROM t1;
   416    416       INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
   417    417       SELECT * FROM t1 order by a;
   418    418     }
................................................................................
   426    426   } {0 {1 2 3 4 8}}
   427    427   do_test notnull-3.20 {
   428    428     catchsql {
   429    429       DELETE FROM t1;
   430    430       INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
   431    431       SELECT * FROM t1 order by a;
   432    432     }
   433         -} {1 {t1.e may not be NULL}}
          433  +} {1 {NOT NULL constraint failed: t1.e}}
   434    434   verify_ex_errcode notnull-3.20b SQLITE_CONSTRAINT_NOTNULL
   435    435   do_test notnull-3.21 {
   436    436     catchsql {
   437    437       DELETE FROM t1;
   438    438       INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
   439    439       SELECT * FROM t1 order by a;
   440    440     }
................................................................................
   443    443   do_test notnull-4.1 {
   444    444     catchsql {
   445    445       DELETE FROM t1;
   446    446       INSERT INTO t1 VALUES(1,2,3,4,5);
   447    447       UPDATE t1 SET a=null;
   448    448       SELECT * FROM t1 ORDER BY a;
   449    449     }
   450         -} {1 {t1.a may not be NULL}}
          450  +} {1 {NOT NULL constraint failed: t1.a}}
   451    451   verify_ex_errcode notnull-4.1b SQLITE_CONSTRAINT_NOTNULL
   452    452   do_test notnull-4.2 {
   453    453     catchsql {
   454    454       DELETE FROM t1;
   455    455       INSERT INTO t1 VALUES(1,2,3,4,5);
   456    456       UPDATE OR REPLACE t1 SET a=null;
   457    457       SELECT * FROM t1 ORDER BY a;
   458    458     }
   459         -} {1 {t1.a may not be NULL}}
          459  +} {1 {NOT NULL constraint failed: t1.a}}
   460    460   verify_ex_errcode notnull-4.2b SQLITE_CONSTRAINT_NOTNULL
   461    461   do_test notnull-4.3 {
   462    462     catchsql {
   463    463       DELETE FROM t1;
   464    464       INSERT INTO t1 VALUES(1,2,3,4,5);
   465    465       UPDATE OR IGNORE t1 SET a=null;
   466    466       SELECT * FROM t1 ORDER BY a;
................................................................................
   469    469   do_test notnull-4.4 {
   470    470     catchsql {
   471    471       DELETE FROM t1;
   472    472       INSERT INTO t1 VALUES(1,2,3,4,5);
   473    473       UPDATE OR ABORT t1 SET a=null;
   474    474       SELECT * FROM t1 ORDER BY a;
   475    475     }
   476         -} {1 {t1.a may not be NULL}}
          476  +} {1 {NOT NULL constraint failed: t1.a}}
   477    477   verify_ex_errcode notnull-4.4b SQLITE_CONSTRAINT_NOTNULL
   478    478   do_test notnull-4.5 {
   479    479     catchsql {
   480    480       DELETE FROM t1;
   481    481       INSERT INTO t1 VALUES(1,2,3,4,5);
   482    482       UPDATE t1 SET b=null;
   483    483       SELECT * FROM t1 ORDER BY a;
   484    484     }
   485         -} {1 {t1.b may not be NULL}}
          485  +} {1 {NOT NULL constraint failed: t1.b}}
   486    486   verify_ex_errcode notnull-4.5b SQLITE_CONSTRAINT_NOTNULL
   487    487   do_test notnull-4.6 {
   488    488     catchsql {
   489    489       DELETE FROM t1;
   490    490       INSERT INTO t1 VALUES(1,2,3,4,5);
   491    491       UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
   492    492       SELECT * FROM t1 ORDER BY a;
................................................................................
   519    519   do_test notnull-4.10 {
   520    520     catchsql {
   521    521       DELETE FROM t1;
   522    522       INSERT INTO t1 VALUES(1,2,3,4,5);
   523    523       UPDATE t1 SET e=null, a=b, b=a;
   524    524       SELECT * FROM t1 ORDER BY a;
   525    525     }
   526         -} {1 {t1.e may not be NULL}}
          526  +} {1 {NOT NULL constraint failed: t1.e}}
   527    527   verify_ex_errcode notnull-4.10b SQLITE_CONSTRAINT_NOTNULL
   528    528   
   529    529   # Test that bug 29ab7be99f is fixed.
   530    530   #
   531    531   do_test notnull-5.1 {
   532    532     execsql {
   533    533       DROP TABLE IF EXISTS t1;
................................................................................
   538    538     }
   539    539   }  {}
   540    540   do_test notnull-5.2 {
   541    541     catchsql {
   542    542       INSERT INTO t1 VALUES(1, 2);
   543    543       INSERT INTO t1 SELECT * FROM t2;
   544    544     }
   545         -} {1 {t1.b may not be NULL}}
          545  +} {1 {NOT NULL constraint failed: t1.b}}
   546    546   verify_ex_errcode notnull-5.2b SQLITE_CONSTRAINT_NOTNULL
   547    547   do_test notnull-5.3 {
   548    548     execsql { SELECT * FROM t1 }
   549    549   } {1 2}
   550    550   do_test notnull-5.4 {
   551    551     catchsql {
   552    552       DELETE FROM t1;
   553    553       BEGIN;
   554    554         INSERT INTO t1 VALUES(1, 2);
   555    555         INSERT INTO t1 SELECT * FROM t2;
   556    556       COMMIT;
   557    557     }
   558         -} {1 {t1.b may not be NULL}}
          558  +} {1 {NOT NULL constraint failed: t1.b}}
   559    559   verify_ex_errcode notnull-5.4b SQLITE_CONSTRAINT_NOTNULL
   560    560   do_test notnull-5.5 {
   561    561     execsql { SELECT * FROM t1 }
   562    562   } {1 2}
   563    563   
   564    564   finish_test

Changes to test/pager1.test.

   267    267       INSERT INTO t1 VALUES(1, randomblob(1500));
   268    268       INSERT INTO t1 VALUES(2, randomblob(1500));
   269    269       INSERT INTO t1 VALUES(3, randomblob(1500));
   270    270       SELECT * FROM counter;
   271    271   } {3 0}
   272    272   do_catchsql_test pager1-3.1.3 {
   273    273       INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1
   274         -} {1 {constraint failed}}
          274  +} {1 {CHECK constraint failed: counter}}
   275    275   do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
   276    276   do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
   277    277   do_execsql_test pager1-3.6 { COMMIT } {}
   278    278   
   279    279   foreach {tn sql tcl} {
   280    280     7  { PRAGMA synchronous = NORMAL ; PRAGMA temp_store = 0 } {
   281    281       testvfs tv -default 1
................................................................................
  1699   1699   do_execsql_test pager1-14.1.3 {
  1700   1700     SELECT * FROM t1;
  1701   1701   } {1 2}
  1702   1702   do_catchsql_test pager1-14.1.4 {
  1703   1703     BEGIN;
  1704   1704       INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;
  1705   1705       INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;
  1706         -} {1 {PRIMARY KEY must be unique}}
         1706  +} {1 {UNIQUE constraint failed: t1.rowid}}
  1707   1707   do_execsql_test pager1-14.1.5 {
  1708   1708     COMMIT;
  1709   1709     SELECT * FROM t1;
  1710   1710   } {1 2 2 2}
  1711   1711   
  1712   1712   #-------------------------------------------------------------------------
  1713   1713   # Test opening and closing the pager sub-system with different values

Changes to test/rollback.test.

    50     50     # This causes a ROLLBACK, which deletes the table out from underneath the
    51     51     # SELECT statement.
    52     52     #
    53     53     do_test rollback-1.4 {
    54     54       catchsql {
    55     55         INSERT INTO t3 SELECT a FROM t1;
    56     56       }
    57         -  } {1 {column a is not unique}}
           57  +  } {1 {UNIQUE constraint failed: t3.a}}
    58     58     
    59     59     # Try to continue with the SELECT statement
    60     60     #
    61     61     do_test rollback-1.5 {
    62     62       sqlite3_step $STMT
    63     63     } {SQLITE_ERROR}
    64     64   

Changes to test/savepoint.test.

   854    854       BEGIN;
   855    855         INSERT INTO t4 VALUES(2, 'two');
   856    856         SAVEPOINT sp1;
   857    857           INSERT INTO t4 VALUES(3, 'three');
   858    858           SAVEPOINT sp2;
   859    859             INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
   860    860     }
   861         -} {1 {PRIMARY KEY must be unique}}
          861  +} {1 {UNIQUE constraint failed: t4.a}}
   862    862   do_test savepoint-12.3 {
   863    863     sqlite3_get_autocommit db
   864    864   } {1}
   865    865   do_test savepoint-12.4 {
   866    866     execsql { SAVEPOINT one }
   867    867   } {}
   868    868   wal_check_journal_mode savepoint-12.5

Changes to test/schema5.test.

    26     26       CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one);
    27     27       INSERT INTO t1 VALUES(1,2,3);
    28     28       SELECT * FROM t1;
    29     29     }
    30     30   } {1 2 3}
    31     31   do_test schema5-1.2 {
    32     32     catchsql {INSERT INTO t1 VALUES(1,3,4);}
    33         -} {1 {PRIMARY KEY must be unique}}
           33  +} {1 {UNIQUE constraint failed: t1.a}}
    34     34   do_test schema5-1.3 {
    35     35     db eval {
    36     36       DROP TABLE t1;
    37     37       CREATE TABLE t1(a,b,c,
    38     38           CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b)
    39     39           CONSTRAINT three
    40     40       );
    41     41       INSERT INTO t1 VALUES(1,2,3);
    42     42       SELECT * FROM t1;
    43     43     }
    44     44   } {1 2 3}
    45     45   do_test schema5-1.4 {
    46     46     catchsql {INSERT INTO t1 VALUES(10,11,12);}
    47         -} {1 {constraint two failed}}
           47  +} {1 {CHECK constraint failed: two}}
    48     48   do_test schema5-1.5 {
    49     49     db eval {
    50     50       DROP TABLE t1;
    51     51       CREATE TABLE t1(a,b,c,
    52     52          UNIQUE(a) CONSTRAINT one,
    53     53          PRIMARY KEY(b,c) CONSTRAINT two
    54     54       );
    55     55       INSERT INTO t1 VALUES(1,2,3);
    56     56     }
    57     57   } {}
    58     58   do_test schema5-1.6 {
    59     59     catchsql {INSERT INTO t1 VALUES(1,3,4)}
    60         -} {1 {column a is not unique}}
           60  +} {1 {UNIQUE constraint failed: t1.a}}
    61     61   do_test schema5-1.7 {
    62     62     catchsql {INSERT INTO t1 VALUES(10,2,3)}
    63         -} {1 {PRIMARY KEY must be unique}}
           63  +} {1 {UNIQUE constraint failed: t1.b, t1.c}}
    64     64   
    65     65   
    66     66   
    67     67       
    68     68   
    69     69   finish_test

Changes to test/table.test.

   460    460   #
   461    461   ifcapable {foreignkey} {
   462    462   do_test table-10.1 {
   463    463     catchsql {
   464    464       CREATE TABLE t6(a REFERENCES t4(a) NOT NULL);
   465    465       INSERT INTO t6 VALUES(NULL);
   466    466     }
   467         -} {1 {t6.a may not be NULL}}
          467  +} {1 {NOT NULL constraint failed: t6.a}}
   468    468   do_test table-10.2 {
   469    469     catchsql {
   470    470       DROP TABLE t6;
   471    471       CREATE TABLE t6(a REFERENCES t4(a) MATCH PARTIAL);
   472    472     }
   473    473   } {0 {}}
   474    474   do_test table-10.3 {

Changes to test/tkt-4a03edc4c8.test.

    27     27       INSERT INTO t1 VALUES(2, 2);
    28     28     }
    29     29     catchsql {
    30     30       BEGIN;
    31     31         INSERT INTO t1 VALUES(1, 2);
    32     32       COMMIT;
    33     33     }
    34         -} {1 {column b is not unique}}
           34  +} {1 {UNIQUE constraint failed: t1.b}}
    35     35   do_test tkt-4a03ed-1.2 {
    36     36     db eval {
    37     37       PRAGMA integrity_check;
    38     38     }
    39     39   } {ok}
    40     40   do_test tkt-4a03ed-1.3 {
    41     41     db eval {
    42     42       SELECT * FROM t1 ORDER BY a;
    43     43     }
    44     44   } {1 1 2 2}
    45     45   
    46     46   finish_test

Changes to test/tkt-78e04e52ea.test.

    25     25       SELECT * FROM "", t2;
    26     26     }
    27     27   } {1 {} 2}
    28     28   do_test tkt-78e04-1.1 {
    29     29     catchsql {
    30     30       INSERT INTO ""("") VALUES(1);
    31     31     }
    32         -} {1 {column  is not unique}}
           32  +} {1 {UNIQUE constraint failed: .}}
    33     33   do_test tkt-78e04-1.2 {
    34     34     execsql {
    35     35       PRAGMA table_info("");
    36     36     }
    37     37   } {0 {} {} 0 {} 0 1 x CHAR(100) 0 {} 0}
    38     38   do_test tkt-78e04-1.3 {
    39     39     execsql {

Changes to test/tkt-b1d3a2e531.test.

    94     94   }
    95     95   do_catchsql_test 3.2 {
    96     96     BEGIN;
    97     97       DELETE FROM pp2;
    98     98       DROP TABLE pp1;
    99     99       DROP TABLE cc1;
   100    100     COMMIT;
   101         -} {1 {foreign key constraint failed}}
          101  +} {1 {FOREIGN KEY constraint failed}}
   102    102   do_catchsql_test 3.3 {
   103    103       DROP TABLE cc2;
   104    104     COMMIT;
   105    105   } {0 {}}
   106    106   
   107    107   
   108    108   
   109    109   finish_test

Changes to test/tkt1567.test.

    36     36       UPDATE t1 SET a = a||'x' WHERE rowid%2==0;
    37     37     }
    38     38   } {}
    39     39   do_test tkt1567-1.4 {
    40     40     catchsql {
    41     41       UPDATE t1 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;
    42     42     }
    43         -} {1 {PRIMARY KEY must be unique}}
           43  +} {1 {UNIQUE constraint failed: t1.a}}
    44     44   do_test tkt1567-1.5 {
    45     45     execsql {
    46     46       COMMIT;
    47     47     }
    48     48   } {}
    49     49   integrity_check tkt1567-1.6
    50     50   
................................................................................
    67     67       UPDATE t2 SET a = a||'x' WHERE rowid%2==0;
    68     68     }
    69     69   } {}
    70     70   do_test tkt1567-2.4 {
    71     71     catchsql {
    72     72       UPDATE t2 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;
    73     73     }
    74         -} {1 {PRIMARY KEY must be unique}}
           74  +} {1 {UNIQUE constraint failed: t2.a}}
    75     75   do_test tkt1567-2.5 {
    76     76     execsql {
    77     77       COMMIT;
    78     78     }
    79     79   } {}
    80     80   integrity_check tkt1567-2.6
    81     81   
    82     82   finish_test

Changes to test/tkt35xx.test.

    70     70   do_test tkt35xx-1.2.2 {
    71     71     catchsql {
    72     72       BEGIN;
    73     73       CREATE TABLE t5(e PRIMARY KEY, f);
    74     74       DROP TABLE t5;
    75     75       INSERT INTO t3(a, b) SELECT c, d FROM t4;
    76     76     }
    77         -} {1 {PRIMARY KEY must be unique}}
           77  +} {1 {UNIQUE constraint failed: t3.a}}
    78     78   do_test tkt35xx-1.2.3 {
    79     79     # Show that the transaction has not been rolled back.
    80     80     catchsql BEGIN
    81     81   } {1 {cannot start a transaction within a transaction}}
    82     82   do_test tkt35xx-1.2.4 {
    83     83     execsql { SELECT count(*) FROM t3 }
    84     84   } {4}

Changes to test/trigger2.test.

   493    493         SELECT * from tbl;
   494    494       }
   495    495     } {1 2 3}
   496    496     do_test trigger2-6.1b {
   497    497       catchsql {
   498    498         INSERT OR ABORT INTO tbl values (2, 2, 3);
   499    499       }
   500         -  } {1 {PRIMARY KEY must be unique}}
          500  +  } {1 {UNIQUE constraint failed: tbl.a}}
   501    501     do_test trigger2-6.1c {
   502    502       execsql {
   503    503         SELECT * from tbl;
   504    504       }
   505    505     } {1 2 3}
   506    506     do_test trigger2-6.1d {
   507    507       catchsql {
   508    508         INSERT OR FAIL INTO tbl values (2, 2, 3);
   509    509       }
   510         -  } {1 {PRIMARY KEY must be unique}}
          510  +  } {1 {UNIQUE constraint failed: tbl.a}}
   511    511     do_test trigger2-6.1e {
   512    512       execsql {
   513    513         SELECT * from tbl;
   514    514       }
   515    515     } {1 2 3 2 2 3}
   516    516     do_test trigger2-6.1f {
   517    517       execsql {
................................................................................
   519    519         SELECT * from tbl;
   520    520       }
   521    521     } {1 2 3 2 0 0}
   522    522     do_test trigger2-6.1g {
   523    523       catchsql {
   524    524         INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
   525    525       }
   526         -  } {1 {PRIMARY KEY must be unique}}
          526  +  } {1 {UNIQUE constraint failed: tbl.a}}
   527    527     do_test trigger2-6.1h {
   528    528       execsql {
   529    529         SELECT * from tbl;
   530    530       }
   531    531     } {}
   532    532     execsql {DELETE FROM tbl}
   533    533     
................................................................................
   547    547         SELECT * from tbl;
   548    548       }
   549    549     } {1 2 10 6 3 4}
   550    550     do_test trigger2-6.2b {
   551    551       catchsql {
   552    552         UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
   553    553       }
   554         -  } {1 {PRIMARY KEY must be unique}}
          554  +  } {1 {UNIQUE constraint failed: tbl.a}}
   555    555     do_test trigger2-6.2c {
   556    556       execsql {
   557    557         SELECT * from tbl;
   558    558       }
   559    559     } {1 2 10 6 3 4}
   560    560     do_test trigger2-6.2d {
   561    561       catchsql {
   562    562         UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
   563    563       }
   564         -  } {1 {PRIMARY KEY must be unique}}
          564  +  } {1 {UNIQUE constraint failed: tbl.a}}
   565    565     do_test trigger2-6.2e {
   566    566       execsql {
   567    567         SELECT * from tbl;
   568    568       }
   569    569     } {4 2 10 6 3 4}
   570    570     do_test trigger2-6.2f.1 {
   571    571       execsql {
................................................................................
   579    579         SELECT * FROM tbl;
   580    580       }
   581    581     } {1 3 10 2 3 4}
   582    582     do_test trigger2-6.2g {
   583    583       catchsql {
   584    584         UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
   585    585       }
   586         -  } {1 {PRIMARY KEY must be unique}}
          586  +  } {1 {UNIQUE constraint failed: tbl.a}}
   587    587     do_test trigger2-6.2h {
   588    588       execsql {
   589    589         SELECT * from tbl;
   590    590       }
   591    591     } {4 2 3 6 3 4}
   592    592     execsql {
   593    593       DROP TABLE tbl;

Changes to test/triggerC.test.

   153    153       INSERT INTO t1 VALUES(1,2,3,4,5);
   154    154       INSERT INTO t1 VALUES(6,7,8,9,10);
   155    155       INSERT INTO t1 VALUES(11,12,13,14,15);
   156    156     }
   157    157   } {}
   158    158   do_test triggerC-1.15 {
   159    159     catchsql { UPDATE OR ROLLBACK t1 SET a=100 }
   160         -} {1 {PRIMARY KEY must be unique}}
          160  +} {1 {UNIQUE constraint failed: t1.a}}
   161    161   
   162    162   
   163    163   #-------------------------------------------------------------------------
   164    164   # This block of tests, triggerC-2.*, tests that recursive trigger
   165    165   # programs (triggers that fire themselves) work. More specifically,
   166    166   # this block focuses on recursive INSERT triggers.
   167    167   #

Changes to test/unique.test.

    43     43       INSERT INTO t1(a,b,c) VALUES(1,2,3)
    44     44     }
    45     45   } {0 {}}
    46     46   do_test unique-1.3 {
    47     47     catchsql {
    48     48       INSERT INTO t1(a,b,c) VALUES(1,3,4)
    49     49     }
    50         -} {1 {PRIMARY KEY must be unique}}
           50  +} {1 {UNIQUE constraint failed: t1.a}}
    51     51   verify_ex_errcode unique-1.3b SQLITE_CONSTRAINT_PRIMARYKEY
    52     52   do_test unique-1.4 {
    53     53     execsql {
    54     54       SELECT * FROM t1 ORDER BY a;
    55     55     }
    56     56   } {1 2 3}
    57     57   do_test unique-1.5 {
    58     58     catchsql {
    59     59       INSERT INTO t1(a,b,c) VALUES(3,2,4)
    60     60     }
    61         -} {1 {column b is not unique}}
           61  +} {1 {UNIQUE constraint failed: t1.b}}
    62     62   verify_ex_errcode unique-1.5b SQLITE_CONSTRAINT_UNIQUE
    63     63   do_test unique-1.6 {
    64     64     execsql {
    65     65       SELECT * FROM t1 ORDER BY a;
    66     66     }
    67     67   } {1 2 3}
    68     68   do_test unique-1.7 {
................................................................................
    96     96       SELECT * FROM t2 ORDER BY a
    97     97     }
    98     98   } {0 {1 2 3 4}}
    99     99   do_test unique-2.3 {
   100    100     catchsql {
   101    101       INSERT INTO t2 VALUES(1,5);
   102    102     }
   103         -} {1 {column a is not unique}}
          103  +} {1 {UNIQUE constraint failed: t2.a}}
   104    104   verify_ex_errcode unique-2.3b SQLITE_CONSTRAINT_UNIQUE
   105    105   do_test unique-2.4 {
   106    106     catchsql {
   107    107       SELECT * FROM t2 ORDER BY a
   108    108     }
   109    109   } {0 {1 2 3 4}}
   110    110   do_test unique-2.5 {
................................................................................
   123    123       SELECT * FROM t2 ORDER BY a, b;
   124    124     }
   125    125   } {0 {1 2 1 5 3 4}}
   126    126   do_test unique-2.8 {
   127    127     catchsql {
   128    128       CREATE UNIQUE INDEX i2 ON t2(a);
   129    129     }
   130         -} {1 {indexed columns are not unique}}
          130  +} {1 {UNIQUE constraint failed: t2.a}}
   131    131   verify_ex_errcode unique-2.8b SQLITE_CONSTRAINT_UNIQUE
   132    132   do_test unique-2.9 {
   133    133     catchsql {
   134    134       CREATE INDEX i2 ON t2(a);
   135    135     }
   136    136   } {0 {}}
   137    137   integrity_check unique-2.10
................................................................................
   162    162     }
   163    163   } {0 {1 2 3 4 1 2 3 5}}
   164    164   do_test unique-3.4 {
   165    165     catchsql {
   166    166       INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
   167    167       SELECT * FROM t3 ORDER BY a,b,c,d;
   168    168     }
   169         -} {1 {columns a, c, d are not unique}}
          169  +} {1 {UNIQUE constraint failed: t3.a, t3.c, t3.d}}
   170    170   verify_ex_errcode unique-3.4b SQLITE_CONSTRAINT_UNIQUE
   171    171   integrity_check unique-3.5
   172    172   
   173    173   # Make sure NULLs are distinct as far as the UNIQUE tests are
   174    174   # concerned.
   175    175   #
   176    176   do_test unique-4.1 {
................................................................................
   217    217     catchsql {CREATE UNIQUE INDEX i4a ON t4(a,b)}
   218    218   } {0 {}}
   219    219   do_test unique-4.9 {
   220    220     catchsql {CREATE UNIQUE INDEX i4b ON t4(a,b,c)}
   221    221   } {0 {}}
   222    222   do_test unique-4.10 {
   223    223     catchsql {CREATE UNIQUE INDEX i4c ON t4(b)}
   224         -} {1 {indexed columns are not unique}}
          224  +} {1 {UNIQUE constraint failed: t4.b}}
   225    225   verify_ex_errcode unique-4.10b SQLITE_CONSTRAINT_UNIQUE
   226    226   integrity_check unique-4.99
   227    227   
   228    228   # Test the error message generation logic.  In particular, make sure we
   229    229   # do not overflow the static buffer used to generate the error message.
   230    230   #
   231    231   do_test unique-5.1 {
................................................................................
   250    250       SELECT * FROM t5;
   251    251     }
   252    252   } {1 2 3 4 5 6}
   253    253   do_test unique-5.2 {
   254    254     catchsql {
   255    255       INSERT INTO t5 VALUES(1,2,3,4,5,6);
   256    256     }
   257         -} {1 {columns first_column_with_long_name, second_column_with_long_name, third_column_with_long_name, fourth_column_with_long_name, fifth_column_with_long_name, sixth_column_with_long_name are not unique}}
          257  +} {1 {UNIQUE constraint failed: t5.first_column_with_long_name, t5.second_column_with_long_name, t5.third_column_with_long_name, t5.fourth_column_with_long_name, t5.fifth_column_with_long_name, t5.sixth_column_with_long_name}}
   258    258   verify_ex_errcode unique-5.2b SQLITE_CONSTRAINT_UNIQUE
   259    259   
   260    260   
   261    261   finish_test

Changes to test/update.test.

   448    448     }
   449    449   } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
   450    450   do_test update-10.3 {
   451    451     catchsql {
   452    452       UPDATE t1 SET a=1, e=10 WHERE f=7;
   453    453       SELECT * FROM t1;
   454    454     }
   455         -} {1 {PRIMARY KEY must be unique}}
          455  +} {1 {UNIQUE constraint failed: t1.a}}
   456    456   do_test update-10.4 {
   457    457     catchsql {
   458    458       SELECT * FROM t1;
   459    459     }
   460    460   } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
   461    461   do_test update-10.5 {
   462    462     catchsql {
................................................................................
   465    465     }
   466    466   } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
   467    467   do_test update-10.6 {
   468    468     catchsql {
   469    469       UPDATE t1 SET b=2, e=12 WHERE f=7;
   470    470       SELECT * FROM t1;
   471    471     }
   472         -} {1 {column b is not unique}}
          472  +} {1 {UNIQUE constraint failed: t1.b}}
   473    473   do_test update-10.7 {
   474    474     catchsql {
   475    475       SELECT * FROM t1;
   476    476     }
   477    477   } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
   478    478   do_test update-10.8 {
   479    479     catchsql {
................................................................................
   482    482     }
   483    483   } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
   484    484   do_test update-10.9 {
   485    485     catchsql {
   486    486       UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;
   487    487       SELECT * FROM t1;
   488    488     }
   489         -} {1 {columns c, d are not unique}}
          489  +} {1 {UNIQUE constraint failed: t1.c, t1.d}}
   490    490   do_test update-10.10 {
   491    491     catchsql {
   492    492       SELECT * FROM t1;
   493    493     }
   494    494   } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
   495    495   
   496    496   # Make sure we can handle a subquery in the where clause.

Changes to test/vtab1.test.

  1036   1036       CREATE VIRTUAL TABLE echo_c USING echo(c);
  1037   1037     }
  1038   1038   } {}
  1039   1039   
  1040   1040   # First test outside of a transaction.
  1041   1041   do_test vtab1.12-2 {
  1042   1042     catchsql { INSERT INTO echo_c SELECT * FROM b; }
  1043         -} {1 {echo-vtab-error: column a is not unique}}
         1043  +} {1 {echo-vtab-error: UNIQUE constraint failed: c.a}}
  1044   1044   do_test vtab1.12-2.1 {
  1045   1045     sqlite3_errmsg db
  1046         -} {echo-vtab-error: column a is not unique}
         1046  +} {echo-vtab-error: UNIQUE constraint failed: c.a}
  1047   1047   do_test vtab1.12-3 {
  1048   1048     execsql { SELECT * FROM c }
  1049   1049   } {3 G H}
  1050   1050   
  1051   1051   # Now the real test - wrapped in a transaction.
  1052   1052   do_test vtab1.12-4 {
  1053   1053     execsql  {BEGIN}
  1054   1054     catchsql { INSERT INTO echo_c SELECT * FROM b; }
  1055         -} {1 {echo-vtab-error: column a is not unique}}
         1055  +} {1 {echo-vtab-error: UNIQUE constraint failed: c.a}}
  1056   1056   do_test vtab1.12-5 {
  1057   1057     execsql { SELECT * FROM c }
  1058   1058   } {3 G H}
  1059   1059   do_test vtab1.12-6 {
  1060   1060     execsql { COMMIT }
  1061   1061     execsql { SELECT * FROM c }
  1062   1062   } {3 G H}

Changes to test/wal.test.

   318    318     execsql {
   319    319       CREATE TEMP TABLE t3(x UNIQUE);
   320    320       BEGIN;
   321    321         INSERT INTO t2 VALUES(3, 4);
   322    322         INSERT INTO t3 VALUES('abc');
   323    323     }
   324    324     catchsql { INSERT INTO t3 VALUES('abc') }
   325         -} {1 {column x is not unique}}
          325  +} {1 {UNIQUE constraint failed: t3.x}}
   326    326   do_test wal-5.5 {
   327    327     execsql {
   328    328       COMMIT;
   329    329       SELECT * FROM t2;
   330    330     }
   331    331   } {1 2 3 4}
   332    332   db close

Changes to test/without_rowid1.test.

    48     48   
    49     49   # Trying to insert a duplicate PRIMARY KEY fails.
    50     50   #
    51     51   do_test without_rowid1-1.21 {
    52     52     catchsql {
    53     53       INSERT INTO t1 VALUES('dynamic','phone','flipper','harvard');
    54     54     }
    55         -} {1 {PRIMARY KEY must be unique}}
           55  +} {1 {UNIQUE constraint failed: t1.c, t1.a}}
    56     56   
    57     57   # REPLACE INTO works, however.
    58     58   #
    59     59   do_execsql_test without_rowid1-1.22 {
    60     60     REPLACE INTO t1 VALUES('dynamic','phone','flipper','harvard');
    61     61     SELECT *, '|' FROM t1 ORDER BY c, a;
    62     62   } {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic phone flipper harvard | journal sherman gamma patriot |}

Changes to test/without_rowid3.test.

   101    101   
   102    102     CREATE TABLE t9(a REFERENCES nosuchtable, b);
   103    103     CREATE TABLE t10(a REFERENCES t9(c) /D/, b);
   104    104   }
   105    105   
   106    106   
   107    107   set FkeySimpleTests {
   108         -  1.1  "INSERT INTO t2 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          108  +  1.1  "INSERT INTO t2 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   109    109     1.2  "INSERT INTO t1 VALUES(1, 2)"      {0 {}}
   110    110     1.3  "INSERT INTO t2 VALUES(1, 3)"      {0 {}}
   111         -  1.4  "INSERT INTO t2 VALUES(2, 4)"      {1 {foreign key constraint failed}}
          111  +  1.4  "INSERT INTO t2 VALUES(2, 4)"      {1 {FOREIGN KEY constraint failed}}
   112    112     1.5  "INSERT INTO t2 VALUES(NULL, 4)"   {0 {}}
   113         -  1.6  "UPDATE t2 SET c=2 WHERE d=4"      {1 {foreign key constraint failed}}
          113  +  1.6  "UPDATE t2 SET c=2 WHERE d=4"      {1 {FOREIGN KEY constraint failed}}
   114    114     1.7  "UPDATE t2 SET c=1 WHERE d=4"      {0 {}}
   115    115     1.9  "UPDATE t2 SET c=1 WHERE d=4"      {0 {}}
   116    116     1.10 "UPDATE t2 SET c=NULL WHERE d=4"   {0 {}}
   117         -  1.11 "DELETE FROM t1 WHERE a=1"         {1 {foreign key constraint failed}}
   118         -  1.12 "UPDATE t1 SET a = 2"              {1 {foreign key constraint failed}}
          117  +  1.11 "DELETE FROM t1 WHERE a=1"         {1 {FOREIGN KEY constraint failed}}
          118  +  1.12 "UPDATE t1 SET a = 2"              {1 {FOREIGN KEY constraint failed}}
   119    119     1.13 "UPDATE t1 SET a = 1"              {0 {}}
   120    120   
   121         -  2.1  "INSERT INTO t4 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          121  +  2.1  "INSERT INTO t4 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   122    122     2.2  "INSERT INTO t3 VALUES(1, 2)"      {0 {}}
   123    123     2.3  "INSERT INTO t4 VALUES(1, 3)"      {0 {}}
   124    124   
   125         -  4.1  "INSERT INTO t8 VALUES(1, 3)"      {1 {foreign key constraint failed}}
          125  +  4.1  "INSERT INTO t8 VALUES(1, 3)"      {1 {FOREIGN KEY constraint failed}}
   126    126     4.2  "INSERT INTO t7 VALUES(2, 1)"      {0 {}}
   127    127     4.3  "INSERT INTO t8 VALUES(1, 3)"      {0 {}}
   128         -  4.4  "INSERT INTO t8 VALUES(2, 4)"      {1 {foreign key constraint failed}}
          128  +  4.4  "INSERT INTO t8 VALUES(2, 4)"      {1 {FOREIGN KEY constraint failed}}
   129    129     4.5  "INSERT INTO t8 VALUES(NULL, 4)"   {0 {}}
   130         -  4.6  "UPDATE t8 SET c=2 WHERE d=4"      {1 {foreign key constraint failed}}
          130  +  4.6  "UPDATE t8 SET c=2 WHERE d=4"      {1 {FOREIGN KEY constraint failed}}
   131    131     4.7  "UPDATE t8 SET c=1 WHERE d=4"      {0 {}}
   132    132     4.9  "UPDATE t8 SET c=1 WHERE d=4"      {0 {}}
   133    133     4.10 "UPDATE t8 SET c=NULL WHERE d=4"   {0 {}}
   134         -  4.11 "DELETE FROM t7 WHERE b=1"         {1 {foreign key constraint failed}}
   135         -  4.12 "UPDATE t7 SET b = 2"              {1 {foreign key constraint failed}}
          134  +  4.11 "DELETE FROM t7 WHERE b=1"         {1 {FOREIGN KEY constraint failed}}
          135  +  4.12 "UPDATE t7 SET b = 2"              {1 {FOREIGN KEY constraint failed}}
   136    136     4.13 "UPDATE t7 SET b = 1"              {0 {}}
   137         -  4.14 "INSERT INTO t8 VALUES('a', 'b')"  {1 {foreign key constraint failed}}
   138         -  4.15 "UPDATE t7 SET b = 5"              {1 {foreign key constraint failed}}
          137  +  4.14 "INSERT INTO t8 VALUES('a', 'b')"  {1 {FOREIGN KEY constraint failed}}
          138  +  4.15 "UPDATE t7 SET b = 5"              {1 {FOREIGN KEY constraint failed}}
   139    139     4.17 "UPDATE t7 SET a = 10"             {0 {}}
   140    140   
   141    141     5.1  "INSERT INTO t9 VALUES(1, 3)"      {1 {no such table: main.nosuchtable}}
   142    142     5.2  "INSERT INTO t10 VALUES(1, 3)"  
   143    143                               {1 {foreign key mismatch - "t10" referencing "t9"}}
   144    144   }
   145    145   
................................................................................
   211    211       INSERT INTO i VALUES(35);
   212    212       INSERT INTO j VALUES('35.0');
   213    213       SELECT j, typeof(j) FROM j;
   214    214     }
   215    215   } {35.0 text}
   216    216   do_test without_rowid3-1.5.2 {
   217    217     catchsql { DELETE FROM i }
   218         -} {1 {foreign key constraint failed}}
          218  +} {1 {FOREIGN KEY constraint failed}}
   219    219   
   220    220   # Same test using a regular primary key with integer affinity.
   221    221   drop_all_tables
   222    222   do_test without_rowid3-1.6.1 {
   223    223     execsql {
   224    224       CREATE TABLE i(i INT UNIQUE);
   225    225       CREATE TABLE j(j REFERENCES i(i));
................................................................................
   227    227       INSERT INTO j VALUES('35.0');
   228    228       SELECT j, typeof(j) FROM j;
   229    229       SELECT i, typeof(i) FROM i;
   230    230     }
   231    231   } {35.0 text 35 integer}
   232    232   do_test without_rowid3-1.6.2 {
   233    233     catchsql { DELETE FROM i }
   234         -} {1 {foreign key constraint failed}}
          234  +} {1 {FOREIGN KEY constraint failed}}
   235    235   
   236    236   # Use a collation sequence on the parent key.
   237    237   drop_all_tables
   238    238   do_test without_rowid3-1.7.1 {
   239    239     execsql {
   240    240       CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY) WITHOUT rowid;
   241    241       CREATE TABLE j(j TEXT COLLATE binary REFERENCES i(i));
   242    242       INSERT INTO i VALUES('SQLite');
   243    243       INSERT INTO j VALUES('sqlite');
   244    244     }
   245    245     catchsql { DELETE FROM i }
   246         -} {1 {foreign key constraint failed}}
          246  +} {1 {FOREIGN KEY constraint failed}}
   247    247   
   248    248   # Use the parent key collation even if it is default and the child key
   249    249   # has an explicit value.
   250    250   drop_all_tables
   251    251   do_test without_rowid3-1.7.2 {
   252    252     execsql {
   253    253       CREATE TABLE i(i TEXT PRIMARY KEY) WITHOUT rowid;  -- Colseq is "BINARY"
   254    254       CREATE TABLE j(j TEXT COLLATE nocase REFERENCES i(i));
   255    255       INSERT INTO i VALUES('SQLite');
   256    256     }
   257    257     catchsql { INSERT INTO j VALUES('sqlite') }
   258         -} {1 {foreign key constraint failed}}
          258  +} {1 {FOREIGN KEY constraint failed}}
   259    259   do_test without_rowid3-1.7.3 {
   260    260     execsql {
   261    261       INSERT INTO i VALUES('sqlite');
   262    262       INSERT INTO j VALUES('sqlite');
   263    263       DELETE FROM i WHERE i = 'SQLite';
   264    264     }
   265    265     catchsql { DELETE FROM i WHERE i = 'sqlite' }
   266         -} {1 {foreign key constraint failed}}
          266  +} {1 {FOREIGN KEY constraint failed}}
   267    267   
   268    268   #-------------------------------------------------------------------------
   269    269   # This section (test cases without_rowid3-2.*) contains tests to check that the
   270    270   # deferred foreign key constraint logic works.
   271    271   #
   272    272   proc without_rowid3-2-test {tn nocommit sql {res {}}} {
   273    273     if {$res eq "FKV"} {
   274         -    set expected {1 {foreign key constraint failed}}
          274  +    set expected {1 {FOREIGN KEY constraint failed}}
   275    275     } else {
   276    276       set expected [list 0 $res]
   277    277     }
   278    278     do_test without_rowid3-2.$tn [list catchsql $sql] $expected
   279    279     if {$nocommit} {
   280    280       do_test without_rowid3-2.${tn}c {
   281    281         catchsql COMMIT
   282         -    } {1 {foreign key constraint failed}}
          282  +    } {1 {FOREIGN KEY constraint failed}}
   283    283     }
   284    284   }
   285    285   
   286    286   without_rowid3-2-test 1 0 {
   287    287     CREATE TABLE node(
   288    288       nodeid PRIMARY KEY,
   289    289       parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
................................................................................
   371    371   without_rowid3-2-test 62 0   "DELETE FROM leaf"
   372    372   without_rowid3-2-test 63 0   "DELETE FROM node"
   373    373   without_rowid3-2-test 64 1   "INSERT INTO leaf VALUES('a', 1)"
   374    374   without_rowid3-2-test 65 1   "INSERT INTO leaf VALUES('b', 2)"
   375    375   without_rowid3-2-test 66 1   "INSERT INTO leaf VALUES('c', 1)"
   376    376   do_test without_rowid3-2-test-67 {
   377    377     catchsql          "INSERT INTO node SELECT parent, 3 FROM leaf"
   378         -} {1 {PRIMARY KEY must be unique}}
          378  +} {1 {UNIQUE constraint failed: node.nodeid}}
   379    379   without_rowid3-2-test 68 0 "COMMIT"           FKV
   380    380   without_rowid3-2-test 69 1   "INSERT INTO node VALUES(1, NULL)"
   381    381   without_rowid3-2-test 70 0   "INSERT INTO node VALUES(2, NULL)"
   382    382   without_rowid3-2-test 71 0 "COMMIT"
   383    383   
   384    384   without_rowid3-2-test 72 0 "BEGIN"
   385    385   without_rowid3-2-test 73 1   "DELETE FROM node"
................................................................................
   413    413       INSERT INTO ab VALUES(1, 'b');
   414    414       INSERT INTO cd VALUES(1, 'd');
   415    415       INSERT INTO ef VALUES(1, 'e');
   416    416     }
   417    417   } {}
   418    418   do_test without_rowid3-3.1.3 {
   419    419     catchsql { UPDATE ab SET a = 5 }
   420         -} {1 {constraint failed}}
          420  +} {1 {CHECK constraint failed: ef}}
   421    421   do_test without_rowid3-3.1.4 {
   422    422     execsql { SELECT * FROM ab }
   423    423   } {1 b}
   424    424   do_test without_rowid3-3.1.4 {
   425    425     execsql BEGIN;
   426    426     catchsql { UPDATE ab SET a = 5 }
   427         -} {1 {constraint failed}}
          427  +} {1 {CHECK constraint failed: ef}}
   428    428   do_test without_rowid3-3.1.5 {
   429    429     execsql COMMIT;
   430    430     execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
   431    431   } {1 b 1 d 1 e}
   432    432   
   433    433   do_test without_rowid3-3.2.1 {
   434    434     execsql BEGIN;
   435    435     catchsql { DELETE FROM ab }
   436         -} {1 {foreign key constraint failed}}
          436  +} {1 {FOREIGN KEY constraint failed}}
   437    437   do_test without_rowid3-3.2.2 {
   438    438     execsql COMMIT
   439    439     execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
   440    440   } {1 b 1 d 1 e}
   441    441   
   442    442   #-------------------------------------------------------------------------
   443    443   # Test cases without_rowid3-4.* test that recursive foreign key actions 
................................................................................
   540    540     execsql {
   541    541       CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
   542    542       CREATE TABLE t2(c INT PRIMARY KEY REFERENCES t1, b) WITHOUT rowid;
   543    543     }
   544    544   } {}
   545    545   do_test without_rowid3-7.2 {
   546    546     catchsql { INSERT INTO t2 VALUES(1, 'A'); }
   547         -} {1 {foreign key constraint failed}}
          547  +} {1 {FOREIGN KEY constraint failed}}
   548    548   do_test without_rowid3-7.3 {
   549    549     execsql { 
   550    550       INSERT INTO t1 VALUES(1, 2);
   551    551       INSERT INTO t1 VALUES(2, 3);
   552    552       INSERT INTO t2 VALUES(1, 'A');
   553    553     }
   554    554   } {}
   555    555   do_test without_rowid3-7.4 {
   556    556     execsql { UPDATE t2 SET c = 2 }
   557    557   } {}
   558    558   do_test without_rowid3-7.5 {
   559    559     catchsql { UPDATE t2 SET c = 3 }
   560         -} {1 {foreign key constraint failed}}
          560  +} {1 {FOREIGN KEY constraint failed}}
   561    561   do_test without_rowid3-7.6 {
   562    562     catchsql { DELETE FROM t1 WHERE a = 2 }
   563         -} {1 {foreign key constraint failed}}
          563  +} {1 {FOREIGN KEY constraint failed}}
   564    564   do_test without_rowid3-7.7 {
   565    565     execsql { DELETE FROM t1 WHERE a = 1 }
   566    566   } {}
   567    567   do_test without_rowid3-7.8 {
   568    568     catchsql { UPDATE t1 SET a = 3 }
   569         -} {1 {foreign key constraint failed}}
          569  +} {1 {FOREIGN KEY constraint failed}}
   570    570   
   571    571   #-------------------------------------------------------------------------
   572    572   # Test that it is not possible to enable/disable FK support while a
   573    573   # transaction is open.
   574    574   # 
   575    575   drop_all_tables
   576    576   proc without_rowid3-8-test {tn zSql value} {
................................................................................
   627    627     }
   628    628   } {1 2}
   629    629   do_test without_rowid3-9.1.4 {
   630    630     execsql { SELECT * FROM t1 }
   631    631   } {2 two}
   632    632   do_test without_rowid3-9.1.5 {
   633    633     catchsql { DELETE FROM t1 }
   634         -} {1 {foreign key constraint failed}}
          634  +} {1 {FOREIGN KEY constraint failed}}
   635    635   
   636    636   do_test without_rowid3-9.2.1 {
   637    637     execsql {
   638    638       CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;
   639    639       CREATE TABLE cc(d DEFAULT 3, e DEFAULT 1, f DEFAULT 2,
   640    640           FOREIGN KEY(f, d) REFERENCES pp 
   641    641           ON UPDATE SET DEFAULT 
................................................................................
   762    762     execsql "INSERT INTO t2 VALUES('two')"
   763    763   } {}
   764    764   do_test without_rowid3-12.1.3 { 
   765    765     execsql "UPDATE t1 SET b = 'four' WHERE b = 'one'"
   766    766   } {}
   767    767   do_test without_rowid3-12.1.4 { 
   768    768     catchsql "UPDATE t1 SET b = 'five' WHERE b = 'two'"
   769         -} {1 {foreign key constraint failed}}
          769  +} {1 {FOREIGN KEY constraint failed}}
   770    770   do_test without_rowid3-12.1.5 { 
   771    771     execsql "DELETE FROM t1 WHERE b = 'two'"
   772    772   } {}
   773    773   do_test without_rowid3-12.1.6 { 
   774    774     catchsql "COMMIT"
   775         -} {1 {foreign key constraint failed}}
          775  +} {1 {FOREIGN KEY constraint failed}}
   776    776   do_test without_rowid3-12.1.7 { 
   777    777     execsql {
   778    778       INSERT INTO t1 VALUES(2, 'two');
   779    779       COMMIT;
   780    780     }
   781    781   } {}
   782    782   
................................................................................
   810    810     execsql {
   811    811       DROP TABLE t2;
   812    812       CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);
   813    813       INSERT INTO t2 VALUES('a');
   814    814       INSERT INTO t2 VALUES('b');
   815    815     }
   816    816     catchsql { DELETE FROM t1 }
   817         -} {1 {foreign key constraint failed}}
          817  +} {1 {FOREIGN KEY constraint failed}}
   818    818   do_test without_rowid3-12.2.4 {
   819    819     execsql {
   820    820       SELECT * FROM t1;
   821    821       SELECT * FROM t2;
   822    822     }
   823    823   } {A B a b}
   824    824   
................................................................................
   848    848       UPDATE up SET c34 = 'possibly';
   849    849       SELECT c38, c39 FROM down;
   850    850       DELETE FROM down;
   851    851     }
   852    852   } {no possibly}
   853    853   do_test without_rowid3-12.3.3 {
   854    854     catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }
   855         -} {1 {foreign key constraint failed}}
          855  +} {1 {FOREIGN KEY constraint failed}}
   856    856   do_test without_rowid3-12.3.4 {
   857    857     execsql { 
   858    858       INSERT INTO up(c34, c35) VALUES('yes', 'no');
   859    859       INSERT INTO down(c39, c38) VALUES('yes', 'no');
   860    860     }
   861    861     catchsql { DELETE FROM up WHERE c34 = 'yes' }
   862         -} {1 {foreign key constraint failed}}
          862  +} {1 {FOREIGN KEY constraint failed}}
   863    863   do_test without_rowid3-12.3.5 {
   864    864     execsql { 
   865    865       DELETE FROM up WHERE c34 = 'possibly';
   866    866       SELECT c34, c35 FROM up;
   867    867       SELECT c39, c38 FROM down;
   868    868     }
   869    869   } {yes no yes no}
................................................................................
   882    882     }
   883    883   } {}
   884    884   foreach {tn stmt} {
   885    885     1   "REPLACE INTO pp VALUES(1, 4, 5)"
   886    886   } {
   887    887     do_test without_rowid3-13.1.$tn.1 {
   888    888       catchsql $stmt
   889         -  } {1 {foreign key constraint failed}}
          889  +  } {1 {FOREIGN KEY constraint failed}}
   890    890     do_test without_rowid3-13.1.$tn.2 {
   891    891       execsql {
   892    892         SELECT * FROM pp;
   893    893         SELECT * FROM cc;
   894    894       }
   895    895     } {1 2 3 2 3 1}
   896    896     do_test without_rowid3-13.1.$tn.3 {
   897    897       execsql BEGIN;
   898    898       catchsql $stmt
   899         -  } {1 {foreign key constraint failed}}
          899  +  } {1 {FOREIGN KEY constraint failed}}
   900    900     do_test without_rowid3-13.1.$tn.4 {
   901    901       execsql {
   902    902         COMMIT;
   903    903         SELECT * FROM pp;
   904    904         SELECT * FROM cc;
   905    905       }
   906    906     } {1 2 3 2 3 1}
................................................................................
   985    985       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid}      \
   986    986       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
   987    987               WITHOUT rowid}     \
   988    988       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
   989    989     ]
   990    990     do_test without_rowid3-14.2.2.3 {
   991    991       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
   992         -  } {1 {foreign key constraint failed}}
          992  +  } {1 {FOREIGN KEY constraint failed}}
   993    993     do_test without_rowid3-14.2.2.4 {
   994    994       execsql { INSERT INTO t4 VALUES(1, NULL) }
   995    995     } {}
   996    996     do_test without_rowid3-14.2.2.5 {
   997    997       catchsql { UPDATE t4 SET b = 5 }
   998         -  } {1 {foreign key constraint failed}}
          998  +  } {1 {FOREIGN KEY constraint failed}}
   999    999     do_test without_rowid3-14.2.2.6 {
  1000   1000       catchsql { UPDATE t4 SET b = 1 }
  1001   1001     } {0 {}}
  1002   1002     do_test without_rowid3-14.2.2.7 {
  1003   1003       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1004   1004     } {}
  1005   1005   
................................................................................
  1069   1069       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid}      \
  1070   1070       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
  1071   1071               WITHOUT rowid}     \
  1072   1072       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1073   1073     ]
  1074   1074     do_test without_rowid3-14.2tmp.2.3 {
  1075   1075       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
  1076         -  } {1 {foreign key constraint failed}}
         1076  +  } {1 {FOREIGN KEY constraint failed}}
  1077   1077     do_test without_rowid3-14.2tmp.2.4 {
  1078   1078       execsql { INSERT INTO t4 VALUES(1, NULL) }
  1079   1079     } {}
  1080   1080     do_test without_rowid3-14.2tmp.2.5 {
  1081   1081       catchsql { UPDATE t4 SET b = 5 }
  1082         -  } {1 {foreign key constraint failed}}
         1082  +  } {1 {FOREIGN KEY constraint failed}}
  1083   1083     do_test without_rowid3-14.2tmp.2.6 {
  1084   1084       catchsql { UPDATE t4 SET b = 1 }
  1085   1085     } {0 {}}
  1086   1086     do_test without_rowid3-14.2tmp.2.7 {
  1087   1087       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1088   1088     } {}
  1089   1089   
................................................................................
  1154   1154       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid}      \
  1155   1155       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
  1156   1156               WITHOUT rowid}     \
  1157   1157       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1158   1158     ]
  1159   1159     do_test without_rowid3-14.2aux.2.3 {
  1160   1160       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
  1161         -  } {1 {foreign key constraint failed}}
         1161  +  } {1 {FOREIGN KEY constraint failed}}
  1162   1162     do_test without_rowid3-14.2aux.2.4 {
  1163   1163       execsql { INSERT INTO t4 VALUES(1, NULL) }
  1164   1164     } {}
  1165   1165     do_test without_rowid3-14.2aux.2.5 {
  1166   1166       catchsql { UPDATE t4 SET b = 5 }
  1167         -  } {1 {foreign key constraint failed}}
         1167  +  } {1 {FOREIGN KEY constraint failed}}
  1168   1168     do_test without_rowid3-14.2aux.2.6 {
  1169   1169       catchsql { UPDATE t4 SET b = 1 }
  1170   1170     } {0 {}}
  1171   1171     do_test without_rowid3-14.2aux.2.7 {
  1172   1172       execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
  1173   1173     } {}
  1174   1174   }
................................................................................
  1186   1186       INSERT INTO t1 VALUES('a', 1);
  1187   1187       CREATE TABLE t2(x REFERENCES t1);
  1188   1188       INSERT INTO t2 VALUES('a');
  1189   1189     }
  1190   1190   } {}
  1191   1191   do_test without_rowid3-2.14.3.3 {
  1192   1192     catchsql { DROP TABLE t1 }
  1193         -} {1 {foreign key constraint failed}}
         1193  +} {1 {FOREIGN KEY constraint failed}}
  1194   1194   do_test without_rowid3-2.14.3.4 {
  1195   1195     execsql {
  1196   1196       DELETE FROM t2;
  1197   1197       DROP TABLE t1;
  1198   1198     }
  1199   1199   } {}
  1200   1200   do_test without_rowid3-2.14.3.4 {
................................................................................
  1205   1205       CREATE TABLE t1(x PRIMARY KEY) WITHOUT rowid;
  1206   1206       INSERT INTO t1 VALUES('x');
  1207   1207     }
  1208   1208     execsql { INSERT INTO t2 VALUES('x') }
  1209   1209   } {}
  1210   1210   do_test without_rowid3-2.14.3.6 {
  1211   1211     catchsql { DROP TABLE t1 }
  1212         -} {1 {foreign key constraint failed}}
         1212  +} {1 {FOREIGN KEY constraint failed}}
  1213   1213   do_test without_rowid3-2.14.3.7 {
  1214   1214     execsql {
  1215   1215       DROP TABLE t2;
  1216   1216       DROP TABLE t1;
  1217   1217     }
  1218   1218   } {}
  1219   1219   do_test without_rowid3-2.14.3.8 {
................................................................................
  1365   1365     } {}
  1366   1366     do_test without_rowid3-16.1.$tn.2 {
  1367   1367       execsql { UPDATE self SET a = 14, b = 14 }
  1368   1368     } {}
  1369   1369   
  1370   1370     do_test without_rowid3-16.1.$tn.3 {
  1371   1371       catchsql { UPDATE self SET b = 15 }
  1372         -  } {1 {foreign key constraint failed}}
         1372  +  } {1 {FOREIGN KEY constraint failed}}
  1373   1373   
  1374   1374     do_test without_rowid3-16.1.$tn.4 {
  1375   1375       catchsql { UPDATE self SET a = 15 }
  1376         -  } {1 {foreign key constraint failed}}
         1376  +  } {1 {FOREIGN KEY constraint failed}}
  1377   1377   
  1378   1378     do_test without_rowid3-16.1.$tn.5 {
  1379   1379       catchsql { UPDATE self SET a = 15, b = 16 }
  1380         -  } {1 {foreign key constraint failed}}
         1380  +  } {1 {FOREIGN KEY constraint failed}}
  1381   1381   
  1382   1382     do_test without_rowid3-16.1.$tn.6 {
  1383   1383       catchsql { UPDATE self SET a = 17, b = 17 }
  1384   1384     } {0 {}}
  1385   1385   
  1386   1386     do_test without_rowid3-16.1.$tn.7 {
  1387   1387       execsql { DELETE FROM self }
  1388   1388     } {}
  1389   1389     do_test without_rowid3-16.1.$tn.8 {
  1390   1390       catchsql { INSERT INTO self VALUES(20, 21) }
  1391         -  } {1 {foreign key constraint failed}}
         1391  +  } {1 {FOREIGN KEY constraint failed}}
  1392   1392   }
  1393   1393   
  1394   1394   # Additional tests cases using multi-column self-referential
  1395   1395   # FOREIGN KEY constraints.
  1396   1396   #
  1397   1397   drop_all_tables
  1398   1398   do_execsql_test without_rowid3-16.4.1.1 {
................................................................................
  1418   1418     SELECT *, '|' FROM t1 ORDER BY a, b;
  1419   1419   } {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
  1420   1420   
  1421   1421   do_test without_rowid3-16.4.1.4 {
  1422   1422     catchsql {
  1423   1423       UPDATE t1 SET c=11, e=22 WHERE a=1;
  1424   1424     }
  1425         -} {1 {foreign key constraint failed}}
         1425  +} {1 {FOREIGN KEY constraint failed}}
  1426   1426   
  1427   1427   do_test without_rowid3-16.4.1.5 {
  1428   1428     catchsql {
  1429   1429       UPDATE t1 SET d=11, f=22 WHERE a=1;
  1430   1430     }
  1431         -} {1 {foreign key constraint failed}}
         1431  +} {1 {FOREIGN KEY constraint failed}}
  1432   1432   
  1433   1433   do_execsql_test without_rowid3-16.4.1.6 {
  1434   1434     DELETE FROM t1 WHERE a=1;
  1435   1435     SELECT *, '|' FROM t1 ORDER BY a, b;
  1436   1436   } {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
  1437   1437   
  1438   1438   do_execsql_test without_rowid3-16.4.2.1 {
................................................................................
  1458   1458     SELECT *, '|' FROM t1 ORDER BY a, b;
  1459   1459   } {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
  1460   1460   
  1461   1461   do_test without_rowid3-16.4.2.4 {
  1462   1462     catchsql {
  1463   1463       UPDATE t1 SET c=11, e=22 WHERE a=1;
  1464   1464     }
  1465         -} {1 {foreign key constraint failed}}
         1465  +} {1 {FOREIGN KEY constraint failed}}
  1466   1466   
  1467   1467   do_test without_rowid3-16.4.2.5 {
  1468   1468     catchsql {
  1469   1469       UPDATE t1 SET d=11, f=22 WHERE a=1;
  1470   1470     }
  1471         -} {1 {foreign key constraint failed}}
         1471  +} {1 {FOREIGN KEY constraint failed}}
  1472   1472   
  1473   1473   do_execsql_test without_rowid3-16.4.2.6 {
  1474   1474     DELETE FROM t1 WHERE a=1;
  1475   1475     SELECT *, '|' FROM t1 ORDER BY a, b;
  1476   1476   } {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
  1477   1477   
  1478   1478   
................................................................................
  1526   1526   } {1 1 1 1 1}
  1527   1527   do_test without_rowid3-17.1.6 {
  1528   1528     catchsql {
  1529   1529       BEGIN;
  1530   1530         INSERT INTO one VALUES(0, 0, 0);
  1531   1531         UPDATE two SET e=e+1, f=f+1;
  1532   1532     }
  1533         -} {1 {foreign key constraint failed}}
         1533  +} {1 {FOREIGN KEY constraint failed}}
  1534   1534   do_test without_rowid3-17.1.7 {
  1535   1535     execsql { SELECT * FROM one }
  1536   1536   } {1 2 3 2 3 4 3 4 5 0 0 0}
  1537   1537   do_test without_rowid3-17.1.8 {
  1538   1538     execsql { SELECT * FROM two }
  1539   1539   } {1 2 3 2 3 4 3 4 5}
  1540   1540   do_test without_rowid3-17.1.9 {
................................................................................
  1682   1682     rename auth {}
  1683   1683     proc auth {args} {
  1684   1684       if {[lindex $args 1] == "long"} {return SQLITE_IGNORE}
  1685   1685       return SQLITE_OK
  1686   1686     }
  1687   1687     do_test without_rowid3-18.8 {
  1688   1688       catchsql { INSERT INTO short VALUES(1, 3, 2) }
  1689         -  } {1 {foreign key constraint failed}}
         1689  +  } {1 {FOREIGN KEY constraint failed}}
  1690   1690     do_test without_rowid3-18.9 {
  1691   1691       execsql { INSERT INTO short VALUES(1, 3, NULL) }
  1692   1692     } {}
  1693   1693     do_test without_rowid3-18.10 {
  1694   1694       execsql { SELECT * FROM short }
  1695   1695     } {1 3 2 1 3 {}}
  1696   1696     do_test without_rowid3-18.11 {
  1697   1697       catchsql { UPDATE short SET f = 2 WHERE f IS NULL }
  1698         -  } {1 {foreign key constraint failed}}
         1698  +  } {1 {FOREIGN KEY constraint failed}}
  1699   1699   
  1700   1700     db auth {}
  1701   1701     unset authargs
  1702   1702   }
  1703   1703   
  1704   1704   
  1705   1705   do_test without_rowid3-19.1 {
................................................................................
  1743   1743     3 "INSERT OR ABORT"
  1744   1744     4 "INSERT OR ROLLBACK"
  1745   1745     5 "INSERT OR REPLACE"
  1746   1746     6 "INSERT OR FAIL"
  1747   1747   } {
  1748   1748     do_test without_rowid3-20.2.$tn.1 {
  1749   1749       catchsql "$insert INTO cc VALUES(1, 2)"
  1750         -  } {1 {foreign key constraint failed}}
         1750  +  } {1 {FOREIGN KEY constraint failed}}
  1751   1751     do_test without_rowid3-20.2.$tn.2 {
  1752   1752       execsql { SELECT * FROM cc }
  1753   1753     } {}
  1754   1754     do_test without_rowid3-20.2.$tn.3 {
  1755   1755       execsql {
  1756   1756         BEGIN;
  1757   1757           INSERT INTO pp VALUES(2, 'two');
  1758   1758           INSERT INTO cc VALUES(1, 2);
  1759   1759       }
  1760   1760       catchsql "$insert INTO cc VALUES(3, 4)"
  1761         -  } {1 {foreign key constraint failed}}
         1761  +  } {1 {FOREIGN KEY constraint failed}}
  1762   1762     do_test without_rowid3-20.2.$tn.4 {
  1763   1763       execsql { COMMIT ; SELECT * FROM cc }
  1764   1764     } {1 2}
  1765   1765     do_test without_rowid3-20.2.$tn.5 {
  1766   1766       execsql { DELETE FROM cc ; DELETE FROM pp }
  1767   1767     } {}
  1768   1768   }
................................................................................
  1779   1779       execsql {
  1780   1780         INSERT INTO pp VALUES(2, 'two');
  1781   1781         INSERT INTO cc VALUES(1, 2);
  1782   1782       }
  1783   1783     } {}
  1784   1784     do_test without_rowid3-20.3.$tn.2 {
  1785   1785       catchsql "$update pp SET a = 1"
  1786         -  } {1 {foreign key constraint failed}}
         1786  +  } {1 {FOREIGN KEY constraint failed}}
  1787   1787     do_test without_rowid3-20.3.$tn.3 {
  1788   1788       execsql { SELECT * FROM pp }
  1789   1789     } {2 two}
  1790   1790     do_test without_rowid3-20.3.$tn.4 {
  1791   1791       catchsql "$update cc SET d = 1"
  1792         -  } {1 {foreign key constraint failed}}
         1792  +  } {1 {FOREIGN KEY constraint failed}}
  1793   1793     do_test without_rowid3-20.3.$tn.5 {
  1794   1794       execsql { SELECT * FROM cc }
  1795   1795     } {1 2}
  1796   1796     do_test without_rowid3-20.3.$tn.6 {
  1797   1797       execsql {
  1798   1798         BEGIN;
  1799   1799           INSERT INTO pp VALUES(3, 'three');
  1800   1800       }
  1801   1801       catchsql "$update pp SET a = 1 WHERE a = 2"
  1802         -  } {1 {foreign key constraint failed}}
         1802  +  } {1 {FOREIGN KEY constraint failed}}
  1803   1803     do_test without_rowid3-20.3.$tn.7 {
  1804   1804       execsql { COMMIT ; SELECT * FROM pp }
  1805   1805     } {2 two 3 three}
  1806   1806     do_test without_rowid3-20.3.$tn.8 {
  1807   1807       execsql {
  1808   1808         BEGIN;
  1809   1809           INSERT INTO cc VALUES(2, 2);
  1810   1810       }
  1811   1811       catchsql "$update cc SET d = 1 WHERE c = 1"
  1812         -  } {1 {foreign key constraint failed}}
         1812  +  } {1 {FOREIGN KEY constraint failed}}
  1813   1813     do_test without_rowid3-20.3.$tn.9 {
  1814   1814       execsql { COMMIT ; SELECT * FROM cc }
  1815   1815     } {1 2 2 2}
  1816   1816     do_test without_rowid3-20.3.$tn.10 {
  1817   1817       execsql { DELETE FROM cc ; DELETE FROM pp }
  1818   1818     } {}
  1819   1819   }
................................................................................
  1831   1831       CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;
  1832   1832       CREATE TABLE t2(e REFERENCES t1, f);
  1833   1833       CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));
  1834   1834     }
  1835   1835   } {}
  1836   1836   do_test without_rowid3-genfkey.1.2 {
  1837   1837     catchsql { INSERT INTO t2 VALUES(1, 2) }
  1838         -} {1 {foreign key constraint failed}}
         1838  +} {1 {FOREIGN KEY constraint failed}}
  1839   1839   do_test without_rowid3-genfkey.1.3 {
  1840   1840     execsql {
  1841   1841       INSERT INTO t1 VALUES(1, 2, 3);
  1842   1842       INSERT INTO t2 VALUES(1, 2);
  1843   1843     }
  1844   1844   } {}
  1845   1845   do_test without_rowid3-genfkey.1.4 {
  1846   1846     execsql { INSERT INTO t2 VALUES(NULL, 3) }
  1847   1847   } {}
  1848   1848   do_test without_rowid3-genfkey.1.5 {
  1849   1849     catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }
  1850         -} {1 {foreign key constraint failed}}
         1850  +} {1 {FOREIGN KEY constraint failed}}
  1851   1851   do_test without_rowid3-genfkey.1.6 {
  1852   1852     execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }
  1853   1853   } {}
  1854   1854   do_test without_rowid3-genfkey.1.7 {
  1855   1855     execsql { UPDATE t2 SET e = NULL WHERE f = 3 }
  1856   1856   } {}
  1857   1857   do_test without_rowid3-genfkey.1.8 {
  1858   1858     catchsql { UPDATE t1 SET a = 10 }
  1859         -} {1 {foreign key constraint failed}}
         1859  +} {1 {FOREIGN KEY constraint failed}}
  1860   1860   do_test without_rowid3-genfkey.1.9 {
  1861   1861     catchsql { UPDATE t1 SET a = NULL }
  1862         -} {1 {t1.a may not be NULL}}
         1862  +} {1 {NOT NULL constraint failed: t1.a}}
  1863   1863   do_test without_rowid3-genfkey.1.10 {
  1864   1864     catchsql { DELETE FROM t1 }
  1865         -} {1 {foreign key constraint failed}}
         1865  +} {1 {FOREIGN KEY constraint failed}}
  1866   1866   do_test without_rowid3-genfkey.1.11 {
  1867   1867     execsql { UPDATE t2 SET e = NULL }
  1868   1868   } {}
  1869   1869   do_test without_rowid3-genfkey.1.12 {
  1870   1870     execsql { 
  1871   1871       UPDATE t1 SET a = 10;
  1872   1872       DELETE FROM t1;
................................................................................
  1878   1878       INSERT INTO t3 VALUES(1, NULL, NULL);
  1879   1879       INSERT INTO t3 VALUES(1, 2, NULL);
  1880   1880       INSERT INTO t3 VALUES(1, NULL, 3);
  1881   1881     }
  1882   1882   } {}
  1883   1883   do_test without_rowid3-genfkey.1.14 {
  1884   1884     catchsql { INSERT INTO t3 VALUES(3, 1, 4) }
  1885         -} {1 {foreign key constraint failed}}
         1885  +} {1 {FOREIGN KEY constraint failed}}
  1886   1886   do_test without_rowid3-genfkey.1.15 {
  1887   1887     execsql { 
  1888   1888       INSERT INTO t1 VALUES(1, 1, 4);
  1889   1889       INSERT INTO t3 VALUES(3, 1, 4);
  1890   1890     }
  1891   1891   } {}
  1892   1892   do_test without_rowid3-genfkey.1.16 {
  1893   1893     catchsql { DELETE FROM t1 }
  1894         -} {1 {foreign key constraint failed}}
         1894  +} {1 {FOREIGN KEY constraint failed}}
  1895   1895   do_test without_rowid3-genfkey.1.17 {
  1896   1896     catchsql { UPDATE t1 SET b = 10}
  1897         -} {1 {foreign key constraint failed}}
         1897  +} {1 {FOREIGN KEY constraint failed}}
  1898   1898   do_test without_rowid3-genfkey.1.18 {
  1899   1899     execsql { UPDATE t1 SET a = 10}
  1900   1900   } {}
  1901   1901   do_test without_rowid3-genfkey.1.19 {
  1902   1902     catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}
  1903         -} {1 {foreign key constraint failed}}
         1903  +} {1 {FOREIGN KEY constraint failed}}
  1904   1904   
  1905   1905   drop_all_tables
  1906   1906   do_test without_rowid3-genfkey.2.1 {
  1907   1907     execsql {
  1908   1908       CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;
  1909   1909       CREATE TABLE t2(e REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE, f);
  1910   1910       CREATE TABLE t3(g, h, i, 
................................................................................
  2009   2009       INSERT INTO tdd08_b VALUES(100,200,300);
  2010   2010     }
  2011   2011   } {}
  2012   2012   do_test without_rowid3-dd08e5.1.2 {
  2013   2013     catchsql {
  2014   2014       DELETE FROM tdd08;
  2015   2015     }
  2016         -} {1 {foreign key constraint failed}}
         2016  +} {1 {FOREIGN KEY constraint failed}}
  2017   2017   do_test without_rowid3-dd08e5.1.3 {
  2018   2018     execsql {
  2019   2019       SELECT * FROM tdd08;
  2020   2020     }
  2021   2021   } {200 300}
  2022   2022   do_test without_rowid3-dd08e5.1.4 {
  2023   2023     catchsql {
  2024   2024       INSERT INTO tdd08_b VALUES(400,500,300);
  2025   2025     }
  2026         -} {1 {foreign key constraint failed}}
         2026  +} {1 {FOREIGN KEY constraint failed}}
  2027   2027   do_test without_rowid3-dd08e5.1.5 {
  2028   2028     catchsql {
  2029   2029       UPDATE tdd08_b SET x=x+1;
  2030   2030     }
  2031         -} {1 {foreign key constraint failed}}
         2031  +} {1 {FOREIGN KEY constraint failed}}
  2032   2032   do_test without_rowid3-dd08e5.1.6 {
  2033   2033     catchsql {
  2034   2034       UPDATE tdd08 SET a=a+1;
  2035   2035     }
  2036         -} {1 {foreign key constraint failed}}
         2036  +} {1 {FOREIGN KEY constraint failed}}
  2037   2037   
  2038   2038   #-------------------------------------------------------------------------
  2039   2039   # Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba
  2040   2040   # fixed.
  2041   2041   #
  2042   2042   do_test without_rowid3-ce7c13.1.1 {
  2043   2043     execsql {
................................................................................
  2050   2050       SELECT * FROM tce71, tce72;
  2051   2051     }
  2052   2052   } {100 200 300 100 200}
  2053   2053   do_test without_rowid3-ce7c13.1.2 {
  2054   2054     catchsql {
  2055   2055       UPDATE tce71 set b = 201 where a = 100;
  2056   2056     }
  2057         -} {1 {foreign key constraint failed}}
         2057  +} {1 {FOREIGN KEY constraint failed}}
  2058   2058   do_test without_rowid3-ce7c13.1.3 {
  2059   2059     catchsql {
  2060   2060       UPDATE tce71 set a = 101 where a = 100;
  2061   2061     }
  2062         -} {1 {foreign key constraint failed}}
         2062  +} {1 {FOREIGN KEY constraint failed}}
  2063   2063   do_test without_rowid3-ce7c13.1.4 {
  2064   2064     execsql {
  2065   2065       CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b)) WITHOUT rowid;
  2066   2066       INSERT INTO tce73 VALUES(100,200);
  2067   2067       CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));
  2068   2068       INSERT INTO tce74 VALUES(300,100,200);
  2069   2069       UPDATE tce73 set b = 200 where a = 100;
................................................................................
  2070   2070       SELECT * FROM tce73, tce74;
  2071   2071     }
  2072   2072   } {100 200 300 100 200}
  2073   2073   do_test without_rowid3-ce7c13.1.5 {
  2074   2074     catchsql {
  2075   2075       UPDATE tce73 set b = 201 where a = 100;
  2076   2076     }
  2077         -} {1 {foreign key constraint failed}}
         2077  +} {1 {FOREIGN KEY constraint failed}}
  2078   2078   do_test without_rowid3-ce7c13.1.6 {
  2079   2079     catchsql {
  2080   2080       UPDATE tce73 set a = 101 where a = 100;
  2081   2081     }
  2082         -} {1 {foreign key constraint failed}}
         2082  +} {1 {FOREIGN KEY constraint failed}}
  2083   2083   
  2084   2084   finish_test

Changes to test/without_rowid4.test.

   498    498         SELECT * from tbl;
   499    499       }
   500    500     } {1 2 3}
   501    501     do_test without_rowid4-6.1b {
   502    502       catchsql {
   503    503         INSERT OR ABORT INTO tbl values (2, 2, 3);
   504    504       }
   505         -  } {1 {PRIMARY KEY must be unique}}
          505  +  } {1 {UNIQUE constraint failed: tbl.a}}
   506    506     do_test without_rowid4-6.1c {
   507    507       execsql {
   508    508         SELECT * from tbl;
   509    509       }
   510    510     } {1 2 3}
   511    511     do_test without_rowid4-6.1d {
   512    512       catchsql {
   513    513         INSERT OR FAIL INTO tbl values (2, 2, 3);
   514    514       }
   515         -  } {1 {PRIMARY KEY must be unique}}
          515  +  } {1 {UNIQUE constraint failed: tbl.a}}
   516    516     do_test without_rowid4-6.1e {
   517    517       execsql {
   518    518         SELECT * from tbl;
   519    519       }
   520    520     } {1 2 3 2 2 3}
   521    521     do_test without_rowid4-6.1f {
   522    522       execsql {
................................................................................
   524    524         SELECT * from tbl;
   525    525       }
   526    526     } {1 2 3 2 0 0}
   527    527     do_test without_rowid4-6.1g {
   528    528       catchsql {
   529    529         INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
   530    530       }
   531         -  } {1 {PRIMARY KEY must be unique}}
          531  +  } {1 {UNIQUE constraint failed: tbl.a}}
   532    532     do_test without_rowid4-6.1h {
   533    533       execsql {
   534    534         SELECT * from tbl;
   535    535       }
   536    536     } {}
   537    537     execsql {DELETE FROM tbl}
   538    538     
................................................................................
   552    552         SELECT * from tbl;
   553    553       }
   554    554     } {1 2 10 6 3 4}
   555    555     do_test without_rowid4-6.2b {
   556    556       catchsql {
   557    557         UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
   558    558       }
   559         -  } {1 {PRIMARY KEY must be unique}}
          559  +  } {1 {UNIQUE constraint failed: tbl.a}}
   560    560     do_test without_rowid4-6.2c {
   561    561       execsql {
   562    562         SELECT * from tbl;
   563    563       }
   564    564     } {1 2 10 6 3 4}
   565    565     do_test without_rowid4-6.2d {
   566    566       catchsql {
   567    567         UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
   568    568       }
   569         -  } {1 {PRIMARY KEY must be unique}}
          569  +  } {1 {UNIQUE constraint failed: tbl.a}}
   570    570     do_test without_rowid4-6.2e {
   571    571       execsql {
   572    572         SELECT * from tbl;
   573    573       }
   574    574     } {4 2 10 6 3 4}
   575    575     do_test without_rowid4-6.2f.1 {
   576    576       execsql {
................................................................................
   584    584         SELECT * FROM tbl;
   585    585       }
   586    586     } {1 3 10 2 3 4}
   587    587     do_test without_rowid4-6.2g {
   588    588       catchsql {
   589    589         UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
   590    590       }
   591         -  } {1 {PRIMARY KEY must be unique}}
          591  +  } {1 {UNIQUE constraint failed: tbl.a}}
   592    592     do_test without_rowid4-6.2h {
   593    593       execsql {
   594    594         SELECT * from tbl;
   595    595       }
   596    596     } {4 2 3 6 3 4}
   597    597     execsql {
   598    598       DROP TABLE tbl;