/ Check-in [007aec11]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:The makefile now runs mkkeywordhash.c. Keywords that are unused are omitted from the keyword hash table. (CVS 2045)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 007aec11333432e08d1091b728773011e9078bc3
User & Date: drh 2004-11-03 03:59:57
Context
2004-11-03
08:44
Auto-vacuum bug: Correctly manipulate page cache hash-table entries in sqlite3pager_movepage(). (CVS 2046) check-in: 719c1b79 user: danielk1977 tags: trunk
03:59
The makefile now runs mkkeywordhash.c. Keywords that are unused are omitted from the keyword hash table. (CVS 2045) check-in: 007aec11 user: drh tags: trunk
03:52
Auto-vacuum bugfix: Do not attempt to move a pointer-map page during auto-vacuum. (CVS 2044) check-in: bd50fbb5 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

    72     72   # default to file, 2 to default to memory, and 3 to force temporary
    73     73   # tables to always be in memory.
    74     74   #
    75     75   TEMP_STORE = -DTEMP_STORE=@TEMP_STORE@
    76     76   
    77     77   # You should not have to change anything below this line
    78     78   ###############################################################################
           79  +
           80  +BEXE = @BUILD_EXEEXT@
    79     81   
    80     82   # Object files for the SQLite library.
    81     83   #
    82     84   LIBOBJ = attach.lo auth.lo btree.lo build.lo date.lo delete.lo \
    83     85            expr.lo func.lo hash.lo insert.lo \
    84     86            main.lo opcodes.lo os_mac.lo os_unix.lo os_win.lo \
    85     87            pager.lo parse.lo pragma.lo printf.lo random.lo \
................................................................................
   207    209   
   208    210   # This target creates a directory named "tsrc" and fills it with
   209    211   # copies of all of the C source code and header files needed to
   210    212   # build on the target system.  Some of the C source code and header
   211    213   # files are automatically generated.  This target takes care of
   212    214   # all that automatic generation.
   213    215   #
   214         -target_source:	$(SRC) $(VDBEHDR) 
          216  +target_source:	$(SRC) parse.c opcodes.c keywordhash.c $(VDBEHDR) 
   215    217   	rm -rf tsrc
   216    218   	mkdir -p tsrc
   217    219   	cp $(SRC) $(VDBEHDR) tsrc
   218    220   	rm tsrc/sqlite.h.in tsrc/parse.y
   219         -	cp parse.c opcodes.c tsrc
          221  +	cp parse.c opcodes.c keywordhash.c tsrc
   220    222   	cp $(TOP)/sqlite3.def tsrc
   221    223   
   222    224   # Rules to build the LEMON compiler generator
   223    225   #
   224         -lemon@BUILD_EXEEXT@:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
          226  +lemon$(BEXE):	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
   225    227   	$(BCC) -o lemon $(TOP)/tool/lemon.c
   226    228   	cp $(TOP)/tool/lempar.c .
   227    229   
   228    230   
   229    231   # Rules to build individual files
   230    232   #
   231    233   attach.lo:	$(TOP)/src/attach.c $(HDR)
................................................................................
   302    304   	$(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_win.c
   303    305   
   304    306   parse.lo:	parse.c $(HDR)
   305    307   	$(LTCOMPILE) -c parse.c
   306    308   
   307    309   parse.h:	parse.c
   308    310   
   309         -parse.c:	$(TOP)/src/parse.y lemon@BUILD_EXEEXT@
          311  +parse.c:	$(TOP)/src/parse.y lemon$(BEXE)
   310    312   	cp $(TOP)/src/parse.y .
   311    313   	./lemon $(OPTS) parse.y
   312    314   
   313    315   pragma.lo:	$(TOP)/src/pragma.c $(HDR)
   314    316   	$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
   315    317   
   316    318   printf.lo:	$(TOP)/src/printf.c $(HDR)
................................................................................
   328    330   
   329    331   table.lo:	$(TOP)/src/table.c $(HDR)
   330    332   	$(LTCOMPILE) -c $(TOP)/src/table.c
   331    333   
   332    334   tclsqlite.lo:	$(TOP)/src/tclsqlite.c $(HDR)
   333    335   	$(LTCOMPILE) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
   334    336   
   335         -tokenize.lo:	$(TOP)/src/tokenize.c $(HDR)
          337  +tokenize.lo:	$(TOP)/src/tokenize.c keywordhash.c $(HDR)
   336    338   	$(LTCOMPILE) -c $(TOP)/src/tokenize.c
          339  +
          340  +keywordhash.c:	$(TOP)/tool/mkkeywordhash.c
          341  +	$(BCC) -o mkkeywordhash$(BEXE) $(OPTS) $(TOP)/tool/mkkeywordhash.c
          342  +	./mkkeywordhash$(BEXE) >keywordhash.c
   337    343   
   338    344   trigger.lo:	$(TOP)/src/trigger.c $(HDR)
   339    345   	$(LTCOMPILE) -c $(TOP)/src/trigger.c
   340    346   
   341    347   update.lo:	$(TOP)/src/update.c $(HDR)
   342    348   	$(LTCOMPILE) -c $(TOP)/src/update.c
   343    349   
................................................................................
   550    556   	$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig; 
   551    557   	$(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(libdir)/pkgconfig; 
   552    558   
   553    559   clean:	
   554    560   	rm -f *.lo *.la *.o sqlite3@TARGET_EXEEXT@ libsqlite3.la
   555    561   	rm -f sqlite3.h opcodes.*
   556    562   	rm -rf .libs .deps 
   557         -	rm -f lemon@BUILD_EXEEXT@ lempar.c parse.* sqlite*.tar.gz
          563  +	rm -f lemon$(BEXE) lempar.c parse.* sqlite*.tar.gz
          564  +	rm -f mkkeywordhash$(BEXE) keywordhash.c
   558    565   	rm -f $(PUBLISH)
   559    566   	rm -f *.da *.bb *.bbg gmon.out
   560    567   	rm -f testfixture@TARGET_EXEEXT@ test.db
   561    568   	rm -rf doc
   562    569   	rm -f common.tcl
   563    570   	rm -f sqlite3.dll sqlite3.lib
   564    571   

Changes to main.mk.

   177    177   
   178    178   # This target creates a directory named "tsrc" and fills it with
   179    179   # copies of all of the C source code and header files needed to
   180    180   # build on the target system.  Some of the C source code and header
   181    181   # files are automatically generated.  This target takes care of
   182    182   # all that automatic generation.
   183    183   #
   184         -target_source:	$(SRC) $(VDBEHDR) opcodes.c
          184  +target_source:	$(SRC) $(VDBEHDR) opcodes.c keyworkhash.c
   185    185   	rm -rf tsrc
   186    186   	mkdir tsrc
   187    187   	cp $(SRC) $(VDBEHDR) tsrc
   188    188   	rm tsrc/sqlite.h.in tsrc/parse.y
   189         -	cp parse.c opcodes.c tsrc
          189  +	cp parse.c opcodes.c keywordhash.c tsrc
   190    190   	cp $(TOP)/sqlite3.def tsrc
   191    191   
   192    192   # Rules to build the LEMON compiler generator
   193    193   #
   194    194   lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
   195    195   	$(BCC) -o lemon $(TOP)/tool/lemon.c
   196    196   	cp $(TOP)/tool/lempar.c .
................................................................................
   298    298   
   299    299   table.o:	$(TOP)/src/table.c $(HDR)
   300    300   	$(TCCX) -c $(TOP)/src/table.c
   301    301   
   302    302   tclsqlite.o:	$(TOP)/src/tclsqlite.c $(HDR)
   303    303   	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
   304    304   
   305         -tokenize.o:	$(TOP)/src/tokenize.c $(HDR)
          305  +tokenize.o:	$(TOP)/src/tokenize.c keywordhash.c $(HDR)
   306    306   	$(TCCX) -c $(TOP)/src/tokenize.c
          307  +
          308  +keywordhash.c:	$(TOP)/tool/mkkeywordhash.c
          309  +	$(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c
          310  +	./mkkeywordhash >keywordhash.c
   307    311   
   308    312   trigger.o:	$(TOP)/src/trigger.c $(HDR)
   309    313   	$(TCCX) -c $(TOP)/src/trigger.c
   310    314   
   311    315   update.o:	$(TOP)/src/update.c $(HDR)
   312    316   	$(TCCX) -c $(TOP)/src/update.c
   313    317   
................................................................................
   523    527   install:	sqlite3 libsqlite3.a sqlite3.h
   524    528   	mv sqlite3 /usr/bin
   525    529   	mv libsqlite3.a /usr/lib
   526    530   	mv sqlite3.h /usr/include
   527    531   
   528    532   clean:	
   529    533   	rm -f *.o sqlite3 libsqlite3.a sqlite3.h opcodes.*
   530         -	rm -f lemon lempar.c parse.* sqlite*.tar.gz
          534  +	rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.c
   531    535   	rm -f $(PUBLISH)
   532    536   	rm -f *.da *.bb *.bbg gmon.out
   533    537   	rm -rf tsrc

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.145 2004/10/31 02:22:49 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.146 2004/11/03 03:59:57 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     if( pParse->zErrMsg==0 ){
................................................................................
   146    146     DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR
   147    147     GLOB IGNORE IMMEDIATE INITIALLY INSTEAD LIKE MATCH KEY
   148    148     OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT
   149    149     TEMP TRIGGER VACUUM VIEW
   150    150   %ifdef SQLITE_OMIT_COMPOUND_SELECT
   151    151     EXCEPT INTERSECT UNION
   152    152   %endif
          153  +  REINDEX RENAME AUTOINCR CDATE CTIME CTIMESTAMP ALTER
   153    154     .
   154    155   
   155    156   // Define operator precedence early so that this is the first occurance
   156    157   // of the operator tokens in the grammer.  Keeping the operators together
   157    158   // causes them to be assigned integer values that are close together,
   158    159   // which keeps parser tables smaller.
   159    160   //

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.93 2004/10/31 02:22:49 drh Exp $
           18  +** $Id: tokenize.c,v 1.94 2004/11/03 03:59:58 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   /*
    26         -** This function looks up an identifier to determine if it is a
    27         -** keyword.  If it is a keyword, the token code of that keyword is 
           26  +** The sqlite3KeywordCode function looks up an identifier to determine if
           27  +** it is a keyword.  If it is a keyword, the token code of that keyword is 
    28     28   ** returned.  If the input is not a keyword, TK_ID is returned.
    29     29   **
    30     30   ** The implementation of this routine was generated by a program,
    31     31   ** mkkeywordhash.c, located in the tool subdirectory of the distribution.
    32         -** The output of the mkkeywordhash.c program was manually cut and pasted
    33         -** into this file.  When the set of keywords for SQLite changes, you
    34         -** must modify the mkkeywordhash.c program (to add or remove keywords from
    35         -** the data tables) then rerun that program to regenerate this function.
           32  +** The output of the mkkeywordhash.c program is written into a file
           33  +** named keywordhash.c and then included into this source file by
           34  +** the #include below.
    36     35   */
    37         -int sqlite3KeywordCode(const char *z, int n){
    38         -  static const char zText[443] =
    39         -    "ABORTABLEFTEMPORARYAFTERAISELECTHENDATABASEACHECKEYANDEFAULTRANSACTION"
    40         -    "ATURALIKELSEXCEPTRIGGEREFERENCESTATEMENTATTACHAVINGLOBEFOREIGN"
    41         -    "OREPLACEXCLUSIVEXPLAINDEXBEGINITIALLYBETWEENOTNULLIMITBYCASCADE"
    42         -    "FERRABLECASECOLLATECOMMITCONFLICTCONSTRAINTERSECTCREATECROSSDEFERRED"
    43         -    "ELETEDESCDETACHDISTINCTDROPRAGMATCHFAILFROMFULLGROUPDATEIMMEDIATE"
    44         -    "INNERESTRICTINSERTINSTEADINTOFFSETISNULLJOINORDERIGHTOUTEROLLBACK"
    45         -    "PRIMARYROWHENUNIONUNIQUEUSINGVACUUMVALUESVIEWHERE";
    46         -  static const unsigned char aHash[154] = {
    47         -       0,  26,  82,   0,   0,  91,  90,   0,  27,   0,   0,   0,   0,
    48         -       0,   0,  49,   0,  96,  17,   0,   0,   0,   0,   0,   0,   0,
    49         -       0,  97,   5,  31,   0,  62,  51,  28,  58,  52,   0,   0,  60,
    50         -      61,   0,  12,  41,  50,   0,   0,   0,  36,  63,   0,   0,  15,
    51         -       0,   0,   0,  39,   0,  42,   0,   0,   0,   0,  78,   0,  34,
    52         -      29,   0,  74,  71,   0,  66,  70,  37,   0,   0,  59,   0,  33,
    53         -       0,  53,   0,  54,   0,  55,   0,  83,  72,  67,   0,  24,   0,
    54         -       0,  79,  80,  84,   0,   0,   0,   0,   0,   0,   0,  75,   0,
    55         -       0,   0,   0,   0,  45,  77,  35,  44,  57,   0,   0,   0,   0,
    56         -      20,   2,   0,  38,   0,   3,  46,  93,   0,   0,  40,   0,  94,
    57         -       0,  43,  87,  98,   0,   0,   0,   0,   0,  81,   0,   0,   0,
    58         -       0,  10,   0,   0,   0,   0,   0,  92,  19,   0,  95,
    59         -  };
    60         -  static const unsigned char aNext[98] = {
    61         -       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   7,
    62         -       0,  14,   0,   0,   0,   0,   0,   0,   0,   0,   0,   9,   0,
    63         -       0,   0,   0,   0,   0,  18,  22,   0,   0,   0,   0,   0,   0,
    64         -       0,  23,   0,  16,  21,   8,   0,  32,   0,   0,  30,   0,  48,
    65         -       0,   0,   0,   0,   0,   0,   0,  11,   0,   0,   0,   0,   0,
    66         -       0,  56,   0,   1,   0,  69,  64,   0,   0,  65,   0,   0,  13,
    67         -      68,   0,   0,  76,  47,   0,   0,   0,  85,   6,   0,  89,  25,
    68         -       4,  73,  88,  86,   0,   0,   0,
    69         -  };
    70         -  static const unsigned char aLen[98] = {
    71         -       5,   5,   4,   4,   9,   2,   5,   5,   6,   4,   3,   8,   2,
    72         -       4,   5,   3,   3,   7,  11,   2,   7,   4,   4,   6,   7,  10,
    73         -       9,   6,   6,   4,   6,   3,   7,   6,   7,   9,   7,   5,   5,
    74         -       9,   3,   7,   3,   7,   4,   5,   2,   7,   3,  10,   4,   7,
    75         -       6,   8,  10,   2,   9,   6,   5,   8,   6,   4,   6,   8,   2,
    76         -       4,   6,   5,   4,   4,   4,   5,   6,   9,   5,   8,   6,   7,
    77         -       4,   2,   6,   3,   6,   4,   5,   5,   5,   8,   7,   3,   4,
    78         -       5,   6,   5,   6,   6,   4,   5,
    79         -  };
    80         -  static const unsigned short int aOffset[98] = {
    81         -       0,   4,   7,  10,  10,  14,  19,  23,  26,  31,  33,  35,  40,
    82         -      42,  44,  48,  51,  53,  59,  68,  69,  75,  78,  81,  86,  92,
    83         -     101, 110, 115, 120, 123, 125, 125, 129, 133, 139, 147, 152, 157,
    84         -     160, 165, 169, 175, 175, 178, 181, 186, 188, 189, 193, 203, 207,
    85         -     214, 220, 228, 235, 235, 244, 250, 255, 262, 268, 272, 278, 279,
    86         -     286, 289, 293, 298, 302, 306, 310, 313, 319, 328, 332, 340, 346,
    87         -     353, 356, 356, 359, 362, 368, 372, 376, 381, 385, 393, 400, 402,
    88         -     406, 411, 417, 422, 428, 434, 437,
    89         -  };
    90         -  static const unsigned char aCode[98] = {
    91         -    TK_ABORT,      TK_TABLE,      TK_JOIN_KW,    TK_TEMP,       TK_TEMP,       
    92         -    TK_OR,         TK_AFTER,      TK_RAISE,      TK_SELECT,     TK_THEN,       
    93         -    TK_END,        TK_DATABASE,   TK_AS,         TK_EACH,       TK_CHECK,      
    94         -    TK_KEY,        TK_AND,        TK_DEFAULT,    TK_TRANSACTION,TK_ON,         
    95         -    TK_JOIN_KW,    TK_LIKE,       TK_ELSE,       TK_EXCEPT,     TK_TRIGGER,    
    96         -    TK_REFERENCES, TK_STATEMENT,  TK_ATTACH,     TK_HAVING,     TK_GLOB,       
    97         -    TK_BEFORE,     TK_FOR,        TK_FOREIGN,    TK_IGNORE,     TK_REPLACE,    
    98         -    TK_EXCLUSIVE,  TK_EXPLAIN,    TK_INDEX,      TK_BEGIN,      TK_INITIALLY,  
    99         -    TK_ALL,        TK_BETWEEN,    TK_NOT,        TK_NOTNULL,    TK_NULL,       
   100         -    TK_LIMIT,      TK_BY,         TK_CASCADE,    TK_ASC,        TK_DEFERRABLE, 
   101         -    TK_CASE,       TK_COLLATE,    TK_COMMIT,     TK_CONFLICT,   TK_CONSTRAINT, 
   102         -    TK_IN,         TK_INTERSECT,  TK_CREATE,     TK_JOIN_KW,    TK_DEFERRED,   
   103         -    TK_DELETE,     TK_DESC,       TK_DETACH,     TK_DISTINCT,   TK_IS,         
   104         -    TK_DROP,       TK_PRAGMA,     TK_MATCH,      TK_FAIL,       TK_FROM,       
   105         -    TK_JOIN_KW,    TK_GROUP,      TK_UPDATE,     TK_IMMEDIATE,  TK_JOIN_KW,    
   106         -    TK_RESTRICT,   TK_INSERT,     TK_INSTEAD,    TK_INTO,       TK_OF,         
   107         -    TK_OFFSET,     TK_SET,        TK_ISNULL,     TK_JOIN,       TK_ORDER,      
   108         -    TK_JOIN_KW,    TK_JOIN_KW,    TK_ROLLBACK,   TK_PRIMARY,    TK_ROW,        
   109         -    TK_WHEN,       TK_UNION,      TK_UNIQUE,     TK_USING,      TK_VACUUM,     
   110         -    TK_VALUES,     TK_VIEW,       TK_WHERE,      
   111         -  };
   112         -  int h, i;
   113         -  if( n<2 ) return TK_ID;
   114         -  h = (sqlite3UpperToLower[((unsigned char*)z)[0]]*5 + 
   115         -      sqlite3UpperToLower[((unsigned char*)z)[n-1]]*3 +
   116         -      n) % 154;
   117         -  for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
   118         -    if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
   119         -      return aCode[i];
   120         -    }
   121         -  }
   122         -  return TK_ID;
   123         -}
           36  +#include "keywordhash.c"
   124     37   
   125     38   
   126     39   /*
   127     40   ** If X is a character that can be used in an identifier and
   128     41   ** X&0x80==0 then isIdChar[X] will be 1.  If X&0x80==0x80 then
   129     42   ** X is always an identifier character.  (Hence all UTF-8
   130     43   ** characters can be part of an identifier).  isIdChar[X] will

Changes to tool/mkkeywordhash.c.

    11     11   ** All the keywords of the SQL language are stored as in a hash
    12     12   ** table composed of instances of the following structure.
    13     13   */
    14     14   typedef struct Keyword Keyword;
    15     15   struct Keyword {
    16     16     char *zName;         /* The keyword name */
    17     17     char *zTokenType;    /* Token value for this keyword */
           18  +  int mask;            /* Code this keyword if non-zero */
    18     19     int id;              /* Unique ID for this record */
    19     20     int hash;            /* Hash on the keyword */
    20     21     int offset;          /* Offset to start of name string */
    21     22     int len;             /* Length of this keyword, not counting final \000 */
    22     23     int prefix;          /* Number of characters in prefix */
    23     24     int iNext;           /* Index in aKeywordTable[] of next with same hash */
    24     25     int substrId;        /* Id to another keyword this keyword is embedded in */
    25     26     int substrOffset;    /* Offset into substrId for start of this keyword */
    26     27   };
           28  +
           29  +/*
           30  +** Define masks used to determine which keywords are allowed
           31  +*/
           32  +#ifdef SQLITE_OMIT_ALTER_TABLE
           33  +#  define ALTER      0
           34  +#else
           35  +#  define ALTER      1
           36  +#endif
           37  +#define ALWAYS     2
           38  +#ifdef SQLITE_OMIT_ATTACH
           39  +#  define ATTACH     0
           40  +#else
           41  +#  define ATTACH     4
           42  +#endif
           43  +#ifdef SQLITE_OMIT_AUTOINCREMENT
           44  +#  define AUTOINCR   0
           45  +#else
           46  +#  define AUTOINCR   8
           47  +#endif
           48  +#ifdef SQLITE_OMIT_COMPOUND_SELECT
           49  +#  define COMPOUND   0
           50  +#else
           51  +#  define COMPOUND   16
           52  +#endif
           53  +#ifdef SQLITE_OMIT_CONFLICT_CLAUSE
           54  +#  define CONFLICT   0
           55  +#else
           56  +#  define CONFLICT   32
           57  +#endif
           58  +#ifdef SQLITE_OMIT_EXPLAIN
           59  +#  define EXPLAIN    0
           60  +#else
           61  +#  define EXPLAIN    64
           62  +#endif
           63  +#ifdef SQLITE_OMIT_FOREIGN_KEY
           64  +#  define FKEY       0
           65  +#else
           66  +#  define FKEY       128
           67  +#endif
           68  +#ifdef SQLITE_OMIT_PRAGMA
           69  +#  define PRAGMA     0
           70  +#else
           71  +#  define PRAGMA     256
           72  +#endif
           73  +#ifdef SQLITE_OMIT_REINDEX
           74  +#  define REINDEX    0
           75  +#else
           76  +#  define REINDEX    512
           77  +#endif
           78  +#ifdef SQLITE_OMIT_TRIGGER
           79  +#  define TRIGGER    0
           80  +#else
           81  +#  define TRIGGER    1024
           82  +#endif
           83  +#ifdef SQLITE_OMIT_VACUUM
           84  +#  define VACUUM     0
           85  +#else
           86  +#  define VACUUM     2048
           87  +#endif
           88  +#ifdef SQLITE_OMIT_VIEW
           89  +#  define VIEW       0
           90  +#else
           91  +#  define VIEW       4096
           92  +#endif
           93  +
    27     94   
    28     95   /*
    29     96   ** These are the keywords
    30     97   */
    31     98   static Keyword aKeywordTable[] = {
    32         -  { "ABORT",            "TK_ABORT",        },
    33         -  { "AFTER",            "TK_AFTER",        },
    34         -  { "ALL",              "TK_ALL",          },
    35         -  { "AND",              "TK_AND",          },
    36         -  { "AS",               "TK_AS",           },
    37         -  { "ASC",              "TK_ASC",          },
    38         -  { "ATTACH",           "TK_ATTACH",       },
    39         -  { "BEFORE",           "TK_BEFORE",       },
    40         -  { "BEGIN",            "TK_BEGIN",        },
    41         -  { "BETWEEN",          "TK_BETWEEN",      },
    42         -  { "BY",               "TK_BY",           },
    43         -  { "CASCADE",          "TK_CASCADE",      },
    44         -  { "CASE",             "TK_CASE",         },
    45         -  { "CHECK",            "TK_CHECK",        },
    46         -  { "COLLATE",          "TK_COLLATE",      },
    47         -  { "COMMIT",           "TK_COMMIT",       },
    48         -  { "CONFLICT",         "TK_CONFLICT",     },
    49         -  { "CONSTRAINT",       "TK_CONSTRAINT",   },
    50         -  { "CREATE",           "TK_CREATE",       },
    51         -  { "CROSS",            "TK_JOIN_KW",      },
    52         -  { "DATABASE",         "TK_DATABASE",     },
    53         -  { "DEFAULT",          "TK_DEFAULT",      },
    54         -  { "DEFERRED",         "TK_DEFERRED",     },
    55         -  { "DEFERRABLE",       "TK_DEFERRABLE",   },
    56         -  { "DELETE",           "TK_DELETE",       },
    57         -  { "DESC",             "TK_DESC",         },
    58         -  { "DETACH",           "TK_DETACH",       },
    59         -  { "DISTINCT",         "TK_DISTINCT",     },
    60         -  { "DROP",             "TK_DROP",         },
    61         -  { "END",              "TK_END",          },
    62         -  { "EACH",             "TK_EACH",         },
    63         -  { "ELSE",             "TK_ELSE",         },
    64         -  { "EXCEPT",           "TK_EXCEPT",       },
    65         -  { "EXCLUSIVE",        "TK_EXCLUSIVE",    },
    66         -  { "EXPLAIN",          "TK_EXPLAIN",      },
    67         -  { "FAIL",             "TK_FAIL",         },
    68         -  { "FOR",              "TK_FOR",          },
    69         -  { "FOREIGN",          "TK_FOREIGN",      },
    70         -  { "FROM",             "TK_FROM",         },
    71         -  { "FULL",             "TK_JOIN_KW",      },
    72         -  { "GLOB",             "TK_GLOB",         },
    73         -  { "GROUP",            "TK_GROUP",        },
    74         -  { "HAVING",           "TK_HAVING",       },
    75         -  { "IGNORE",           "TK_IGNORE",       },
    76         -  { "IMMEDIATE",        "TK_IMMEDIATE",    },
    77         -  { "IN",               "TK_IN",           },
    78         -  { "INDEX",            "TK_INDEX",        },
    79         -  { "INITIALLY",        "TK_INITIALLY",    },
    80         -  { "INNER",            "TK_JOIN_KW",      },
    81         -  { "INSERT",           "TK_INSERT",       },
    82         -  { "INSTEAD",          "TK_INSTEAD",      },
    83         -  { "INTERSECT",        "TK_INTERSECT",    },
    84         -  { "INTO",             "TK_INTO",         },
    85         -  { "IS",               "TK_IS",           },
    86         -  { "ISNULL",           "TK_ISNULL",       },
    87         -  { "JOIN",             "TK_JOIN",         },
    88         -  { "KEY",              "TK_KEY",          },
    89         -  { "LEFT",             "TK_JOIN_KW",      },
    90         -  { "LIKE",             "TK_LIKE",         },
    91         -  { "LIMIT",            "TK_LIMIT",        },
    92         -  { "MATCH",            "TK_MATCH",        },
    93         -  { "NATURAL",          "TK_JOIN_KW",      },
    94         -  { "NOT",              "TK_NOT",          },
    95         -  { "NOTNULL",          "TK_NOTNULL",      },
    96         -  { "NULL",             "TK_NULL",         },
    97         -  { "OF",               "TK_OF",           },
    98         -  { "OFFSET",           "TK_OFFSET",       },
    99         -  { "ON",               "TK_ON",           },
   100         -  { "OR",               "TK_OR",           },
   101         -  { "ORDER",            "TK_ORDER",        },
   102         -  { "OUTER",            "TK_JOIN_KW",      },
   103         -  { "PRAGMA",           "TK_PRAGMA",       },
   104         -  { "PRIMARY",          "TK_PRIMARY",      },
   105         -  { "RAISE",            "TK_RAISE",        },
   106         -  { "REFERENCES",       "TK_REFERENCES",   },
   107         -  { "REPLACE",          "TK_REPLACE",      },
   108         -  { "RESTRICT",         "TK_RESTRICT",     },
   109         -  { "RIGHT",            "TK_JOIN_KW",      },
   110         -  { "ROLLBACK",         "TK_ROLLBACK",     },
   111         -  { "ROW",              "TK_ROW",          },
   112         -  { "SELECT",           "TK_SELECT",       },
   113         -  { "SET",              "TK_SET",          },
   114         -  { "STATEMENT",        "TK_STATEMENT",    },
   115         -  { "TABLE",            "TK_TABLE",        },
   116         -  { "TEMP",             "TK_TEMP",         },
   117         -  { "TEMPORARY",        "TK_TEMP",         },
   118         -  { "THEN",             "TK_THEN",         },
   119         -  { "TRANSACTION",      "TK_TRANSACTION",  },
   120         -  { "TRIGGER",          "TK_TRIGGER",      },
   121         -  { "UNION",            "TK_UNION",        },
   122         -  { "UNIQUE",           "TK_UNIQUE",       },
   123         -  { "UPDATE",           "TK_UPDATE",       },
   124         -  { "USING",            "TK_USING",        },
   125         -  { "VACUUM",           "TK_VACUUM",       },
   126         -  { "VALUES",           "TK_VALUES",       },
   127         -  { "VIEW",             "TK_VIEW",         },
   128         -  { "WHEN",             "TK_WHEN",         },
   129         -  { "WHERE",            "TK_WHERE",        },
           99  +  { "ABORT",            "TK_ABORT",        CONFLICT|TRIGGER       },
          100  +  { "AFTER",            "TK_AFTER",        TRIGGER                },
          101  +  { "ALL",              "TK_ALL",          ALWAYS                 },
          102  +  { "ALTER",            "TK_ALTER",        ALTER                  },
          103  +  { "AND",              "TK_AND",          ALWAYS                 },
          104  +  { "AS",               "TK_AS",           ALWAYS                 },
          105  +  { "ASC",              "TK_ASC",          ALWAYS                 },
          106  +  { "ATTACH",           "TK_ATTACH",       ATTACH                 },
          107  +  { "AUTOINCREMENT",    "TK_AUTOINCR",     AUTOINCR               },
          108  +  { "BEFORE",           "TK_BEFORE",       TRIGGER                },
          109  +  { "BEGIN",            "TK_BEGIN",        ALWAYS                 },
          110  +  { "BETWEEN",          "TK_BETWEEN",      ALWAYS                 },
          111  +  { "BY",               "TK_BY",           ALWAYS                 },
          112  +  { "CASCADE",          "TK_CASCADE",      FKEY                   },
          113  +  { "CASE",             "TK_CASE",         ALWAYS                 },
          114  +  { "CHECK",            "TK_CHECK",        ALWAYS                 },
          115  +  { "COLLATE",          "TK_COLLATE",      ALWAYS                 },
          116  +  { "COMMIT",           "TK_COMMIT",       ALWAYS                 },
          117  +  { "CONFLICT",         "TK_CONFLICT",     CONFLICT               },
          118  +  { "CONSTRAINT",       "TK_CONSTRAINT",   ALWAYS                 },
          119  +  { "CREATE",           "TK_CREATE",       ALWAYS                 },
          120  +  { "CROSS",            "TK_JOIN_KW",      ALWAYS                 },
          121  +  { "CURRENT_DATE",     "TK_CDATE",        ALWAYS                 },
          122  +  { "CURRENT_TIME",     "TK_CTIME",        ALWAYS                 },
          123  +  { "CURRENT_TIMESTAMP","TK_CTIMESTAMP",   ALWAYS                 },
          124  +  { "DATABASE",         "TK_DATABASE",     ATTACH                 },
          125  +  { "DEFAULT",          "TK_DEFAULT",      ALWAYS                 },
          126  +  { "DEFERRED",         "TK_DEFERRED",     FKEY                   },
          127  +  { "DEFERRABLE",       "TK_DEFERRABLE",   FKEY                   },
          128  +  { "DELETE",           "TK_DELETE",       ALWAYS                 },
          129  +  { "DESC",             "TK_DESC",         ALWAYS                 },
          130  +  { "DETACH",           "TK_DETACH",       ATTACH                 },
          131  +  { "DISTINCT",         "TK_DISTINCT",     ALWAYS                 },
          132  +  { "DROP",             "TK_DROP",         ALWAYS                 },
          133  +  { "END",              "TK_END",          ALWAYS                 },
          134  +  { "EACH",             "TK_EACH",         TRIGGER                },
          135  +  { "ELSE",             "TK_ELSE",         ALWAYS                 },
          136  +  { "EXCEPT",           "TK_EXCEPT",       COMPOUND               },
          137  +  { "EXCLUSIVE",        "TK_EXCLUSIVE",    ALWAYS                 },
          138  +  { "EXPLAIN",          "TK_EXPLAIN",      EXPLAIN                },
          139  +  { "FAIL",             "TK_FAIL",         CONFLICT|TRIGGER       },
          140  +  { "FOR",              "TK_FOR",          TRIGGER                },
          141  +  { "FOREIGN",          "TK_FOREIGN",      FKEY                   },
          142  +  { "FROM",             "TK_FROM",         ALWAYS                 },
          143  +  { "FULL",             "TK_JOIN_KW",      ALWAYS                 },
          144  +  { "GLOB",             "TK_GLOB",         ALWAYS                 },
          145  +  { "GROUP",            "TK_GROUP",        ALWAYS                 },
          146  +  { "HAVING",           "TK_HAVING",       ALWAYS                 },
          147  +  { "IGNORE",           "TK_IGNORE",       CONFLICT|TRIGGER       },
          148  +  { "IMMEDIATE",        "TK_IMMEDIATE",    FKEY                   },
          149  +  { "IN",               "TK_IN",           ALWAYS                 },
          150  +  { "INDEX",            "TK_INDEX",        ALWAYS                 },
          151  +  { "INITIALLY",        "TK_INITIALLY",    FKEY                   },
          152  +  { "INNER",            "TK_JOIN_KW",      ALWAYS                 },
          153  +  { "INSERT",           "TK_INSERT",       ALWAYS                 },
          154  +  { "INSTEAD",          "TK_INSTEAD",      TRIGGER                },
          155  +  { "INTERSECT",        "TK_INTERSECT",    COMPOUND               },
          156  +  { "INTO",             "TK_INTO",         ALWAYS                 },
          157  +  { "IS",               "TK_IS",           ALWAYS                 },
          158  +  { "ISNULL",           "TK_ISNULL",       ALWAYS                 },
          159  +  { "JOIN",             "TK_JOIN",         ALWAYS                 },
          160  +  { "KEY",              "TK_KEY",          ALWAYS                 },
          161  +  { "LEFT",             "TK_JOIN_KW",      ALWAYS                 },
          162  +  { "LIKE",             "TK_LIKE",         ALWAYS                 },
          163  +  { "LIMIT",            "TK_LIMIT",        ALWAYS                 },
          164  +  { "MATCH",            "TK_MATCH",        ALWAYS                 },
          165  +  { "NATURAL",          "TK_JOIN_KW",      ALWAYS                 },
          166  +  { "NOT",              "TK_NOT",          ALWAYS                 },
          167  +  { "NOTNULL",          "TK_NOTNULL",      ALWAYS                 },
          168  +  { "NULL",             "TK_NULL",         ALWAYS                 },
          169  +  { "OF",               "TK_OF",           ALWAYS                 },
          170  +  { "OFFSET",           "TK_OFFSET",       ALWAYS                 },
          171  +  { "ON",               "TK_ON",           ALWAYS                 },
          172  +  { "OR",               "TK_OR",           ALWAYS                 },
          173  +  { "ORDER",            "TK_ORDER",        ALWAYS                 },
          174  +  { "OUTER",            "TK_JOIN_KW",      ALWAYS                 },
          175  +  { "PRAGMA",           "TK_PRAGMA",       PRAGMA                 },
          176  +  { "PRIMARY",          "TK_PRIMARY",      ALWAYS                 },
          177  +  { "RAISE",            "TK_RAISE",        TRIGGER                },
          178  +  { "REFERENCES",       "TK_REFERENCES",   FKEY                   },
          179  +  { "REINDEX",          "TK_REINDEX",      REINDEX                },
          180  +  { "RENAME",           "TK_RENAME",       ALTER                  },
          181  +  { "REPLACE",          "TK_REPLACE",      CONFLICT               },
          182  +  { "RESTRICT",         "TK_RESTRICT",     FKEY                   },
          183  +  { "RIGHT",            "TK_JOIN_KW",      ALWAYS                 },
          184  +  { "ROLLBACK",         "TK_ROLLBACK",     ALWAYS                 },
          185  +  { "ROW",              "TK_ROW",          TRIGGER                },
          186  +  { "SELECT",           "TK_SELECT",       ALWAYS                 },
          187  +  { "SET",              "TK_SET",          ALWAYS                 },
          188  +  { "STATEMENT",        "TK_STATEMENT",    TRIGGER                },
          189  +  { "TABLE",            "TK_TABLE",        ALWAYS                 },
          190  +  { "TEMP",             "TK_TEMP",         ALWAYS                 },
          191  +  { "TEMPORARY",        "TK_TEMP",         ALWAYS                 },
          192  +  { "THEN",             "TK_THEN",         ALWAYS                 },
          193  +  { "TRANSACTION",      "TK_TRANSACTION",  ALWAYS                 },
          194  +  { "TRIGGER",          "TK_TRIGGER",      TRIGGER                },
          195  +  { "UNION",            "TK_UNION",        COMPOUND               },
          196  +  { "UNIQUE",           "TK_UNIQUE",       ALWAYS                 },
          197  +  { "UPDATE",           "TK_UPDATE",       ALWAYS                 },
          198  +  { "USING",            "TK_USING",        ALWAYS                 },
          199  +  { "VACUUM",           "TK_VACUUM",       VACUUM                 },
          200  +  { "VALUES",           "TK_VALUES",       ALWAYS                 },
          201  +  { "VIEW",             "TK_VIEW",         VIEW                   },
          202  +  { "WHEN",             "TK_WHEN",         ALWAYS                 },
          203  +  { "WHERE",            "TK_WHERE",        ALWAYS                 },
   130    204   };
   131    205   
   132    206   /* Number of keywords */
   133         -#define NKEYWORD (sizeof(aKeywordTable)/sizeof(aKeywordTable[0]))
          207  +static int NKEYWORD = (sizeof(aKeywordTable)/sizeof(aKeywordTable[0]));
   134    208   
   135    209   /* An array to map all upper-case characters into their corresponding
   136    210   ** lower-case character. 
   137    211   */
   138    212   const unsigned char sqlite3UpperToLower[] = {
   139    213         0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
   140    214        18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
................................................................................
   196    270   */
   197    271   int main(int argc, char **argv){
   198    272     int i, j, k, h;
   199    273     int bestSize, bestCount;
   200    274     int count;
   201    275     int nChar;
   202    276     int aHash[1000];  /* 1000 is much bigger than NKEYWORD */
          277  +
          278  +  /* Remove entries from the list of keywords that have mask==0 */
          279  +  for(i=j=0; i<NKEYWORD; i++){
          280  +    if( aKeywordTable[i].mask==0 ) continue;
          281  +    if( j<i ){
          282  +      aKeywordTable[j] = aKeywordTable[i];
          283  +    }
          284  +    j++;
          285  +  }
          286  +  NKEYWORD = j;
   203    287   
   204    288     /* Fill in the lengths of strings and hashes for all entries. */
   205    289     for(i=0; i<NKEYWORD; i++){
   206    290       Keyword *p = &aKeywordTable[i];
   207    291       p->len = strlen(p->zName);
   208    292       p->hash = UpperToLower[p->zName[0]]*5 +
   209    293                 UpperToLower[p->zName[p->len-1]]*3 + p->len;