/ Check-in [05783a9d]
Login

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 | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:05783a9db585c1ead42135252dca97d2bc6e2118
User & Date: drh 2002-06-17 17:07:19
Context
2002-06-17
17:15
Update the change summary for version 2.5.0 (CVS 626) check-in: 7a216ade 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: 05783a9d 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: cd74495f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -2.4.12
            1  +2.5.0

Changes to src/build.c.

    21     21   **     COPY
    22     22   **     VACUUM
    23     23   **     BEGIN TRANSACTION
    24     24   **     COMMIT
    25     25   **     ROLLBACK
    26     26   **     PRAGMA
    27     27   **
    28         -** $Id: build.c,v 1.95 2002/05/24 20:31:37 drh Exp $
           28  +** $Id: build.c,v 1.96 2002/06/17 17:07:20 drh Exp $
    29     29   */
    30     30   #include "sqliteInt.h"
    31     31   #include <ctype.h>
    32     32   
    33     33   /*
    34     34   ** This routine is called after a single SQL statement has been
    35     35   ** parsed and we want to execute the VDBE code to implement 
................................................................................
   640    640              zType && sqliteStrICmp(zType, "INTEGER")==0 ){
   641    641       pTab->iPKey = iCol;
   642    642       pTab->keyConf = onError;
   643    643     }else{
   644    644       sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0);
   645    645     }
   646    646   }
          647  +
          648  +/*
          649  +** Return the appropriate collating type given the collation type token.
          650  +** Report an error if the type is undefined.
          651  +*/
          652  +int sqliteCollateType(Parse *pParse, Token *pType){
          653  +  if( pType==0 ) return SQLITE_SO_UNK;
          654  +  if( pType->n==4 && sqliteStrNICmp(pType->z, "text", 4)==0 ){
          655  +    return SQLITE_SO_TEXT;
          656  +  }
          657  +  if( pType->n==7 && sqliteStrNICmp(pType->z, "numeric", 7)==0 ){
          658  +    return SQLITE_SO_NUM;
          659  +  }
          660  +  sqliteSetNString(&pParse->zErrMsg, "unknown collating type: ", -1,
          661  +    pType->z, pType->n, 0);
          662  +  pParse->nErr++;
          663  +  return SQLITE_SO_UNK;
          664  +}
          665  +
          666  +/*
          667  +** This routine is called by the parser while in the middle of
          668  +** parsing a CREATE TABLE statement.  A "COLLATE" clause has
          669  +** been seen on a column.  This routine sets the Column.sortOrder on
          670  +** the column currently under construction.
          671  +*/
          672  +void sqliteAddCollateType(Parse *pParse, int collType){
          673  +  Table *p;
          674  +  int i;
          675  +  if( (p = pParse->pNewTable)==0 ) return;
          676  +  i = p->nCol-1;
          677  +  if( i>=0 ) p->aCol[i].sortOrder = collType;
          678  +}
   647    679   
   648    680   /*
   649    681   ** Come up with a new random value for the schema cookie.  Make sure
   650    682   ** the new value is different from the old.
   651    683   **
   652    684   ** The schema cookie is used to determine when the schema for the
   653    685   ** database changes.  After each schema change, the cookie value

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.71 2002/06/11 02:25:41 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.72 2002/06/17 17:07:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Construct a new expression node and return a pointer to it.  Memory
    22     22   ** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
   163    163   */
   164    164   Expr *sqliteExprDup(Expr *p){
   165    165     Expr *pNew;
   166    166     if( p==0 ) return 0;
   167    167     pNew = sqliteMalloc( sizeof(*p) );
   168    168     if( pNew==0 ) return 0;
   169    169     pNew->op = p->op;
          170  +  pNew->dataType = p->dataType;
   170    171     pNew->pLeft = sqliteExprDup(p->pLeft);
   171    172     pNew->pRight = sqliteExprDup(p->pRight);
   172    173     pNew->pList = sqliteExprListDup(p->pList);
   173    174     pNew->iTable = p->iTable;
   174    175     pNew->iColumn = p->iColumn;
   175    176     pNew->iAgg = p->iAgg;
   176    177     pNew->token = p->token;

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.73 2002/06/11 02:25:42 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.74 2002/06/17 17:07:20 drh Exp $
    18     18   */
    19     19   %token_prefix TK_
    20     20   %token_type {Token}
    21     21   %default_type {Token}
    22     22   %extra_argument {Parse *pParse}
    23     23   %syntax_error {
    24     24     sqliteSetString(&pParse->zErrMsg,"syntax error",0);
................................................................................
   113    113   id(A) ::= ID(X).         {A = X;}
   114    114   
   115    115   // The following directive causes tokens ABORT, AFTER, ASC, etc. to
   116    116   // fallback to ID if they will not parse as their original value.
   117    117   // This obviates the need for the "id" nonterminal.
   118    118   //
   119    119   %fallback ID 
   120         -  ABORT AFTER ASC BEFORE BEGIN CASCADE CLUSTER CONFLICT
          120  +  ABORT AFTER ASC BEFORE BEGIN CASCADE CLUSTER COLLATE CONFLICT
   121    121     COPY DEFERRED DELIMITERS DESC EACH END EXPLAIN FAIL FOR
   122    122     FULL IGNORE IMMEDIATE INITIALLY INSTEAD MATCH JOIN KEY
   123    123     OF OFFSET PARTIAL PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT
   124    124     TEMP TRIGGER VACUUM VIEW.
   125    125   
   126    126   // And "ids" is an identifer-or-string.
   127    127   //
................................................................................
   159    159   //
   160    160   ccons ::= NOT NULL onconf(R).               {sqliteAddNotNull(pParse, R);}
   161    161   ccons ::= PRIMARY KEY sortorder onconf(R).  {sqliteAddPrimaryKey(pParse,0,R);}
   162    162   ccons ::= UNIQUE onconf(R).            {sqliteCreateIndex(pParse,0,0,0,R,0,0);}
   163    163   ccons ::= CHECK LP expr RP onconf.
   164    164   ccons ::= references.
   165    165   ccons ::= defer_subclause.
          166  +ccons ::= COLLATE id(C).  {
          167  +   sqliteAddCollateType(pParse, sqliteCollateType(pParse, &C));
          168  +}
   166    169   
   167    170   // A REFERENCES clause is parsed but the current implementation does not
   168    171   // do anything with it.
   169    172   //
   170    173   references ::= REFERENCES ids LP idxlist RP refargs.
   171    174   references ::= REFERENCES ids refargs.
   172    175   refargs ::= .
................................................................................
   375    378   %type sortlist {ExprList*}
   376    379   %destructor sortlist {sqliteExprListDelete($$);}
   377    380   %type sortitem {Expr*}
   378    381   %destructor sortitem {sqliteExprDelete($$);}
   379    382   
   380    383   orderby_opt(A) ::= .                          {A = 0;}
   381    384   orderby_opt(A) ::= ORDER BY sortlist(X).      {A = X;}
   382         -sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). {
          385  +sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). {
   383    386     A = sqliteExprListAppend(X,Y,0);
   384         -  if( A ) A->a[A->nExpr-1].sortOrder = Z;  /* 0=ascending, 1=decending */
          387  +  if( A ) A->a[A->nExpr-1].sortOrder = C+Z;
   385    388   }
   386    389   sortlist(A) ::= sortitem(Y) sortorder(Z). {
   387    390     A = sqliteExprListAppend(0,Y,0);
   388    391     if( A ) A->a[0].sortOrder = Z;
   389    392   }
   390    393   sortitem(A) ::= expr(X).   {A = X;}
   391    394   
   392    395   %type sortorder {int}
          396  +%type collate {int}
   393    397   
   394         -sortorder(A) ::= ASC.      {A = 0;}
   395         -sortorder(A) ::= DESC.     {A = 1;}
   396         -sortorder(A) ::= .         {A = 0;}
          398  +sortorder(A) ::= ASC.           {A = SQLITE_SO_ASC;}
          399  +sortorder(A) ::= DESC.          {A = SQLITE_SO_DESC;}
          400  +sortorder(A) ::= .              {A = SQLITE_SO_ASC;}
          401  +collate(C) ::= .                {C = SQLITE_SO_UNK;}
          402  +collate(C) ::= COLLATE id(X).   {C = sqliteCollateType(pParse, &X);}
   397    403   
   398    404   %type groupby_opt {ExprList*}
   399    405   %destructor groupby_opt {sqliteExprListDelete($$);}
   400    406   groupby_opt(A) ::= .                      {A = 0;}
   401    407   groupby_opt(A) ::= GROUP BY exprlist(X).  {A = X;}
   402    408   
   403    409   %type having_opt {Expr*}

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.124 2002/06/16 18:21:44 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.125 2002/06/17 17:07:20 drh Exp $
    15     15   */
    16     16   #include "sqlite.h"
    17     17   #include "hash.h"
    18     18   #include "vdbe.h"
    19     19   #include "parse.h"
    20     20   #include "btree.h"
    21     21   #include <stdio.h>
................................................................................
   254    254   */
   255    255   struct Column {
   256    256     char *zName;     /* Name of this column */
   257    257     char *zDflt;     /* Default value of this column */
   258    258     char *zType;     /* Data type for this column */
   259    259     u8 notNull;      /* True if there is a NOT NULL constraint */
   260    260     u8 isPrimKey;    /* True if this column is an INTEGER PRIMARY KEY */
          261  +  u8 sortOrder;    /* Some combination of SQLITE_SO_... values */
   261    262   };
   262    263   
          264  +/*
          265  +** The allowed sort orders.
          266  +**
          267  +** The TEXT and NUM values use bits that do not overlap with DESC and ASC.
          268  +** That way the two can be combined into a single number.
          269  +*/
          270  +#define SQLITE_SO_UNK       0  /* Use the default collating type.  (SCT_NUM) */
          271  +#define SQLITE_SO_TEXT      2  /* Sort using memcmp() */
          272  +#define SQLITE_SO_NUM       4  /* Sort using sqliteCompare() */
          273  +#define SQLITE_SO_TYPEMASK  6  /* Mask to extract the collating sequence */
          274  +#define SQLITE_SO_ASC       0  /* Sort in ascending order */
          275  +#define SQLITE_SO_DESC      1  /* Sort in descending order */
          276  +#define SQLITE_SO_DIRMASK   1  /* Mask to extract the sort direction */
          277  +
   263    278   /*
   264    279   ** Each SQL table is represented in memory by an instance of the
   265    280   ** following structure.
   266    281   **
   267    282   ** Expr.zName is the name of the table.  The case of the original
   268    283   ** CREATE TABLE statement is stored, but case is not significant for
   269    284   ** comparisons.
................................................................................
   405    420   **
   406    421   ** The Expr.pSelect field points to a SELECT statement.  The SELECT might
   407    422   ** be the right operand of an IN operator.  Or, if a scalar SELECT appears
   408    423   ** in an expression the opcode is TK_SELECT and Expr.pSelect is the only
   409    424   ** operand.
   410    425   */
   411    426   struct Expr {
   412         -  int op;                /* Operation performed by this node */
          427  +  u16 op;                /* Operation performed by this node */
          428  +  u8 dataType;           /* Either SQLITE_SO_TEXT or SQLITE_SO_NUM */
   413    429     Expr *pLeft, *pRight;  /* Left and right subnodes */
   414    430     ExprList *pList;       /* A list of expressions used as function arguments
   415    431                            ** or in "<expr> IN (<expr-list)" */
   416    432     Token token;           /* An operand token */
   417    433     Token span;            /* Complete text of the expression */
   418    434     int iTable, iColumn;   /* When op==TK_COLUMN, then this expr node means the
   419         -                         ** iColumn-th field of the iTable-th table.  When
   420         -                         ** op==TK_FUNCTION, iColumn holds the function id */
          435  +                         ** iColumn-th field of the iTable-th table. */
   421    436     int iAgg;              /* When op==TK_COLUMN and pParse->useAgg==TRUE, pull
   422    437                            ** result from the iAgg-th element of the aggregator */
   423    438     Select *pSelect;       /* When the expression is a sub-select.  Also the
   424    439                            ** right side of "<expr> IN (<select>)" */
   425    440   };
   426    441   
   427    442   /*
................................................................................
   433    448   ** field is not used.
   434    449   */
   435    450   struct ExprList {
   436    451     int nExpr;             /* Number of expressions on the list */
   437    452     struct ExprList_item {
   438    453       Expr *pExpr;           /* The list of expressions */
   439    454       char *zName;           /* Token associated with this expression */
   440         -    char sortOrder;        /* 1 for DESC or 0 for ASC */
   441         -    char isAgg;            /* True if this is an aggregate like count(*) */
   442         -    char done;             /* A flag to indicate when processing is finished */
          455  +    u8 sortOrder;          /* 1 for DESC or 0 for ASC */
          456  +    u8 isAgg;              /* True if this is an aggregate like count(*) */
          457  +    u8 done;               /* A flag to indicate when processing is finished */
   443    458     } *a;                  /* One entry for each expression */
   444    459   };
   445    460   
   446    461   /*
   447    462   ** An instance of this structure can hold a simple list of identifiers,
   448    463   ** such as the list "a,b,c" in the following statements:
   449    464   **
................................................................................
   817    832   Table *sqliteResultSetOfSelect(Parse*,char*,Select*);
   818    833   void sqliteStartTable(Parse*,Token*,Token*,int);
   819    834   void sqliteAddColumn(Parse*,Token*);
   820    835   void sqliteAddNotNull(Parse*, int);
   821    836   void sqliteAddPrimaryKey(Parse*, IdList*, int);
   822    837   void sqliteAddColumnType(Parse*,Token*,Token*);
   823    838   void sqliteAddDefaultValue(Parse*,Token*,int);
          839  +int sqliteCollateType(Parse*, Token*);
          840  +void sqliteAddCollateType(Parse*, int);
   824    841   void sqliteEndTable(Parse*,Token*,Select*);
   825    842   void sqliteCreateView(Parse*,Token*,Token*,Select*);
   826    843   int sqliteViewGetColumnNames(Parse*,Table*);
   827    844   void sqliteViewResetAll(sqlite*);
   828    845   void sqliteDropTable(Parse*, Token*, int);
   829    846   void sqliteDeleteTable(sqlite*, Table*);
   830    847   void sqliteInsert(Parse*, Token*, ExprList*, Select*, IdList*, int);

Changes to src/tokenize.c.

    11     11   *************************************************************************
    12     12   ** An tokenizer for SQL
    13     13   **
    14     14   ** This file contains C code that splits an SQL input string up into
    15     15   ** individual tokens and sends those tokens one-by-one over to the
    16     16   ** parser for analysis.
    17     17   **
    18         -** $Id: tokenize.c,v 1.45 2002/06/11 02:25:42 danielk1977 Exp $
           18  +** $Id: tokenize.c,v 1.46 2002/06/17 17:07:20 drh Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   
    25     25   /*
................................................................................
    48     48     { "BEGIN",             0, TK_BEGIN,            0 },
    49     49     { "BETWEEN",           0, TK_BETWEEN,          0 },
    50     50     { "BY",                0, TK_BY,               0 },
    51     51     { "CASCADE",           0, TK_CASCADE,          0 },
    52     52     { "CASE",              0, TK_CASE,             0 },
    53     53     { "CHECK",             0, TK_CHECK,            0 },
    54     54     { "CLUSTER",           0, TK_CLUSTER,          0 },
           55  +  { "COLLATE",           0, TK_COLLATE,          0 },
    55     56     { "COMMIT",            0, TK_COMMIT,           0 },
    56     57     { "CONFLICT",          0, TK_CONFLICT,         0 },
    57     58     { "CONSTRAINT",        0, TK_CONSTRAINT,       0 },
    58     59     { "COPY",              0, TK_COPY,             0 },
    59     60     { "CREATE",            0, TK_CREATE,           0 },
    60     61     { "DEFAULT",           0, TK_DEFAULT,          0 },
    61     62     { "DEFERRED",          0, TK_DEFERRED,         0 },