/ Check-in [795454a3]
Login

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

Overview
Comment:Omit the LikeOp object from the parser. Change more sqlite3PExpr() calls into sqlite3ExprAlloc() calls.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 795454a3fa5f9ccc486593b5e16e8fad38c934fb
User & Date: drh 2016-09-24 17:42:43
Context
2016-09-26
12:38
Inline the relevent parts of sqlite3ExprAlloc() into spanExpr(), for a performance improvement. check-in: fe89225e user: drh tags: trunk
2016-09-24
17:42
Omit the LikeOp object from the parser. Change more sqlite3PExpr() calls into sqlite3ExprAlloc() calls. check-in: 795454a3 user: drh tags: trunk
01:41
Add -DSQLITE_MAX_EXPR_DEPTH=0 to the --lean option on speed-check.sh. check-in: a8cb1390 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    76     76   ** LIMIT clause of a SELECT statement.
    77     77   */
    78     78   struct LimitVal {
    79     79     Expr *pLimit;    /* The LIMIT expression.  NULL if there is no limit */
    80     80     Expr *pOffset;   /* The OFFSET expression.  NULL if there is none */
    81     81   };
    82     82   
    83         -/*
    84         -** An instance of this structure is used to store the LIKE,
    85         -** GLOB, NOT LIKE, and NOT GLOB operators.
    86         -*/
    87         -struct LikeOp {
    88         -  Token eOperator;  /* "like" or "glob" or "regexp" */
    89         -  int bNot;         /* True if the NOT keyword is present */
    90         -};
    91         -
    92     83   /*
    93     84   ** An instance of the following structure describes the event of a
    94     85   ** TRIGGER.  "a" is the event type, one of TK_UPDATE, TK_INSERT,
    95     86   ** TK_DELETE, or TK_INSTEAD.  If the event is of the form
    96     87   **
    97     88   **      UPDATE ON (a,b,c)
    98     89   **
    99     90   ** Then the "b" IdList records the list "a,b,c".
   100     91   */
   101     92   struct TrigEvent { int a; IdList * b; };
   102     93   
   103         -/*
   104         -** An instance of this structure holds the ATTACH key and the key type.
   105         -*/
   106         -struct AttachKey { int type;  Token key; };
   107         -
   108     94   /*
   109     95   ** Disable lookaside memory allocation for objects that might be
   110     96   ** shared across database connections.
   111     97   */
   112     98   static void disableLookaside(Parse *pParse){
   113     99     pParse->disableLookaside++;
   114    100     pParse->db->lookaside.bDisable++;
................................................................................
   861    847   expr(A) ::= term(A).
   862    848   expr(A) ::= LP(B) expr(X) RP(E).
   863    849               {spanSet(&A,&B,&E); /*A-overwrites-B*/  A.pExpr = X.pExpr;}
   864    850   term(A) ::= NULL(X).        {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/}
   865    851   expr(A) ::= id(X).          {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}
   866    852   expr(A) ::= JOIN_KW(X).     {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}
   867    853   expr(A) ::= nm(X) DOT nm(Y). {
   868         -  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);
   869         -  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &Y);
          854  +  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
          855  +  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
   870    856     spanSet(&A,&X,&Y); /*A-overwrites-X*/
   871    857     A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
   872    858   }
   873    859   expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
   874         -  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);
   875         -  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &Y);
   876         -  Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &Z);
          860  +  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
          861  +  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
          862  +  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &Z, 1);
   877    863     Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
   878    864     spanSet(&A,&X,&Z); /*A-overwrites-X*/
   879    865     A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
   880    866   }
   881    867   term(A) ::= INTEGER|FLOAT|BLOB(X). {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/}
   882    868   term(A) ::= STRING(X).             {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/}
   883    869   expr(A) ::= VARIABLE(X).     {
................................................................................
   972    958   expr(A) ::= expr(A) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
   973    959                                           {spanBinaryExpr(pParse,@OP,&A,&Y);}
   974    960   expr(A) ::= expr(A) PLUS|MINUS(OP) expr(Y).
   975    961                                           {spanBinaryExpr(pParse,@OP,&A,&Y);}
   976    962   expr(A) ::= expr(A) STAR|SLASH|REM(OP) expr(Y).
   977    963                                           {spanBinaryExpr(pParse,@OP,&A,&Y);}
   978    964   expr(A) ::= expr(A) CONCAT(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}
   979         -%type likeop {struct LikeOp}
   980         -likeop(A) ::= LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 0;/*A-overwrites-X*/}
   981         -likeop(A) ::= NOT LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 1;}
          965  +%type likeop {Token}
          966  +likeop(A) ::= LIKE_KW|MATCH(X).     {A=X;/*A-overwrites-X*/}
          967  +likeop(A) ::= NOT LIKE_KW|MATCH(X). {A=X; A.n|=0x80000000; /*A-overwrite-X*/}
   982    968   expr(A) ::= expr(A) likeop(OP) expr(Y).  [LIKE_KW]  {
   983    969     ExprList *pList;
          970  +  int bNot = OP.n & 0x80000000;
          971  +  OP.n &= 0x7fffffff;
   984    972     pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
   985    973     pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);
   986         -  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator);
   987         -  exprNot(pParse, OP.bNot, &A);
          974  +  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);
          975  +  exprNot(pParse, bNot, &A);
   988    976     A.zEnd = Y.zEnd;
   989    977     if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
   990    978   }
   991    979   expr(A) ::= expr(A) likeop(OP) expr(Y) ESCAPE expr(E).  [LIKE_KW]  {
   992    980     ExprList *pList;
          981  +  int bNot = OP.n & 0x80000000;
          982  +  OP.n &= 0x7fffffff;
   993    983     pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
   994    984     pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);
   995    985     pList = sqlite3ExprListAppend(pParse,pList, E.pExpr);
   996         -  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator);
   997         -  exprNot(pParse, OP.bNot, &A);
          986  +  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);
          987  +  exprNot(pParse, bNot, &A);
   998    988     A.zEnd = E.zEnd;
   999    989     if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
  1000    990   }
  1001    991   
  1002    992   %include {
  1003    993     /* Construct an expression node for a unary postfix operator
  1004    994     */