/ Check-in [c1fb41aa]
Login

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

Overview
Comment:Improve on the previous checkin. Still a bit slow.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | weak-fallback
Files: files | file ages | folders
SHA3-256: c1fb41aa7b7207b81ee1d5d32da3380b36d694033b87a2873981e0c6437ba956
User & Date: dan 2018-06-29 19:54:51
Context
2018-06-29
20:21
Further tweaks to sqlite3RunParser(). check-in: eef61ffa user: dan tags: weak-fallback
19:54
Improve on the previous checkin. Still a bit slow. check-in: c1fb41aa user: dan tags: weak-fallback
17:44
Instead of using a lemon %fallback directive, have the tokenizer try to figure out whether an instance of "WINDOW" should be TK_WINDOW or TK_ID. check-in: 022079cb user: dan tags: weak-fallback
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tokenize.c.

   218    218   **   * TK_ID, or something else that can be used as a window name, and
   219    219   **   * TK_AS.
   220    220   **
   221    221   ** Instead of using sqlite3GetToken() to parse tokens directly, this function
   222    222   ** uses windowGetToken(). This is to avoid recursion if the input is similar
   223    223   ** to "window window window window".
   224    224   */
   225         -static void analyzeWindowKeyword(const unsigned char *z, int *tokenType){
          225  +static int analyzeWindowKeyword(const unsigned char *z){
   226    226     int t;
   227         -  assert( *tokenType==TK_WINDOW );
          227  +  int ret = TK_WINDOW;
   228    228     while( (t = windowGetToken(&z))==TK_SPACE );
   229    229     if( t!=TK_ID && t!=TK_STRING 
   230    230      && t!=TK_JOIN_KW && sqlite3ParserFallback(t)!=TK_ID 
   231    231     ){
   232         -    *tokenType = TK_ID;
          232  +    ret = TK_ID;
   233    233     }else{
   234    234       while( (t = windowGetToken(&z))==TK_SPACE );
   235    235       if( t!=TK_AS ){
   236         -      *tokenType = TK_ID;
          236  +      ret = TK_ID;
   237    237       }
   238    238     }
          239  +  return ret;
   239    240   }
   240    241   
   241    242   /*
   242    243   ** Return the length (in bytes) of the token that begins at z[0]. 
   243    244   ** Store the token type in *tokenType before returning.
   244    245   */
   245    246   int sqlite3GetToken(const unsigned char *z, int *tokenType){
................................................................................
   478    479           /* This token started out using characters that can appear in keywords,
   479    480           ** but z[i] is a character not allowed within keywords, so this must
   480    481           ** be an identifier instead */
   481    482           i++;
   482    483           break;
   483    484         }
   484    485         *tokenType = TK_ID;
   485         -      keywordCode((char*)z, i, tokenType);
   486         -      if( *tokenType==TK_WINDOW ){
   487         -        assert( i==6 );
   488         -        analyzeWindowKeyword(&z[6], tokenType);
   489         -      }
   490         -      return i;
          486  +      return keywordCode((char*)z, i, tokenType);
   491    487       }
   492    488       case CC_X: {
   493    489   #ifndef SQLITE_OMIT_BLOB_LITERAL
   494    490         testcase( z[0]=='x' ); testcase( z[0]=='X' );
   495    491         if( z[1]=='\'' ){
   496    492           *tokenType = TK_BLOB;
   497    493           for(i=2; sqlite3Isxdigit(z[i]); i++){}
................................................................................
   590    586         }
   591    587         if( tokenType==TK_ILLEGAL ){
   592    588           sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
   593    589           break;
   594    590         }
   595    591         zSql += n;
   596    592       }else{
          593  +      if( tokenType==TK_WINDOW ){
          594  +        tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
          595  +      }
   597    596         pParse->sLastToken.z = zSql;
   598    597         pParse->sLastToken.n = n;
   599    598         sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
   600    599         lastTokenParsed = tokenType;
   601    600         zSql += n;
   602    601         if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
   603    602       }