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 |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ccc82f1ab4539a60ee5cc2625743c538 |
User & Date: | drh 2003-01-29 18:46:52.000 |
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: af1e929946 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: ccc82f1ab4 user: drh tags: trunk) | |
14:06 | The callback-free API is now working, though much more testing is need. (CVS 853) (check-in: 162b259188 user: drh tags: trunk) | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | ** COPY ** VACUUM ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ** COPY ** VACUUM ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** ** $Id: build.c,v 1.127 2003/01/29 18:46:52 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Check to see if the schema for the database needs |
︙ | ︙ | |||
87 88 89 90 91 92 93 | rc = sqliteVdbeList(v); db->next_cookie = db->schema_cookie; }else{ sqliteVdbeExec(v); } rc = sqliteVdbeFinalize(v, &pParse->zErrMsg); if( rc ) pParse->nErr++; | < > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | rc = sqliteVdbeList(v); db->next_cookie = db->schema_cookie; }else{ sqliteVdbeExec(v); } rc = sqliteVdbeFinalize(v, &pParse->zErrMsg); if( rc ) pParse->nErr++; pParse->pVdbe = 0; pParse->rc = rc; if( rc ) pParse->nErr++; }else{ pParse->rc = pParse->nErr ? SQLITE_ERROR : SQLITE_DONE; } pParse->colNamesSet = 0; pParse->schemaVerified = 0; }else if( pParse->useCallback==0 ){ pParse->rc = SQLITE_ERROR; } pParse->nTab = 0; pParse->nMem = 0; pParse->nSet = 0; pParse->nAgg = 0; } |
︙ | ︙ | |||
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 | lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0); for(i=0; i<pIndex->nColumn; i++){ sqliteVdbeAddOp(v, OP_Column, 2, pIndex->aiColumn[i]); } sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0); if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex); sqliteVdbeAddOp(v, OP_IdxPut, 1, pIndex->onError!=OE_None); sqliteVdbeAddOp(v, OP_Next, 2, lbl1); sqliteVdbeResolveLabel(v, lbl2); sqliteVdbeAddOp(v, OP_Close, 2, 0); sqliteVdbeAddOp(v, OP_Close, 1, 0); } if( pTable!=0 ){ if( !isTemp ){ | > | 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 | lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0); for(i=0; i<pIndex->nColumn; i++){ sqliteVdbeAddOp(v, OP_Column, 2, pIndex->aiColumn[i]); } 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); sqliteVdbeAddOp(v, OP_Close, 1, 0); } if( pTable!=0 ){ if( !isTemp ){ |
︙ | ︙ |
Changes to src/expr.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.87 2003/01/29 18:46:52 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Construct a new expression node and return a pointer to it. Memory ** for this node is obtained from sqliteMalloc(). The calling function |
︙ | ︙ | |||
1212 1213 1214 1215 1216 1217 1218 | sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->iColumn); sqliteDequote(msg); sqliteVdbeChangeP3(v, -1, msg, 0); sqliteFree(msg); } else { assert( pExpr->iColumn == OE_Ignore ); sqliteVdbeAddOp(v, OP_Goto, 0, pParse->trigStack->ignoreJump); | | | 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 | sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->iColumn); sqliteDequote(msg); sqliteVdbeChangeP3(v, -1, msg, 0); sqliteFree(msg); } else { assert( pExpr->iColumn == OE_Ignore ); sqliteVdbeAddOp(v, OP_Goto, 0, pParse->trigStack->ignoreJump); sqliteVdbeChangeP3(v, -1, "(IGNORE jump)", 0); } } break; } } /* |
︙ | ︙ |
Changes to src/insert.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** ** $Id: insert.c,v 1.72 2003/01/29 18:46:52 drh Exp $ */ #include "sqliteInt.h" /* ** This routine is call to handle SQL of the following forms: ** ** insert into TABLE (IDLIST) values(EXPRLIST) |
︙ | ︙ | |||
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | } sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1); addr = sqliteVdbeAddOp(v, OP_NotNull, 1, 0); switch( onError ){ case OE_Rollback: case OE_Abort: case OE_Fail: { sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); break; } case OE_Ignore: { sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; } | > > > > | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | } sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1); addr = sqliteVdbeAddOp(v, OP_NotNull, 1, 0); switch( onError ){ 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: { sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; } |
︙ | ︙ | |||
703 704 705 706 707 708 709 710 711 712 713 714 715 716 | sqliteVdbeAddOp(v, OP_Dup, nCol, 1); jumpInst2 = sqliteVdbeAddOp(v, OP_NotExists, base, 0); switch( onError ){ case OE_Rollback: case OE_Abort: case OE_Fail: { sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); break; } case OE_Ignore: { sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; } | > | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | sqliteVdbeAddOp(v, OP_Dup, nCol, 1); jumpInst2 = sqliteVdbeAddOp(v, OP_NotExists, base, 0); switch( onError ){ case OE_Rollback: 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: { sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; } |
︙ | ︙ | |||
756 757 758 759 760 761 762 763 764 765 766 767 768 769 | sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1); jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0); switch( onError ){ case OE_Rollback: case OE_Abort: case OE_Fail: { sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); break; } case OE_Ignore: { assert( seenReplace==0 ); sqliteVdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; | > | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1); jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0); switch( onError ){ case OE_Rollback: 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: { assert( seenReplace==0 ); sqliteVdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0); sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest); break; |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.112 2003/01/29 18:46:53 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** A pointer to this structure is used to communicate information |
︙ | ︙ | |||
712 713 714 715 716 717 718 | ** should use sqlite_freemem() to delete the message when it has finished ** with it. */ int sqlite_finalize( sqlite_vm *pVm, /* The virtual machine to be destroyed */ char **pzErrMsg /* OUT: Write error messages here */ ){ | | > > | 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | ** should use sqlite_freemem() to delete the message when it has finished ** with it. */ int sqlite_finalize( sqlite_vm *pVm, /* The virtual machine to be destroyed */ char **pzErrMsg /* OUT: Write error messages here */ ){ int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg); sqliteStrRealloc(pzErrMsg); return rc; } /* ** Return a static string that describes the kind of error specified in the ** argument. */ const char *sqlite_error_string(int rc){ |
︙ | ︙ |
Changes to src/parse.y.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** ** @(#) $Id: parse.y,v 1.90 2003/01/29 18:46:53 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} %syntax_error { if( pParse->zErrMsg==0 ){ |
︙ | ︙ | |||
68 69 70 71 72 73 74 | // Input is zero or more commands. input ::= cmdlist. // A list of commands is zero or more commands // cmdlist ::= ecmd. cmdlist ::= cmdlist ecmd. | | > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | // Input is zero or more commands. input ::= cmdlist. // A list of commands is zero or more commands // cmdlist ::= ecmd. cmdlist ::= cmdlist ecmd. ecmd ::= explain cmdx SEMI. ecmd ::= SEMI. cmdx ::= cmd. { sqliteExec(pParse); } explain ::= EXPLAIN. { sqliteBeginParse(pParse, 1); } explain ::= . { sqliteBeginParse(pParse, 0); } ///////////////////// Begin and end transactions. //////////////////////////// // cmd ::= BEGIN trans_opt onconf(R). {sqliteBeginTransaction(pParse,R);} |
︙ | ︙ |
Changes to src/printf.c.
︙ | ︙ | |||
674 675 676 677 678 679 680 681 682 683 684 685 686 687 | } if( pM->zText ){ memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); pM->nChar += nNewChar; pM->zText[pM->nChar] = 0; } } /* ** 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 *sqlite_mprintf(const char *zFormat, ...){ | > > > > > > > > > > > > > > > > > > > > > > | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | } if( pM->zText ){ memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); pM->nChar += nNewChar; pM->zText[pM->nChar] = 0; } } /* ** 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 ** sqliteFree() to release the memory allocated. */ char *sqlite_mprintf(const char *zFormat, ...){ |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.159 2003/01/29 18:46:53 drh Exp $ */ #include "config.h" #include "sqlite.h" #include "hash.h" #include "vdbe.h" #include "parse.h" #include "btree.h" |
︙ | ︙ | |||
920 921 922 923 924 925 926 927 928 929 930 931 932 933 | void *sqliteMallocRaw(int); void sqliteFree(void*); void *sqliteRealloc(void*,int); char *sqliteStrDup(const char*); char *sqliteStrNDup(const char*, int); # define sqliteCheckMemory(a,b) #endif void sqliteSetString(char **, const char *, ...); void sqliteSetNString(char **, ...); void sqliteDequote(char*); int sqliteKeywordCode(const char*, int); int sqliteRunParser(Parse*, const char*, char **); void sqliteExec(Parse*); Expr *sqliteExpr(int, Expr*, Expr*, Token*); | > | 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | void *sqliteMallocRaw(int); void sqliteFree(void*); void *sqliteRealloc(void*,int); char *sqliteStrDup(const 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*); int sqliteKeywordCode(const char*, int); int sqliteRunParser(Parse*, const char*, char **); void sqliteExec(Parse*); Expr *sqliteExpr(int, Expr*, Expr*, Token*); |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.19 2003/01/29 18:46:53 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | if( argc!=4 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB SQL TAILVAR", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; rc = sqlite_compile(db, argv[2], &zTail, &vm, &zErr); if( rc ){ assert( vm==0 ); sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, zErr, 0); sqlite_freemem(zErr); return TCL_ERROR; } if( vm ){ sprintf(zBuf, "%p", vm); Tcl_AppendResult(interp, zBuf, 0); } | > < | 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | if( argc!=4 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB SQL TAILVAR", 0); return TCL_ERROR; } 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); Tcl_AppendResult(interp, zBuf, zErr, 0); sqlite_freemem(zErr); return TCL_ERROR; } if( vm ){ sprintf(zBuf, "%p", vm); Tcl_AppendResult(interp, zBuf, 0); } return TCL_OK; } /* ** Usage: sqlite_step VM NVAR VALUEVAR COLNAMEVAR ** ** Step a virtual machine. Return a the result code as a string. |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
32 33 34 35 36 37 38 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** 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.202 2003/01/29 18:46:53 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The makefile scans this source file and creates the following ** array of string constants which are the names of all VDBE opcodes. |
︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | ** VDBE, but do not rollback the transaction. ** ** There is an implied "Halt 0 0 0" instruction inserted at the very end of ** every program. So a jump past the last instruction of the program ** is the same as executing Halt. */ case OP_Halt: { if( pOp->p1!=SQLITE_OK ){ p->rc = pOp->p1; p->errorAction = pOp->p2; if( pOp->p3 ){ sqliteSetString(&p->zErrMsg, pOp->p3, 0); } }else{ p->rc = SQLITE_OK; | > > < < | > | 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 | ** VDBE, but do not rollback the transaction. ** ** There is an implied "Halt 0 0 0" instruction inserted at the very end of ** every program. So a jump past the last instruction of the program ** 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; } } /* Opcode: Integer P1 * P3 ** ** The integer value P1 is pushed onto the stack. If P3 is not zero ** then it is assumed to be a string representation of the same integer. */ |
︙ | ︙ | |||
4303 4304 4305 4306 4307 4308 4309 | sqliteBtreeKeySize(pCrsr, &n); if( n==nKey && sqliteBtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &c)==SQLITE_OK && c==0 ){ rc = SQLITE_CONSTRAINT; if( pOp->p3 && pOp->p3[0] ){ | | | 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 | sqliteBtreeKeySize(pCrsr, &n); if( n==nKey && sqliteBtreeKeyCompare(pCrsr, zKey, nKey-4, 4, &c)==SQLITE_OK && c==0 ){ rc = SQLITE_CONSTRAINT; if( pOp->p3 && pOp->p3[0] ){ sqliteSetString(&p->zErrMsg, pOp->p3, 0); } goto abort_due_to_error; } if( res<0 ){ sqliteBtreeNext(pCrsr, &res); res = +1; }else{ |
︙ | ︙ | |||
5610 5611 5612 5613 5614 5615 5616 | rc = SQLITE_MISUSE; /* Fall thru into abort_due_to_error */ /* Jump to here for any other kind of fatal error. The "rc" variable ** should hold the error number. */ abort_due_to_error: | > | > | 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 | rc = SQLITE_MISUSE; /* Fall thru into abort_due_to_error */ /* Jump to here for any other kind of fatal error. The "rc" variable ** should hold the error number. */ abort_due_to_error: 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 ** flag. */ abort_due_to_interrupt: assert( db->flags & SQLITE_Interrupt ); |
︙ | ︙ | |||
5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 | /* ** Clean up the VDBE after execution. Return an integer which is the ** result code. */ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){ sqlite *db = p->db; Btree *pBt = p->pBt; if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){ sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), 0); return SQLITE_MISUSE; } if( p->zErrMsg ){ if( pzErrMsg && *pzErrMsg==0 ){ | > | 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 | /* ** Clean up the VDBE after execution. Return an integer which is the ** result code. */ 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); return SQLITE_MISUSE; } if( p->zErrMsg ){ if( pzErrMsg && *pzErrMsg==0 ){ |
︙ | ︙ | |||
5723 5724 5725 5726 5727 5728 5729 | ); vdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif | > > | | 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 | ); vdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif rc = p->rc; sqliteVdbeDelete(p); return rc; } |
Changes to src/vdbe.h.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** 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.64 2003/01/29 18:46:53 drh Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ #include <stdio.h> /* ** A single VDBE is an opaque structure named "Vdbe". Only routines |
︙ | ︙ | |||
46 47 48 49 50 51 52 | }; typedef struct VdbeOp VdbeOp; /* ** Allowed values of VdbeOp.p3type */ #define P3_NOTUSED 0 /* The P3 parameter is not used */ | | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | }; 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 (-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 ** of a VdbeOp structure into a negative number so that ** sqliteVdbeAddOpList() knows that the address is relative. Calling ** the macro again restores the address. */ |
︙ | ︙ |
Changes to test/capi2.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # 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.2 2003/01/29 18:46:54 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Check basic functionality # do_test capi2-1.1 { db close 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 } {} do_test capi2-1.2 { sqlite_step $VM N VALUES COLNAMES } {SQLITE_ROW} do_test capi2-1.3 { set N } {2} do_test capi2-1.4 { set VALUES } {t1 1} do_test capi2-1.5 { 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 } {SQLITE_DONE} do_test capi2-1.7 { 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 } {SQLITE_MISUSE} do_test capi2-1.9 { list $N $VALUES $COLNAMES } {x y z} do_test capi2-1.10 { 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 { 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 } { 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] 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] lappend r $n $val $colname } {SQLITE_DONE 2 {} {name rowid text INTEGER}} do_test capi2-2.4 { sqlite_finalize $VM } {} do_test capi2-2.5 { 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] lappend r $n $val $colname } {SQLITE_DONE 2 {} {name rowid text INTEGER}} do_test capi2-2.7 { sqlite_finalize $VM } {} do_test capi2-2.8 { 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 |
Changes to test/conflict.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the conflict resolution extension # to SQLite. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the conflict resolution extension # to SQLite. # # $Id: conflict.test,v 1.15 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create tables for the first group of tests. # do_test conflict-1.0 { |
︙ | ︙ | |||
284 285 286 287 288 289 290 | 18 {} REPLACE INSERT 0 5 1 19 {} FAIL INSERT 1 {} 1 20 {} ABORT INSERT 1 {} 1 21 {} ROLLBACK INSERT 1 {} {} 22 REPLACE FAIL INSERT 0 5 1 23 IGNORE ROLLBACK INSERT 0 {} 1 } { | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | 18 {} REPLACE INSERT 0 5 1 19 {} FAIL INSERT 1 {} 1 20 {} ABORT INSERT 1 {} 1 21 {} ROLLBACK INSERT 1 {} {} 22 REPLACE FAIL INSERT 0 5 1 23 IGNORE ROLLBACK INSERT 0 {} 1 } { 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"} set r0 [catch {execsql [subst { DROP TABLE t1; CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5); DELETE FROM t2; |
︙ | ︙ | |||
352 353 354 355 356 357 358 | 18 {} REPLACE UPDATE 0 {7 6 9} 1 19 {} FAIL UPDATE 1 {6 7 3 4} 1 20 {} ABORT UPDATE 1 {1 2 3 4} 1 21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0 22 REPLACE FAIL UPDATE 0 {7 6 9} 1 23 IGNORE ROLLBACK UPDATE 0 {6 7 3 9} 1 } { | | | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | 18 {} REPLACE UPDATE 0 {7 6 9} 1 19 {} FAIL UPDATE 1 {6 7 3 4} 1 20 {} ABORT UPDATE 1 {1 2 3 4} 1 21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0 22 REPLACE FAIL UPDATE 0 {7 6 9} 1 23 IGNORE ROLLBACK UPDATE 0 {6 7 3 9} 1 } { 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"} set r0 [catch {execsql [subst { DROP TABLE t1; CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1); INSERT INTO t1 SELECT * FROM t2; |
︙ | ︙ | |||
528 529 530 531 532 533 534 | } } {0 {1 1 1 1 1 2 2 2 2 2}} do_test conflict-9.5 { catchsql { INSERT INTO t2 VALUES(3,1,3,3,3); SELECT * FROM t2; } | | | | | | | | | | | | | | | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | } } {0 {1 1 1 1 1 2 2 2 2 2}} do_test conflict-9.5 { catchsql { INSERT INTO t2 VALUES(3,1,3,3,3); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.6 { catchsql { UPDATE t2 SET b=b+1 WHERE b=1; SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.7 { catchsql { BEGIN; UPDATE t3 SET x=x+1; INSERT INTO t2 VALUES(3,1,3,3,3); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.8 { execsql {COMMIT} execsql {SELECT * FROM t3} } {2} 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 {uniqueness constraint failed}} do_test conflict-9.10 { execsql {COMMIT} execsql {SELECT * FROM t3} } {3} do_test conflict-9.11 { catchsql { INSERT INTO t2 VALUES(3,3,3,1,3); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.12 { catchsql { UPDATE t2 SET d=d+1 WHERE d=1; SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.13 { catchsql { BEGIN; UPDATE t3 SET x=x+1; INSERT INTO t2 VALUES(3,3,3,1,3); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.14 { execsql {COMMIT} execsql {SELECT * FROM t3} } {4} do_test conflict-9.15 { catchsql { BEGIN; UPDATE t3 SET x=x+1; UPDATE t2 SET d=d+1 WHERE d=1; SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.16 { execsql {COMMIT} execsql {SELECT * FROM t3} } {5} do_test conflict-9.17 { catchsql { INSERT INTO t2 VALUES(3,3,3,3,1); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.18 { catchsql { UPDATE t2 SET e=e+1 WHERE e=1; SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.19 { catchsql { BEGIN; UPDATE t3 SET x=x+1; INSERT INTO t2 VALUES(3,3,3,3,1); SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.20 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} } {5} do_test conflict-9.21 { catchsql { BEGIN; UPDATE t3 SET x=x+1; UPDATE t2 SET e=e+1 WHERE e=1; SELECT * FROM t2; } } {1 {uniqueness constraint failed}} do_test conflict-9.22 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} } {5} do_test conflict-9.23 { catchsql { INSERT INTO t2 VALUES(3,3,1,3,3); |
︙ | ︙ |
Changes to test/copy.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the COPY statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the COPY statement. # # $Id: copy.test,v 1.13 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a file of data from which to copy. # set f [open data1.txt w] |
︙ | ︙ | |||
192 193 194 195 196 197 198 | set fd [open data6.txt w] puts $fd "33|22|44" close $fd catchsql { COPY t1 FROM 'data6.txt' USING DELIMITERS '|'; SELECT * FROM t1; } | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | set fd [open data6.txt w] puts $fd "33|22|44" close $fd catchsql { COPY t1 FROM 'data6.txt' USING DELIMITERS '|'; SELECT * FROM t1; } } {1 {uniqueness constraint failed}} do_test copy-5.3 { set fd [open data6.txt w] puts $fd "33|22|44" close $fd catchsql { COPY OR IGNORE t1 FROM 'data6.txt' USING DELIMITERS '|'; SELECT * FROM t1; |
︙ | ︙ |
Changes to test/intpkey.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the special processing associated # with INTEGER PRIMARY KEY columns. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the special processing associated # with INTEGER PRIMARY KEY columns. # # $Id: intpkey.test,v 1.12 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table with a primary key and a datatype other than # integer # |
︙ | ︙ | |||
72 73 74 75 76 77 78 | # failure. # do_test intpkey-1.6 { set r [catch {execsql { INSERT INTO t1 VALUES(5,'second','entry'); }} msg] lappend r $msg | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # failure. # do_test intpkey-1.6 { set r [catch {execsql { INSERT INTO t1 VALUES(5,'second','entry'); }} msg] lappend r $msg } {1 {PRIMARY KEY must be unique}} do_test intpkey-1.7 { execsql { SELECT rowid, * FROM t1; } } {5 5 hello world} do_test intpkey-1.8 { set r [catch {execsql { |
︙ | ︙ |
Changes to test/misc1.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc1.test,v 1.19 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test the creation and use of tables that have a large number # of columns. # |
︙ | ︙ | |||
218 219 220 221 222 223 224 | SELECT * FROM t5 ORDER BY a; } } {1 2 3} do_test misc1-7.4 { catchsql { INSERT INTO t5 VALUES(1,2,4); } | | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | SELECT * FROM t5 ORDER BY a; } } {1 2 3} do_test misc1-7.4 { catchsql { INSERT INTO t5 VALUES(1,2,4); } } {1 {uniqueness constraint failed}} do_test misc1-7.5 { catchsql { INSERT INTO t5 VALUES(0,2,4); } } {0 {}} do_test misc1-7.6 { execsql { |
︙ | ︙ |
Changes to test/notnull.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the NOT NULL constraint. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the NOT NULL constraint. # # $Id: notnull.test,v 1.3 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test notnull-1.0 { execsql { CREATE TABLE t1 ( |
︙ | ︙ | |||
38 39 40 41 42 43 44 | } {0 {1 2 3 4 5}} do_test notnull-1.2 { catchsql { DELETE FROM t1; INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | } {0 {1 2 3 4 5}} do_test notnull-1.2 { catchsql { DELETE FROM t1; INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} do_test notnull-1.3 { catchsql { DELETE FROM t1; INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {0 {}} do_test notnull-1.4 { catchsql { DELETE FROM t1; INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {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 {t1.a may not be NULL}} do_test notnull-1.6 { catchsql { DELETE FROM t1; INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5); SELECT * FROM t1 order by a; } } {0 {1 5 3 4 5}} |
︙ | ︙ | |||
94 95 96 97 98 99 100 | } {0 {1 5 3 4 5}} do_test notnull-1.10 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | } {0 {1 5 3 4 5}} do_test notnull-1.10 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } } {1 {t1.b may not be NULL}} do_test notnull-1.11 { catchsql { DELETE FROM t1; INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } } {0 {}} |
︙ | ︙ | |||
136 137 138 139 140 141 142 | } {0 {1 2 6 4 5}} do_test notnull-1.16 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5); SELECT * FROM t1 order by a; } | | | | | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | } {0 {1 2 6 4 5}} do_test notnull-1.16 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5); SELECT * FROM t1 order by a; } } {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 {t1.d may not be NULL}} do_test notnull-1.18 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5); SELECT * FROM t1 order by a; } } {0 {1 2 3 7 5}} do_test notnull-1.19 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4); SELECT * FROM t1 order by a; } } {0 {1 2 3 4 8}} do_test notnull-1.20 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null); SELECT * FROM t1 order by a; } } {1 {t1.e may not be NULL}} do_test notnull-1.21 { catchsql { DELETE FROM t1; INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5); SELECT * FROM t1 order by a; } } {0 {5 5 3 2 1}} do_test notnull-2.1 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-2.2 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR REPLACE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-2.3 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR IGNORE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {0 {1 2 3 4 5}} do_test notnull-2.4 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR ABORT t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-2.5 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET b=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.b may not be NULL}} do_test notnull-2.6 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR REPLACE t1 SET b=null, d=e, e=d; SELECT * FROM t1 ORDER BY a; } |
︙ | ︙ | |||
252 253 254 255 256 257 258 | do_test notnull-2.10 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET e=null, a=b, b=a; SELECT * FROM t1 ORDER BY a; } | | | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | do_test notnull-2.10 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET e=null, a=b, b=a; SELECT * FROM t1 ORDER BY a; } } {1 {t1.e may not be NULL}} do_test notnull-3.0 { execsql { CREATE INDEX t1a ON t1(a); CREATE INDEX t1b ON t1(b); CREATE INDEX t1c ON t1(c); CREATE INDEX t1d ON t1(d); |
︙ | ︙ | |||
277 278 279 280 281 282 283 | } {0 {1 2 3 4 5}} do_test notnull-3.2 { catchsql { DELETE FROM t1; INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } | | | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | } {0 {1 2 3 4 5}} do_test notnull-3.2 { catchsql { DELETE FROM t1; INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} do_test notnull-3.3 { catchsql { DELETE FROM t1; INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {0 {}} do_test notnull-3.4 { catchsql { DELETE FROM t1; INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5); SELECT * FROM t1 order by a; } } {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 {t1.a may not be NULL}} do_test notnull-3.6 { catchsql { DELETE FROM t1; INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5); SELECT * FROM t1 order by a; } } {0 {1 5 3 4 5}} |
︙ | ︙ | |||
333 334 335 336 337 338 339 | } {0 {1 5 3 4 5}} do_test notnull-3.10 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | } {0 {1 5 3 4 5}} do_test notnull-3.10 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } } {1 {t1.b may not be NULL}} do_test notnull-3.11 { catchsql { DELETE FROM t1; INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5); SELECT * FROM t1 order by a; } } {0 {}} |
︙ | ︙ | |||
375 376 377 378 379 380 381 | } {0 {1 2 6 4 5}} do_test notnull-3.16 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5); SELECT * FROM t1 order by a; } | | | | | | | | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | } {0 {1 2 6 4 5}} do_test notnull-3.16 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5); SELECT * FROM t1 order by a; } } {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 {t1.d may not be NULL}} do_test notnull-3.18 { catchsql { DELETE FROM t1; INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5); SELECT * FROM t1 order by a; } } {0 {1 2 3 7 5}} do_test notnull-3.19 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4); SELECT * FROM t1 order by a; } } {0 {1 2 3 4 8}} do_test notnull-3.20 { catchsql { DELETE FROM t1; INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null); SELECT * FROM t1 order by a; } } {1 {t1.e may not be NULL}} do_test notnull-3.21 { catchsql { DELETE FROM t1; INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5); SELECT * FROM t1 order by a; } } {0 {5 5 3 2 1}} do_test notnull-4.1 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-4.2 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR REPLACE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-4.3 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR IGNORE t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {0 {1 2 3 4 5}} do_test notnull-4.4 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR ABORT t1 SET a=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} do_test notnull-4.5 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET b=null; SELECT * FROM t1 ORDER BY a; } } {1 {t1.b may not be NULL}} do_test notnull-4.6 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE OR REPLACE t1 SET b=null, d=e, e=d; SELECT * FROM t1 ORDER BY a; } |
︙ | ︙ | |||
491 492 493 494 495 496 497 | do_test notnull-4.10 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET e=null, a=b, b=a; SELECT * FROM t1 ORDER BY a; } | | | 491 492 493 494 495 496 497 498 499 500 | do_test notnull-4.10 { catchsql { DELETE FROM t1; INSERT INTO t1 VALUES(1,2,3,4,5); UPDATE t1 SET e=null, a=b, b=a; SELECT * FROM t1 ORDER BY a; } } {1 {t1.e may not be NULL}} finish_test |
Changes to test/table.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE TABLE statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE TABLE statement. # # $Id: table.test,v 1.22 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a basic table and verify it is added to sqlite_master # do_test table-1.1 { |
︙ | ︙ | |||
381 382 383 384 385 386 387 | # Check the foreign key syntax. # do_test table-10.1 { catchsql { CREATE TABLE t6(a REFERENCES t4(a) NOT NULL); INSERT INTO t6 VALUES(NULL); } | | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | # Check the foreign key syntax. # do_test table-10.1 { catchsql { CREATE TABLE t6(a REFERENCES t4(a) NOT NULL); INSERT INTO t6 VALUES(NULL); } } {1 {t6.a may not be NULL}} do_test table-10.2 { catchsql { DROP TABLE t6; CREATE TABLE t6(a REFERENCES t4(a) MATCH PARTIAL); } } {0 {}} do_test table-10.3 { |
︙ | ︙ |
Changes to test/trigger2.test.
︙ | ︙ | |||
444 445 446 447 448 449 450 | SELECT * from tbl; } } {1 2 3} do_test trigger2-6.1b { catchsql { INSERT OR ABORT INTO tbl values (2, 2, 3); } | | | | | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | SELECT * from tbl; } } {1 2 3} do_test trigger2-6.1b { catchsql { INSERT OR ABORT INTO tbl values (2, 2, 3); } } {1 {uniqueness constraint failed}} do_test trigger2-6.1c { execsql { SELECT * from tbl; } } {1 2 3} do_test trigger2-6.1d { catchsql { INSERT OR FAIL INTO tbl values (2, 2, 3); } } {1 {uniqueness constraint failed}} do_test trigger2-6.1e { execsql { SELECT * from tbl; } } {1 2 3 2 2 3} do_test trigger2-6.1f { execsql { INSERT OR REPLACE INTO tbl values (2, 2, 3); SELECT * from tbl; } } {1 2 3 2 0 0} do_test trigger2-6.1g { catchsql { INSERT OR ROLLBACK INTO tbl values (3, 2, 3); } } {1 {uniqueness constraint failed}} do_test trigger2-6.1h { execsql { SELECT * from tbl; } } {} |
︙ | ︙ | |||
497 498 499 500 501 502 503 | SELECT * from tbl; } } {1 2 10 6 3 4} do_test trigger2-6.2b { catchsql { UPDATE OR ABORT tbl SET a = 4 WHERE a = 1; } | | | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | SELECT * from tbl; } } {1 2 10 6 3 4} do_test trigger2-6.2b { catchsql { UPDATE OR ABORT tbl SET a = 4 WHERE a = 1; } } {1 {uniqueness constraint failed}} do_test trigger2-6.2c { execsql { SELECT * from tbl; } } {1 2 10 6 3 4} do_test trigger2-6.2d { catchsql { UPDATE OR FAIL tbl SET a = 4 WHERE a = 1; } } {1 {uniqueness constraint failed}} do_test trigger2-6.2e { execsql { SELECT * from tbl; } } {4 2 10 6 3 4} do_test trigger2-6.2f { execsql { UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4; SELECT * from tbl; } } {1 3 10} execsql { INSERT INTO tbl VALUES (2, 3, 4); } do_test trigger2-6.2g { catchsql { UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1; } } {1 {uniqueness constraint failed}} do_test trigger2-6.2h { execsql { SELECT * from tbl; } } {4 2 3 6 3 4} execsql { DROP TABLE tbl; |
︙ | ︙ |
Changes to test/unique.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE UNIQUE INDEX statement, # and primary keys, and the UNIQUE constraint on table columns # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # 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.5 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to create a table with two primary keys. # (This is allowed in SQLite even that it is not valid SQL) # |
︙ | ︙ | |||
43 44 45 46 47 48 49 | INSERT INTO t1(a,b,c) VALUES(1,2,3) } } {0 {}} do_test unique-1.3 { catchsql { INSERT INTO t1(a,b,c) VALUES(1,3,4) } | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | INSERT INTO t1(a,b,c) VALUES(1,2,3) } } {0 {}} do_test unique-1.3 { catchsql { INSERT INTO t1(a,b,c) VALUES(1,3,4) } } {1 {uniqueness constraint failed}} do_test unique-1.4 { execsql { SELECT * FROM t1 ORDER BY a; } } {1 2 3} do_test unique-1.5 { catchsql { INSERT INTO t1(a,b,c) VALUES(3,2,4) } } {1 {uniqueness constraint failed}} do_test unique-1.6 { execsql { SELECT * FROM t1 ORDER BY a; } } {1 2 3} do_test unique-1.7 { catchsql { |
︙ | ︙ | |||
93 94 95 96 97 98 99 | SELECT * FROM t2 ORDER BY a } } {0 {1 2 3 4}} do_test unique-2.3 { catchsql { INSERT INTO t2 VALUES(1,5); } | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | SELECT * FROM t2 ORDER BY a } } {0 {1 2 3 4}} do_test unique-2.3 { catchsql { INSERT INTO t2 VALUES(1,5); } } {1 {uniqueness constraint failed}} do_test unique-2.4 { catchsql { SELECT * FROM t2 ORDER BY a } } {0 {1 2 3 4}} do_test unique-2.5 { catchsql { |
︙ | ︙ | |||
119 120 121 122 123 124 125 | SELECT * FROM t2 ORDER BY a, b; } } {0 {1 2 1 5 3 4}} do_test unique-2.8 { catchsql { CREATE UNIQUE INDEX i2 ON t2(a); } | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | SELECT * FROM t2 ORDER BY a, b; } } {0 {1 2 1 5 3 4}} do_test unique-2.8 { catchsql { CREATE UNIQUE INDEX i2 ON t2(a); } } {1 {indexed columns are not unique}} do_test unique-2.9 { catchsql { CREATE INDEX i2 ON t2(a); } } {0 {}} # Test the UNIQUE keyword as used on two or more fields. |
︙ | ︙ | |||
156 157 158 159 160 161 162 | } } {0 {1 2 3 4 1 2 3 5}} do_test unique-3.4 { catchsql { INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5); SELECT * FROM t3 ORDER BY a,b,c,d; } | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | } } {0 {1 2 3 4 1 2 3 5}} do_test unique-3.4 { catchsql { INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5); SELECT * FROM t3 ORDER BY a,b,c,d; } } {1 {uniqueness constraint failed}} # Make sure NULLs are distinct as far as the UNIQUE tests are # concerned. # do_test unique-4.1 { execsql { CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c)); |
︙ | ︙ |
Changes to test/update.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the UPDATE statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the UPDATE statement. # # $Id: update.test,v 1.11 2003/01/29 18:46:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to update an non-existent table # do_test update-1.1 { |
︙ | ︙ | |||
435 436 437 438 439 440 441 | } } {0 {1 2 3 4 9 6 2 3 4 4 6 7}} do_test update-10.3 { catchsql { UPDATE t1 SET a=1, e=10 WHERE f=7; SELECT * FROM t1; } | | | | | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | } } {0 {1 2 3 4 9 6 2 3 4 4 6 7}} do_test update-10.3 { catchsql { UPDATE t1 SET a=1, e=10 WHERE f=7; SELECT * FROM t1; } } {1 {PRIMARY KEY must be unique}} do_test update-10.4 { catchsql { SELECT * FROM t1; } } {0 {1 2 3 4 9 6 2 3 4 4 6 7}} do_test update-10.5 { catchsql { UPDATE t1 SET b=2, e=11 WHERE f=6; SELECT * FROM t1; } } {0 {1 2 3 4 11 6 2 3 4 4 6 7}} do_test update-10.6 { catchsql { UPDATE t1 SET b=2, e=12 WHERE f=7; SELECT * FROM t1; } } {1 {uniqueness constraint failed}} do_test update-10.7 { catchsql { SELECT * FROM t1; } } {0 {1 2 3 4 11 6 2 3 4 4 6 7}} do_test update-10.8 { catchsql { UPDATE t1 SET c=3, d=4, e=13 WHERE f=6; SELECT * FROM t1; } } {0 {1 2 3 4 13 6 2 3 4 4 6 7}} do_test update-10.9 { catchsql { UPDATE t1 SET c=3, d=4, e=14 WHERE f=7; SELECT * FROM t1; } } {1 {uniqueness constraint failed}} do_test update-10.10 { catchsql { SELECT * FROM t1; } } {0 {1 2 3 4 13 6 2 3 4 4 6 7}} # Make sure we can handle a subquery in the where clause. |
︙ | ︙ |