SQLite

Changes On Branch degenerate_IN
Login

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

Changes In Branch degenerate_IN Excluding Merge-Ins

This is equivalent to a diff from 2c3af657 to 8b4c3c5e

2012-10-17
13:15
Remove an incorrect "#ifndef SQLITE_OMIT_AUTOVACUUM" from pager. (check-in: bf44d73d user: drh tags: trunk)
2012-10-16
23:17
Enable optimization of IN operators on constraints to virtual tables. (check-in: aa650746 user: drh tags: vtab-IN-opt)
23:08
Merge updates from trunk. (check-in: f021559d user: mistachkin tags: configReadOnly)
21:08
An optimization that converts "a IN (b)" into "a==b". Seems to work, but needs additional test cases. (Leaf check-in: 8b4c3c5e user: drh tags: degenerate_IN)
2012-10-15
20:28
Correct comments and enhance readability of the mkvsix tool. (check-in: 2c3af657 user: mistachkin tags: trunk)
18:02
Hold the mutex on the shared-cache for the duration of a VACUUM operation. (check-in: 629a42d4 user: dan tags: trunk)

Changes to src/parse.y.

994
995
996
997
998
999
1000


1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011










1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
  A.zEnd = Y.zEnd;
}
%ifndef SQLITE_OMIT_SUBQUERY
  %type in_op {int}
  in_op(A) ::= IN.      {A = 0;}
  in_op(A) ::= NOT IN.  {A = 1;}
  expr(A) ::= expr(X) in_op(N) LP exprlist(Y) RP(E). [IN] {


    if( Y==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */
      A.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[N]);
      sqlite3ExprDelete(pParse->db, X.pExpr);










    }else{
      A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
      if( A.pExpr ){
        A.pExpr->x.pList = Y;
        sqlite3ExprSetHeight(pParse, A.pExpr);
      }else{
        sqlite3ExprListDelete(pParse->db, Y);
      }
      if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0);
    }
    A.zStart = X.zStart;
    A.zEnd = &E.z[E.n];
  }
  expr(A) ::= LP(B) select(X) RP(E). {







>
>
|









|
>
>
>
>
>
>
>
>
>
>



|


|







994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
  A.zEnd = Y.zEnd;
}
%ifndef SQLITE_OMIT_SUBQUERY
  %type in_op {int}
  in_op(A) ::= IN.      {A = 0;}
  in_op(A) ::= NOT IN.  {A = 1;}
  expr(A) ::= expr(X) in_op(N) LP exprlist(Y) RP(E). [IN] {
    sqlite3 *db = pParse->db;
    ExprList *pY = Y;
    if( pY==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */
      A.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[N]);
      sqlite3ExprDelete(db, X.pExpr);
    }else if( pY->nExpr==1 ){
      /* If the RHS of the IN operator has a single term, simplify as follows:
      **
      **      expr1 IN (Y)        -->      expr1 = Y
      **      expr1 NOT IN (Y)    -->      expr1 <> Y
      */
      assert( TK_EQ==TK_NE+1 );
      A.pExpr = sqlite3PExpr(pParse, TK_EQ-N, X.pExpr, pY->a[0].pExpr, 0);
      pY->a[0].pExpr = 0;
      sqlite3ExprListDelete(db, pY);
    }else{
      A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
      if( A.pExpr ){
        A.pExpr->x.pList = pY;
        sqlite3ExprSetHeight(pParse, A.pExpr);
      }else{
        sqlite3ExprListDelete(pParse->db, pY);
      }
      if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0);
    }
    A.zStart = X.zStart;
    A.zEnd = &E.z[E.n];
  }
  expr(A) ::= LP(B) select(X) RP(E). {