/ Check-in [05b6ac9a]
Login

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

Overview
Comment:Add infrastructure for the ANALYZE command. Does not yet actually do anything. (CVS 2537)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 05b6ac9a76fd5765c50e81588f8e71c59fe35ce4
User & Date: drh 2005-07-08 12:13:04
Context
2005-07-08
13:08
Replace OP_List with OP_Fifo. This is the first step toward allowing recursive delete triggers and later foreign keys with cascading deletes. (CVS 2538) check-in: 94c120bb user: drh tags: trunk
12:13
Add infrastructure for the ANALYZE command. Does not yet actually do anything. (CVS 2537) check-in: 05b6ac9a user: drh tags: trunk
2005-07-06
13:51
Fix a quoting problem in the configure script. (CVS 2536) check-in: b34647a2 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   108    108   ###############################################################################
   109    109   
   110    110   OPTS += -DSQLITE_OMIT_CURSOR          # Cursors do not work at this time
   111    111   TCC += -DSQLITE_OMIT_CURSOR
   112    112   
   113    113   # Object files for the SQLite library.
   114    114   #
   115         -LIBOBJ = alter.lo attach.lo auth.lo btree.lo build.lo callback.lo date.lo \
          115  +LIBOBJ = alter.lo analyze.lo attach.lo auth.lo btree.lo build.lo \
          116  +         callback.lo date.lo \
   116    117            delete.lo expr.lo func.lo hash.lo insert.lo \
   117    118            main.lo opcodes.lo os_unix.lo os_win.lo \
   118    119            pager.lo parse.lo pragma.lo prepare.lo printf.lo random.lo \
   119    120            select.lo table.lo tokenize.lo trigger.lo update.lo \
   120    121            util.lo vacuum.lo vdbe.lo vdbeapi.lo vdbeaux.lo vdbemem.lo \
   121    122            where.lo utf.lo legacy.lo
   122    123   
   123    124   # All of the source code files.
   124    125   #
   125    126   SRC = \
   126    127     $(TOP)/src/alter.c \
          128  +  $(TOP)/src/analyze.c \
   127    129     $(TOP)/src/attach.c \
   128    130     $(TOP)/src/auth.c \
   129    131     $(TOP)/src/btree.c \
   130    132     $(TOP)/src/btree.h \
   131    133     $(TOP)/src/build.c \
   132    134     $(TOP)/src/callback.c \
   133    135     $(TOP)/src/date.c \
................................................................................
   260    262   	cp $(TOP)/tool/lempar.c .
   261    263   
   262    264   
   263    265   # Rules to build individual files
   264    266   #
   265    267   alter.lo:	$(TOP)/src/alter.c $(HDR)
   266    268   	$(LTCOMPILE) -c $(TOP)/src/alter.c
          269  +
          270  +analyze.lo:	$(TOP)/src/analyze.c $(HDR)
          271  +	$(LTCOMPILE) -c $(TOP)/src/analyze.c
   267    272   
   268    273   attach.lo:	$(TOP)/src/attach.c $(HDR)
   269    274   	$(LTCOMPILE) -c $(TOP)/src/attach.c
   270    275   
   271    276   auth.lo:	$(TOP)/src/auth.c $(HDR)
   272    277   	$(LTCOMPILE) -c $(TOP)/src/auth.c
   273    278   

Changes to main.mk.

    50     50   
    51     51   # This is how we compile
    52     52   #
    53     53   TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
    54     54   
    55     55   # Object files for the SQLite library.
    56     56   #
    57         -LIBOBJ+= alter.o attach.o auth.o btree.o build.o callback.o date.o delete.o \
           57  +LIBOBJ+= alter.o analyze.o attach.o auth.o btree.o build.o \
           58  +         callback.o date.o delete.o \
    58     59            expr.o func.o hash.o insert.o \
    59     60            main.o opcodes.o os_unix.o os_win.o \
    60     61            pager.o parse.o pragma.o prepare.o printf.o random.o \
    61     62            select.o table.o tclsqlite.o tokenize.o trigger.o \
    62     63            update.o util.o vacuum.o \
    63     64            vdbe.o vdbeapi.o vdbeaux.o vdbemem.o \
    64     65            where.o utf.o legacy.o
    65     66   
    66     67   # All of the source code files.
    67     68   #
    68     69   SRC = \
    69     70     $(TOP)/src/alter.c \
           71  +  $(TOP)/src/analyze.c \
    70     72     $(TOP)/src/attach.c \
    71     73     $(TOP)/src/auth.c \
    72     74     $(TOP)/src/btree.c \
    73     75     $(TOP)/src/btree.h \
    74     76     $(TOP)/src/build.c \
    75     77     $(TOP)/src/callback.c \
    76     78     $(TOP)/src/date.c \
................................................................................
   195    197   	$(BCC) -o lemon $(TOP)/tool/lemon.c
   196    198   	cp $(TOP)/tool/lempar.c .
   197    199   
   198    200   # Rules to build individual files
   199    201   #
   200    202   alter.o:	$(TOP)/src/alter.c $(HDR)
   201    203   	$(TCCX) -c $(TOP)/src/alter.c
          204  +
          205  +analyze.o:	$(TOP)/src/analyze.c $(HDR)
          206  +	$(TCCX) -c $(TOP)/src/analyze.c
   202    207   
   203    208   attach.o:	$(TOP)/src/attach.c $(HDR)
   204    209   	$(TCCX) -c $(TOP)/src/attach.c
   205    210   
   206    211   auth.o:	$(TOP)/src/auth.c $(HDR)
   207    212   	$(TCCX) -c $(TOP)/src/auth.c
   208    213   

Added src/analyze.c.

            1  +/*
            2  +** 2005 July 8
            3  +**
            4  +** The author disclaims copyright to this source code.  In place of
            5  +** a legal notice, here is a blessing:
            6  +**
            7  +**    May you do good and not evil.
            8  +**    May you find forgiveness for yourself and forgive others.
            9  +**    May you share freely, never taking more than you give.
           10  +**
           11  +*************************************************************************
           12  +** This file contains code associated with the ANALYZE command.
           13  +**
           14  +** @(#) $Id: analyze.c,v 1.1 2005/07/08 12:13:05 drh Exp $
           15  +*/
           16  +#ifndef SQLITE_OMIT_ANALYZE
           17  +#include "sqliteInt.h"
           18  +
           19  +/*
           20  +** Generate code for the ANALYZE command
           21  +**
           22  +**        ANALYZE                            -- 1
           23  +**        ANALYZE  <database >               -- 2
           24  +**        ANALYZE  ?<database>.?<tablename>  -- 3
           25  +**
           26  +** Form 1 causes all indices in all attached databases to be analyzed.
           27  +** Form 2 analyzes all indices the single database named.
           28  +** Form 3 analyzes all indices associated with the named table.
           29  +*/
           30  +void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){
           31  +}
           32  +
           33  +
           34  +#endif /* SQLITE_OMIT_ANALYZE */

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.174 2005/06/30 17:04:21 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.175 2005/07/08 12:13:05 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   166    166   id(A) ::= ID(X).         {A = X;}
   167    167   
   168    168   // The following directive causes tokens ABORT, AFTER, ASC, etc. to
   169    169   // fallback to ID if they will not parse as their original value.
   170    170   // This obviates the need for the "id" nonterminal.
   171    171   //
   172    172   %fallback ID
   173         -  ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT
          173  +  ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT
   174    174     DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR
   175    175     IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH KEY
   176    176     OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT
   177    177     TEMP TRIGGER VACUUM VIEW
   178    178   %ifdef SQLITE_OMIT_COMPOUND_SELECT
   179    179     EXCEPT INTERSECT UNION
   180    180   %endif
................................................................................
  1015   1015   }
  1016   1016   
  1017   1017   ////////////////////////// REINDEX collation //////////////////////////////////
  1018   1018   %ifndef SQLITE_OMIT_REINDEX
  1019   1019   cmd ::= REINDEX.                {sqlite3Reindex(pParse, 0, 0);}
  1020   1020   cmd ::= REINDEX nm(X) dbnm(Y).  {sqlite3Reindex(pParse, &X, &Y);}
  1021   1021   %endif
         1022  +
         1023  +/////////////////////////////////// ANALYZE ///////////////////////////////////
         1024  +%ifndef SQLITE_OMIT_ANALYZE
         1025  +cmd ::= ANALYZE.                {sqlite3Analyze(pParse, 0, 0);}
         1026  +cmd ::= ANALYZE nm(X) dbnm(Y).  {sqlite3Analyze(pParse, &X, &Y);}
         1027  +%endif
  1022   1028   
  1023   1029   //////////////////////// ALTER TABLE table ... ////////////////////////////////
  1024   1030   %ifndef SQLITE_OMIT_ALTERTABLE
  1025   1031   cmd ::= ALTER TABLE fullname(X) RENAME TO nm(Z). {
  1026   1032     sqlite3AlterRenameTable(pParse,X,&Z);
  1027   1033   }
  1028   1034   cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column(Y). {

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.389 2005/06/30 17:04:21 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.390 2005/07/08 12:13:05 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** These #defines should enable >2GB file support on Posix if the
    21     21   ** underlying operating system supports it.  If the OS lacks
................................................................................
  1561   1561   int sqlite3SelectResolve(Parse *, Select *, NameContext *);
  1562   1562   void sqlite3ColumnDefault(Vdbe *, Table *, int);
  1563   1563   void sqlite3AlterFinishAddColumn(Parse *, Token *);
  1564   1564   void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
  1565   1565   const char *sqlite3TestErrorName(int);
  1566   1566   CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char *, int);
  1567   1567   char sqlite3AffinityType(const Token*);
         1568  +void sqlite3Analyze(Parse*, Token*, Token*);
  1568   1569   
  1569   1570   #ifdef SQLITE_SSE
  1570   1571   #include "sseInt.h"
  1571   1572   #endif
  1572   1573   
  1573   1574   #endif

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.146 2005/06/25 19:31:48 drh Exp $
           16  +** $Id: test1.c,v 1.147 2005/07/08 12:13:05 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  2754   2754   */
  2755   2755   static void set_options(Tcl_Interp *interp){
  2756   2756   #ifdef SQLITE_32BIT_ROWID
  2757   2757     Tcl_SetVar2(interp, "sqlite_options", "rowid32", "1", TCL_GLOBAL_ONLY);
  2758   2758   #else
  2759   2759     Tcl_SetVar2(interp, "sqlite_options", "rowid32", "0", TCL_GLOBAL_ONLY);
  2760   2760   #endif
         2761  +
         2762  +#ifdef SQLITE_CASE_SENSITIVE_LIKE
         2763  +  Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","1",TCL_GLOBAL_ONLY);
         2764  +#else
         2765  +  Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","0",TCL_GLOBAL_ONLY);
         2766  +#endif
  2761   2767   
  2762   2768   #ifdef SQLITE_OMIT_ALTERTABLE
  2763   2769     Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY);
  2764   2770   #else
  2765   2771     Tcl_SetVar2(interp, "sqlite_options", "altertable", "1", TCL_GLOBAL_ONLY);
  2766   2772   #endif
         2773  +
         2774  +#ifdef SQLITE_OMIT_ANALYZE
         2775  +  Tcl_SetVar2(interp, "sqlite_options", "analyze", "0", TCL_GLOBAL_ONLY);
         2776  +#else
         2777  +  Tcl_SetVar2(interp, "sqlite_options", "analyze", "1", TCL_GLOBAL_ONLY);
         2778  +#endif
  2767   2779   
  2768   2780   #ifdef SQLITE_OMIT_AUTHORIZATION
  2769   2781     Tcl_SetVar2(interp, "sqlite_options", "auth", "0", TCL_GLOBAL_ONLY);
  2770   2782   #else
  2771   2783     Tcl_SetVar2(interp, "sqlite_options", "auth", "1", TCL_GLOBAL_ONLY);
  2772   2784   #endif
  2773   2785   

Changes to tool/mkkeywordhash.c.

    28     28   
    29     29   /*
    30     30   ** Define masks used to determine which keywords are allowed
    31     31   */
    32     32   #ifdef SQLITE_OMIT_ALTERTABLE
    33     33   #  define ALTER      0
    34     34   #else
    35         -#  define ALTER      1
           35  +#  define ALTER      0x00000001
    36     36   #endif
    37         -#define ALWAYS     2
           37  +#define ALWAYS       0x00000002
           38  +#ifdef SQLITE_OMIT_ANALYZE
           39  +#  define ANALYZE    0
           40  +#else
           41  +#  define ANALYZE    0x00000004
           42  +#endif
    38     43   #ifdef SQLITE_OMIT_ATTACH
    39     44   #  define ATTACH     0
    40     45   #else
    41         -#  define ATTACH     4
           46  +#  define ATTACH     0x00000008
    42     47   #endif
    43     48   #ifdef SQLITE_OMIT_AUTOINCREMENT
    44     49   #  define AUTOINCR   0
    45     50   #else
    46         -#  define AUTOINCR   8
           51  +#  define AUTOINCR   0x00000010
           52  +#endif
           53  +#ifdef SQLITE_OMIT_CAST
           54  +#  define CAST       0
           55  +#else
           56  +#  define CAST       0x00000020
    47     57   #endif
    48     58   #ifdef SQLITE_OMIT_COMPOUND_SELECT
    49     59   #  define COMPOUND   0
    50     60   #else
    51         -#  define COMPOUND   16
           61  +#  define COMPOUND   0x00000040
    52     62   #endif
    53     63   #ifdef SQLITE_OMIT_CONFLICT_CLAUSE
    54     64   #  define CONFLICT   0
    55     65   #else
    56         -#  define CONFLICT   32
           66  +#  define CONFLICT   0x00000080
    57     67   #endif
    58     68   #ifdef SQLITE_OMIT_EXPLAIN
    59     69   #  define EXPLAIN    0
    60     70   #else
    61         -#  define EXPLAIN    128
           71  +#  define EXPLAIN    0x00000100
    62     72   #endif
    63     73   #ifdef SQLITE_OMIT_FOREIGN_KEY
    64     74   #  define FKEY       0
    65     75   #else
    66         -#  define FKEY       256
           76  +#  define FKEY       0x00000200
    67     77   #endif
    68     78   #ifdef SQLITE_OMIT_PRAGMA
    69     79   #  define PRAGMA     0
    70     80   #else
    71         -#  define PRAGMA     512
           81  +#  define PRAGMA     0x00000400
    72     82   #endif
    73     83   #ifdef SQLITE_OMIT_REINDEX
    74     84   #  define REINDEX    0
    75     85   #else
    76         -#  define REINDEX    1024
           86  +#  define REINDEX    0x00000800
    77     87   #endif
    78     88   #ifdef SQLITE_OMIT_SUBQUERY
    79     89   #  define SUBQUERY   0
    80     90   #else
    81         -#  define SUBQUERY   2048
           91  +#  define SUBQUERY   0x00001000
    82     92   #endif
    83     93   #ifdef SQLITE_OMIT_TRIGGER
    84     94   #  define TRIGGER    0
    85     95   #else
    86         -#  define TRIGGER    4096
           96  +#  define TRIGGER    0x00002000
    87     97   #endif
    88     98   #ifdef SQLITE_OMIT_VACUUM
    89     99   #  define VACUUM     0
    90    100   #else
    91         -#  define VACUUM     8192
          101  +#  define VACUUM     0x00004000
    92    102   #endif
    93    103   #ifdef SQLITE_OMIT_VIEW
    94    104   #  define VIEW       0
    95    105   #else
    96         -#  define VIEW       16384
    97         -#endif
    98         -#ifdef SQLITE_OMIT_CAST
    99         -#  define CAST       0
   100         -#else
   101         -#  define CAST       32768
          106  +#  define VIEW       0x00008000
   102    107   #endif
   103    108   
   104    109   
   105    110   /*
   106    111   ** These are the keywords
   107    112   */
   108    113   static Keyword aKeywordTable[] = {
   109    114     { "ABORT",            "TK_ABORT",        CONFLICT|TRIGGER       },
   110    115     { "ADD",              "TK_ADD",          ALTER                  },
   111    116     { "AFTER",            "TK_AFTER",        TRIGGER                },
   112    117     { "ALL",              "TK_ALL",          ALWAYS                 },
   113    118     { "ALTER",            "TK_ALTER",        ALTER                  },
          119  +  { "ANALYZE",          "TK_ANALYZE",      ANALYZE                },
   114    120     { "AND",              "TK_AND",          ALWAYS                 },
   115    121     { "AS",               "TK_AS",           ALWAYS                 },
   116    122     { "ASC",              "TK_ASC",          ALWAYS                 },
   117    123     { "ATTACH",           "TK_ATTACH",       ATTACH                 },
   118    124     { "AUTOINCREMENT",    "TK_AUTOINCR",     AUTOINCR               },
   119    125     { "BEFORE",           "TK_BEFORE",       TRIGGER                },
   120    126     { "BEGIN",            "TK_BEGIN",        ALWAYS                 },