/ Check-in [eef61ffa]
Login

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

Overview
Comment:Further tweaks to sqlite3RunParser().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | weak-fallback
Files: files | file ages | folders
SHA3-256: eef61ffab7fa36b126f57bf7028dd35c67ed4617c47145be059f91e58023b0a4
User & Date: dan 2018-06-29 20:21:24
Context
2018-06-29
20:43
Further performance related tweaks for sqlite3RunParser(). check-in: 5eb47765 user: dan tags: weak-fallback
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
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tokenize.c.

   555    555     }
   556    556   #endif
   557    557     assert( pParse->pNewTable==0 );
   558    558     assert( pParse->pNewTrigger==0 );
   559    559     assert( pParse->nVar==0 );
   560    560     assert( pParse->pVList==0 );
   561    561     while( 1 ){
   562         -    if( zSql[0]!=0 ){
   563         -      n = sqlite3GetToken((u8*)zSql, &tokenType);
   564         -      mxSqlLen -= n;
   565         -      if( mxSqlLen<0 ){
   566         -        pParse->rc = SQLITE_TOOBIG;
   567         -        break;
   568         -      }
   569         -    }else{
   570         -      /* Upon reaching the end of input, call the parser two more times
   571         -      ** with tokens TK_SEMI and 0, in that order. */
   572         -      if( lastTokenParsed==TK_SEMI ){
   573         -        tokenType = 0;
   574         -      }else if( lastTokenParsed==0 ){
   575         -        break;
   576         -      }else{
   577         -        tokenType = TK_SEMI;
   578         -      }
   579         -      n = 0;
          562  +    n = sqlite3GetToken((u8*)zSql, &tokenType);
          563  +    mxSqlLen -= n;
          564  +    if( mxSqlLen<0 ){
          565  +      pParse->rc = SQLITE_TOOBIG;
          566  +      break;
   580    567       }
   581    568       if( tokenType>=TK_SPACE ){
   582    569         assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
   583    570         if( db->u1.isInterrupted ){
   584    571           pParse->rc = SQLITE_INTERRUPT;
   585    572           break;
   586    573         }
   587         -      if( tokenType==TK_ILLEGAL ){
          574  +      if( tokenType==TK_SPACE ){
          575  +        zSql += n;
          576  +        continue;
          577  +      }
          578  +      if( zSql[0]==0 ){
          579  +        /* Upon reaching the end of input, call the parser two more times
          580  +        ** with tokens TK_SEMI and 0, in that order. */
          581  +        if( lastTokenParsed==TK_SEMI ){
          582  +          tokenType = 0;
          583  +        }else if( lastTokenParsed==0 ){
          584  +          break;
          585  +        }else{
          586  +          tokenType = TK_SEMI;
          587  +        }
          588  +        n = 0;
          589  +      }else{
   588    590           sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
   589    591           break;
   590    592         }
   591         -      zSql += n;
   592         -    }else{
   593         -      if( tokenType==TK_WINDOW ){
   594         -        tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
   595         -      }
   596         -      pParse->sLastToken.z = zSql;
   597         -      pParse->sLastToken.n = n;
   598         -      sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
   599         -      lastTokenParsed = tokenType;
   600         -      zSql += n;
   601         -      if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
          593  +    }
          594  +    else if( tokenType==TK_WINDOW ){
          595  +      tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);
   602    596       }
          597  +    pParse->sLastToken.z = zSql;
          598  +    pParse->sLastToken.n = n;
          599  +    sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
          600  +    lastTokenParsed = tokenType;
          601  +    zSql += n;
          602  +    if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
   603    603     }
   604    604     assert( nErr==0 );
   605    605   #ifdef YYTRACKMAXSTACKDEPTH
   606    606     sqlite3_mutex_enter(sqlite3MallocMutex());
   607    607     sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
   608    608         sqlite3ParserStackPeak(pEngine)
   609    609     );