Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fixed the support of UNIQUE and PRIMARY KEY. (CVS 268) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
116fdad06868acf6aca9e75c2c3497c0 |
User & Date: | drh 2001-09-27 15:11:54.000 |
Context
2001-09-27
| ||
15:13 | Alpha-3 (CVS 269) (check-in: a70d445070 user: drh tags: trunk) | |
15:11 | Fixed the support of UNIQUE and PRIMARY KEY. (CVS 268) (check-in: 116fdad068 user: drh tags: trunk) | |
03:22 | Added basic support for enforcement of UNIQUE on indices and primary keys. Support for addition constraints is to follow. (CVS 267) (check-in: 34c42967f3 user: drh tags: trunk) | |
Changes
Changes to src/build.c.
︙ | |||
21 22 23 24 25 26 27 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | - + | ** COPY ** VACUUM ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** |
︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | + | ** more of the CREATE TABLE statement is parsed, additional action ** routines are called to build up more of the table. */ void sqliteStartTable(Parse *pParse, Token *pStart, Token *pName){ Table *pTable; char *zName; sqlite *db = pParse->db; Vdbe *v; pParse->sFirstToken = *pStart; zName = sqliteTableNameFromToken(pName); if( zName==0 ) return; pTable = sqliteFindTable(db, zName); if( pTable!=0 ){ sqliteSetNString(&pParse->zErrMsg, "table ", 0, pName->z, pName->n, |
︙ | |||
366 367 368 369 370 371 372 | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | + - + - - + | if( pTable==0 ) return; pTable->zName = zName; pTable->nCol = 0; pTable->aCol = 0; pTable->pIndex = 0; if( pParse->pNewTable ) sqliteDeleteTable(db, pParse->pNewTable); pParse->pNewTable = pTable; if( !pParse->initFlag && (v = sqliteGetVdbe(pParse))!=0 ){ |
︙ | |||
487 488 489 490 491 492 493 | 488 489 490 491 492 493 494 495 496 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 | - - - - + - - - + + - - - - - - - - + - - - - - - - - - - - + + + | ** pParse->newTnum field. (The page number should have been put ** there by the sqliteOpenCb routine.) If the table has a primary ** key, the root page of the index associated with the primary key ** should be in pParse->newKnum. */ if( pParse->initFlag ){ p->tnum = pParse->newTnum; |
︙ | |||
630 631 632 633 634 635 636 | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | - - + + + - + + | db->flags |= SQLITE_InternChanges; } } /* ** Create a new index for an SQL table. pIndex is the name of the index ** and pTable is the name of the table that is to be indexed. Both will |
︙ | |||
675 676 677 678 679 680 681 | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 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 | - - + + + + + + + - + | pParse->nErr++; goto exit_create_index; } /* ** Find the name of the index. Make sure there is not already another ** index or table with the same name. If pName==0 it means that we are |
︙ | |||
742 743 744 745 746 747 748 | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | - + - - - - - - - - + + + + - + + - - + + - - - + - + - - - - - - - - - - - - - - - - - + + + - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - | sqliteFree(pIndex); goto exit_create_index; } pIndex->aiColumn[i] = j; } /* Link the new Index structure to its table and to the other |
︙ |
Changes to src/main.c.
︙ | |||
10 11 12 13 14 15 16 | 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 | - + - - + - + - + - + + - - - - + + + + - - + + + + + + + + + | ** ************************************************************************* ** 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. ** |
︙ | |||
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 | - + - - + - | ** The master database table has a structure like this */ static char master_schema[] = "CREATE TABLE " MASTER_NAME " (\n" " type text,\n" " name text,\n" " tbl_name text,\n" |
︙ | |||
132 133 134 135 136 137 138 | 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 | - + - - - + + - - + + - + - - - - - + + + + - + - - - - - + + + + - - + | ** SQL for each index. The callback will invoke the ** parser to build the internal representation of the ** database scheme. */ static VdbeOp initProg[] = { { OP_Open, 0, 2, 0}, { OP_Rewind, 0, 0, 0}, |
︙ | |||
199 200 201 202 203 204 205 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | - - + + - - + | } if( rc==SQLITE_OK ){ Table *pTab; char *azArg[6]; azArg[0] = "table"; azArg[1] = MASTER_NAME; azArg[2] = "2"; |
︙ |
Changes to src/parse.y.
︙ | |||
10 11 12 13 14 15 16 | 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. ** |
︙ | |||
121 122 123 124 125 126 127 | 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 | - + - + - - + + | carg ::= DEFAULT MINUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,1);} carg ::= DEFAULT NULL. // In addition to the type name, we also care about the primary key. // ccons ::= NOT NULL. ccons ::= PRIMARY KEY sortorder. {sqliteCreateIndex(pParse,0,0,0,1,0,0);} |
︙ |
Changes to src/shell.c.
︙ | |||
8 9 10 11 12 13 14 | 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 code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** |
︙ | |||
644 645 646 647 648 649 650 651 652 653 654 655 656 657 | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | + | extern int sqliteStrICmp(const char*,const char*); if( sqliteStrICmp(azArg[1],"sqlite_master")==0 ){ char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TABLE sqlite_master (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" " sql text\n" ")"; new_argv[1] = 0; new_colv[0] = "sql"; new_colv[1] = 0; callback(&data, 1, new_argv, new_colv); }else{ |
︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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. ** |
︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | + | void sqliteUpdate(Parse*, Token*, ExprList*, Expr*); WhereInfo *sqliteWhereBegin(Parse*, IdList*, Expr*, int); void sqliteWhereEnd(WhereInfo*); void sqliteExprCode(Parse*, Expr*); void sqliteExprIfTrue(Parse*, Expr*, int); void sqliteExprIfFalse(Parse*, Expr*, int); Table *sqliteFindTable(sqlite*,char*); Index *sqliteFindIndex(sqlite*,char*); void sqliteCopy(Parse*, Token*, Token*, Token*); void sqliteVacuum(Parse*, Token*); int sqliteGlobCompare(const unsigned char*,const unsigned char*); int sqliteLikeCompare(const unsigned char*,const unsigned char*); char *sqliteTableNameFromToken(Token*); int sqliteExprCheck(Parse*, Expr*, int, int*); int sqliteExprCompare(Expr*, Expr*); |
︙ |
Changes to src/vdbe.c.
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + | ** type to the other occurs as necessary. ** ** Most of the code in this file is taken up by the sqliteVdbeExec() ** function which does the work of interpreting a VDBE program. ** But other routines are also provided to help in building up ** a program instruction by instruction. ** |
︙ | |||
198 199 200 201 202 203 204 | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | - - | char *zLine; /* A single line from the input file */ int nLineAlloc; /* Number of spaces allocated for zLine */ int nMem; /* Number of memory locations currently allocated */ Mem *aMem; /* The memory locations */ Agg agg; /* Aggregate information */ int nSet; /* Number of sets allocated */ Set *aSet; /* An array of sets */ |
︙ | |||
222 223 224 225 226 227 228 | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | - - - - - - - - - - - - - - - - - - | /* ** Turn tracing on or off */ void sqliteVdbeTrace(Vdbe *p, FILE *trace){ p->trace = trace; } |
︙ | |||
284 285 286 287 288 289 290 291 292 293 294 295 296 297 | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | + | p->aOp[i].p1 = p1; if( p2<0 && (-1-p2)<p->nLabel && p->aLabel[-1-p2]>=0 ){ p2 = p->aLabel[-1-p2]; } p->aOp[i].p2 = p2; if( p3 && p3[0] ){ p->aOp[i].p3 = sqliteStrDup(p3); p->aOp[i].p3dyn = 1; }else{ p->aOp[i].p3 = 0; } if( lbl<0 && (-lbl)<=p->nLabel ){ p->aLabel[-1-lbl] = i; for(j=0; j<i; j++){ if( p->aOp[j].p2==lbl ) p->aOp[j].p2 = i; |
︙ | |||
363 364 365 366 367 368 369 370 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 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 | + + + + + + + + - + + + + + + + + + - + + + - + - - + + + + + + + + - + + + + + + | } /* ** Change the value of the P3 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqliteVdbeAddOpList but we want to make a ** few minor changes to the program. ** ** If n>=0 then the P3 operand is dynamic, meaning that a copy of ** the string is made into memory obtained from sqliteMalloc(). ** A value of n==0 means copy bytes of zP3 up to and including the ** first null byte. If n>0 then copy n+1 bytes of zP3. ** ** If n<0 then zP3 is assumed to be a pointer to a static string. ** P3 is made to point directly to this string without any copying. */ |
︙ | |||
743 744 745 746 747 748 749 | 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | - - + - + + | AggReset(&p->agg); for(i=0; i<p->nSet; i++){ sqliteHashClear(&p->aSet[i].hash); } sqliteFree(p->aSet); p->aSet = 0; p->nSet = 0; |
︙ | |||
2614 2615 2616 2617 2618 2619 2620 | 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 | - + | int res, rx; Cursor *pCrsr; VERIFY( if( tos<0 ) goto not_enough_stack; ) if( i>=0 && i<p->nCursor && (pCrsr = &p->aCsr[i])->pCursor!=0 ){ if( Stringify(p, tos) ) goto no_mem; if( pCrsr->zKey ) sqliteFree(pCrsr->zKey); pCrsr->nKey = aStack[tos].n; |
︙ | |||
2770 2771 2772 2773 2774 2775 2776 | 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 | - + - + - - - + - - + + - + - - - - - + + - + - + - - - + - - + + - + - - - - - + + | ** See also: Destroy */ case OP_Clear: { sqliteBtreeClearTable(pBt, pOp->p1); break; } |
︙ | |||
3861 3862 3863 3864 3865 3866 3867 | 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 | - - - - | fprintf(p->trace,"\n"); } #endif } cleanup: Cleanup(p); |
︙ |
Changes to src/vdbe.h.
︙ | |||
11 12 13 14 15 16 17 | 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. ** |
︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + | ** as an instance of the following structure: */ struct VdbeOp { int opcode; /* What operation to perform */ int p1; /* First operand */ int p2; /* Second parameter (often the jump destination) */ char *p3; /* Third parameter */ int p3dyn; /* True if p3 is malloced. False if it is static */ }; typedef struct VdbeOp VdbeOp; /* ** 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 |
︙ | |||
183 184 185 186 187 188 189 | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - - - + | /* ** Prototypes for the VDBE interface. See comments on the implementation ** for a description of what each of these routines does. */ Vdbe *sqliteVdbeCreate(sqlite*); void sqliteVdbeCreateCallback(Vdbe*, int*); |
Changes to test/index.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 INDEX statement. # |
︙ | |||
199 200 201 202 203 204 205 | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | - - - + + + + + | } execsql {SELECT count(*) FROM test1} } {19} do_test index-7.2 { execsql {SELECT f1 FROM test1 WHERE f2=65536} } {16} do_test index-7.3 { |
︙ |
Changes to test/table.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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. # |
︙ | |||
159 160 161 162 163 164 165 | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | - + | f17 text, f18 text, f19 text, f20 text )} do_test table-3.1 { execsql $big_table |
︙ |
Changes to test/tester.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 some common TCL routines used for regression # testing the SQLite library # |
︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | + + + + + + + + + | # A procedure to execute SQL # proc execsql {sql {db db}} { # puts "SQL = $sql" return [$db eval $sql] } # Execute SQL and catch exceptions. # proc catchsql {sql {db db}} { # puts "SQL = $sql" set r [catch {$db eval $sql} msg] lappend r $msg return $r } # Another procedure to execute SQL. This one includes the field # names in the returned list. # proc execsql2 {sql} { set result {} db eval $sql data { |
︙ |
Added test/unique.test.
|