/ Check-in [d2728192]
Login

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

Overview
Comment:Eliminate the tool/addopcodes.tcl script. The purpose of that script was to keep the number of parser codes below 256 in order to save parser table space. But we have long since blown through that ceiling so the addopcodes.tcl script was just needless complexity. There is no longer any reason to keep it around.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d272819298083ebbde57962a2938925b1aaa1caf03e48bb3ea26ad91e0461d84
User & Date: drh 2019-04-05 20:56:46
Context
2019-04-05
21:17
Remove some stale references to the addopcodes.tcl script from documentation. check-in: c0381b0b user: drh tags: trunk
20:56
Eliminate the tool/addopcodes.tcl script. The purpose of that script was to keep the number of parser codes below 256 in order to save parser table space. But we have long since blown through that ceiling so the addopcodes.tcl script was just needless complexity. There is no longer any reason to keep it around. check-in: d2728192 user: drh tags: trunk
20:47
Add further tests so that veryquick.test covers all vdbe branches. check-in: cbc67de5 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

  1047   1047   opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/tool/mkopcodeh.tcl
  1048   1048   	cat parse.h $(TOP)/src/vdbe.c | $(TCLSH_CMD) $(TOP)/tool/mkopcodeh.tcl >opcodes.h
  1049   1049   
  1050   1050   # Rules to build parse.c and parse.h - the outputs of lemon.
  1051   1051   #
  1052   1052   parse.h:	parse.c
  1053   1053   
  1054         -parse.c:	$(TOP)/src/parse.y lemon$(BEXE) $(TOP)/tool/addopcodes.tcl
         1054  +parse.c:	$(TOP)/src/parse.y lemon$(BEXE)
  1055   1055   	cp $(TOP)/src/parse.y .
  1056         -	rm -f parse.h
  1057   1056   	./lemon$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) parse.y
  1058         -	mv parse.h parse.h.temp
  1059         -	$(TCLSH_CMD) $(TOP)/tool/addopcodes.tcl parse.h.temp >parse.h
  1060   1057   
  1061   1058   sqlite3.h:	$(TOP)/src/sqlite.h.in $(TOP)/manifest mksourceid$(BEXE) $(TOP)/VERSION
  1062   1059   	$(TCLSH_CMD) $(TOP)/tool/mksqlite3h.tcl $(TOP) >sqlite3.h
  1063   1060   
  1064   1061   keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
  1065   1062   	$(BCC) -o mkkeywordhash$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)/tool/mkkeywordhash.c
  1066   1063   	./mkkeywordhash$(BEXE) >keywordhash.h

Changes to Makefile.msc.

  2135   2135   opcodes.h:	parse.h $(TOP)\src\vdbe.c $(TOP)\tool\mkopcodeh.tcl
  2136   2136   	type parse.h $(TOP)\src\vdbe.c | $(TCLSH_CMD) $(TOP)\tool\mkopcodeh.tcl > opcodes.h
  2137   2137   
  2138   2138   # Rules to build parse.c and parse.h - the outputs of lemon.
  2139   2139   #
  2140   2140   parse.h:	parse.c
  2141   2141   
  2142         -parse.c:	$(TOP)\src\parse.y lemon.exe $(TOP)\tool\addopcodes.tcl
         2142  +parse.c:	$(TOP)\src\parse.y lemon.exe
  2143   2143   	del /Q parse.y parse.h parse.h.temp 2>NUL
  2144   2144   	copy $(TOP)\src\parse.y .
  2145   2145   	.\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) parse.y
  2146         -	move parse.h parse.h.temp
  2147         -	$(TCLSH_CMD) $(TOP)\tool\addopcodes.tcl parse.h.temp > parse.h
  2148   2146   
  2149   2147   $(SQLITE3H):	$(TOP)\src\sqlite.h.in $(TOP)\manifest mksourceid.exe $(TOP)\VERSION
  2150   2148   	$(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H) $(MKSQLITE3H_ARGS)
  2151   2149   
  2152   2150   sqlite3ext.h:	.target_source
  2153   2151   !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
  2154   2152   	type tsrc\sqlite3ext.h | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*\)" "(SQLITE_CALLBACK *)" \

Changes to main.mk.

   712    712   	cat parse.h $(TOP)/src/vdbe.c | \
   713    713   		tclsh $(TOP)/tool/mkopcodeh.tcl >opcodes.h
   714    714   
   715    715   # Rules to build parse.c and parse.h - the outputs of lemon.
   716    716   #
   717    717   parse.h:	parse.c
   718    718   
   719         -parse.c:	$(TOP)/src/parse.y lemon $(TOP)/tool/addopcodes.tcl
          719  +parse.c:	$(TOP)/src/parse.y lemon
   720    720   	cp $(TOP)/src/parse.y .
   721         -	rm -f parse.h
   722    721   	./lemon -s $(OPTS) parse.y
   723         -	mv parse.h parse.h.temp
   724         -	tclsh $(TOP)/tool/addopcodes.tcl parse.h.temp >parse.h
   725    722   
   726    723   sqlite3.h:	$(TOP)/src/sqlite.h.in $(TOP)/manifest mksourceid $(TOP)/VERSION $(TOP)/ext/rtree/sqlite3rtree.h
   727    724   	tclsh $(TOP)/tool/mksqlite3h.tcl $(TOP) >sqlite3.h
   728    725   
   729    726   keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
   730    727   	$(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c
   731    728   	./mkkeywordhash >keywordhash.h

Changes to src/expr.c.

   853    853     if( op==TK_AND && pParse->nErr==0 && !IN_RENAME_OBJECT ){
   854    854       /* Take advantage of short-circuit false optimization for AND */
   855    855       p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
   856    856     }else{
   857    857       p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr));
   858    858       if( p ){
   859    859         memset(p, 0, sizeof(Expr));
   860         -      p->op = op & TKFLG_MASK;
          860  +      p->op = op & 0xff;
   861    861         p->iAgg = -1;
   862    862       }
   863    863       sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
   864    864     }
   865    865     if( p ) {
   866    866       sqlite3ExprCheckHeight(pParse, p->nHeight);
   867    867     }

Changes to src/parse.y.

  1740   1740       sqlite3ExprDelete(pParse->db, W);
  1741   1741     }
  1742   1742   }
  1743   1743   
  1744   1744   filter_opt(A) ::= .                            { A = 0; }
  1745   1745   filter_opt(A) ::= FILTER LP WHERE expr(X) RP.  { A = X; }
  1746   1746   %endif /* SQLITE_OMIT_WINDOWFUNC */
         1747  +
         1748  +/*
         1749  +** The code generator needs some extra TK_ token values for tokens that
         1750  +** are synthesized and do not actually appear in the grammar:
         1751  +*/
         1752  +%token
         1753  +  TRUEFALSE       /* True or false keyword */
         1754  +  ISNOT           /* Combination of IS and NOT */
         1755  +  FUNCTION        /* A function invocation */
         1756  +  COLUMN          /* Reference to a table column */
         1757  +  AGG_FUNCTION    /* An aggregate function */
         1758  +  AGG_COLUMN      /* An aggregated column */
         1759  +  UMINUS          /* Unary minus */
         1760  +  UPLUS           /* Unary plus */
         1761  +  TRUTH           /* IS TRUE or IS FALSE or IS NOT TRUE or IS NOT FALSE */
         1762  +  REGISTER        /* Reference to a VDBE register */
         1763  +  VECTOR          /* Vector */
         1764  +  SELECT_COLUMN   /* Choose a single column from a multi-column SELECT */
         1765  +  IF_NULL_ROW     /* the if-null-row operator */
         1766  +  ASTERISK        /* The "*" in count(*) and similar */
         1767  +  SPAN            /* The span operator */
         1768  +.
         1769  +/* There must be no more than 255 tokens defined above.  If this grammar
         1770  +** is extended with new rules and tokens, they must either be so few in
         1771  +** number that TK_SPAN is no more than 255, or else the new tokens must
         1772  +** appear after this line.
         1773  +*/
         1774  +%include {
         1775  +#if TK_SPAN>255
         1776  +# error too many tokens in the grammar
         1777  +#endif
         1778  +}
         1779  +
         1780  +/*
         1781  +** The TK_SPACE and TK_ILLEGAL tokens must be the last two tokens.  The
         1782  +** parser depends on this.  Those tokens are not used in any grammar rule.
         1783  +** They are only used by the tokenizer.  Declare them last so that they
         1784  +** are guaranteed to be the last two tokens
         1785  +*/
         1786  +%token SPACE ILLEGAL.

Changes to src/wherecode.c.

  1963   1963           if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
  1964   1964           if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
  1965   1965           testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
  1966   1966           pExpr = sqlite3ExprDup(db, pExpr, 0);
  1967   1967           pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
  1968   1968         }
  1969   1969         if( pAndExpr ){
  1970         -        pAndExpr = sqlite3PExpr(pParse, TK_AND|TKFLG_DONTFOLD, 0, pAndExpr);
         1970  +        /* The extra 0x10000 bit on the opcode is masked off and does not
         1971  +        ** become part of the new Expr.op.  However, it does make the
         1972  +        ** op==TK_AND comparison inside of sqlite3PExpr() false, and this
         1973  +        ** prevents sqlite3PExpr() from implementing AND short-circuit 
         1974  +        ** optimization, which we do not want here. */
         1975  +        pAndExpr = sqlite3PExpr(pParse, TK_AND|0x10000, 0, pAndExpr);
  1971   1976         }
  1972   1977       }
  1973   1978   
  1974   1979       /* Run a separate WHERE clause for each term of the OR clause.  After
  1975   1980       ** eliminating duplicates from other WHERE clauses, the action for each
  1976   1981       ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
  1977   1982       */

Deleted tool/addopcodes.tcl.

     1         -#!/usr/bin/tclsh
     2         -#
     3         -# This script appends additional token codes to the end of the
     4         -# parse.h file that lemon generates.  These extra token codes are
     5         -# not used by the parser.  But they are used by the tokenizer and/or
     6         -# the code generator.
     7         -#
     8         -#
     9         -set in [open [lindex $argv 0] rb]
    10         -set max 0
    11         -while {![eof $in]} {
    12         -  set line [gets $in]
    13         -  if {[regexp {^#define TK_} $line]} {
    14         -    puts $line
    15         -    set x [lindex $line 2]
    16         -    if {$x>$max} {set max $x}
    17         -  }
    18         -}
    19         -close $in
    20         -
    21         -# The following are the extra token codes to be added.  SPACE and 
    22         -# ILLEGAL *must* be the last two token codes and they must be in that order.
    23         -#
    24         -set extras {
    25         -  TRUEFALSE
    26         -  ISNOT
    27         -  FUNCTION
    28         -  COLUMN
    29         -  AGG_FUNCTION
    30         -  AGG_COLUMN
    31         -  UMINUS
    32         -  UPLUS
    33         -  TRUTH
    34         -  REGISTER
    35         -  VECTOR
    36         -  SELECT_COLUMN
    37         -  IF_NULL_ROW
    38         -  ASTERISK
    39         -  SPAN
    40         -  END_OF_FILE
    41         -  UNCLOSED_STRING
    42         -  SPACE
    43         -  ILLEGAL
    44         -}
    45         -if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} {
    46         -  error "SPACE and ILLEGAL must be the last two token codes and they\
    47         -         must be in that order"
    48         -}
    49         -foreach x $extras {
    50         -  incr max
    51         -  puts [format "#define TK_%-29s %4d" $x $max]
    52         -}
    53         -
    54         -# Some additional #defines related to token codes.
    55         -#
    56         -puts "\n/* The token codes above must all fit in 8 bits */"
    57         -puts [format "#define %-20s %-6s" TKFLG_MASK 0xff]
    58         -puts "\n/* Flags that can be added to a token code when it is not"
    59         -puts "** being stored in a u8: */"
    60         -foreach {fg val comment} {
    61         -  TKFLG_DONTFOLD  0x100  {/* Omit constant folding optimizations */}
    62         -} {
    63         -  puts [format "#define %-20s %-6s %s" $fg $val $comment]
    64         -}