]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Better error messages on constraint violations. Additional tests and bug fixes
authordrh <drh@noemail.net>
Wed, 29 Jan 2003 18:46:51 +0000 (18:46 +0000)
committerdrh <drh@noemail.net>
Wed, 29 Jan 2003 18:46:51 +0000 (18:46 +0000)
for the callback-free API. (CVS 854)

FossilOrigin-Name: ccc82f1ab4539a60ee5cc2625743c5389f9ccd8e

22 files changed:
manifest
manifest.uuid
src/build.c
src/expr.c
src/insert.c
src/main.c
src/parse.y
src/printf.c
src/sqliteInt.h
src/test1.c
src/vdbe.c
src/vdbe.h
test/capi2.test
test/conflict.test
test/copy.test
test/intpkey.test
test/misc1.test
test/notnull.test
test/table.test
test/trigger2.test
test/unique.test
test/update.test

index 611f847ef957f033f25af163aeca9bc021b10432..ce629e696c72b5df7cd2efa8e950cbdd2fa133aa 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\scallback-free\sAPI\sis\snow\sworking,\sthough\smuch\smore\stesting\sis\sneed.\s(CVS\s853)
-D 2003-01-29T14:06:08
+C Better\serror\smessages\son\sconstraint\sviolations.\s\sAdditional\stests\sand\sbug\sfixes\nfor\sthe\scallback-free\sAPI.\s(CVS\s854)
+D 2003-01-29T18:46:52
 F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -21,31 +21,31 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
 F src/auth.c 9c2db0bc7707f2d2e227f47e3d557b41d44ade75
 F src/btree.c eb4f430b062500d7533c031097d3ff8824eca3ba
 F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda
-F src/build.c 1a4c0d71863f0aa0be7e5a2148b103c3e761c771
+F src/build.c 6e0310086b8e2deef74f0d4fb3297c4e8fcf6222
 F src/delete.c cbd499f3f9297504c42e328af89bef1a2113d04c
 F src/encode.c faf03741efe921755ec371cf4a6984536de00042
-F src/expr.c 382839b92cb66a34cfa71cf1d2bc8fb818226c90
+F src/expr.c 359ae28321ce78d20ef38f4fd6ee7429b100186f
 F src/func.c 90c583f0b91220f7cd411a2407deaf9327245d63
 F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
-F src/insert.c db954e955970795819145a3649fd2ad116a58890
-F src/main.c f1c86161875337c6421cf988bf5595eda515851a
+F src/insert.c 13c2ef8984ce0f38701a8af89e4ba7a3c86c0701
+F src/main.c 764a72e6a4f021ae1d3db7e82dab625075f4fedb
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c ed27e178e0c4b71f2807da81b8851f0fadc50778
 F src/os.h afa3e096213bad86845f8bdca81a9e917505e401
 F src/pager.c 95f5c5c775ed47e837ce02b407d80527d93e6c43
 F src/pager.h 540833e8cb826b80ce2e39aa917deee5e12db626
-F src/parse.y aea0819c07ec9c81b810039df9be9d5705b1e497
-F src/printf.c e8e9a0605602cb1a3a2dc754e0978fa9064ecee7
+F src/parse.y cdaed5009423d851708848bd279147c268e6022e
+F src/printf.c f8fd911a8738f9b2eb07aca2870473d34707055d
 F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
 F src/select.c 13b8e5ea8aacaf204468518aed7b054a583f2f25
 F src/shell.c cbb29252f0bd7b144d1e3126e64e17e5a314f2fd
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in 6f648803f2ffb9beb35cb1cfa42b323d55519171
-F src/sqliteInt.h d4d1eb361e2121d62ec320e53e32b42569b7613e
+F src/sqliteInt.h f22092ed33fea784f58bcd57b90c0babd16a0e29
 F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
 F src/tclsqlite.c 9f2c00a92338c51171ded8943bd42d77f7e69e64
-F src/test1.c 2ef543e6e49329d5254c0ad4b09586a4eaad5ed4
+F src/test1.c a24735c6e6364ccaa73ce3b106859fb325b076d9
 F src/test2.c 03f05e984c8e2f2badc44644d42baf72b249096b
 F src/test3.c c12ea7f1c3fbbd58904e81e6cb10ad424e6fc728
 F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
@@ -53,8 +53,8 @@ F src/tokenize.c bc40937d6666f188037aa3e54f0a2661a6fef6d1
 F src/trigger.c da142decd2808bc39e801f3bb1f161dbc2bd4005
 F src/update.c f06afa9bf1f777d17702e0f6e33cf44c44bc4f75
 F src/util.c 757875a366be838d96c09f255631596a2f558fca
-F src/vdbe.c a9dd0f68751587eeff81afb404f9f63e4ac6185a
-F src/vdbe.h 162071f1dd0b43236930712f4238c59a6a0de298
+F src/vdbe.c de4c00495ed6d3c7798153996ea174881fc29b42
+F src/vdbe.h ed43771f1dc2b994d5c484fdf2eab357c6ef0ee3
 F src/where.c 5bf7f1e1d756ab3d25a18b24bb42106cb8e14d18
 F test/all.test 873d30e25a41b3aa48fec5633a7ec1816e107029
 F test/auth.test 95aeda24f76b6fd028bdb3d6ae1e30b153d942fe
@@ -64,9 +64,9 @@ F test/btree.test 10e75aec120ecefc0edc4c912a0980a43db1b6c2
 F test/btree2.test e3b81ec33dc2f89b3e6087436dfe605b870c9080
 F test/btree3.test e597fb59be2ac0ea69c62aaa2064e998e528b665
 F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
-F test/capi2.test 158d76afd093d71b4aac860c0d12511706b1d8d0
-F test/conflict.test 0173a12a257f73bac2c9d53ad44cac9b15ea517e
-F test/copy.test 55d60a4d5ed342a0fa08b7cd07d46d43ea0d0d7f
+F test/capi2.test 21f73319ae288d874f68787b5af4bd2022e25dcb
+F test/conflict.test d7d9dbea9909c1b843f9e89c8318fdb7ca07a5e5
+F test/copy.test 73df5ed3112e858e006a8b7ddb4c9bab6a25d0fb
 F test/delete.test 5821a95a66061ae09723a88938f23d10d8a881ad
 F test/expr.test 290e2617b89b5c5e3bf71f19367d285102128be4
 F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
@@ -76,7 +76,7 @@ F test/in.test 15428c85d141edda7543bfc3f9a32ce65193717b
 F test/index.test 2a5a1b654f50ca0768fb10ae44b72e6a776b1f18
 F test/insert.test a122afb86911e77c181d912348866a5b1a61eeab
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
-F test/intpkey.test f3620158fd7963af1306b01047277f10ae91a30b
+F test/intpkey.test e0e283b0cbeaa97eeee183e1cdb91fa73d720866
 F test/ioerr.test 57d9bffaca18b34f9e976f786eadc2591d6efc6a
 F test/join.test 178b25dc3c5be6cbdd195b904e66bee62475d0bf
 F test/limit.test 9f26f874bc765df5b3f5c92d26d1b12eac6d4cf9
@@ -85,9 +85,9 @@ F test/main.test c66b564554b770ee7fdbf6a66c0cd90329bc2c85
 F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
 F test/memleak.test b4f59aa44488793b00feff2011d77d0f05b22468
 F test/minmax.test 29bc5727c3e4c792d5c4745833dd4b505905819e
-F test/misc1.test 9f9e8b6f824b4c388ce3ad0cabdc873e0d22e28e
+F test/misc1.test 6d61d1282f2d1f1c184f50e0373d9ffc7d42f744
 F test/misuse.test a3aa2b18a97e4c409a1fcaff5151a4dd804a0162
-F test/notnull.test b1f3e42fc475b0b5827b27b2e9b562081995ff30
+F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
 F test/null.test 5c2b57307e4b6178aae825eb65ddbee01e76b0fd
 F test/pager.test d3a2e2f00999f97e056822a39d5ee2fad18bf12c
 F test/pragma.test 0ca0773e2559ec9715f72d90695554dc3368e8f2
@@ -103,18 +103,18 @@ F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac
 F test/select6.test efb8d0c07a440441db87db2c4ade6904e1407e85
 F test/sort.test 61a729023ae4ac3be9b225dc0be026fb43fec4e6
 F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
-F test/table.test 2a94f55b39008daa79b81f37aaf7be81386ca71e
+F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
 F test/tableapi.test 3c80421a889e1d106df16e5800fa787f0d2914a6
 F test/tclsqlite.test 2441ab135e5af85110326b3e3b057e7257c144e1
 F test/temptable.test 03b7bdb7d6ce2c658ad20c94b037652c6cad34e0
 F test/tester.tcl 6f603d90881bd835ea27c568a7fecaa57dce91cc
 F test/trans.test 10b53c77e2cc4ad9529c15fdcb390b8d5722ea65
 F test/trigger1.test ec1da76e1a9f618deb96e505f459dcf8a23f2247
-F test/trigger2.test ee346d8c612e7f847c9543058f1b89d094d27ffb
+F test/trigger2.test 592daa956dc62b19930fe673405e389a80c5764e
 F test/trigger3.test 870afef7997a5b86bf3ea893ce0c2e85d6356c72
 F test/trigger4.test 9a5c1406344d743020c2753ae8d6dfe6eb75f818
-F test/unique.test 572aa791327c1e8d797932263e9d67f176cfdb44
-F test/update.test 7ffb062d580a972e7870d0f51d5af3ab9bfeae08
+F test/unique.test 22a46df72a3e0a3fd1a2d39e96fb59f18448dd5f
+F test/update.test e7b224f4ed652b3d6defdd6174ebc2ccd894307a
 F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe
 F test/version.test 605fd0d7e7d571370c32b12dbf395b58953de246
 F test/view.test c64fa39ea57f3c2066c854290f032ad13b23b83d
@@ -155,7 +155,7 @@ F www/speed.tcl 4d463e2aea41f688ed320a937f93ff885be918c3
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 065fa818ffc8d7562889172acea16e4e44e773ef
-R 0f5c157d8052fdb9f4b710d54301a2ba
+P 162b259188e6967fe9c3722da26b81aab5655d83
+R 715f66b82d831caba169ad25678a9655
 U drh
-Z b732b2962b2533af4ee430d0fd255a71
+Z 12bd865865cbc9da0a476fa88511badb
index 841615f10c3b44f940207bd9c40c3e9981dbb90f..54d77cb4ad8be86563dd93fa929610a8f45a7dce 100644 (file)
@@ -1 +1 @@
-162b259188e6967fe9c3722da26b81aab5655d83
\ No newline at end of file
+ccc82f1ab4539a60ee5cc2625743c5389f9ccd8e
\ No newline at end of file
index 9afb8a14a95e1c9f4dbf8adfd0b61039c020e6ad..4e7bf7400b917b855b031fa15d566f98b8d9a013 100644 (file)
@@ -25,7 +25,7 @@
 **     ROLLBACK
 **     PRAGMA
 **
-** $Id: build.c,v 1.126 2003/01/28 23:13:11 drh Exp $
+** $Id: build.c,v 1.127 2003/01/29 18:46:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -91,7 +91,6 @@ void sqliteExec(Parse *pParse){
       }
       rc = sqliteVdbeFinalize(v, &pParse->zErrMsg);
       if( rc ) pParse->nErr++;
-      sqliteVdbeDelete(v);
       pParse->pVdbe = 0;
       pParse->rc = rc;
       if( rc ) pParse->nErr++;
@@ -100,6 +99,8 @@ void sqliteExec(Parse *pParse){
     }
     pParse->colNamesSet = 0;
     pParse->schemaVerified = 0;
+  }else if( pParse->useCallback==0 ){
+    pParse->rc = SQLITE_ERROR;
   }
   pParse->nTab = 0;
   pParse->nMem = 0;
@@ -1666,6 +1667,7 @@ void sqliteCreateIndex(
       sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0);
       if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex);
       sqliteVdbeAddOp(v, OP_IdxPut, 1, pIndex->onError!=OE_None);
+      sqliteVdbeChangeP3(v, -1, "indexed columns are not unique", P3_STATIC);
       sqliteVdbeAddOp(v, OP_Next, 2, lbl1);
       sqliteVdbeResolveLabel(v, lbl2);
       sqliteVdbeAddOp(v, OP_Close, 2, 0);
index 415cc3a1f7b2e8a5a1f15e41d23799442dd7298a..6b431a6da6cf95846b4404b26d222ec5fce272b5 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.86 2003/01/18 20:11:07 drh Exp $
+** $Id: expr.c,v 1.87 2003/01/29 18:46:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1216,7 +1216,7 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
       } else {
          assert( pExpr->iColumn == OE_Ignore );
          sqliteVdbeAddOp(v, OP_Goto, 0, pParse->trigStack->ignoreJump);
-         sqliteVdbeChangeP3(v, -1, "(IGNORE jump)", -1);
+         sqliteVdbeChangeP3(v, -1, "(IGNORE jump)", 0);
       }
     }
     break;
index 93a073b5012f77e6185c84a35bb84ff1ccb03c3d..f90e2ab0d198987aefdaa45352f9d42560b3b0d6 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle INSERT statements in SQLite.
 **
-** $Id: insert.c,v 1.71 2003/01/13 23:27:33 drh Exp $
+** $Id: insert.c,v 1.72 2003/01/29 18:46:52 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -657,7 +657,11 @@ void sqliteGenerateConstraintChecks(
       case OE_Rollback:
       case OE_Abort:
       case OE_Fail: {
+        char *zMsg = 0;
         sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
+        sqliteSetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName,
+                        " may not be NULL", 0);
+        sqliteVdbeChangeP3(v, -1, zMsg, P3_DYNAMIC);
         break;
       }
       case OE_Ignore: {
@@ -707,6 +711,7 @@ void sqliteGenerateConstraintChecks(
         case OE_Abort:
         case OE_Fail: {
           sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
+          sqliteVdbeChangeP3(v, -1, "PRIMARY KEY must be unique", P3_STATIC);
           break;
         }
         case OE_Ignore: {
@@ -760,6 +765,7 @@ void sqliteGenerateConstraintChecks(
       case OE_Abort:
       case OE_Fail: {
         sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
+        sqliteVdbeChangeP3(v, -1, "uniqueness constraint failed", P3_STATIC);
         break;
       }
       case OE_Ignore: {
index 7b5c76e5ebcc0e5f98a5a22a310f6f3e0fa82677..9a4b3f8724fd6b017d57a7d482d7b7294b46cc97 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.111 2003/01/29 14:06:08 drh Exp $
+** $Id: main.c,v 1.112 2003/01/29 18:46:53 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -716,7 +716,9 @@ int sqlite_finalize(
   sqlite_vm *pVm,            /* The virtual machine to be destroyed */
   char **pzErrMsg            /* OUT: Write error messages here */
 ){
-  return sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
+  int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
+  sqliteStrRealloc(pzErrMsg);
+  return rc;
 }
 
 /*
index 665b46e65d22366f6c7d974ee4326cf81f219f51..e9dd9819e38d56ded0d468d360b087cece538820 100644 (file)
@@ -14,7 +14,7 @@
 ** the parser.  Lemon will also generate a header file containing
 ** numeric codes for all of the tokens.
 **
-** @(#) $Id: parse.y,v 1.89 2003/01/28 23:13:12 drh Exp $
+** @(#) $Id: parse.y,v 1.90 2003/01/29 18:46:53 drh Exp $
 */
 %token_prefix TK_
 %token_type {Token}
@@ -72,8 +72,9 @@ input ::= cmdlist.
 //
 cmdlist ::= ecmd.
 cmdlist ::= cmdlist ecmd.
-ecmd ::= explain cmd SEMI.  {sqliteExec(pParse);}
+ecmd ::= explain cmdx SEMI.
 ecmd ::= SEMI.
+cmdx ::= cmd.           { sqliteExec(pParse); }
 explain ::= EXPLAIN.    { sqliteBeginParse(pParse, 1); }
 explain ::= .           { sqliteBeginParse(pParse, 0); }
 
index 1ef6f42ce9948349847c5601dcbfee2e870f17fd..387ea1c2da2ba6ad25d26db2725a652094c9662a 100644 (file)
@@ -679,6 +679,28 @@ static void mout(void *arg, char *zNewText, int nNewChar){
   }
 }
 
+/*
+** sqlite_mprintf() works like printf(), but allocations memory to hold the
+** resulting string and returns a pointer to the allocated memory.  Use
+** sqliteFree() to release the memory allocated.
+*/
+char *sqliteMPrintf(const char *zFormat, ...){
+  va_list ap;
+  struct sgMprintf sMprintf;
+  char *zNew;
+  char zBuf[200];
+
+  sMprintf.nChar = 0;
+  sMprintf.nAlloc = sizeof(zBuf);
+  sMprintf.zText = zBuf;
+  sMprintf.zBase = zBuf;
+  va_start(ap,zFormat);
+  vxprintf(mout,&sMprintf,zFormat,ap);
+  va_end(ap);
+  sMprintf.zText[sMprintf.nChar] = 0;
+  return sqliteRealloc(sMprintf.zText, sMprintf.nChar+1);
+}
+
 /*
 ** sqlite_mprintf() works like printf(), but allocations memory to hold the
 ** resulting string and returns a pointer to the allocated memory.  Use
index 19cf9993e9e6026a3922b4613c3a8070d3b3be27..0920b47f3e1526d056b3e394412513008c5dc2c6 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.158 2003/01/29 14:06:09 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.159 2003/01/29 18:46:53 drh Exp $
 */
 #include "config.h"
 #include "sqlite.h"
@@ -924,6 +924,7 @@ void sqliteRealToSortable(double r, char *);
   char *sqliteStrNDup(const char*, int);
 # define sqliteCheckMemory(a,b)
 #endif
+char *sqliteMPrintf(const char *,...);
 void sqliteSetString(char **, const char *, ...);
 void sqliteSetNString(char **, ...);
 void sqliteDequote(char*);
index 09d6c1953eedd72f2fc2b9a60fef7ea444ad9881..b6fc45e6d80bf05e88d74bd1e54f73a659ebb303 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.18 2003/01/29 14:06:09 drh Exp $
+** $Id: test1.c,v 1.19 2003/01/29 18:46:53 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -726,6 +726,7 @@ static int test_compile(
   }
   if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
   rc = sqlite_compile(db, argv[2], &zTail, &vm, &zErr);
+  Tcl_SetVar(interp, argv[3], zTail, 0);
   if( rc ){
     assert( vm==0 );
     sprintf(zBuf, "(%d) ", rc);
@@ -737,7 +738,6 @@ static int test_compile(
     sprintf(zBuf, "%p", vm);
     Tcl_AppendResult(interp, zBuf, 0);
   }
-  Tcl_SetVar(interp, argv[3], zTail, 0);
   return TCL_OK;
 }
 
index c0ec8ac3f5a2d7ffa867ee11d817725396b54a61..3db04a1c874a5a5b3f66e108fedd8392a102eabe 100644 (file)
@@ -36,7 +36,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.201 2003/01/29 14:06:09 drh Exp $
+** $Id: vdbe.c,v 1.202 2003/01/29 18:46:53 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1710,17 +1710,18 @@ case OP_Return: {
 ** is the same as executing Halt.
 */
 case OP_Halt: {
+  p->magic = VDBE_MAGIC_HALT;
   if( pOp->p1!=SQLITE_OK ){
     p->rc = pOp->p1;
     p->errorAction = pOp->p2;
     if( pOp->p3 ){
       sqliteSetString(&p->zErrMsg, pOp->p3, 0);
     }
+    return SQLITE_ERROR;
   }else{
     p->rc = SQLITE_OK;
+    return SQLITE_DONE;
   }
-  p->magic = VDBE_MAGIC_HALT;
-  return SQLITE_DONE;
 }
 
 /* Opcode: Integer P1 * P3
@@ -4307,7 +4308,7 @@ case OP_IdxPut: {
         ){
           rc = SQLITE_CONSTRAINT;
           if( pOp->p3 && pOp->p3[0] ){
-            sqliteSetString(&p->zErrMsg, "duplicate index entry: ", pOp->p3,0);
+            sqliteSetString(&p->zErrMsg, pOp->p3, 0);
           }
           goto abort_due_to_error;
         }
@@ -5614,7 +5615,9 @@ abort_due_to_misuse:
   ** should hold the error number.
   */
 abort_due_to_error:
-  sqliteSetString(&p->zErrMsg, sqlite_error_string(rc), 0);
+  if( p->zErrMsg==0 ){
+    sqliteSetString(&p->zErrMsg, sqlite_error_string(rc), 0);
+  }
   goto vdbe_halt;
 
   /* Jump to here if the sqlite_interrupt() API sets the interrupt
@@ -5659,6 +5662,7 @@ bad_instruction:
 int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){
   sqlite *db = p->db;
   Btree *pBt = p->pBt;
+  int rc;
 
   if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){
     sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), 0);
@@ -5727,5 +5731,7 @@ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){
     }
   }
 #endif
-  return p->rc;
+  rc = p->rc;
+  sqliteVdbeDelete(p);
+  return rc;
 }
index 6a8e191f54dd95b0b8a770586cdda36a28764b49..e66fb3ed9310f4d7dbe55296a7d9abac498ed017 100644 (file)
@@ -15,7 +15,7 @@
 ** or VDBE.  The VDBE implements an abstract machine that runs a
 ** simple program to access and modify the underlying database.
 **
-** $Id: vdbe.h,v 1.63 2003/01/29 14:06:10 drh Exp $
+** $Id: vdbe.h,v 1.64 2003/01/29 18:46:53 drh Exp $
 */
 #ifndef _SQLITE_VDBE_H_
 #define _SQLITE_VDBE_H_
@@ -50,9 +50,9 @@ typedef struct VdbeOp VdbeOp;
 ** Allowed values of VdbeOp.p3type
 */
 #define P3_NOTUSED    0   /* The P3 parameter is not used */
-#define P3_DYNAMIC    1   /* Pointer to a string obtained from sqliteMalloc() */
-#define P3_STATIC   (-1)  /* Pointer to a static string */
-#define P3_POINTER  (-2)  /* P3 is a pointer to some structure or object */
+#define P3_DYNAMIC  (-1)  /* Pointer to a string obtained from sqliteMalloc() */
+#define P3_STATIC   (-2)  /* Pointer to a static string */
+#define P3_POINTER  (-3)  /* P3 is a pointer to some structure or object */
 
 /*
 ** The following macro converts a relative address in the p2 field
index 47f411718c7067ebb0c8848b7e2d3100047e5e92..796f4710a385fa12433d4c27262cb33d0c12e3e2 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script testing the callback-free C/C++ API.
 #
-# $Id: capi2.test,v 1.1 2003/01/29 14:06:10 drh Exp $
+# $Id: capi2.test,v 1.2 2003/01/29 18:46:54 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -21,88 +21,160 @@ source $testdir/tester.tcl
 #
 do_test capi2-1.1 {
   db close
-  set ::DB [sqlite db test.db]
+  set DB [sqlite db test.db]
   execsql {CREATE TABLE t1(a,b,c)}
-  set ::VM [sqlite_compile $::DB {SELECT name, rowid FROM sqlite_master} tail]
-  set tail
+  set VM [sqlite_compile $DB {SELECT name, rowid FROM sqlite_master} TAIL]
+  set TAIL
 } {}
 do_test capi2-1.2 {
-  sqlite_step $::VM ::N ::VALUES ::COLNAMES
+  sqlite_step $VM N VALUES COLNAMES
 } {SQLITE_ROW}
 do_test capi2-1.3 {
-  set ::N
+  set N
 } {2}
 do_test capi2-1.4 {
-  set ::VALUES
+  set VALUES
 } {t1 1}
 do_test capi2-1.5 {
-  set ::COLNAMES
+  set COLNAMES
 } {name rowid text INTEGER}
 do_test capi2-1.6 {
-  set ::N x
-  set ::VALUES y
-  set ::COLNAMES z
-  sqlite_step $::VM ::N ::VALUES ::COLNAMES
+  set N x
+  set VALUES y
+  set COLNAMES z
+  sqlite_step $VM N VALUES COLNAMES
 } {SQLITE_DONE}
 do_test capi2-1.7 {
-  list $::N $::VALUES $::COLNAMES
+  list $N $VALUES $COLNAMES
 } {2 {} {name rowid text INTEGER}}
 do_test capi2-1.8 {
-  set ::N x
-  set ::VALUES y
-  set ::COLNAMES z
-  sqlite_step $::VM ::N ::VALUES ::COLNAMES
+  set N x
+  set VALUES y
+  set COLNAMES z
+  sqlite_step $VM N VALUES COLNAMES
 } {SQLITE_MISUSE}
 do_test capi2-1.9 {
-  list $::N $::VALUES $::COLNAMES
+  list $N $VALUES $COLNAMES
 } {x y z}
 do_test capi2-1.10 {
-  sqlite_finalize $::VM
+  sqlite_finalize $VM
 } {}
 
 # Check to make sure that the "tail" of a multi-statement SQL script
 # is returned by sqlite_compile.
 #
 do_test capi2-2.1 {
-  set ::SQL {
+  set SQL {
     SELECT name, rowid FROM sqlite_master;
     SELECT name, rowid FROM sqlite_temp_master;
     -- A comment at the end
   }
-  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
-  set ::SQL
+  set VM [sqlite_compile $DB $SQL SQL]
+  set SQL
 } {
     SELECT name, rowid FROM sqlite_temp_master;
     -- A comment at the end
   }
 do_test capi2-2.2 {
-  set r [sqlite_step $::VM n val colname]
+  set r [sqlite_step $VM n val colname]
   lappend r $n $val $colname
 } {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
 do_test capi2-2.3 {
-  set r [sqlite_step $::VM n val colname]
+  set r [sqlite_step $VM n val colname]
   lappend r $n $val $colname
 } {SQLITE_DONE 2 {} {name rowid text INTEGER}}
 do_test capi2-2.4 {
-  sqlite_finalize $::VM
+  sqlite_finalize $VM
 } {}
 do_test capi2-2.5 {
-  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
-  set ::SQL
+  set VM [sqlite_compile $DB $SQL SQL]
+  set SQL
 } {
     -- A comment at the end
   }
 do_test capi2-2.6 {
-  set r [sqlite_step $::VM n val colname]
+  set r [sqlite_step $VM n val colname]
   lappend r $n $val $colname
 } {SQLITE_DONE 2 {} {name rowid text INTEGER}}
 do_test capi2-2.7 {
-  sqlite_finalize $::VM
+  sqlite_finalize $VM
 } {}
 do_test capi2-2.8 {
-  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
-  list $::SQL $::VM
+  set VM [sqlite_compile $DB $SQL SQL]
+  list $SQL $VM
 } {{} {}}
 
+# Check the error handling.
+#
+do_test capi2-3.1 {
+  set rc [catch {
+      sqlite_compile $DB {select bogus from sqlite_master} TAIL
+  } msg]
+  lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {}}
+do_test capi2-3.2 {
+  set rc [catch {
+      sqlite_compile $DB {select bogus from } TAIL
+  } msg]
+  lappend rc $msg $TAIL
+} {1 {(1) near " ": syntax error} {}}
+do_test capi2-3.3 {
+  set rc [catch {
+      sqlite_compile $DB {;;;;select bogus from sqlite_master} TAIL
+  } msg]
+  lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {}}
+do_test capi2-3.4 {
+  set rc [catch {
+      sqlite_compile $DB {select bogus from sqlite_master;x;} TAIL
+  } msg]
+  lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {x;}}
+do_test capi2-3.5 {
+  set rc [catch {
+      sqlite_compile $DB {select bogus from sqlite_master;;;x;} TAIL
+  } msg]
+  lappend rc $msg $TAIL
+} {1 {(1) no such column: bogus} {;;x;}}
+do_test capi2-3.6 {
+  set rc [catch {
+      sqlite_compile $DB {select 5/0} TAIL
+  } VM]
+  lappend rc $TAIL
+} {0 {}}
+do_test capi2-3.7 {
+  set N {}
+  set VALUE {}
+  set COLNAME {}
+  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
+} {SQLITE_ROW 1 {{}} {5/0 NUMERIC}}
+do_test capi2-3.8 {
+  sqlite_finalize $VM
+} {}
+do_test capi2-3.9 {
+  execsql {CREATE UNIQUE INDEX i1 ON t1(a)}
+  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,2,3)} TAIL]
+  set TAIL
+} {}
+do_test capi2-3.10 {
+  set N {}
+  set VALUE {}
+  set COLNAME {}
+  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
+} {SQLITE_DONE 0 {} {}}
+do_test capi2-3.11 {
+  sqlite_finalize $VM
+} {}
+do_test capi2-3.12 {
+  list [catch {sqlite_finalize $VM} msg] [set msg]
+} {1 {(21) library routine called out of sequence}}
+do_test capi2-3.13 {
+  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,3,4)} TAIL]
+  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
+} {SQLITE_ERROR 0 {} {}}
+do_test capi2-3.14 {
+  list [catch {sqlite_finalize $VM} msg] [set msg]
+} {1 {(19) uniqueness constraint failed}}
+
 
 finish_test
index 843f5fe0b72cd3e9068426f3d06da331181c9f75..558dd5c2aa2c4751f273b81fc3d2d6958b2b12d0 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for the conflict resolution extension
 # to SQLite.
 #
-# $Id: conflict.test,v 1.14 2002/08/18 20:28:07 drh Exp $
+# $Id: conflict.test,v 1.15 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -288,7 +288,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
  22 REPLACE  FAIL     INSERT                  0 5   1
  23 IGNORE   ROLLBACK INSERT                  0 {}  1
 } {
-  if {$t0} {set t1 {constraint failed}}
+  if {$t0} {set t1 {t1.c may not be NULL}}
   do_test conflict-5.$i {
     if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
     if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
@@ -356,7 +356,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
  22 REPLACE  FAIL     UPDATE                  0 {7 6 9}    1
  23 IGNORE   ROLLBACK UPDATE                  0 {6 7 3 9}  1
 } {
-  if {$t0} {set t1 {constraint failed}}
+  if {$t0} {set t1 {uniqueness constraint failed}}
   do_test conflict-6.$i {
     if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
     if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
@@ -532,13 +532,13 @@ do_test conflict-9.5 {
     INSERT INTO t2 VALUES(3,1,3,3,3);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.6 {
   catchsql {
     UPDATE t2 SET b=b+1 WHERE b=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.7 {
   catchsql {
     BEGIN;
@@ -546,19 +546,19 @@ do_test conflict-9.7 {
     INSERT INTO t2 VALUES(3,1,3,3,3);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.8 {
   execsql {COMMIT}
   execsql {SELECT * FROM t3}
 } {2}
-do_test conflict-9.6 {
+do_test conflict-9.9 {
   catchsql {
     BEGIN;
     UPDATE t3 SET x=x+1;
     UPDATE t2 SET b=b+1 WHERE b=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.10 {
   execsql {COMMIT}
   execsql {SELECT * FROM t3}
@@ -568,13 +568,13 @@ do_test conflict-9.11 {
     INSERT INTO t2 VALUES(3,3,3,1,3);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.12 {
   catchsql {
     UPDATE t2 SET d=d+1 WHERE d=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.13 {
   catchsql {
     BEGIN;
@@ -582,7 +582,7 @@ do_test conflict-9.13 {
     INSERT INTO t2 VALUES(3,3,3,1,3);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.14 {
   execsql {COMMIT}
   execsql {SELECT * FROM t3}
@@ -594,7 +594,7 @@ do_test conflict-9.15 {
     UPDATE t2 SET d=d+1 WHERE d=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.16 {
   execsql {COMMIT}
   execsql {SELECT * FROM t3}
@@ -604,13 +604,13 @@ do_test conflict-9.17 {
     INSERT INTO t2 VALUES(3,3,3,3,1);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.18 {
   catchsql {
     UPDATE t2 SET e=e+1 WHERE e=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.19 {
   catchsql {
     BEGIN;
@@ -618,7 +618,7 @@ do_test conflict-9.19 {
     INSERT INTO t2 VALUES(3,3,3,3,1);
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.20 {
   catch {execsql {COMMIT}}
   execsql {SELECT * FROM t3}
@@ -630,7 +630,7 @@ do_test conflict-9.21 {
     UPDATE t2 SET e=e+1 WHERE e=1;
     SELECT * FROM t2;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test conflict-9.22 {
   catch {execsql {COMMIT}}
   execsql {SELECT * FROM t3}
index d64d8e9040e998cc0304a23532b335823b902ea9..c1a109384a552acf35508966bb126b16352965fd 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the COPY statement.
 #
-# $Id: copy.test,v 1.12 2002/07/30 17:20:41 drh Exp $
+# $Id: copy.test,v 1.13 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -196,7 +196,7 @@ do_test copy-5.2 {
     COPY t1 FROM 'data6.txt' USING DELIMITERS '|';
     SELECT * FROM t1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test copy-5.3 {
   set fd [open data6.txt w]
   puts $fd "33|22|44"
index 1118001b158933f34410dc600d0d9a63a0a1c286..10a7d15c7e623b2c869adc5d2756526b8a4d3829 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for the special processing associated
 # with INTEGER PRIMARY KEY columns.
 #
-# $Id: intpkey.test,v 1.11 2002/08/15 01:26:11 drh Exp $
+# $Id: intpkey.test,v 1.12 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -76,7 +76,7 @@ do_test intpkey-1.6 {
      INSERT INTO t1 VALUES(5,'second','entry');
   }} msg]
   lappend r $msg
-} {1 {constraint failed}}
+} {1 {PRIMARY KEY must be unique}}
 do_test intpkey-1.7 {
   execsql {
     SELECT rowid, * FROM t1;
index d8e5a202430854c0e131d400f336099ae59b2155..d365df8c69c586420d23cb49ed49dac3555d1f28 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc1.test,v 1.18 2003/01/18 20:11:07 drh Exp $
+# $Id: misc1.test,v 1.19 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -222,7 +222,7 @@ do_test misc1-7.4 {
   catchsql {
     INSERT INTO t5 VALUES(1,2,4);
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test misc1-7.5 {
   catchsql {
     INSERT INTO t5 VALUES(0,2,4);
index 2ae67b40ac5bff37fd472cdf3292731aabce4550..279362b81d7f7f1b14644205c47513a36e09c929 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for the NOT NULL constraint.
 #
-# $Id: notnull.test,v 1.2 2002/01/31 15:54:23 drh Exp $
+# $Id: notnull.test,v 1.3 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -42,7 +42,7 @@ do_test notnull-1.2 {
     INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-1.3 {
   catchsql {
     DELETE FROM t1;
@@ -56,14 +56,14 @@ do_test notnull-1.4 {
     INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-1.5 {
   catchsql {
     DELETE FROM t1;
     INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-1.6 {
   catchsql {
     DELETE FROM t1;
@@ -98,7 +98,7 @@ do_test notnull-1.10 {
     INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.b may not be NULL}}
 do_test notnull-1.11 {
   catchsql {
     DELETE FROM t1;
@@ -140,14 +140,14 @@ do_test notnull-1.16 {
     INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.c may not be NULL}}
 do_test notnull-1.17 {
   catchsql {
     DELETE FROM t1;
     INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.d may not be NULL}}
 do_test notnull-1.18 {
   catchsql {
     DELETE FROM t1;
@@ -168,7 +168,7 @@ do_test notnull-1.20 {
     INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.e may not be NULL}}
 do_test notnull-1.21 {
   catchsql {
     DELETE FROM t1;
@@ -184,7 +184,7 @@ do_test notnull-2.1 {
     UPDATE t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-2.2 {
   catchsql {
     DELETE FROM t1;
@@ -192,7 +192,7 @@ do_test notnull-2.2 {
     UPDATE OR REPLACE t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-2.3 {
   catchsql {
     DELETE FROM t1;
@@ -208,7 +208,7 @@ do_test notnull-2.4 {
     UPDATE OR ABORT t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-2.5 {
   catchsql {
     DELETE FROM t1;
@@ -216,7 +216,7 @@ do_test notnull-2.5 {
     UPDATE t1 SET b=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.b may not be NULL}}
 do_test notnull-2.6 {
   catchsql {
     DELETE FROM t1;
@@ -256,7 +256,7 @@ do_test notnull-2.10 {
     UPDATE t1 SET e=null, a=b, b=a;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.e may not be NULL}}
 
 do_test notnull-3.0 {
   execsql {
@@ -281,7 +281,7 @@ do_test notnull-3.2 {
     INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-3.3 {
   catchsql {
     DELETE FROM t1;
@@ -295,14 +295,14 @@ do_test notnull-3.4 {
     INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-3.5 {
   catchsql {
     DELETE FROM t1;
     INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-3.6 {
   catchsql {
     DELETE FROM t1;
@@ -337,7 +337,7 @@ do_test notnull-3.10 {
     INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.b may not be NULL}}
 do_test notnull-3.11 {
   catchsql {
     DELETE FROM t1;
@@ -379,14 +379,14 @@ do_test notnull-3.16 {
     INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.c may not be NULL}}
 do_test notnull-3.17 {
   catchsql {
     DELETE FROM t1;
     INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.d may not be NULL}}
 do_test notnull-3.18 {
   catchsql {
     DELETE FROM t1;
@@ -407,7 +407,7 @@ do_test notnull-3.20 {
     INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
     SELECT * FROM t1 order by a;
   }
-} {1 {constraint failed}}
+} {1 {t1.e may not be NULL}}
 do_test notnull-3.21 {
   catchsql {
     DELETE FROM t1;
@@ -423,7 +423,7 @@ do_test notnull-4.1 {
     UPDATE t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-4.2 {
   catchsql {
     DELETE FROM t1;
@@ -431,7 +431,7 @@ do_test notnull-4.2 {
     UPDATE OR REPLACE t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-4.3 {
   catchsql {
     DELETE FROM t1;
@@ -447,7 +447,7 @@ do_test notnull-4.4 {
     UPDATE OR ABORT t1 SET a=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.a may not be NULL}}
 do_test notnull-4.5 {
   catchsql {
     DELETE FROM t1;
@@ -455,7 +455,7 @@ do_test notnull-4.5 {
     UPDATE t1 SET b=null;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.b may not be NULL}}
 do_test notnull-4.6 {
   catchsql {
     DELETE FROM t1;
@@ -495,6 +495,6 @@ do_test notnull-4.10 {
     UPDATE t1 SET e=null, a=b, b=a;
     SELECT * FROM t1 ORDER BY a;
   }
-} {1 {constraint failed}}
+} {1 {t1.e may not be NULL}}
 
 finish_test
index adad1567c54b0126db7e7edaaf94d89bffbdcc57..ebb00e22e26ae4130b59c2a533936f8572fe620a 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the CREATE TABLE statement.
 #
-# $Id: table.test,v 1.21 2003/01/04 16:48:10 drh Exp $
+# $Id: table.test,v 1.22 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -385,7 +385,7 @@ do_test table-10.1 {
     CREATE TABLE t6(a REFERENCES t4(a) NOT NULL);
     INSERT INTO t6 VALUES(NULL);
   }
-} {1 {constraint failed}}
+} {1 {t6.a may not be NULL}}
 do_test table-10.2 {
   catchsql {
     DROP TABLE t6;
index a75f932e7b2809b36f44a7afbb50551943e1bfeb..1e9e8cf0515cdca5000e775e59ab471036ce15e0 100644 (file)
@@ -448,7 +448,7 @@ do_test trigger2-6.1b {
   catchsql {
     INSERT OR ABORT INTO tbl values (2, 2, 3);
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.1c {
   execsql {
     SELECT * from tbl;
@@ -458,7 +458,7 @@ do_test trigger2-6.1d {
   catchsql {
     INSERT OR FAIL INTO tbl values (2, 2, 3);
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.1e {
   execsql {
     SELECT * from tbl;
@@ -474,7 +474,7 @@ do_test trigger2-6.1g {
   catchsql {
     INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.1h {
   execsql {
     SELECT * from tbl;
@@ -501,7 +501,7 @@ do_test trigger2-6.2b {
   catchsql {
     UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.2c {
   execsql {
     SELECT * from tbl;
@@ -511,7 +511,7 @@ do_test trigger2-6.2d {
   catchsql {
     UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.2e {
   execsql {
     SELECT * from tbl;
@@ -530,7 +530,7 @@ do_test trigger2-6.2g {
   catchsql {
     UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test trigger2-6.2h {
   execsql {
     SELECT * from tbl;
index 27cb3e716f57c049522297a1afb9e66437f0b213..4a18d2c418a5ee0bfde322cf92fa35aa6eab8b5b 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing the CREATE UNIQUE INDEX statement,
 # and primary keys, and the UNIQUE constraint on table columns
 #
-# $Id: unique.test,v 1.4 2002/05/26 20:54:35 drh Exp $
+# $Id: unique.test,v 1.5 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -47,7 +47,7 @@ do_test unique-1.3 {
   catchsql {
     INSERT INTO t1(a,b,c) VALUES(1,3,4)
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test unique-1.4 {
   execsql {
     SELECT * FROM t1 ORDER BY a;
@@ -57,7 +57,7 @@ do_test unique-1.5 {
   catchsql {
     INSERT INTO t1(a,b,c) VALUES(3,2,4)
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test unique-1.6 {
   execsql {
     SELECT * FROM t1 ORDER BY a;
@@ -97,7 +97,7 @@ do_test unique-2.3 {
   catchsql {
     INSERT INTO t2 VALUES(1,5);
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test unique-2.4 {
   catchsql {
     SELECT * FROM t2 ORDER BY a
@@ -123,7 +123,7 @@ do_test unique-2.8 {
   catchsql {
     CREATE UNIQUE INDEX i2 ON t2(a);
   }
-} {1 {constraint failed}}
+} {1 {indexed columns are not unique}}
 do_test unique-2.9 {
   catchsql {
     CREATE INDEX i2 ON t2(a);
@@ -160,7 +160,7 @@ do_test unique-3.4 {
     INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
     SELECT * FROM t3 ORDER BY a,b,c,d;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 
 # Make sure NULLs are distinct as far as the UNIQUE tests are
 # concerned.
index c73ee3c817be55e77521006d257f23a975685c45..db6bd21fb1c87cadbfbb52b78ba52e790aab65fe 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the UPDATE statement.
 #
-# $Id: update.test,v 1.10 2002/07/16 17:22:51 drh Exp $
+# $Id: update.test,v 1.11 2003/01/29 18:46:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -439,7 +439,7 @@ do_test update-10.3 {
     UPDATE t1 SET a=1, e=10 WHERE f=7;
     SELECT * FROM t1;
   }
-} {1 {constraint failed}}
+} {1 {PRIMARY KEY must be unique}}
 do_test update-10.4 {
   catchsql {
     SELECT * FROM t1;
@@ -456,7 +456,7 @@ do_test update-10.6 {
     UPDATE t1 SET b=2, e=12 WHERE f=7;
     SELECT * FROM t1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test update-10.7 {
   catchsql {
     SELECT * FROM t1;
@@ -473,7 +473,7 @@ do_test update-10.9 {
     UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;
     SELECT * FROM t1;
   }
-} {1 {constraint failed}}
+} {1 {uniqueness constraint failed}}
 do_test update-10.10 {
   catchsql {
     SELECT * FROM t1;