/ Check-in [bc0fb1c3]
Login

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

Overview
Comment:Use a separate bit on db->dbOptFlags to disable the xInverse optimization on window functions, rather than reusing the query-flattener disable bit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bc0fb1c324be2fd668bc4398c7d364b7e3c5a98537fe5fb58a125b66f3e6d041
User & Date: drh 2019-04-02 17:45:56
Context
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
17:45
Including the phrase EXCLUDE NO OTHERS in the frame-spec of a window function (which is the default setting for EXCLUDE) silently disables the xInverse optimization. This is a feature, but we will keep it undocumented for now in case we later decide it is a bad idea. check-in: 10aedce3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  1569   1569   
  1570   1570   /*
  1571   1571   ** Bits of the sqlite3.dbOptFlags field that are used by the
  1572   1572   ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
  1573   1573   ** selectively disable various optimizations.
  1574   1574   */
  1575   1575   #define SQLITE_QueryFlattener 0x0001   /* Query flattening */
  1576         -                          /*  0x0002   available for reuse */
         1576  +#define SQLITE_WindowFunc     0x0002   /* Use xInverse for window functions */
  1577   1577   #define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */
  1578   1578   #define SQLITE_FactorOutConst 0x0008   /* Constant factoring */
  1579   1579   #define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */
  1580   1580   #define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */
  1581   1581   #define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */
  1582   1582   #define SQLITE_Transitive     0x0080   /* Transitive constraints */
  1583   1583   #define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */

Changes to src/window.c.

  1088   1088     }
  1089   1089   
  1090   1090     pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  1091   1091     if( pWin==0 ) goto windowAllocErr;
  1092   1092     pWin->eFrmType = eType;
  1093   1093     pWin->eStart = eStart;
  1094   1094     pWin->eEnd = eEnd;
  1095         -  if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_QueryFlattener) ){
         1095  +  if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_WindowFunc) ){
  1096   1096       eExclude = TK_NO;
  1097   1097     }
  1098   1098     pWin->eExclude = eExclude;
  1099   1099     pWin->bImplicitFrame = bImplicitFrame;
  1100   1100     pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
  1101   1101     pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
  1102   1102     return pWin;