Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add preliminary logic for the eventual move to having separate TEXT and NUMTEXT datatypes. Also change the version number to 2.5.0 in preparation for an interim release. (CVS 625) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
05783a9db585c1ead42135252dca97d2 |
User & Date: | drh 2002-06-17 17:07:19.000 |
Context
2002-06-17
| ||
17:15 | Update the change summary for version 2.5.0 (CVS 626) (check-in: 7a216adea5 user: drh tags: trunk) | |
17:07 | Add preliminary logic for the eventual move to having separate TEXT and NUMTEXT datatypes. Also change the version number to 2.5.0 in preparation for an interim release. (CVS 625) (check-in: 05783a9db5 user: drh tags: trunk) | |
2002-06-16
| ||
18:21 | Expose an additional internal API routine (sqliteInitCallback()) for use by private code. (CVS 624) (check-in: cd74495f99 user: drh tags: trunk) | |
Changes
Changes to VERSION.
|
| | | 1 | 2.5.0 |
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.96 2002/06/17 17:07:20 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called after a single SQL statement has been ** parsed and we want to execute the VDBE code to implement |
︙ | ︙ | |||
640 641 642 643 644 645 646 647 648 649 650 651 652 653 | zType && sqliteStrICmp(zType, "INTEGER")==0 ){ pTab->iPKey = iCol; pTab->keyConf = onError; }else{ sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0); } } /* ** Come up with a new random value for the schema cookie. Make sure ** the new value is different from the old. ** ** The schema cookie is used to determine when the schema for the ** database changes. After each schema change, the cookie value | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 676 677 678 679 680 681 682 683 684 685 | zType && sqliteStrICmp(zType, "INTEGER")==0 ){ pTab->iPKey = iCol; pTab->keyConf = onError; }else{ sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0); } } /* ** Return the appropriate collating type given the collation type token. ** Report an error if the type is undefined. */ int sqliteCollateType(Parse *pParse, Token *pType){ if( pType==0 ) return SQLITE_SO_UNK; if( pType->n==4 && sqliteStrNICmp(pType->z, "text", 4)==0 ){ return SQLITE_SO_TEXT; } if( pType->n==7 && sqliteStrNICmp(pType->z, "numeric", 7)==0 ){ return SQLITE_SO_NUM; } sqliteSetNString(&pParse->zErrMsg, "unknown collating type: ", -1, pType->z, pType->n, 0); pParse->nErr++; return SQLITE_SO_UNK; } /* ** This routine is called by the parser while in the middle of ** parsing a CREATE TABLE statement. A "COLLATE" clause has ** been seen on a column. This routine sets the Column.sortOrder on ** the column currently under construction. */ void sqliteAddCollateType(Parse *pParse, int collType){ Table *p; int i; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; if( i>=0 ) p->aCol[i].sortOrder = collType; } /* ** Come up with a new random value for the schema cookie. Make sure ** the new value is different from the old. ** ** The schema cookie is used to determine when the schema for the ** database changes. After each schema change, the cookie value |
︙ | ︙ |
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.72 2002/06/17 17:07:20 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 |
︙ | ︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | */ Expr *sqliteExprDup(Expr *p){ Expr *pNew; if( p==0 ) return 0; pNew = sqliteMalloc( sizeof(*p) ); if( pNew==0 ) return 0; pNew->op = p->op; pNew->pLeft = sqliteExprDup(p->pLeft); pNew->pRight = sqliteExprDup(p->pRight); pNew->pList = sqliteExprListDup(p->pList); pNew->iTable = p->iTable; pNew->iColumn = p->iColumn; pNew->iAgg = p->iAgg; pNew->token = p->token; | > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | */ Expr *sqliteExprDup(Expr *p){ Expr *pNew; if( p==0 ) return 0; pNew = sqliteMalloc( sizeof(*p) ); if( pNew==0 ) return 0; pNew->op = p->op; pNew->dataType = p->dataType; pNew->pLeft = sqliteExprDup(p->pLeft); pNew->pRight = sqliteExprDup(p->pRight); pNew->pList = sqliteExprListDup(p->pList); pNew->iTable = p->iTable; pNew->iColumn = p->iColumn; pNew->iAgg = p->iAgg; pNew->token = p->token; |
︙ | ︙ |
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.74 2002/06/17 17:07:20 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} %syntax_error { sqliteSetString(&pParse->zErrMsg,"syntax error",0); |
︙ | ︙ | |||
113 114 115 116 117 118 119 | id(A) ::= ID(X). {A = X;} // The following directive causes tokens ABORT, AFTER, ASC, etc. to // fallback to ID if they will not parse as their original value. // This obviates the need for the "id" nonterminal. // %fallback ID | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | id(A) ::= ID(X). {A = X;} // The following directive causes tokens ABORT, AFTER, ASC, etc. to // fallback to ID if they will not parse as their original value. // This obviates the need for the "id" nonterminal. // %fallback ID ABORT AFTER ASC BEFORE BEGIN CASCADE CLUSTER COLLATE CONFLICT COPY DEFERRED DELIMITERS DESC EACH END EXPLAIN FAIL FOR FULL IGNORE IMMEDIATE INITIALLY INSTEAD MATCH JOIN KEY OF OFFSET PARTIAL PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT TEMP TRIGGER VACUUM VIEW. // And "ids" is an identifer-or-string. // |
︙ | ︙ | |||
159 160 161 162 163 164 165 166 167 168 169 170 171 172 | // ccons ::= NOT NULL onconf(R). {sqliteAddNotNull(pParse, R);} ccons ::= PRIMARY KEY sortorder onconf(R). {sqliteAddPrimaryKey(pParse,0,R);} ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0);} ccons ::= CHECK LP expr RP onconf. ccons ::= references. ccons ::= defer_subclause. // A REFERENCES clause is parsed but the current implementation does not // do anything with it. // references ::= REFERENCES ids LP idxlist RP refargs. references ::= REFERENCES ids refargs. refargs ::= . | > > > | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | // ccons ::= NOT NULL onconf(R). {sqliteAddNotNull(pParse, R);} ccons ::= PRIMARY KEY sortorder onconf(R). {sqliteAddPrimaryKey(pParse,0,R);} ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0);} ccons ::= CHECK LP expr RP onconf. ccons ::= references. ccons ::= defer_subclause. ccons ::= COLLATE id(C). { sqliteAddCollateType(pParse, sqliteCollateType(pParse, &C)); } // A REFERENCES clause is parsed but the current implementation does not // do anything with it. // references ::= REFERENCES ids LP idxlist RP refargs. references ::= REFERENCES ids refargs. refargs ::= . |
︙ | ︙ | |||
375 376 377 378 379 380 381 | %type sortlist {ExprList*} %destructor sortlist {sqliteExprListDelete($$);} %type sortitem {Expr*} %destructor sortitem {sqliteExprDelete($$);} orderby_opt(A) ::= . {A = 0;} orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} | | | > | | | > > | 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 | %type sortlist {ExprList*} %destructor sortlist {sqliteExprListDelete($$);} %type sortitem {Expr*} %destructor sortitem {sqliteExprDelete($$);} orderby_opt(A) ::= . {A = 0;} orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). { A = sqliteExprListAppend(X,Y,0); if( A ) A->a[A->nExpr-1].sortOrder = C+Z; } sortlist(A) ::= sortitem(Y) sortorder(Z). { A = sqliteExprListAppend(0,Y,0); if( A ) A->a[0].sortOrder = Z; } sortitem(A) ::= expr(X). {A = X;} %type sortorder {int} %type collate {int} sortorder(A) ::= ASC. {A = SQLITE_SO_ASC;} sortorder(A) ::= DESC. {A = SQLITE_SO_DESC;} sortorder(A) ::= . {A = SQLITE_SO_ASC;} collate(C) ::= . {C = SQLITE_SO_UNK;} collate(C) ::= COLLATE id(X). {C = sqliteCollateType(pParse, &X);} %type groupby_opt {ExprList*} %destructor groupby_opt {sqliteExprListDelete($$);} groupby_opt(A) ::= . {A = 0;} groupby_opt(A) ::= GROUP BY exprlist(X). {A = X;} %type having_opt {Expr*} |
︙ | ︙ |
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.125 2002/06/17 17:07:20 drh Exp $ */ #include "sqlite.h" #include "hash.h" #include "vdbe.h" #include "parse.h" #include "btree.h" #include <stdio.h> |
︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | */ struct Column { char *zName; /* Name of this column */ char *zDflt; /* Default value of this column */ char *zType; /* Data type for this column */ u8 notNull; /* True if there is a NOT NULL constraint */ u8 isPrimKey; /* True if this column is an INTEGER PRIMARY KEY */ }; /* ** Each SQL table is represented in memory by an instance of the ** following structure. ** ** Expr.zName is the name of the table. The case of the original ** CREATE TABLE statement is stored, but case is not significant for ** comparisons. | > > > > > > > > > > > > > > > | 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 | */ struct Column { char *zName; /* Name of this column */ char *zDflt; /* Default value of this column */ char *zType; /* Data type for this column */ u8 notNull; /* True if there is a NOT NULL constraint */ u8 isPrimKey; /* True if this column is an INTEGER PRIMARY KEY */ u8 sortOrder; /* Some combination of SQLITE_SO_... values */ }; /* ** The allowed sort orders. ** ** The TEXT and NUM values use bits that do not overlap with DESC and ASC. ** That way the two can be combined into a single number. */ #define SQLITE_SO_UNK 0 /* Use the default collating type. (SCT_NUM) */ #define SQLITE_SO_TEXT 2 /* Sort using memcmp() */ #define SQLITE_SO_NUM 4 /* Sort using sqliteCompare() */ #define SQLITE_SO_TYPEMASK 6 /* Mask to extract the collating sequence */ #define SQLITE_SO_ASC 0 /* Sort in ascending order */ #define SQLITE_SO_DESC 1 /* Sort in descending order */ #define SQLITE_SO_DIRMASK 1 /* Mask to extract the sort direction */ /* ** Each SQL table is represented in memory by an instance of the ** following structure. ** ** Expr.zName is the name of the table. The case of the original ** CREATE TABLE statement is stored, but case is not significant for ** comparisons. |
︙ | ︙ | |||
405 406 407 408 409 410 411 | ** ** The Expr.pSelect field points to a SELECT statement. The SELECT might ** be the right operand of an IN operator. Or, if a scalar SELECT appears ** in an expression the opcode is TK_SELECT and Expr.pSelect is the only ** operand. */ struct Expr { | | > | < | | | | 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 | ** ** The Expr.pSelect field points to a SELECT statement. The SELECT might ** be the right operand of an IN operator. Or, if a scalar SELECT appears ** in an expression the opcode is TK_SELECT and Expr.pSelect is the only ** operand. */ struct Expr { u16 op; /* Operation performed by this node */ u8 dataType; /* Either SQLITE_SO_TEXT or SQLITE_SO_NUM */ Expr *pLeft, *pRight; /* Left and right subnodes */ ExprList *pList; /* A list of expressions used as function arguments ** or in "<expr> IN (<expr-list)" */ Token token; /* An operand token */ Token span; /* Complete text of the expression */ int iTable, iColumn; /* When op==TK_COLUMN, then this expr node means the ** iColumn-th field of the iTable-th table. */ int iAgg; /* When op==TK_COLUMN and pParse->useAgg==TRUE, pull ** result from the iAgg-th element of the aggregator */ Select *pSelect; /* When the expression is a sub-select. Also the ** right side of "<expr> IN (<select>)" */ }; /* ** A list of expressions. Each expression may optionally have a ** name. An expr/name combination can be used in several ways, such ** as the list of "expr AS ID" fields following a "SELECT" or in the ** list of "ID = expr" items in an UPDATE. A list of expressions can ** also be used as the argument to a function, in which case the a.zName ** field is not used. */ struct ExprList { int nExpr; /* Number of expressions on the list */ struct ExprList_item { Expr *pExpr; /* The list of expressions */ char *zName; /* Token associated with this expression */ u8 sortOrder; /* 1 for DESC or 0 for ASC */ u8 isAgg; /* True if this is an aggregate like count(*) */ u8 done; /* A flag to indicate when processing is finished */ } *a; /* One entry for each expression */ }; /* ** An instance of this structure can hold a simple list of identifiers, ** such as the list "a,b,c" in the following statements: ** |
︙ | ︙ | |||
817 818 819 820 821 822 823 824 825 826 827 828 829 830 | Table *sqliteResultSetOfSelect(Parse*,char*,Select*); void sqliteStartTable(Parse*,Token*,Token*,int); void sqliteAddColumn(Parse*,Token*); void sqliteAddNotNull(Parse*, int); void sqliteAddPrimaryKey(Parse*, IdList*, int); void sqliteAddColumnType(Parse*,Token*,Token*); void sqliteAddDefaultValue(Parse*,Token*,int); void sqliteEndTable(Parse*,Token*,Select*); void sqliteCreateView(Parse*,Token*,Token*,Select*); int sqliteViewGetColumnNames(Parse*,Table*); void sqliteViewResetAll(sqlite*); void sqliteDropTable(Parse*, Token*, int); void sqliteDeleteTable(sqlite*, Table*); void sqliteInsert(Parse*, Token*, ExprList*, Select*, IdList*, int); | > > | 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 | Table *sqliteResultSetOfSelect(Parse*,char*,Select*); void sqliteStartTable(Parse*,Token*,Token*,int); void sqliteAddColumn(Parse*,Token*); void sqliteAddNotNull(Parse*, int); void sqliteAddPrimaryKey(Parse*, IdList*, int); void sqliteAddColumnType(Parse*,Token*,Token*); void sqliteAddDefaultValue(Parse*,Token*,int); int sqliteCollateType(Parse*, Token*); void sqliteAddCollateType(Parse*, int); void sqliteEndTable(Parse*,Token*,Select*); void sqliteCreateView(Parse*,Token*,Token*,Select*); int sqliteViewGetColumnNames(Parse*,Table*); void sqliteViewResetAll(sqlite*); void sqliteDropTable(Parse*, Token*, int); void sqliteDeleteTable(sqlite*, Table*); void sqliteInsert(Parse*, Token*, ExprList*, Select*, IdList*, int); |
︙ | ︙ |
Changes to src/tokenize.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** 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. ** | | | 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. ** ** $Id: tokenize.c,v 1.46 2002/06/17 17:07:20 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include <stdlib.h> /* |
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | { "BEGIN", 0, TK_BEGIN, 0 }, { "BETWEEN", 0, TK_BETWEEN, 0 }, { "BY", 0, TK_BY, 0 }, { "CASCADE", 0, TK_CASCADE, 0 }, { "CASE", 0, TK_CASE, 0 }, { "CHECK", 0, TK_CHECK, 0 }, { "CLUSTER", 0, TK_CLUSTER, 0 }, { "COMMIT", 0, TK_COMMIT, 0 }, { "CONFLICT", 0, TK_CONFLICT, 0 }, { "CONSTRAINT", 0, TK_CONSTRAINT, 0 }, { "COPY", 0, TK_COPY, 0 }, { "CREATE", 0, TK_CREATE, 0 }, { "DEFAULT", 0, TK_DEFAULT, 0 }, { "DEFERRED", 0, TK_DEFERRED, 0 }, | > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | { "BEGIN", 0, TK_BEGIN, 0 }, { "BETWEEN", 0, TK_BETWEEN, 0 }, { "BY", 0, TK_BY, 0 }, { "CASCADE", 0, TK_CASCADE, 0 }, { "CASE", 0, TK_CASE, 0 }, { "CHECK", 0, TK_CHECK, 0 }, { "CLUSTER", 0, TK_CLUSTER, 0 }, { "COLLATE", 0, TK_COLLATE, 0 }, { "COMMIT", 0, TK_COMMIT, 0 }, { "CONFLICT", 0, TK_CONFLICT, 0 }, { "CONSTRAINT", 0, TK_CONSTRAINT, 0 }, { "COPY", 0, TK_COPY, 0 }, { "CREATE", 0, TK_CREATE, 0 }, { "DEFAULT", 0, TK_DEFAULT, 0 }, { "DEFERRED", 0, TK_DEFERRED, 0 }, |
︙ | ︙ |