Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the way token memory is allocated in an effort to fix ticket #136. There is now a memory leak when using views of views. (CVS 725) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
22d8726e61eec0e53893f492cb216382 |
User & Date: | drh 2002-08-24 18:24:52.000 |
Context
2002-08-25
| ||
18:29 | Fix the memory leak introduced by check-in (725). (CVS 726) (check-in: b957dafc26 user: drh tags: trunk) | |
2002-08-24
| ||
18:24 | Change the way token memory is allocated in an effort to fix ticket #136. There is now a memory leak when using views of views. (CVS 725) (check-in: 22d8726e61 user: drh tags: trunk) | |
2002-08-22
| ||
18:18 | Fix for ticket #138: Makefile doesn't use exec_prefix, has some install problems (CVS 724) (check-in: 97fc4a71a1 user: jadams tags: trunk) | |
Changes
Changes to main.mk.
︙ | |||
122 123 124 125 126 127 128 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - - + + | # Generate the file "last_change" which contains the date of change # of the most recently modified source code file # last_change: $(SRC) cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \ | awk '{print $$5,$$6}' >last_change |
︙ |
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 ** |
︙ | |||
840 841 842 843 844 845 846 | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | - + - + + + + + + - + + - + - - - + + + + + - + - - - - + + - | void sqliteCreateView( Parse *pParse, /* The parsing context */ Token *pBegin, /* The CREATE token that begins the statement */ Token *pName, /* The token that holds the name of the view */ Select *pSelect, /* A SELECT statement that will become the new view */ int isTemp /* TRUE for a TEMPORARY view */ ){ |
︙ |
Changes to src/expr.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 routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** |
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 | 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 181 182 183 184 185 186 187 188 189 190 191 | + + + + + + - - - - - + + - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + | sqliteExprDelete(pRight); return 0; } pNew->op = op; pNew->pLeft = pLeft; pNew->pRight = pRight; if( pToken ){ assert( pToken->dyn==0 ); pNew->token = *pToken; pNew->token.base = 1; }else if( pLeft && pRight ){ sqliteExprSpan(pNew, &pLeft->token, &pRight->token); }else{ pNew->token.dyn = 0; pNew->token.base = 1; pNew->token.z = 0; pNew->token.n = 0; } |
︙ | |||
359 360 361 362 363 364 365 366 367 368 369 370 371 372 | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | + + + | while( n>0 && *z && isdigit(*z) ){ z++; n--; } if( n==0 ){ *pValue = atoi(p->token.z); return 1; } break; } case TK_UPLUS: { return sqliteExprIsInteger(p->pLeft, pValue); } case TK_UMINUS: { int v; if( sqliteExprIsInteger(p->pLeft, &v) ){ *pValue = -v; return 1; } break; |
︙ | |||
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 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 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + - - - + - + - + - - + - | } } } } } return 0; } /* ** pExpr is a node that defines a function of some kind. It might ** be a syntactic function like "count(x)" or it might be a function ** that implements an operator, like "a LIKE b". ** ** This routine makes *pzName point to the name of the function and ** *pnName hold the number of characters in the function name. */ static void getFunctionName(Expr *pExpr, const char **pzName, int *pnName){ switch( pExpr->op ){ case TK_FUNCTION: { *pzName = pExpr->token.z; *pnName = pExpr->nFuncName; break; } case TK_LIKE: { *pzName = "like"; *pnName = 4; break; } case TK_GLOB: { *pzName = "glob"; *pnName = 4; break; } default: { *pzName = "can't happen"; *pnName = 12; break; } } } /* ** Error check the functions in an expression. Make sure all ** function names are recognized and all functions have the correct ** number of arguments. Leave an error message in pParse->zErrMsg ** if anything is amiss. Return the number of errors. ** ** if pIsAgg is not null and this expression is an aggregate function ** (like count(*) or max(value)) then write a 1 into *pIsAgg. */ int sqliteExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){ int nErr = 0; if( pExpr==0 ) return 0; switch( pExpr->op ){ case TK_GLOB: case TK_LIKE: case TK_FUNCTION: { int n = pExpr->pList ? pExpr->pList->nExpr : 0; /* Number of arguments */ int no_such_func = 0; /* True if no such function exists */ int is_type_of = 0; /* True if is the special TypeOf() function */ int wrong_num_args = 0; /* True if wrong number of arguments */ int is_agg = 0; /* True if is an aggregate function */ int i; int nId; /* Number of characters in function name */ const char *zId; /* The function name. */ FuncDef *pDef; getFunctionName(pExpr, &zId, &nId); |
︙ | |||
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | + + + | case TK_SLASH: case TK_AND: case TK_OR: case TK_ISNULL: case TK_NOTNULL: case TK_NOT: case TK_UMINUS: case TK_UPLUS: case TK_BITAND: case TK_BITOR: case TK_BITNOT: case TK_LSHIFT: case TK_RSHIFT: case TK_REM: case TK_INTEGER: case TK_FLOAT: case TK_IN: case TK_BETWEEN: case TK_GLOB: case TK_LIKE: return SQLITE_SO_NUM; case TK_STRING: case TK_NULL: case TK_CONCAT: return SQLITE_SO_TEXT; |
︙ | |||
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 | + + + + + + + + + + + + + | break; } case TK_CONCAT: { sqliteExprCode(pParse, pExpr->pLeft); sqliteExprCode(pParse, pExpr->pRight); sqliteVdbeAddOp(v, OP_Concat, 2, 0); break; } case TK_UPLUS: { Expr *pLeft = pExpr->pLeft; if( pLeft && pLeft->op==TK_INTEGER ){ sqliteVdbeAddOp(v, OP_Integer, atoi(pLeft->token.z), 0); sqliteVdbeChangeP3(v, -1, pLeft->token.z, pLeft->token.n); }else if( pLeft && pLeft->op==TK_FLOAT ){ sqliteVdbeAddOp(v, OP_String, 0, 0); sqliteVdbeChangeP3(v, -1, pLeft->token.z, pLeft->token.n); }else{ sqliteExprCode(pParse, pExpr->pLeft); } break; } case TK_UMINUS: { assert( pExpr->pLeft ); if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){ Token *p = &pExpr->pLeft->token; char *z = sqliteMalloc( p->n + 2 ); sprintf(z, "-%.*s", p->n, p->z); |
︙ | |||
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | + + + + + - + - | sqliteVdbeAddOp(v, OP_AddImm, -1, 0); break; } case TK_AGG_FUNCTION: { sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg); break; } case TK_GLOB: case TK_LIKE: case TK_FUNCTION: { int i; ExprList *pList = pExpr->pList; int nExpr = pList ? pList->nExpr : 0; FuncDef *pDef; int nId; const char *zId; getFunctionName(pExpr, &zId, &nId); |
︙ | |||
1398 1399 1400 1401 1402 1403 1404 1405 | 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 | + + + + + + - - + + + | } }else if( pB->pList ){ return 0; } if( pA->pSelect || pB->pSelect ) return 0; if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 0; if( pA->token.z ){ int n; if( pB->token.z==0 ) return 0; if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){ n = pA->nFuncName; if( pB->nFuncName!=n ) return 0; }else{ n = pA->token.n; |
︙ | |||
1471 1472 1473 1474 1475 1476 1477 | 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 | - + | } if( i>=pParse->nAgg ){ i = appendAggInfo(pParse); if( i<0 ) return 1; pParse->aAgg[i].isAgg = 1; pParse->aAgg[i].pExpr = pExpr; pParse->aAgg[i].pFunc = sqliteFindFunction(pParse->db, |
︙ |
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 | - + | ** ************************************************************************* ** 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. ** |
︙ | |||
791 792 793 794 795 796 797 798 | 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 | + + + - + + + + - + | sqlite *db, /* Add the function to this database connection */ const char *zName, /* Name of the function to add */ int nArg, /* Number of arguments */ void (*xFunc)(sqlite_func*,int,const char**), /* The implementation */ void *pUserData /* User data */ ){ FuncDef *p; int nName; if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1; nName = strlen(zName); if( nName>255 ) return 1; |
︙ |
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. ** |
︙ | |||
482 483 484 485 486 487 488 | 482 483 484 485 486 487 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 524 525 526 527 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 | - + + + - - + + + - + + - + + - - + + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + | %right NOT. %left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN. %left GT GE LT LE. %left BITAND BITOR LSHIFT RSHIFT. %left PLUS MINUS. %left STAR SLASH REM. %left CONCAT. |
︙ | |||
713 714 715 716 717 718 719 | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | + + + - + - | plus_opt ::= PLUS. plus_opt ::= . //////////////////////////// The CREATE TRIGGER command ///////////////////// cmd ::= CREATE(A) TRIGGER nm(B) trigger_time(C) trigger_event(D) ON nm(E) foreach_clause(F) when_clause(G) BEGIN trigger_cmd_list(S) END(Z). { Token all; all.z = A.z; all.n = (Z.z - A.z) + Z.n; |
︙ | |||
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 | - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + | trigger_cmd(A) ::= DELETE FROM nm(X) where_opt(Y). {A = sqliteTriggerDeleteStep(&X, Y);} // SELECT trigger_cmd(A) ::= select(X). {A = sqliteTriggerSelectStep(X); } // The special RAISE expression that may occur in trigger programs |
Changes to src/select.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 C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** |
︙ | |||
152 153 154 155 156 157 158 159 | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | + + - - - - | Token dummy; Expr *pE1a, *pE1b, *pE1c; Expr *pE2a, *pE2b, *pE2c; Expr *pE; dummy.z = zCol; dummy.n = strlen(zCol); dummy.base = 1; dummy.dyn = 0; pE1a = sqliteExpr(TK_ID, 0, 0, &dummy); |
︙ | |||
639 640 641 642 643 644 645 | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | - + - + - + - + - + - + | if( iCol<0 ){ zCol = "_ROWID_"; zType = "INTEGER"; }else{ zCol = pTab->aCol[iCol].zName; zType = pTab->aCol[iCol].zType; } |
︙ | |||
726 727 728 729 730 731 732 | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | - - + + | pTab->nCol = pEList->nExpr; assert( pTab->nCol>0 ); pTab->aCol = sqliteMalloc( sizeof(pTab->aCol[0])*pTab->nCol ); for(i=0; i<pTab->nCol; i++){ Expr *p; if( pEList->a[i].zName ){ pTab->aCol[i].zName = sqliteStrDup(pEList->a[i].zName); |
︙ | |||
891 892 893 894 895 896 897 | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | + + - + + - + - - + + + + + + - | ** using clause from the table on the right. */ continue; } pRight = sqliteExpr(TK_ID, 0, 0, 0); if( pRight==0 ) break; pRight->token.z = zName; pRight->token.n = strlen(zName); pRight->token.dyn = 0; pRight->token.base = 1; |
︙ | |||
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 | + + | SrcList *pSrc = p->pSrc; Table *pTab; if( p==0 ) return; for(i=0; i<pSrc->nSrc; i++){ if( (pTab = pSrc->a[i].pTab)!=0 ){ if( pTab->isTransient ){ sqliteDeleteTable(0, pTab); #if 0 sqliteSelectDelete(pSrc->a[i].pSelect); pSrc->a[i].pSelect = 0; #endif } pSrc->a[i].pTab = 0; if( pSrc->a[i].pSelect ){ sqliteSelectUnbind(pSrc->a[i].pSelect); } } } |
︙ | |||
1305 1306 1307 1308 1309 1310 1311 | 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 | + - + | pExpr->op = pNew->op; pExpr->pLeft = sqliteExprDup(pNew->pLeft); pExpr->pRight = sqliteExprDup(pNew->pRight); pExpr->pList = sqliteExprListDup(pNew->pList); pExpr->iTable = pNew->iTable; pExpr->iColumn = pNew->iColumn; pExpr->iAgg = pNew->iAgg; pExpr->nFuncName = pNew->nFuncName; |
︙ | |||
1424 1425 1426 1427 1428 1429 1430 | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 | + - + | iParent = p->base + iFrom; iSub = pSub->base; substExprList(p->pEList, iParent, pSub->pEList, iSub); pList = p->pEList; for(i=0; i<pList->nExpr; i++){ if( pList->a[i].zName==0 ){ Expr *pExpr = pList->a[i].pExpr; assert( pExpr->token.z!=0 ); |
︙ | |||
1531 1532 1533 1534 1535 1536 1537 | 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 | - + | */ if( p->pGroupBy || p->pHaving || p->pWhere ) return 0; if( p->pSrc->nSrc!=1 ) return 0; if( p->pEList->nExpr!=1 ) return 0; pExpr = p->pEList->a[0].pExpr; if( pExpr->op!=TK_AGG_FUNCTION ) return 0; if( pExpr->pList==0 || pExpr->pList->nExpr!=1 ) return 0; |
︙ |
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. ** |
︙ | |||
387 388 389 390 391 392 393 | 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 | - + + + + + + + + + - + - - - - + + + + - - + + - | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ Index *pNext; /* The next index associated with the same table */ }; /* ** Each token coming out of the lexer is an instance of |
︙ | |||
673 674 675 676 677 678 679 | 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | - - - - - | * 1. In the "trigHash" hash table (part of the sqlite* that represents the * database). This allows Trigger structures to be retrieved by name. * 2. All triggers associated with a single table form a linked list, using the * pNext member of struct Trigger. A pointer to the first element of the * linked list is stored as the "pTrigger" member of the associated * struct Table. * |
︙ | |||
704 705 706 707 708 709 710 | 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | - | int tr_tm; /* One of TK_BEFORE, TK_AFTER */ Expr *pWhen; /* The WHEN clause of the expresion (may be NULL) */ IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger, the <column-list> is stored here */ int foreach; /* One of TK_ROW or TK_STATEMENT */ TriggerStep *step_list; /* Link list of trigger program steps */ |
︙ | |||
916 917 918 919 920 921 922 | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 | - - - + - + | int sqliteIsRowid(const char*); void sqliteGenerateRowDelete(sqlite*, Vdbe*, Table*, int, int); void sqliteGenerateRowIndexDelete(sqlite*, Vdbe*, Table*, int, char*); void sqliteGenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); void sqliteCompleteInsertion(Parse*, Table*, int, char*, int, int); void sqliteBeginWriteOperation(Parse*, int); void sqliteEndWriteOperation(Parse*); |
Changes to src/tokenize.c.
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - + | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** |
︙ | |||
414 415 416 417 418 419 420 421 422 423 424 425 426 427 | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | + + | if( (db->flags & SQLITE_Interrupt)!=0 ){ pParse->rc = SQLITE_INTERRUPT; sqliteSetString(pzErrMsg, "interrupt", 0); break; } pParse->sLastToken.z = &zSql[i]; pParse->sLastToken.base = 1; pParse->sLastToken.dyn = 0; pParse->sLastToken.n = sqliteGetToken((unsigned char*)&zSql[i], &tokenType); i += pParse->sLastToken.n; if( once ){ pParse->sFirstToken = pParse->sLastToken; once = 0; } switch( tokenType ){ |
︙ |
Changes to src/trigger.c.
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 | 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 | + + + + + + + + + + + + + + + + + + - + - - - | /* ** ** 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. ** ************************************************************************* * */ #include "sqliteInt.h" /* ** Delete a linked list of TriggerStep structures. */ static void sqliteDeleteTriggerStep(TriggerStep *pTriggerStep){ while( pTriggerStep ){ TriggerStep * pTmp = pTriggerStep; pTriggerStep = pTriggerStep->pNext; if( pTmp->target.dyn ) sqliteFree(pTmp->target.z); sqliteExprDelete(pTmp->pWhere); sqliteExprListDelete(pTmp->pExprList); sqliteSelectDelete(pTmp->pSelect); sqliteIdListDelete(pTmp->pIdList); sqliteFree(pTmp); } } /* ** This is called by the parser when it sees a CREATE TRIGGER statement. See ** comments surrounding struct Trigger in sqliteInt.h for a description of ** how triggers are stored. */ void sqliteCreateTrigger( Parse *pParse, /* The parse context of the CREATE TRIGGER statement */ Token *pName, /* The name of the trigger */ int tr_tm, /* One of TK_BEFORE, TK_AFTER , TK_INSTEAD */ int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ IdList *pColumns, /* column list if this is an UPDATE OF trigger */ Token *pTableName, /* The name of the table/view the trigger applies to */ int foreach, /* One of TK_ROW or TK_STATEMENT */ Expr *pWhen, /* WHEN clause */ TriggerStep *pStepList, /* The triggered program */ |
︙ | |||
94 95 96 97 98 99 100 | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - - - + + + + - - - - - - - - - - - - - - | } /* Build the Trigger object */ nt = (Trigger*)sqliteMalloc(sizeof(Trigger)); if( nt==0 ) goto trigger_cleanup; nt->name = sqliteStrNDup(pName->z, pName->n); nt->table = sqliteStrNDup(pTableName->z, pTableName->n); |
︙ | |||
144 145 146 147 148 149 150 | 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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | - + - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + | sqliteBeginWriteOperation(pParse, 0); sqliteOpenMasterTable(v, tab->isTemp); addr = sqliteVdbeAddOpList(v, ArraySize(insertTrig), insertTrig); sqliteVdbeChangeP3(v, addr, tab->isTemp ? TEMP_MASTER_NAME : MASTER_NAME, P3_STATIC); sqliteVdbeChangeP3(v, addr+2, nt->name, 0); sqliteVdbeChangeP3(v, addr+3, nt->table, 0); |
︙ | |||
232 233 234 235 236 237 238 239 240 241 242 243 244 245 | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | + | pTriggerStep->op = TK_INSERT; pTriggerStep->pSelect = pSelect; pTriggerStep->target = *pTableName; pTriggerStep->pIdList = pColumn; pTriggerStep->pExprList = pEList; pTriggerStep->orconf = orconf; sqlitePersistTriggerStep(pTriggerStep); return pTriggerStep; } /* ** Construct a trigger step that implements an UPDATE statement and return ** a pointer to that trigger step. The parser calls this routine when it |
︙ | |||
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | 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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | + + - - + - - - - - - - - - - - - | if( pTriggerStep==0 ) return 0; pTriggerStep->op = TK_UPDATE; pTriggerStep->target = *pTableName; pTriggerStep->pExprList = pEList; pTriggerStep->pWhere = pWhere; pTriggerStep->orconf = orconf; sqlitePersistTriggerStep(pTriggerStep); return pTriggerStep; } /* ** Construct a trigger step that implements a DELETE statement and return ** a pointer to that trigger step. The parser calls this routine when it ** sees a DELETE statement inside the body of a CREATE TRIGGER. */ TriggerStep *sqliteTriggerDeleteStep(Token *pTableName, Expr *pWhere){ TriggerStep *pTriggerStep = sqliteMalloc(sizeof(TriggerStep)); if( pTriggerStep==0 ) return 0; pTriggerStep->op = TK_DELETE; pTriggerStep->target = *pTableName; pTriggerStep->pWhere = pWhere; pTriggerStep->orconf = OE_Default; sqlitePersistTriggerStep(pTriggerStep); return pTriggerStep; } /* ** Recursively delete a Trigger structure */ void sqliteDeleteTrigger(Trigger *pTrigger){ TriggerStep *pTriggerStep; |
︙ |
Changes to test/all.test.
1 2 3 4 5 6 7 8 9 10 11 12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | - + | # 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 runs all tests. # |
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | + | set LeakList {} set EXCLUDE { all.test quick.test malloc.test misuse.test memleak.test } # btree2.test for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} { set btree_native_byte_order [expr {($Counter>>1)&0x1}] if {$Counter%2} { set ::SETUP_SQL {PRAGMA default_synchronous=off;} |
︙ |
Changes to test/quick.test.
1 2 3 4 5 6 7 8 9 10 11 12 | 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 | - + + | # 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 runs all tests. # |
︙ |
Changes to test/view.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 | - + | # 2002 February 26 # # 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 VIEW statements. # |
︙ | |||
260 261 262 263 264 265 266 267 268 | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | do_test view-7.6 { db close sqlite db test.db execsql { SELECT * FROM test; } } {1 2 3} do_test view-8.1 { execsql { CREATE VIEW v6 AS SELECT pqr, xyz FROM v1; SELECT * FROM v6 ORDER BY xyz; } } {7 2 13 5 19 8 27 12} if 0 { do_test view-8.2 { db close sqlite db test.db execsql { SELECT * FROM v6 ORDER BY xyz; } } {7 2 13 5 19 8 27 12} do_test view-8.3 { execsql { CREATE VIEW v7 AS SELECT pqr+xyz AS a FROM v6; SELECT * FROM v7 ORDER BY a; } } {9 18 27 39} do_test view-8.4 { execsql { PRAGMA vdbe_trace=on; CREATE VIEW v8 AS SELECT max(cnt) FROM (SELECT a%2 AS eo, count(*) AS cnt FROM t1 GROUP BY eo); SELECT * FROM v8; } } 3 } finish_test |
Changes to www/c_interface.tcl.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | # # Run this Tcl script to generate the sqlite.html file. # |
︙ | |||
712 713 714 715 716 717 718 719 720 721 722 723 724 725 | 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | + | from malloc() and returns a pointer to the malloced buffer. <b>sqlite_mprintf()</b> also understands the %q and %Q extensions described above. The <b>sqlite_vmprintf()</b> is a varargs version of the same routine. The string pointer that these routines return should be freed by passing it to <b>sqlite_freemem()</b>. </p> <a name="cfunc"> <h2>Adding New SQL Functions</h2> <p>Beginning with version 2.4.0, SQLite allows the SQL language to be extended with new functions implemented as C code. The following interface is used: </p> |
︙ | |||
756 757 758 759 760 761 762 | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | - + + + + + + + + | The <b>sqlite_create_function()</b> interface is used to create regular functions and <b>sqlite_create_aggregate()</b> is used to create new aggregate functions. In both cases, the <b>db</b> parameter is an open SQLite database on which the functions should be registered, <b>zName</b> is the name of the new function, <b>nArg</b> is the number of arguments, and <b>pUserData</b> is a pointer which is passed through unchanged to the C implementation |
︙ |
Changes to www/faq.tcl.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | # # Run this script to generated a faq.html output file # |
︙ | |||
326 327 328 329 330 331 332 333 334 335 336 337 338 339 | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | + + + + + | tables and indices, but again it is not really possible to reach this limit due to the file size constraint.</p> <p>The name and "CREATE TABLE" statement for a table must fit entirely within a 1-megabyte row of the SQLITE_MASTER table. Other than this, there are no constraints on the length of the name of a table, or on the number of columns, etc. Indices are similarly unconstrained.</p> <p>The names of tables, indices, view, triggers, and columns can be as long as desired. However, the names of SQL functions (as created by the <a href="c_interface.html#cfunc">sqlite_create_function()</a> API) may not exceed 255 characters in length.</p> } faq { What is the maximum size of a VARCHAR in SQLite? } { <p>Remember, SQLite is typeless. A VARCHAR column can hold as much data as any other column. The total amount of data in a single row |
︙ |
Changes to www/omitted.tcl.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | # # Run this script to generated a omitted.html output file # |
︙ | |||
41 42 43 44 45 46 47 | 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 | - + + + + + + + + + + + + + | feature {CHECK constraints} { CHECK constraints are parsed but they are not enforced. NOT NULL and UNIQUE constraints are enforced, however. } feature {Variable subqueries} { Subqueries must be static. They are evaluated only once. They may not, |
︙ |
Changes to www/speed.tcl.
1 2 3 | 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 | - + - + - + - + + + + + - + - - + + + + + + + + - + | # # Run this Tcl script to generate the speed.html file. # |
︙ | |||
96 97 98 99 100 101 102 | 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 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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 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 | - - - - + + + + - - - - + + + + - - - - + + + + - - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - + + + + + + + + + - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - + + + + - - - - + + + + | INSERT INTO t1 VALUES(2,75560,'seventy five thousand five hundred sixty');<br> <i>... 995 lines omitted</i><br> INSERT INTO t1 VALUES(998,66289,'sixty six thousand two hundred eighty nine');<br> INSERT INTO t1 VALUES(999,24322,'twenty four thousand three hundred twenty two');<br> INSERT INTO t1 VALUES(1000,94142,'ninety four thousand one hundred forty two');<br> </blockquote><table border=0 cellpadding=0 cellspacing=0> |
︙ |