/ Check-in [d62cd757]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Small size reduction and performance increase in the parser.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d62cd757a69cc49c2d309e27c948610b5868632f
User & Date: drh 2015-11-09 02:08:09
Context
2015-11-09
12:33
Avoid unnecessary function prologues in the sqlite3VdbeAddOp3() routine. check-in: 7c6a19ba user: drh tags: trunk
02:08
Small size reduction and performance increase in the parser. check-in: d62cd757 user: drh tags: trunk
2015-11-07
18:32
Enhance the sqldiff utility to deal gracefully with ALTER TABLE ADD COLUMN. check-in: 7ea036ac user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/tokenize.c.

   412    412     assert( pParse->pNewTable==0 );
   413    413     assert( pParse->pNewTrigger==0 );
   414    414     assert( pParse->nVar==0 );
   415    415     assert( pParse->nzVar==0 );
   416    416     assert( pParse->azVar==0 );
   417    417     enableLookaside = db->lookaside.bEnabled;
   418    418     if( db->lookaside.pStart ) db->lookaside.bEnabled = 1;
   419         -  while( !db->mallocFailed && zSql[i]!=0 ){
          419  +  while( zSql[i]!=0 ){
   420    420       assert( i>=0 );
   421    421       pParse->sLastToken.z = &zSql[i];
   422    422       pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);
   423    423       i += pParse->sLastToken.n;
   424    424       if( i>mxSqlLen ){
   425    425         pParse->rc = SQLITE_TOOBIG;
   426    426         break;
   427    427       }
   428         -    switch( tokenType ){
   429         -      case TK_SPACE: {
          428  +    if( tokenType>=TK_SPACE ){
          429  +      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
   430    430           if( db->u1.isInterrupted ){
   431    431             sqlite3ErrorMsg(pParse, "interrupt");
   432    432             pParse->rc = SQLITE_INTERRUPT;
   433         -          goto abort_parse;
   434         -        }
   435    433           break;
   436    434         }
   437         -      case TK_ILLEGAL: {
          435  +      if( tokenType==TK_ILLEGAL ){
   438    436           sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"",
   439    437                           &pParse->sLastToken);
   440         -        goto abort_parse;
          438  +        break;
   441    439         }
   442         -      case TK_SEMI: {
   443         -        pParse->zTail = &zSql[i];
   444         -        /* Fall thru into the default case */
   445         -      }
   446         -      default: {
          440  +    }else{
          441  +      if( tokenType==TK_SEMI ) pParse->zTail = &zSql[i];
   447    442           sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
   448    443           lastTokenParsed = tokenType;
   449         -        if( pParse->rc!=SQLITE_OK ){
   450         -          goto abort_parse;
   451         -        }
   452         -        break;
          444  +      if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
   453    445         }
   454    446       }
   455         -  }
   456         -abort_parse:
   457    447     assert( nErr==0 );
   458    448     if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
   459    449       assert( zSql[i]==0 );
   460    450       if( lastTokenParsed!=TK_SEMI ){
   461    451         sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
   462    452         pParse->zTail = &zSql[i];
   463    453       }

Changes to tool/addopcodes.tcl.

    14     14       puts $line
    15     15       set x [lindex $line 2]
    16     16       if {$x>$max} {set max $x}
    17     17     }
    18     18   }
    19     19   close $in
    20     20   
    21         -# The following are the extra token codes to be added
           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.
    22     23   #
    23     24   set extras {
    24     25     TO_TEXT
    25     26     TO_BLOB
    26     27     TO_NUMERIC
    27     28     TO_INT
    28     29     TO_REAL
    29     30     ISNOT
    30     31     END_OF_FILE
    31         -  ILLEGAL
    32         -  SPACE
    33     32     UNCLOSED_STRING
    34     33     FUNCTION
    35     34     COLUMN
    36     35     AGG_FUNCTION
    37     36     AGG_COLUMN
    38     37     UMINUS
    39     38     UPLUS
    40     39     REGISTER
           40  +  SPACE
           41  +  ILLEGAL
           42  +}
           43  +if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} {
           44  +  error "SPACE and ILLEGAL must be the last two token codes and they\
           45  +         must be in that order"
    41     46   }
    42     47   foreach x $extras {
    43     48     incr max
    44     49     puts [format "#define TK_%-29s %4d" $x $max]
    45     50   }
    46     51   
    47     52   # Some additional #defines related to token codes.