/ Check-in [72ebc8cb]
Login

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

Overview
Comment:Allow the entire FROM clause of a SELECT statement to be in parentheses. (CVS 5973)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 72ebc8cbe00f77f7864146de7c0954c4f1c59b8d
User & Date: drh 2008-12-03 23:23:41
Context
2008-12-04
12:17
Always enable the OP_Blob opcode in the VDBE even when SQLITE_OMIT_BLOB_LITERAL is defined, since that opcode is used for other purposes as well. Ticket #3518. (CVS 5974) check-in: 760333de user: drh tags: trunk
2008-12-03
23:23
Allow the entire FROM clause of a SELECT statement to be in parentheses. (CVS 5973) check-in: 72ebc8cb user: drh tags: trunk
22:48
Fix a missing forward declaration that is needed when SQLITE_PREFER_PROXY_LOCKING is defined. (CVS 5972) check-in: 24235300 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.262 2008/10/23 05:45:07 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.263 2008/12/03 23:23:41 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   440    440   %destructor stl_prefix {sqlite3SrcListDelete(pParse->db, $$);}
   441    441   %type from {SrcList*}
   442    442   %destructor from {sqlite3SrcListDelete(pParse->db, $$);}
   443    443   
   444    444   // A complete FROM clause.
   445    445   //
   446    446   from(A) ::= .                {A = sqlite3DbMallocZero(pParse->db, sizeof(*A));}
   447         -from(A) ::= FROM seltablist(X).  {
          447  +from(A) ::= FROM seltablist(X). {
   448    448     A = X;
   449    449     sqlite3SrcListShiftJoinType(A);
   450    450   }
   451    451   
   452    452   // "seltablist" is a "Select Table List" - the content of the FROM clause
   453    453   // in a SELECT statement.  "stl_prefix" is a prefix of this list.
   454    454   //
................................................................................
   458    458   }
   459    459   stl_prefix(A) ::= .                           {A = 0;}
   460    460   seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) on_opt(N) using_opt(U). {
   461    461     A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U);
   462    462     sqlite3SrcListIndexedBy(pParse, A, &I);
   463    463   }
   464    464   %ifndef SQLITE_OMIT_SUBQUERY
   465         -  seltablist(A) ::= stl_prefix(X) LP seltablist_paren(S) RP
          465  +  seltablist(A) ::= stl_prefix(X) LP select(S) RP
   466    466                       as(Z) on_opt(N) using_opt(U). {
   467    467       A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,S,N,U);
          468  +  }
          469  +  seltablist(A) ::= stl_prefix(X) LP seltablist(F) RP
          470  +                    as(Z) on_opt(N) using_opt(U). {
          471  +    if( X==0 && Z.n==0 && N==0 && U==0 ){
          472  +      A = F;
          473  +    }else{
          474  +      Select *pSubquery;
          475  +      sqlite3SrcListShiftJoinType(F);
          476  +      pSubquery = sqlite3SelectNew(pParse,0,F,0,0,0,0,0,0,0);
          477  +      A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,pSubquery,N,U);
          478  +    }
   468    479     }
   469    480     
   470    481     // A seltablist_paren nonterminal represents anything in a FROM that
   471    482     // is contained inside parentheses.  This can be either a subquery or
   472    483     // a grouping of table and subqueries.
   473    484     //
   474         -  %type seltablist_paren {Select*}
   475         -  %destructor seltablist_paren {sqlite3SelectDelete(pParse->db, $$);}
   476         -  seltablist_paren(A) ::= select(S).      {A = S;}
   477         -  seltablist_paren(A) ::= seltablist(F).  {
   478         -     sqlite3SrcListShiftJoinType(F);
   479         -     A = sqlite3SelectNew(pParse,0,F,0,0,0,0,0,0,0);
   480         -  }
          485  +//  %type seltablist_paren {Select*}
          486  +//  %destructor seltablist_paren {sqlite3SelectDelete(pParse->db, $$);}
          487  +//  seltablist_paren(A) ::= select(S).      {A = S;}
          488  +//  seltablist_paren(A) ::= seltablist(F).  {
          489  +//     sqlite3SrcListShiftJoinType(F);
          490  +//     A = sqlite3SelectNew(pParse,0,F,0,0,0,0,0,0,0);
          491  +//  }
   481    492   %endif  SQLITE_OMIT_SUBQUERY
   482    493   
   483    494   %type dbnm {Token}
   484    495   dbnm(A) ::= .          {A.z=0; A.n=0;}
   485    496   dbnm(A) ::= DOT nm(X). {A = X;}
   486    497   
   487    498   %type fullname {SrcList*}