/ Check-in [bce01d95]
Login

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

Overview
Comment:Small optimizations to the grammar for window functions save about 120 bytes of space in the parser tables.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bce01d9584e52b23d7c07c2e832d5fa5d6e6235711c856b903a296725f61ed6e
User & Date: drh 2019-04-02 18:12:20
Context
2019-04-03
16:27
Fix a couple of problems with "RANGE BETWEEN <expr> PRECEDING AND <expr> PRECEDING" frames. check-in: 39225cc7 user: dan tags: trunk
2019-04-02
18:12
Small optimizations to the grammar for window functions save about 120 bytes of space in the parser tables. check-in: bce01d95 user: drh tags: trunk
17:45
Use a separate bit on db->dbOptFlags to disable the xInverse optimization on window functions, rather than reusing the query-flattener disable bit. check-in: bc0fb1c3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

  1690   1690   
  1691   1691   frame_opt(A) ::= .                             { 
  1692   1692     A = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
  1693   1693   }
  1694   1694   frame_opt(A) ::= range_or_rows(X) frame_bound_s(Y) frame_exclude_opt(Z). { 
  1695   1695     A = sqlite3WindowAlloc(pParse, X, Y.eType, Y.pExpr, TK_CURRENT, 0, Z);
  1696   1696   }
  1697         -frame_opt(A) ::= range_or_rows(X) BETWEEN frame_bound_s(Y) AND frame_bound_e(Z) frame_exclude_opt(W). { 
         1697  +frame_opt(A) ::= range_or_rows(X) BETWEEN frame_bound_s(Y) AND
         1698  +                          frame_bound_e(Z) frame_exclude_opt(W). { 
  1698   1699     A = sqlite3WindowAlloc(pParse, X, Y.eType, Y.pExpr, Z.eType, Z.pExpr, W);
  1699   1700   }
  1700   1701   
  1701         -range_or_rows(A) ::= RANGE.   { A = TK_RANGE; }
  1702         -range_or_rows(A) ::= ROWS.    { A = TK_ROWS;  }
  1703         -range_or_rows(A) ::= GROUPS.  { A = TK_GROUPS;}
         1702  +range_or_rows(A) ::= RANGE|ROWS|GROUPS(X).   {A = @X; /*A-overwrites-X*/}
  1704   1703   
         1704  +frame_bound_s(A) ::= frame_bound(X).         {A = X;}
         1705  +frame_bound_s(A) ::= UNBOUNDED(X) PRECEDING. {A.eType = @X; A.pExpr = 0;}
         1706  +frame_bound_e(A) ::= frame_bound(X).         {A = X;}
         1707  +frame_bound_e(A) ::= UNBOUNDED(X) FOLLOWING. {A.eType = @X; A.pExpr = 0;}
  1705   1708   
  1706         -frame_bound_s(A) ::= frame_bound(X). { A = X; }
  1707         -frame_bound_s(A) ::= UNBOUNDED PRECEDING. {A.eType = TK_UNBOUNDED; A.pExpr = 0;}
  1708         -frame_bound_e(A) ::= frame_bound(X). { A = X; }
  1709         -frame_bound_e(A) ::= UNBOUNDED FOLLOWING. {A.eType = TK_UNBOUNDED; A.pExpr = 0;}
  1710         -
  1711         -frame_bound(A) ::= expr(X) PRECEDING.   { A.eType = TK_PRECEDING; A.pExpr = X; }
  1712         -frame_bound(A) ::= CURRENT ROW.         { A.eType = TK_CURRENT  ; A.pExpr = 0; }
  1713         -frame_bound(A) ::= expr(X) FOLLOWING.   { A.eType = TK_FOLLOWING; A.pExpr = X; }
         1709  +frame_bound(A) ::= expr(X) PRECEDING|FOLLOWING(Y).
         1710  +                                             {A.eType = @Y; A.pExpr = X;}
         1711  +frame_bound(A) ::= CURRENT(X) ROW.           {A.eType = @X; A.pExpr = 0;}
  1714   1712   
  1715   1713   %type frame_exclude_opt {u8}
  1716         -frame_exclude_opt(A) ::= . { A = 0; }
  1717         -frame_exclude_opt(A) ::= EXCLUDE frame_exclude(X). { A = X; }
         1714  +frame_exclude_opt(A) ::= . {A = 0;}
         1715  +frame_exclude_opt(A) ::= EXCLUDE frame_exclude(X). {A = X;}
  1718   1716   
  1719   1717   %type frame_exclude {u8}
  1720         -frame_exclude(A) ::= NO OTHERS.   { A = TK_NO; }
  1721         -frame_exclude(A) ::= CURRENT ROW. { A = TK_CURRENT; }
  1722         -frame_exclude(A) ::= GROUP.       { A = TK_GROUP; }
  1723         -frame_exclude(A) ::= TIES.        { A = TK_TIES; }
         1718  +frame_exclude(A) ::= NO(X) OTHERS.   {A = @X; /*A-overwrites-X*/}
         1719  +frame_exclude(A) ::= CURRENT(X) ROW. {A = @X; /*A-overwrites-X*/}
         1720  +frame_exclude(A) ::= GROUP|TIES(X).  {A = @X; /*A-overwrites-X*/}
  1724   1721   
  1725   1722   
  1726   1723   %type window_clause {Window*}
  1727   1724   %destructor window_clause {sqlite3WindowListDelete(pParse->db, $$);}
  1728   1725   window_clause(A) ::= WINDOW windowdefn_list(B). { A = B; }
  1729   1726   
  1730   1727   %type over_clause {Window*}