/ Check-in [ccc82f1a]
Login

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

Overview
Comment:Better error messages on constraint violations. Additional tests and bug fixes for the callback-free API. (CVS 854)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ccc82f1ab4539a60ee5cc2625743c5389f9ccd8e
User & Date: drh 2003-01-29 18:46:52
Context
2003-01-29
22:58
Additional testing and bug fixing with the non-callback API. Updated the C/C++ interface document to describe the non-callback API. (CVS 855) check-in: af1e9299 user: drh tags: trunk
18:46
Better error messages on constraint violations. Additional tests and bug fixes for the callback-free API. (CVS 854) check-in: ccc82f1a user: drh tags: trunk
14:06
The callback-free API is now working, though much more testing is need. (CVS 853) check-in: 162b2591 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    21     21   **     COPY
    22     22   **     VACUUM
    23     23   **     BEGIN TRANSACTION
    24     24   **     COMMIT
    25     25   **     ROLLBACK
    26     26   **     PRAGMA
    27     27   **
    28         -** $Id: build.c,v 1.126 2003/01/28 23:13:11 drh Exp $
           28  +** $Id: build.c,v 1.127 2003/01/29 18:46:52 drh Exp $
    29     29   */
    30     30   #include "sqliteInt.h"
    31     31   #include <ctype.h>
    32     32   
    33     33   /*
    34     34   ** This routine is called when a new SQL statement is beginning to
    35     35   ** be parsed.  Check to see if the schema for the database needs
................................................................................
    87     87           rc = sqliteVdbeList(v);
    88     88           db->next_cookie = db->schema_cookie;
    89     89         }else{
    90     90           sqliteVdbeExec(v);
    91     91         }
    92     92         rc = sqliteVdbeFinalize(v, &pParse->zErrMsg);
    93     93         if( rc ) pParse->nErr++;
    94         -      sqliteVdbeDelete(v);
    95     94         pParse->pVdbe = 0;
    96     95         pParse->rc = rc;
    97     96         if( rc ) pParse->nErr++;
    98     97       }else{
    99     98         pParse->rc = pParse->nErr ? SQLITE_ERROR : SQLITE_DONE;
   100     99       }
   101    100       pParse->colNamesSet = 0;
   102    101       pParse->schemaVerified = 0;
          102  +  }else if( pParse->useCallback==0 ){
          103  +    pParse->rc = SQLITE_ERROR;
   103    104     }
   104    105     pParse->nTab = 0;
   105    106     pParse->nMem = 0;
   106    107     pParse->nSet = 0;
   107    108     pParse->nAgg = 0;
   108    109   }
   109    110   
................................................................................
  1662   1663         lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0);
  1663   1664         for(i=0; i<pIndex->nColumn; i++){
  1664   1665           sqliteVdbeAddOp(v, OP_Column, 2, pIndex->aiColumn[i]);
  1665   1666         }
  1666   1667         sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0);
  1667   1668         if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex);
  1668   1669         sqliteVdbeAddOp(v, OP_IdxPut, 1, pIndex->onError!=OE_None);
         1670  +      sqliteVdbeChangeP3(v, -1, "indexed columns are not unique", P3_STATIC);
  1669   1671         sqliteVdbeAddOp(v, OP_Next, 2, lbl1);
  1670   1672         sqliteVdbeResolveLabel(v, lbl2);
  1671   1673         sqliteVdbeAddOp(v, OP_Close, 2, 0);
  1672   1674         sqliteVdbeAddOp(v, OP_Close, 1, 0);
  1673   1675       }
  1674   1676       if( pTable!=0 ){
  1675   1677         if( !isTemp ){

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.86 2003/01/18 20:11:07 drh Exp $
           15  +** $Id: expr.c,v 1.87 2003/01/29 18:46:52 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Construct a new expression node and return a pointer to it.  Memory
    22     22   ** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
  1212   1212   	  sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->iColumn);
  1213   1213   	  sqliteDequote(msg);
  1214   1214   	  sqliteVdbeChangeP3(v, -1, msg, 0);
  1215   1215   	  sqliteFree(msg);
  1216   1216         } else {
  1217   1217   	  assert( pExpr->iColumn == OE_Ignore );
  1218   1218   	  sqliteVdbeAddOp(v, OP_Goto, 0, pParse->trigStack->ignoreJump);
  1219         -	  sqliteVdbeChangeP3(v, -1, "(IGNORE jump)", -1);
         1219  +	  sqliteVdbeChangeP3(v, -1, "(IGNORE jump)", 0);
  1220   1220         }
  1221   1221       }
  1222   1222       break;
  1223   1223     }
  1224   1224   }
  1225   1225   
  1226   1226   /*

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.71 2003/01/13 23:27:33 drh Exp $
           15  +** $Id: insert.c,v 1.72 2003/01/29 18:46:52 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** This routine is call to handle SQL of the following forms:
    21     21   **
    22     22   **    insert into TABLE (IDLIST) values(EXPRLIST)
................................................................................
   653    653       }
   654    654       sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1);
   655    655       addr = sqliteVdbeAddOp(v, OP_NotNull, 1, 0);
   656    656       switch( onError ){
   657    657         case OE_Rollback:
   658    658         case OE_Abort:
   659    659         case OE_Fail: {
          660  +        char *zMsg = 0;
   660    661           sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
          662  +        sqliteSetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName,
          663  +                        " may not be NULL", 0);
          664  +        sqliteVdbeChangeP3(v, -1, zMsg, P3_DYNAMIC);
   661    665           break;
   662    666         }
   663    667         case OE_Ignore: {
   664    668           sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
   665    669           sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
   666    670           break;
   667    671         }
................................................................................
   703    707         sqliteVdbeAddOp(v, OP_Dup, nCol, 1);
   704    708         jumpInst2 = sqliteVdbeAddOp(v, OP_NotExists, base, 0);
   705    709         switch( onError ){
   706    710           case OE_Rollback:
   707    711           case OE_Abort:
   708    712           case OE_Fail: {
   709    713             sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
          714  +          sqliteVdbeChangeP3(v, -1, "PRIMARY KEY must be unique", P3_STATIC);
   710    715             break;
   711    716           }
   712    717           case OE_Ignore: {
   713    718             sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
   714    719             sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
   715    720             break;
   716    721           }
................................................................................
   756    761       sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1);
   757    762       jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0);
   758    763       switch( onError ){
   759    764         case OE_Rollback:
   760    765         case OE_Abort:
   761    766         case OE_Fail: {
   762    767           sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
          768  +        sqliteVdbeChangeP3(v, -1, "uniqueness constraint failed", P3_STATIC);
   763    769           break;
   764    770         }
   765    771         case OE_Ignore: {
   766    772           assert( seenReplace==0 );
   767    773           sqliteVdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0);
   768    774           sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
   769    775           break;

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.111 2003/01/29 14:06:08 drh Exp $
           17  +** $Id: main.c,v 1.112 2003/01/29 18:46:53 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** A pointer to this structure is used to communicate information
................................................................................
   712    712   ** should use sqlite_freemem() to delete the message when it has finished
   713    713   ** with it.
   714    714   */
   715    715   int sqlite_finalize(
   716    716     sqlite_vm *pVm,            /* The virtual machine to be destroyed */
   717    717     char **pzErrMsg            /* OUT: Write error messages here */
   718    718   ){
   719         -  return sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
          719  +  int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
          720  +  sqliteStrRealloc(pzErrMsg);
          721  +  return rc;
   720    722   }
   721    723   
   722    724   /*
   723    725   ** Return a static string that describes the kind of error specified in the
   724    726   ** argument.
   725    727   */
   726    728   const char *sqlite_error_string(int rc){

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.89 2003/01/28 23:13:12 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.90 2003/01/29 18:46:53 drh Exp $
    18     18   */
    19     19   %token_prefix TK_
    20     20   %token_type {Token}
    21     21   %default_type {Token}
    22     22   %extra_argument {Parse *pParse}
    23     23   %syntax_error {
    24     24     if( pParse->zErrMsg==0 ){
................................................................................
    68     68   // Input is zero or more commands.
    69     69   input ::= cmdlist.
    70     70   
    71     71   // A list of commands is zero or more commands
    72     72   //
    73     73   cmdlist ::= ecmd.
    74     74   cmdlist ::= cmdlist ecmd.
    75         -ecmd ::= explain cmd SEMI.  {sqliteExec(pParse);}
           75  +ecmd ::= explain cmdx SEMI.
    76     76   ecmd ::= SEMI.
           77  +cmdx ::= cmd.           { sqliteExec(pParse); }
    77     78   explain ::= EXPLAIN.    { sqliteBeginParse(pParse, 1); }
    78     79   explain ::= .           { sqliteBeginParse(pParse, 0); }
    79     80   
    80     81   ///////////////////// Begin and end transactions. ////////////////////////////
    81     82   //
    82     83   
    83     84   cmd ::= BEGIN trans_opt onconf(R).  {sqliteBeginTransaction(pParse,R);}

Changes to src/printf.c.

   674    674     }
   675    675     if( pM->zText ){
   676    676       memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
   677    677       pM->nChar += nNewChar;
   678    678       pM->zText[pM->nChar] = 0;
   679    679     }
   680    680   }
          681  +
          682  +/*
          683  +** sqlite_mprintf() works like printf(), but allocations memory to hold the
          684  +** resulting string and returns a pointer to the allocated memory.  Use
          685  +** sqliteFree() to release the memory allocated.
          686  +*/
          687  +char *sqliteMPrintf(const char *zFormat, ...){
          688  +  va_list ap;
          689  +  struct sgMprintf sMprintf;
          690  +  char *zNew;
          691  +  char zBuf[200];
          692  +
          693  +  sMprintf.nChar = 0;
          694  +  sMprintf.nAlloc = sizeof(zBuf);
          695  +  sMprintf.zText = zBuf;
          696  +  sMprintf.zBase = zBuf;
          697  +  va_start(ap,zFormat);
          698  +  vxprintf(mout,&sMprintf,zFormat,ap);
          699  +  va_end(ap);
          700  +  sMprintf.zText[sMprintf.nChar] = 0;
          701  +  return sqliteRealloc(sMprintf.zText, sMprintf.nChar+1);
          702  +}
   681    703   
   682    704   /*
   683    705   ** sqlite_mprintf() works like printf(), but allocations memory to hold the
   684    706   ** resulting string and returns a pointer to the allocated memory.  Use
   685    707   ** sqliteFree() to release the memory allocated.
   686    708   */
   687    709   char *sqlite_mprintf(const char *zFormat, ...){

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.158 2003/01/29 14:06:09 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.159 2003/01/29 18:46:53 drh Exp $
    15     15   */
    16     16   #include "config.h"
    17     17   #include "sqlite.h"
    18     18   #include "hash.h"
    19     19   #include "vdbe.h"
    20     20   #include "parse.h"
    21     21   #include "btree.h"
................................................................................
   920    920     void *sqliteMallocRaw(int);
   921    921     void sqliteFree(void*);
   922    922     void *sqliteRealloc(void*,int);
   923    923     char *sqliteStrDup(const char*);
   924    924     char *sqliteStrNDup(const char*, int);
   925    925   # define sqliteCheckMemory(a,b)
   926    926   #endif
          927  +char *sqliteMPrintf(const char *,...);
   927    928   void sqliteSetString(char **, const char *, ...);
   928    929   void sqliteSetNString(char **, ...);
   929    930   void sqliteDequote(char*);
   930    931   int sqliteKeywordCode(const char*, int);
   931    932   int sqliteRunParser(Parse*, const char*, char **);
   932    933   void sqliteExec(Parse*);
   933    934   Expr *sqliteExpr(int, Expr*, Expr*, Token*);

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.18 2003/01/29 14:06:09 drh Exp $
           16  +** $Id: test1.c,v 1.19 2003/01/29 18:46:53 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
................................................................................
   722    722     if( argc!=4 ){
   723    723       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
   724    724          " DB SQL TAILVAR", 0);
   725    725       return TCL_ERROR;
   726    726     }
   727    727     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
   728    728     rc = sqlite_compile(db, argv[2], &zTail, &vm, &zErr);
          729  +  Tcl_SetVar(interp, argv[3], zTail, 0);
   729    730     if( rc ){
   730    731       assert( vm==0 );
   731    732       sprintf(zBuf, "(%d) ", rc);
   732    733       Tcl_AppendResult(interp, zBuf, zErr, 0);
   733    734       sqlite_freemem(zErr);
   734    735       return TCL_ERROR;
   735    736     }
   736    737     if( vm ){
   737    738       sprintf(zBuf, "%p", vm);
   738    739       Tcl_AppendResult(interp, zBuf, 0);
   739    740     }
   740         -  Tcl_SetVar(interp, argv[3], zTail, 0);
   741    741     return TCL_OK;
   742    742   }
   743    743   
   744    744   /*
   745    745   ** Usage:  sqlite_step  VM  NVAR  VALUEVAR  COLNAMEVAR
   746    746   **
   747    747   ** Step a virtual machine.  Return a the result code as a string.

Changes to src/vdbe.c.

    32     32   **
    33     33   ** Various scripts scan this source file in order to generate HTML
    34     34   ** documentation, headers files, or other derived files.  The formatting
    35     35   ** of the code in this file is, therefore, important.  See other comments
    36     36   ** in this file for details.  If in doubt, do not deviate from existing
    37     37   ** commenting and indentation practices when changing or adding code.
    38     38   **
    39         -** $Id: vdbe.c,v 1.201 2003/01/29 14:06:09 drh Exp $
           39  +** $Id: vdbe.c,v 1.202 2003/01/29 18:46:53 drh Exp $
    40     40   */
    41     41   #include "sqliteInt.h"
    42     42   #include <ctype.h>
    43     43   
    44     44   /*
    45     45   ** The makefile scans this source file and creates the following
    46     46   ** array of string constants which are the names of all VDBE opcodes.
................................................................................
  1706   1706   ** VDBE, but do not rollback the transaction. 
  1707   1707   **
  1708   1708   ** There is an implied "Halt 0 0 0" instruction inserted at the very end of
  1709   1709   ** every program.  So a jump past the last instruction of the program
  1710   1710   ** is the same as executing Halt.
  1711   1711   */
  1712   1712   case OP_Halt: {
         1713  +  p->magic = VDBE_MAGIC_HALT;
  1713   1714     if( pOp->p1!=SQLITE_OK ){
  1714   1715       p->rc = pOp->p1;
  1715   1716       p->errorAction = pOp->p2;
  1716   1717       if( pOp->p3 ){
  1717   1718         sqliteSetString(&p->zErrMsg, pOp->p3, 0);
  1718   1719       }
         1720  +    return SQLITE_ERROR;
  1719   1721     }else{
  1720   1722       p->rc = SQLITE_OK;
         1723  +    return SQLITE_DONE;
  1721   1724     }
  1722         -  p->magic = VDBE_MAGIC_HALT;
  1723         -  return SQLITE_DONE;
  1724   1725   }
  1725   1726   
  1726   1727   /* Opcode: Integer P1 * P3
  1727   1728   **
  1728   1729   ** The integer value P1 is pushed onto the stack.  If P3 is not zero
  1729   1730   ** then it is assumed to be a string representation of the same integer.
  1730   1731   */
................................................................................
  4303   4304           sqliteBtreeKeySize(pCrsr, &n);
  4304   4305           if( n==nKey
  4305   4306              && sqliteBtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &c)==SQLITE_OK
  4306   4307              && c==0
  4307   4308           ){
  4308   4309             rc = SQLITE_CONSTRAINT;
  4309   4310             if( pOp->p3 && pOp->p3[0] ){
  4310         -            sqliteSetString(&p->zErrMsg, "duplicate index entry: ", pOp->p3,0);
         4311  +            sqliteSetString(&p->zErrMsg, pOp->p3, 0);
  4311   4312             }
  4312   4313             goto abort_due_to_error;
  4313   4314           }
  4314   4315           if( res<0 ){
  4315   4316             sqliteBtreeNext(pCrsr, &res);
  4316   4317             res = +1;
  4317   4318           }else{
................................................................................
  5610   5611     rc = SQLITE_MISUSE;
  5611   5612     /* Fall thru into abort_due_to_error */
  5612   5613   
  5613   5614     /* Jump to here for any other kind of fatal error.  The "rc" variable
  5614   5615     ** should hold the error number.
  5615   5616     */
  5616   5617   abort_due_to_error:
  5617         -  sqliteSetString(&p->zErrMsg, sqlite_error_string(rc), 0);
         5618  +  if( p->zErrMsg==0 ){
         5619  +    sqliteSetString(&p->zErrMsg, sqlite_error_string(rc), 0);
         5620  +  }
  5618   5621     goto vdbe_halt;
  5619   5622   
  5620   5623     /* Jump to here if the sqlite_interrupt() API sets the interrupt
  5621   5624     ** flag.
  5622   5625     */
  5623   5626   abort_due_to_interrupt:
  5624   5627     assert( db->flags & SQLITE_Interrupt );
................................................................................
  5655   5658   /*
  5656   5659   ** Clean up the VDBE after execution.  Return an integer which is the
  5657   5660   ** result code.
  5658   5661   */
  5659   5662   int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){
  5660   5663     sqlite *db = p->db;
  5661   5664     Btree *pBt = p->pBt;
         5665  +  int rc;
  5662   5666   
  5663   5667     if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){
  5664   5668       sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), 0);
  5665   5669       return SQLITE_MISUSE;
  5666   5670     }
  5667   5671     if( p->zErrMsg ){
  5668   5672       if( pzErrMsg && *pzErrMsg==0 ){
................................................................................
  5723   5727           );
  5724   5728           vdbePrintOp(out, i, &p->aOp[i]);
  5725   5729         }
  5726   5730         fclose(out);
  5727   5731       }
  5728   5732     }
  5729   5733   #endif
  5730         -  return p->rc;
         5734  +  rc = p->rc;
         5735  +  sqliteVdbeDelete(p);
         5736  +  return rc;
  5731   5737   }

Changes to src/vdbe.h.

    11     11   *************************************************************************
    12     12   ** Header file for the Virtual DataBase Engine (VDBE)
    13     13   **
    14     14   ** This header defines the interface to the virtual database engine
    15     15   ** or VDBE.  The VDBE implements an abstract machine that runs a
    16     16   ** simple program to access and modify the underlying database.
    17     17   **
    18         -** $Id: vdbe.h,v 1.63 2003/01/29 14:06:10 drh Exp $
           18  +** $Id: vdbe.h,v 1.64 2003/01/29 18:46:53 drh Exp $
    19     19   */
    20     20   #ifndef _SQLITE_VDBE_H_
    21     21   #define _SQLITE_VDBE_H_
    22     22   #include <stdio.h>
    23     23   
    24     24   /*
    25     25   ** A single VDBE is an opaque structure named "Vdbe".  Only routines
................................................................................
    46     46   };
    47     47   typedef struct VdbeOp VdbeOp;
    48     48   
    49     49   /*
    50     50   ** Allowed values of VdbeOp.p3type
    51     51   */
    52     52   #define P3_NOTUSED    0   /* The P3 parameter is not used */
    53         -#define P3_DYNAMIC    1   /* Pointer to a string obtained from sqliteMalloc() */
    54         -#define P3_STATIC   (-1)  /* Pointer to a static string */
    55         -#define P3_POINTER  (-2)  /* P3 is a pointer to some structure or object */
           53  +#define P3_DYNAMIC  (-1)  /* Pointer to a string obtained from sqliteMalloc() */
           54  +#define P3_STATIC   (-2)  /* Pointer to a static string */
           55  +#define P3_POINTER  (-3)  /* P3 is a pointer to some structure or object */
    56     56   
    57     57   /*
    58     58   ** The following macro converts a relative address in the p2 field
    59     59   ** of a VdbeOp structure into a negative number so that 
    60     60   ** sqliteVdbeAddOpList() knows that the address is relative.  Calling
    61     61   ** the macro again restores the address.
    62     62   */

Changes to test/capi2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script testing the callback-free C/C++ API.
    13     13   #
    14         -# $Id: capi2.test,v 1.1 2003/01/29 14:06:10 drh Exp $
           14  +# $Id: capi2.test,v 1.2 2003/01/29 18:46:54 drh Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Check basic functionality
    21     21   #
    22     22   do_test capi2-1.1 {
    23     23     db close
    24         -  set ::DB [sqlite db test.db]
           24  +  set DB [sqlite db test.db]
    25     25     execsql {CREATE TABLE t1(a,b,c)}
    26         -  set ::VM [sqlite_compile $::DB {SELECT name, rowid FROM sqlite_master} tail]
    27         -  set tail
           26  +  set VM [sqlite_compile $DB {SELECT name, rowid FROM sqlite_master} TAIL]
           27  +  set TAIL
    28     28   } {}
    29     29   do_test capi2-1.2 {
    30         -  sqlite_step $::VM ::N ::VALUES ::COLNAMES
           30  +  sqlite_step $VM N VALUES COLNAMES
    31     31   } {SQLITE_ROW}
    32     32   do_test capi2-1.3 {
    33         -  set ::N
           33  +  set N
    34     34   } {2}
    35     35   do_test capi2-1.4 {
    36         -  set ::VALUES
           36  +  set VALUES
    37     37   } {t1 1}
    38     38   do_test capi2-1.5 {
    39         -  set ::COLNAMES
           39  +  set COLNAMES
    40     40   } {name rowid text INTEGER}
    41     41   do_test capi2-1.6 {
    42         -  set ::N x
    43         -  set ::VALUES y
    44         -  set ::COLNAMES z
    45         -  sqlite_step $::VM ::N ::VALUES ::COLNAMES
           42  +  set N x
           43  +  set VALUES y
           44  +  set COLNAMES z
           45  +  sqlite_step $VM N VALUES COLNAMES
    46     46   } {SQLITE_DONE}
    47     47   do_test capi2-1.7 {
    48         -  list $::N $::VALUES $::COLNAMES
           48  +  list $N $VALUES $COLNAMES
    49     49   } {2 {} {name rowid text INTEGER}}
    50     50   do_test capi2-1.8 {
    51         -  set ::N x
    52         -  set ::VALUES y
    53         -  set ::COLNAMES z
    54         -  sqlite_step $::VM ::N ::VALUES ::COLNAMES
           51  +  set N x
           52  +  set VALUES y
           53  +  set COLNAMES z
           54  +  sqlite_step $VM N VALUES COLNAMES
    55     55   } {SQLITE_MISUSE}
    56     56   do_test capi2-1.9 {
    57         -  list $::N $::VALUES $::COLNAMES
           57  +  list $N $VALUES $COLNAMES
    58     58   } {x y z}
    59     59   do_test capi2-1.10 {
    60         -  sqlite_finalize $::VM
           60  +  sqlite_finalize $VM
    61     61   } {}
    62     62   
    63     63   # Check to make sure that the "tail" of a multi-statement SQL script
    64     64   # is returned by sqlite_compile.
    65     65   #
    66     66   do_test capi2-2.1 {
    67         -  set ::SQL {
           67  +  set SQL {
    68     68       SELECT name, rowid FROM sqlite_master;
    69     69       SELECT name, rowid FROM sqlite_temp_master;
    70     70       -- A comment at the end
    71     71     }
    72         -  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
    73         -  set ::SQL
           72  +  set VM [sqlite_compile $DB $SQL SQL]
           73  +  set SQL
    74     74   } {
    75     75       SELECT name, rowid FROM sqlite_temp_master;
    76     76       -- A comment at the end
    77     77     }
    78     78   do_test capi2-2.2 {
    79         -  set r [sqlite_step $::VM n val colname]
           79  +  set r [sqlite_step $VM n val colname]
    80     80     lappend r $n $val $colname
    81     81   } {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
    82     82   do_test capi2-2.3 {
    83         -  set r [sqlite_step $::VM n val colname]
           83  +  set r [sqlite_step $VM n val colname]
    84     84     lappend r $n $val $colname
    85     85   } {SQLITE_DONE 2 {} {name rowid text INTEGER}}
    86     86   do_test capi2-2.4 {
    87         -  sqlite_finalize $::VM
           87  +  sqlite_finalize $VM
    88     88   } {}
    89     89   do_test capi2-2.5 {
    90         -  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
    91         -  set ::SQL
           90  +  set VM [sqlite_compile $DB $SQL SQL]
           91  +  set SQL
    92     92   } {
    93     93       -- A comment at the end
    94     94     }
    95     95   do_test capi2-2.6 {
    96         -  set r [sqlite_step $::VM n val colname]
           96  +  set r [sqlite_step $VM n val colname]
    97     97     lappend r $n $val $colname
    98     98   } {SQLITE_DONE 2 {} {name rowid text INTEGER}}
    99     99   do_test capi2-2.7 {
   100         -  sqlite_finalize $::VM
          100  +  sqlite_finalize $VM
   101    101   } {}
   102    102   do_test capi2-2.8 {
   103         -  set ::VM [sqlite_compile $::DB $::SQL ::SQL]
   104         -  list $::SQL $::VM
          103  +  set VM [sqlite_compile $DB $SQL SQL]
          104  +  list $SQL $VM
   105    105   } {{} {}}
   106    106   
          107  +# Check the error handling.
          108  +#
          109  +do_test capi2-3.1 {
          110  +  set rc [catch {
          111  +      sqlite_compile $DB {select bogus from sqlite_master} TAIL
          112  +  } msg]
          113  +  lappend rc $msg $TAIL
          114  +} {1 {(1) no such column: bogus} {}}
          115  +do_test capi2-3.2 {
          116  +  set rc [catch {
          117  +      sqlite_compile $DB {select bogus from } TAIL
          118  +  } msg]
          119  +  lappend rc $msg $TAIL
          120  +} {1 {(1) near " ": syntax error} {}}
          121  +do_test capi2-3.3 {
          122  +  set rc [catch {
          123  +      sqlite_compile $DB {;;;;select bogus from sqlite_master} TAIL
          124  +  } msg]
          125  +  lappend rc $msg $TAIL
          126  +} {1 {(1) no such column: bogus} {}}
          127  +do_test capi2-3.4 {
          128  +  set rc [catch {
          129  +      sqlite_compile $DB {select bogus from sqlite_master;x;} TAIL
          130  +  } msg]
          131  +  lappend rc $msg $TAIL
          132  +} {1 {(1) no such column: bogus} {x;}}
          133  +do_test capi2-3.5 {
          134  +  set rc [catch {
          135  +      sqlite_compile $DB {select bogus from sqlite_master;;;x;} TAIL
          136  +  } msg]
          137  +  lappend rc $msg $TAIL
          138  +} {1 {(1) no such column: bogus} {;;x;}}
          139  +do_test capi2-3.6 {
          140  +  set rc [catch {
          141  +      sqlite_compile $DB {select 5/0} TAIL
          142  +  } VM]
          143  +  lappend rc $TAIL
          144  +} {0 {}}
          145  +do_test capi2-3.7 {
          146  +  set N {}
          147  +  set VALUE {}
          148  +  set COLNAME {}
          149  +  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
          150  +} {SQLITE_ROW 1 {{}} {5/0 NUMERIC}}
          151  +do_test capi2-3.8 {
          152  +  sqlite_finalize $VM
          153  +} {}
          154  +do_test capi2-3.9 {
          155  +  execsql {CREATE UNIQUE INDEX i1 ON t1(a)}
          156  +  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,2,3)} TAIL]
          157  +  set TAIL
          158  +} {}
          159  +do_test capi2-3.10 {
          160  +  set N {}
          161  +  set VALUE {}
          162  +  set COLNAME {}
          163  +  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
          164  +} {SQLITE_DONE 0 {} {}}
          165  +do_test capi2-3.11 {
          166  +  sqlite_finalize $VM
          167  +} {}
          168  +do_test capi2-3.12 {
          169  +  list [catch {sqlite_finalize $VM} msg] [set msg]
          170  +} {1 {(21) library routine called out of sequence}}
          171  +do_test capi2-3.13 {
          172  +  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(1,3,4)} TAIL]
          173  +  list [sqlite_step $VM N VALUE COLNAME] [set N] [set VALUE] [set COLNAME]
          174  +} {SQLITE_ERROR 0 {} {}}
          175  +do_test capi2-3.14 {
          176  +  list [catch {sqlite_finalize $VM} msg] [set msg]
          177  +} {1 {(19) uniqueness constraint failed}}
          178  +
   107    179   
   108    180   finish_test

Changes to test/conflict.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the conflict resolution extension
    14     14   # to SQLite.
    15     15   #
    16         -# $Id: conflict.test,v 1.14 2002/08/18 20:28:07 drh Exp $
           16  +# $Id: conflict.test,v 1.15 2003/01/29 18:46:54 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Create tables for the first group of tests.
    22     22   #
    23     23   do_test conflict-1.0 {
................................................................................
   284    284    18 {}       REPLACE  INSERT                  0 5   1
   285    285    19 {}       FAIL     INSERT                  1 {}  1
   286    286    20 {}       ABORT    INSERT                  1 {}  1
   287    287    21 {}       ROLLBACK INSERT                  1 {}  {}
   288    288    22 REPLACE  FAIL     INSERT                  0 5   1
   289    289    23 IGNORE   ROLLBACK INSERT                  0 {}  1
   290    290   } {
   291         -  if {$t0} {set t1 {constraint failed}}
          291  +  if {$t0} {set t1 {t1.c may not be NULL}}
   292    292     do_test conflict-5.$i {
   293    293       if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
   294    294       if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
   295    295       set r0 [catch {execsql [subst {
   296    296         DROP TABLE t1;
   297    297         CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
   298    298         DELETE FROM t2;
................................................................................
   352    352    18 {}       REPLACE  UPDATE                  0 {7 6 9}    1
   353    353    19 {}       FAIL     UPDATE                  1 {6 7 3 4}  1
   354    354    20 {}       ABORT    UPDATE                  1 {1 2 3 4}  1
   355    355    21 {}       ROLLBACK UPDATE                  1 {1 2 3 4}  0
   356    356    22 REPLACE  FAIL     UPDATE                  0 {7 6 9}    1
   357    357    23 IGNORE   ROLLBACK UPDATE                  0 {6 7 3 9}  1
   358    358   } {
   359         -  if {$t0} {set t1 {constraint failed}}
          359  +  if {$t0} {set t1 {uniqueness constraint failed}}
   360    360     do_test conflict-6.$i {
   361    361       if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
   362    362       if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
   363    363       set r0 [catch {execsql [subst {
   364    364         DROP TABLE t1;
   365    365         CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
   366    366         INSERT INTO t1 SELECT * FROM t2;
................................................................................
   528    528     }
   529    529   } {0 {1 1 1 1 1 2 2 2 2 2}}
   530    530   do_test conflict-9.5 {
   531    531     catchsql {
   532    532       INSERT INTO t2 VALUES(3,1,3,3,3);
   533    533       SELECT * FROM t2;
   534    534     }
   535         -} {1 {constraint failed}}
          535  +} {1 {uniqueness constraint failed}}
   536    536   do_test conflict-9.6 {
   537    537     catchsql {
   538    538       UPDATE t2 SET b=b+1 WHERE b=1;
   539    539       SELECT * FROM t2;
   540    540     }
   541         -} {1 {constraint failed}}
          541  +} {1 {uniqueness constraint failed}}
   542    542   do_test conflict-9.7 {
   543    543     catchsql {
   544    544       BEGIN;
   545    545       UPDATE t3 SET x=x+1;
   546    546       INSERT INTO t2 VALUES(3,1,3,3,3);
   547    547       SELECT * FROM t2;
   548    548     }
   549         -} {1 {constraint failed}}
          549  +} {1 {uniqueness constraint failed}}
   550    550   do_test conflict-9.8 {
   551    551     execsql {COMMIT}
   552    552     execsql {SELECT * FROM t3}
   553    553   } {2}
   554         -do_test conflict-9.6 {
          554  +do_test conflict-9.9 {
   555    555     catchsql {
   556    556       BEGIN;
   557    557       UPDATE t3 SET x=x+1;
   558    558       UPDATE t2 SET b=b+1 WHERE b=1;
   559    559       SELECT * FROM t2;
   560    560     }
   561         -} {1 {constraint failed}}
          561  +} {1 {uniqueness constraint failed}}
   562    562   do_test conflict-9.10 {
   563    563     execsql {COMMIT}
   564    564     execsql {SELECT * FROM t3}
   565    565   } {3}
   566    566   do_test conflict-9.11 {
   567    567     catchsql {
   568    568       INSERT INTO t2 VALUES(3,3,3,1,3);
   569    569       SELECT * FROM t2;
   570    570     }
   571         -} {1 {constraint failed}}
          571  +} {1 {uniqueness constraint failed}}
   572    572   do_test conflict-9.12 {
   573    573     catchsql {
   574    574       UPDATE t2 SET d=d+1 WHERE d=1;
   575    575       SELECT * FROM t2;
   576    576     }
   577         -} {1 {constraint failed}}
          577  +} {1 {uniqueness constraint failed}}
   578    578   do_test conflict-9.13 {
   579    579     catchsql {
   580    580       BEGIN;
   581    581       UPDATE t3 SET x=x+1;
   582    582       INSERT INTO t2 VALUES(3,3,3,1,3);
   583    583       SELECT * FROM t2;
   584    584     }
   585         -} {1 {constraint failed}}
          585  +} {1 {uniqueness constraint failed}}
   586    586   do_test conflict-9.14 {
   587    587     execsql {COMMIT}
   588    588     execsql {SELECT * FROM t3}
   589    589   } {4}
   590    590   do_test conflict-9.15 {
   591    591     catchsql {
   592    592       BEGIN;
   593    593       UPDATE t3 SET x=x+1;
   594    594       UPDATE t2 SET d=d+1 WHERE d=1;
   595    595       SELECT * FROM t2;
   596    596     }
   597         -} {1 {constraint failed}}
          597  +} {1 {uniqueness constraint failed}}
   598    598   do_test conflict-9.16 {
   599    599     execsql {COMMIT}
   600    600     execsql {SELECT * FROM t3}
   601    601   } {5}
   602    602   do_test conflict-9.17 {
   603    603     catchsql {
   604    604       INSERT INTO t2 VALUES(3,3,3,3,1);
   605    605       SELECT * FROM t2;
   606    606     }
   607         -} {1 {constraint failed}}
          607  +} {1 {uniqueness constraint failed}}
   608    608   do_test conflict-9.18 {
   609    609     catchsql {
   610    610       UPDATE t2 SET e=e+1 WHERE e=1;
   611    611       SELECT * FROM t2;
   612    612     }
   613         -} {1 {constraint failed}}
          613  +} {1 {uniqueness constraint failed}}
   614    614   do_test conflict-9.19 {
   615    615     catchsql {
   616    616       BEGIN;
   617    617       UPDATE t3 SET x=x+1;
   618    618       INSERT INTO t2 VALUES(3,3,3,3,1);
   619    619       SELECT * FROM t2;
   620    620     }
   621         -} {1 {constraint failed}}
          621  +} {1 {uniqueness constraint failed}}
   622    622   do_test conflict-9.20 {
   623    623     catch {execsql {COMMIT}}
   624    624     execsql {SELECT * FROM t3}
   625    625   } {5}
   626    626   do_test conflict-9.21 {
   627    627     catchsql {
   628    628       BEGIN;
   629    629       UPDATE t3 SET x=x+1;
   630    630       UPDATE t2 SET e=e+1 WHERE e=1;
   631    631       SELECT * FROM t2;
   632    632     }
   633         -} {1 {constraint failed}}
          633  +} {1 {uniqueness constraint failed}}
   634    634   do_test conflict-9.22 {
   635    635     catch {execsql {COMMIT}}
   636    636     execsql {SELECT * FROM t3}
   637    637   } {5}
   638    638   do_test conflict-9.23 {
   639    639     catchsql {
   640    640       INSERT INTO t2 VALUES(3,3,1,3,3);

Changes to test/copy.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the COPY statement.
    13     13   #
    14         -# $Id: copy.test,v 1.12 2002/07/30 17:20:41 drh Exp $
           14  +# $Id: copy.test,v 1.13 2003/01/29 18:46:54 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a file of data from which to copy.
    20     20   #
    21     21   set f [open data1.txt w]
................................................................................
   192    192     set fd [open data6.txt w]
   193    193     puts $fd "33|22|44"
   194    194     close $fd
   195    195     catchsql {
   196    196       COPY t1 FROM 'data6.txt' USING DELIMITERS '|';
   197    197       SELECT * FROM t1;
   198    198     }
   199         -} {1 {constraint failed}}
          199  +} {1 {uniqueness constraint failed}}
   200    200   do_test copy-5.3 {
   201    201     set fd [open data6.txt w]
   202    202     puts $fd "33|22|44"
   203    203     close $fd
   204    204     catchsql {
   205    205       COPY OR IGNORE t1 FROM 'data6.txt' USING DELIMITERS '|';
   206    206       SELECT * FROM t1;

Changes to test/intpkey.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the special processing associated
    14     14   # with INTEGER PRIMARY KEY columns.
    15     15   #
    16         -# $Id: intpkey.test,v 1.11 2002/08/15 01:26:11 drh Exp $
           16  +# $Id: intpkey.test,v 1.12 2003/01/29 18:46:54 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Create a table with a primary key and a datatype other than
    22     22   # integer
    23     23   #
................................................................................
    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 {constraint failed}}
           79  +} {1 {PRIMARY KEY must be unique}}
    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/misc1.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc1.test,v 1.18 2003/01/18 20:11:07 drh Exp $
           16  +# $Id: misc1.test,v 1.19 2003/01/29 18:46:54 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Test the creation and use of tables that have a large number
    22     22   # of columns.
    23     23   #
................................................................................
   218    218       SELECT * FROM t5 ORDER BY a;
   219    219     }
   220    220   } {1 2 3}
   221    221   do_test misc1-7.4 {
   222    222     catchsql {
   223    223       INSERT INTO t5 VALUES(1,2,4);
   224    224     }
   225         -} {1 {constraint failed}}
          225  +} {1 {uniqueness constraint failed}}
   226    226   do_test misc1-7.5 {
   227    227     catchsql {
   228    228       INSERT INTO t5 VALUES(0,2,4);
   229    229     }
   230    230   } {0 {}}
   231    231   do_test misc1-7.6 {
   232    232     execsql {

Changes to test/notnull.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the NOT NULL constraint.
    14     14   #
    15         -# $Id: notnull.test,v 1.2 2002/01/31 15:54:23 drh Exp $
           15  +# $Id: notnull.test,v 1.3 2003/01/29 18:46:54 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test notnull-1.0 {
    21     21     execsql {
    22     22       CREATE TABLE t1 (
................................................................................
    38     38   } {0 {1 2 3 4 5}}
    39     39   do_test notnull-1.2 {
    40     40     catchsql {
    41     41       DELETE FROM t1;
    42     42       INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
    43     43       SELECT * FROM t1 order by a;
    44     44     }
    45         -} {1 {constraint failed}}
           45  +} {1 {t1.a may not be NULL}}
    46     46   do_test notnull-1.3 {
    47     47     catchsql {
    48     48       DELETE FROM t1;
    49     49       INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
    50     50       SELECT * FROM t1 order by a;
    51     51     }
    52     52   } {0 {}}
    53     53   do_test notnull-1.4 {
    54     54     catchsql {
    55     55       DELETE FROM t1;
    56     56       INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
    57     57       SELECT * FROM t1 order by a;
    58     58     }
    59         -} {1 {constraint failed}}
           59  +} {1 {t1.a may not be NULL}}
    60     60   do_test notnull-1.5 {
    61     61     catchsql {
    62     62       DELETE FROM t1;
    63     63       INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
    64     64       SELECT * FROM t1 order by a;
    65     65     }
    66         -} {1 {constraint failed}}
           66  +} {1 {t1.a may not be NULL}}
    67     67   do_test notnull-1.6 {
    68     68     catchsql {
    69     69       DELETE FROM t1;
    70     70       INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
    71     71       SELECT * FROM t1 order by a;
    72     72     }
    73     73   } {0 {1 5 3 4 5}}
................................................................................
    94     94   } {0 {1 5 3 4 5}}
    95     95   do_test notnull-1.10 {
    96     96     catchsql {
    97     97       DELETE FROM t1;
    98     98       INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
    99     99       SELECT * FROM t1 order by a;
   100    100     }
   101         -} {1 {constraint failed}}
          101  +} {1 {t1.b may not be NULL}}
   102    102   do_test notnull-1.11 {
   103    103     catchsql {
   104    104       DELETE FROM t1;
   105    105       INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   106    106       SELECT * FROM t1 order by a;
   107    107     }
   108    108   } {0 {}}
................................................................................
   136    136   } {0 {1 2 6 4 5}}
   137    137   do_test notnull-1.16 {
   138    138     catchsql {
   139    139       DELETE FROM t1;
   140    140       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
   141    141       SELECT * FROM t1 order by a;
   142    142     }
   143         -} {1 {constraint failed}}
          143  +} {1 {t1.c may not be NULL}}
   144    144   do_test notnull-1.17 {
   145    145     catchsql {
   146    146       DELETE FROM t1;
   147    147       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
   148    148       SELECT * FROM t1 order by a;
   149    149     }
   150         -} {1 {constraint failed}}
          150  +} {1 {t1.d may not be NULL}}
   151    151   do_test notnull-1.18 {
   152    152     catchsql {
   153    153       DELETE FROM t1;
   154    154       INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
   155    155       SELECT * FROM t1 order by a;
   156    156     }
   157    157   } {0 {1 2 3 7 5}}
................................................................................
   164    164   } {0 {1 2 3 4 8}}
   165    165   do_test notnull-1.20 {
   166    166     catchsql {
   167    167       DELETE FROM t1;
   168    168       INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
   169    169       SELECT * FROM t1 order by a;
   170    170     }
   171         -} {1 {constraint failed}}
          171  +} {1 {t1.e may not be NULL}}
   172    172   do_test notnull-1.21 {
   173    173     catchsql {
   174    174       DELETE FROM t1;
   175    175       INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
   176    176       SELECT * FROM t1 order by a;
   177    177     }
   178    178   } {0 {5 5 3 2 1}}
................................................................................
   180    180   do_test notnull-2.1 {
   181    181     catchsql {
   182    182       DELETE FROM t1;
   183    183       INSERT INTO t1 VALUES(1,2,3,4,5);
   184    184       UPDATE t1 SET a=null;
   185    185       SELECT * FROM t1 ORDER BY a;
   186    186     }
   187         -} {1 {constraint failed}}
          187  +} {1 {t1.a may not be NULL}}
   188    188   do_test notnull-2.2 {
   189    189     catchsql {
   190    190       DELETE FROM t1;
   191    191       INSERT INTO t1 VALUES(1,2,3,4,5);
   192    192       UPDATE OR REPLACE t1 SET a=null;
   193    193       SELECT * FROM t1 ORDER BY a;
   194    194     }
   195         -} {1 {constraint failed}}
          195  +} {1 {t1.a may not be NULL}}
   196    196   do_test notnull-2.3 {
   197    197     catchsql {
   198    198       DELETE FROM t1;
   199    199       INSERT INTO t1 VALUES(1,2,3,4,5);
   200    200       UPDATE OR IGNORE t1 SET a=null;
   201    201       SELECT * FROM t1 ORDER BY a;
   202    202     }
................................................................................
   204    204   do_test notnull-2.4 {
   205    205     catchsql {
   206    206       DELETE FROM t1;
   207    207       INSERT INTO t1 VALUES(1,2,3,4,5);
   208    208       UPDATE OR ABORT t1 SET a=null;
   209    209       SELECT * FROM t1 ORDER BY a;
   210    210     }
   211         -} {1 {constraint failed}}
          211  +} {1 {t1.a may not be NULL}}
   212    212   do_test notnull-2.5 {
   213    213     catchsql {
   214    214       DELETE FROM t1;
   215    215       INSERT INTO t1 VALUES(1,2,3,4,5);
   216    216       UPDATE t1 SET b=null;
   217    217       SELECT * FROM t1 ORDER BY a;
   218    218     }
   219         -} {1 {constraint failed}}
          219  +} {1 {t1.b may not be NULL}}
   220    220   do_test notnull-2.6 {
   221    221     catchsql {
   222    222       DELETE FROM t1;
   223    223       INSERT INTO t1 VALUES(1,2,3,4,5);
   224    224       UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
   225    225       SELECT * FROM t1 ORDER BY a;
   226    226     }
................................................................................
   252    252   do_test notnull-2.10 {
   253    253     catchsql {
   254    254       DELETE FROM t1;
   255    255       INSERT INTO t1 VALUES(1,2,3,4,5);
   256    256       UPDATE t1 SET e=null, a=b, b=a;
   257    257       SELECT * FROM t1 ORDER BY a;
   258    258     }
   259         -} {1 {constraint failed}}
          259  +} {1 {t1.e may not be NULL}}
   260    260   
   261    261   do_test notnull-3.0 {
   262    262     execsql {
   263    263       CREATE INDEX t1a ON t1(a);
   264    264       CREATE INDEX t1b ON t1(b);
   265    265       CREATE INDEX t1c ON t1(c);
   266    266       CREATE INDEX t1d ON t1(d);
................................................................................
   277    277   } {0 {1 2 3 4 5}}
   278    278   do_test notnull-3.2 {
   279    279     catchsql {
   280    280       DELETE FROM t1;
   281    281       INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
   282    282       SELECT * FROM t1 order by a;
   283    283     }
   284         -} {1 {constraint failed}}
          284  +} {1 {t1.a may not be NULL}}
   285    285   do_test notnull-3.3 {
   286    286     catchsql {
   287    287       DELETE FROM t1;
   288    288       INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
   289    289       SELECT * FROM t1 order by a;
   290    290     }
   291    291   } {0 {}}
   292    292   do_test notnull-3.4 {
   293    293     catchsql {
   294    294       DELETE FROM t1;
   295    295       INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
   296    296       SELECT * FROM t1 order by a;
   297    297     }
   298         -} {1 {constraint failed}}
          298  +} {1 {t1.a may not be NULL}}
   299    299   do_test notnull-3.5 {
   300    300     catchsql {
   301    301       DELETE FROM t1;
   302    302       INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
   303    303       SELECT * FROM t1 order by a;
   304    304     }
   305         -} {1 {constraint failed}}
          305  +} {1 {t1.a may not be NULL}}
   306    306   do_test notnull-3.6 {
   307    307     catchsql {
   308    308       DELETE FROM t1;
   309    309       INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
   310    310       SELECT * FROM t1 order by a;
   311    311     }
   312    312   } {0 {1 5 3 4 5}}
................................................................................
   333    333   } {0 {1 5 3 4 5}}
   334    334   do_test notnull-3.10 {
   335    335     catchsql {
   336    336       DELETE FROM t1;
   337    337       INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   338    338       SELECT * FROM t1 order by a;
   339    339     }
   340         -} {1 {constraint failed}}
          340  +} {1 {t1.b may not be NULL}}
   341    341   do_test notnull-3.11 {
   342    342     catchsql {
   343    343       DELETE FROM t1;
   344    344       INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
   345    345       SELECT * FROM t1 order by a;
   346    346     }
   347    347   } {0 {}}
................................................................................
   375    375   } {0 {1 2 6 4 5}}
   376    376   do_test notnull-3.16 {
   377    377     catchsql {
   378    378       DELETE FROM t1;
   379    379       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
   380    380       SELECT * FROM t1 order by a;
   381    381     }
   382         -} {1 {constraint failed}}
          382  +} {1 {t1.c may not be NULL}}
   383    383   do_test notnull-3.17 {
   384    384     catchsql {
   385    385       DELETE FROM t1;
   386    386       INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
   387    387       SELECT * FROM t1 order by a;
   388    388     }
   389         -} {1 {constraint failed}}
          389  +} {1 {t1.d may not be NULL}}
   390    390   do_test notnull-3.18 {
   391    391     catchsql {
   392    392       DELETE FROM t1;
   393    393       INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
   394    394       SELECT * FROM t1 order by a;
   395    395     }
   396    396   } {0 {1 2 3 7 5}}
................................................................................
   403    403   } {0 {1 2 3 4 8}}
   404    404   do_test notnull-3.20 {
   405    405     catchsql {
   406    406       DELETE FROM t1;
   407    407       INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
   408    408       SELECT * FROM t1 order by a;
   409    409     }
   410         -} {1 {constraint failed}}
          410  +} {1 {t1.e may not be NULL}}
   411    411   do_test notnull-3.21 {
   412    412     catchsql {
   413    413       DELETE FROM t1;
   414    414       INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
   415    415       SELECT * FROM t1 order by a;
   416    416     }
   417    417   } {0 {5 5 3 2 1}}
................................................................................
   419    419   do_test notnull-4.1 {
   420    420     catchsql {
   421    421       DELETE FROM t1;
   422    422       INSERT INTO t1 VALUES(1,2,3,4,5);
   423    423       UPDATE t1 SET a=null;
   424    424       SELECT * FROM t1 ORDER BY a;
   425    425     }
   426         -} {1 {constraint failed}}
          426  +} {1 {t1.a may not be NULL}}
   427    427   do_test notnull-4.2 {
   428    428     catchsql {
   429    429       DELETE FROM t1;
   430    430       INSERT INTO t1 VALUES(1,2,3,4,5);
   431    431       UPDATE OR REPLACE t1 SET a=null;
   432    432       SELECT * FROM t1 ORDER BY a;
   433    433     }
   434         -} {1 {constraint failed}}
          434  +} {1 {t1.a may not be NULL}}
   435    435   do_test notnull-4.3 {
   436    436     catchsql {
   437    437       DELETE FROM t1;
   438    438       INSERT INTO t1 VALUES(1,2,3,4,5);
   439    439       UPDATE OR IGNORE t1 SET a=null;
   440    440       SELECT * FROM t1 ORDER BY a;
   441    441     }
................................................................................
   443    443   do_test notnull-4.4 {
   444    444     catchsql {
   445    445       DELETE FROM t1;
   446    446       INSERT INTO t1 VALUES(1,2,3,4,5);
   447    447       UPDATE OR ABORT t1 SET a=null;
   448    448       SELECT * FROM t1 ORDER BY a;
   449    449     }
   450         -} {1 {constraint failed}}
          450  +} {1 {t1.a may not be NULL}}
   451    451   do_test notnull-4.5 {
   452    452     catchsql {
   453    453       DELETE FROM t1;
   454    454       INSERT INTO t1 VALUES(1,2,3,4,5);
   455    455       UPDATE t1 SET b=null;
   456    456       SELECT * FROM t1 ORDER BY a;
   457    457     }
   458         -} {1 {constraint failed}}
          458  +} {1 {t1.b may not be NULL}}
   459    459   do_test notnull-4.6 {
   460    460     catchsql {
   461    461       DELETE FROM t1;
   462    462       INSERT INTO t1 VALUES(1,2,3,4,5);
   463    463       UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
   464    464       SELECT * FROM t1 ORDER BY a;
   465    465     }
................................................................................
   491    491   do_test notnull-4.10 {
   492    492     catchsql {
   493    493       DELETE FROM t1;
   494    494       INSERT INTO t1 VALUES(1,2,3,4,5);
   495    495       UPDATE t1 SET e=null, a=b, b=a;
   496    496       SELECT * FROM t1 ORDER BY a;
   497    497     }
   498         -} {1 {constraint failed}}
          498  +} {1 {t1.e may not be NULL}}
   499    499   
   500    500   finish_test

Changes to test/table.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CREATE TABLE statement.
    13     13   #
    14         -# $Id: table.test,v 1.21 2003/01/04 16:48:10 drh Exp $
           14  +# $Id: table.test,v 1.22 2003/01/29 18:46:54 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a basic table and verify it is added to sqlite_master
    20     20   #
    21     21   do_test table-1.1 {
................................................................................
   381    381   # Check the foreign key syntax.
   382    382   #
   383    383   do_test table-10.1 {
   384    384     catchsql {
   385    385       CREATE TABLE t6(a REFERENCES t4(a) NOT NULL);
   386    386       INSERT INTO t6 VALUES(NULL);
   387    387     }
   388         -} {1 {constraint failed}}
          388  +} {1 {t6.a may not be NULL}}
   389    389   do_test table-10.2 {
   390    390     catchsql {
   391    391       DROP TABLE t6;
   392    392       CREATE TABLE t6(a REFERENCES t4(a) MATCH PARTIAL);
   393    393     }
   394    394   } {0 {}}
   395    395   do_test table-10.3 {

Changes to test/trigger2.test.

   444    444       SELECT * from tbl;
   445    445     }
   446    446   } {1 2 3}
   447    447   do_test trigger2-6.1b {
   448    448     catchsql {
   449    449       INSERT OR ABORT INTO tbl values (2, 2, 3);
   450    450     }
   451         -} {1 {constraint failed}}
          451  +} {1 {uniqueness constraint failed}}
   452    452   do_test trigger2-6.1c {
   453    453     execsql {
   454    454       SELECT * from tbl;
   455    455     }
   456    456   } {1 2 3}
   457    457   do_test trigger2-6.1d {
   458    458     catchsql {
   459    459       INSERT OR FAIL INTO tbl values (2, 2, 3);
   460    460     }
   461         -} {1 {constraint failed}}
          461  +} {1 {uniqueness constraint failed}}
   462    462   do_test trigger2-6.1e {
   463    463     execsql {
   464    464       SELECT * from tbl;
   465    465     }
   466    466   } {1 2 3 2 2 3}
   467    467   do_test trigger2-6.1f {
   468    468     execsql {
................................................................................
   470    470       SELECT * from tbl;
   471    471     }
   472    472   } {1 2 3 2 0 0}
   473    473   do_test trigger2-6.1g {
   474    474     catchsql {
   475    475       INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
   476    476     }
   477         -} {1 {constraint failed}}
          477  +} {1 {uniqueness constraint failed}}
   478    478   do_test trigger2-6.1h {
   479    479     execsql {
   480    480       SELECT * from tbl;
   481    481     }
   482    482   } {}
   483    483   
   484    484   
................................................................................
   497    497       SELECT * from tbl;
   498    498     }
   499    499   } {1 2 10 6 3 4}
   500    500   do_test trigger2-6.2b {
   501    501     catchsql {
   502    502       UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
   503    503     }
   504         -} {1 {constraint failed}}
          504  +} {1 {uniqueness constraint failed}}
   505    505   do_test trigger2-6.2c {
   506    506     execsql {
   507    507       SELECT * from tbl;
   508    508     }
   509    509   } {1 2 10 6 3 4}
   510    510   do_test trigger2-6.2d {
   511    511     catchsql {
   512    512       UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
   513    513     }
   514         -} {1 {constraint failed}}
          514  +} {1 {uniqueness constraint failed}}
   515    515   do_test trigger2-6.2e {
   516    516     execsql {
   517    517       SELECT * from tbl;
   518    518     }
   519    519   } {4 2 10 6 3 4}
   520    520   do_test trigger2-6.2f {
   521    521     execsql {
................................................................................
   526    526   execsql {
   527    527     INSERT INTO tbl VALUES (2, 3, 4);
   528    528   }
   529    529   do_test trigger2-6.2g {
   530    530     catchsql {
   531    531       UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
   532    532     }
   533         -} {1 {constraint failed}}
          533  +} {1 {uniqueness constraint failed}}
   534    534   do_test trigger2-6.2h {
   535    535     execsql {
   536    536       SELECT * from tbl;
   537    537     }
   538    538   } {4 2 3 6 3 4}
   539    539   execsql {
   540    540     DROP TABLE tbl;

Changes to test/unique.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the CREATE UNIQUE INDEX statement,
    13     13   # and primary keys, and the UNIQUE constraint on table columns
    14     14   #
    15         -# $Id: unique.test,v 1.4 2002/05/26 20:54:35 drh Exp $
           15  +# $Id: unique.test,v 1.5 2003/01/29 18:46:54 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Try to create a table with two primary keys.
    21     21   # (This is allowed in SQLite even that it is not valid SQL)
    22     22   #
................................................................................
    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 {constraint failed}}
           50  +} {1 {uniqueness constraint failed}}
    51     51   do_test unique-1.4 {
    52     52     execsql {
    53     53       SELECT * FROM t1 ORDER BY a;
    54     54     }
    55     55   } {1 2 3}
    56     56   do_test unique-1.5 {
    57     57     catchsql {
    58     58       INSERT INTO t1(a,b,c) VALUES(3,2,4)
    59     59     }
    60         -} {1 {constraint failed}}
           60  +} {1 {uniqueness constraint failed}}
    61     61   do_test unique-1.6 {
    62     62     execsql {
    63     63       SELECT * FROM t1 ORDER BY a;
    64     64     }
    65     65   } {1 2 3}
    66     66   do_test unique-1.7 {
    67     67     catchsql {
................................................................................
    93     93       SELECT * FROM t2 ORDER BY a
    94     94     }
    95     95   } {0 {1 2 3 4}}
    96     96   do_test unique-2.3 {
    97     97     catchsql {
    98     98       INSERT INTO t2 VALUES(1,5);
    99     99     }
   100         -} {1 {constraint failed}}
          100  +} {1 {uniqueness constraint failed}}
   101    101   do_test unique-2.4 {
   102    102     catchsql {
   103    103       SELECT * FROM t2 ORDER BY a
   104    104     }
   105    105   } {0 {1 2 3 4}}
   106    106   do_test unique-2.5 {
   107    107     catchsql {
................................................................................
   119    119       SELECT * FROM t2 ORDER BY a, b;
   120    120     }
   121    121   } {0 {1 2 1 5 3 4}}
   122    122   do_test unique-2.8 {
   123    123     catchsql {
   124    124       CREATE UNIQUE INDEX i2 ON t2(a);
   125    125     }
   126         -} {1 {constraint failed}}
          126  +} {1 {indexed columns are not unique}}
   127    127   do_test unique-2.9 {
   128    128     catchsql {
   129    129       CREATE INDEX i2 ON t2(a);
   130    130     }
   131    131   } {0 {}}
   132    132   
   133    133   # Test the UNIQUE keyword as used on two or more fields.
................................................................................
   156    156     }
   157    157   } {0 {1 2 3 4 1 2 3 5}}
   158    158   do_test unique-3.4 {
   159    159     catchsql {
   160    160       INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
   161    161       SELECT * FROM t3 ORDER BY a,b,c,d;
   162    162     }
   163         -} {1 {constraint failed}}
          163  +} {1 {uniqueness constraint failed}}
   164    164   
   165    165   # Make sure NULLs are distinct as far as the UNIQUE tests are
   166    166   # concerned.
   167    167   #
   168    168   do_test unique-4.1 {
   169    169     execsql {
   170    170       CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c));

Changes to test/update.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the UPDATE statement.
    13     13   #
    14         -# $Id: update.test,v 1.10 2002/07/16 17:22:51 drh Exp $
           14  +# $Id: update.test,v 1.11 2003/01/29 18:46:54 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Try to update an non-existent table
    20     20   #
    21     21   do_test update-1.1 {
................................................................................
   435    435     }
   436    436   } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
   437    437   do_test update-10.3 {
   438    438     catchsql {
   439    439       UPDATE t1 SET a=1, e=10 WHERE f=7;
   440    440       SELECT * FROM t1;
   441    441     }
   442         -} {1 {constraint failed}}
          442  +} {1 {PRIMARY KEY must be unique}}
   443    443   do_test update-10.4 {
   444    444     catchsql {
   445    445       SELECT * FROM t1;
   446    446     }
   447    447   } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
   448    448   do_test update-10.5 {
   449    449     catchsql {
................................................................................
   452    452     }
   453    453   } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
   454    454   do_test update-10.6 {
   455    455     catchsql {
   456    456       UPDATE t1 SET b=2, e=12 WHERE f=7;
   457    457       SELECT * FROM t1;
   458    458     }
   459         -} {1 {constraint failed}}
          459  +} {1 {uniqueness constraint failed}}
   460    460   do_test update-10.7 {
   461    461     catchsql {
   462    462       SELECT * FROM t1;
   463    463     }
   464    464   } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
   465    465   do_test update-10.8 {
   466    466     catchsql {
................................................................................
   469    469     }
   470    470   } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
   471    471   do_test update-10.9 {
   472    472     catchsql {
   473    473       UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;
   474    474       SELECT * FROM t1;
   475    475     }
   476         -} {1 {constraint failed}}
          476  +} {1 {uniqueness constraint failed}}
   477    477   do_test update-10.10 {
   478    478     catchsql {
   479    479       SELECT * FROM t1;
   480    480     }
   481    481   } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
   482    482   
   483    483   # Make sure we can handle a subquery in the where clause.