/ Check-in [f4b1b6f8]
Login

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

Overview
Comment:Fix a problem caused by a sub-query containing a window function in the FROM clause of a query that itself uses a window function.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | exp-window-functions
Files: files | file ages | folders
SHA3-256: f4b1b6f85b53d72e735a1382f7c3de75af405a7878dd8cdcb10394e859ea3d69
User & Date: dan 2018-06-19 18:11:05
Context
2018-06-19
19:15
Merge latest trunk changes with this branch. check-in: 6ad0e64b user: dan tags: exp-window-functions
18:11
Fix a problem caused by a sub-query containing a window function in the FROM clause of a query that itself uses a window function. check-in: f4b1b6f8 user: dan tags: exp-window-functions
17:13
Fix a problem with using min() or max() as a window function. check-in: 801074ce user: dan tags: exp-window-functions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  4989   4989   static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
  4990   4990     Parse *pParse;
  4991   4991     int i;
  4992   4992     SrcList *pTabList;
  4993   4993     struct SrcList_item *pFrom;
  4994   4994   
  4995   4995     assert( p->selFlags & SF_Resolved );
  4996         -  assert( (p->selFlags & SF_HasTypeInfo)==0 );
         4996  +  if( p->selFlags & SF_HasTypeInfo ) return;
  4997   4997     p->selFlags |= SF_HasTypeInfo;
  4998   4998     pParse = pWalker->pParse;
  4999   4999     pTabList = p->pSrc;
  5000   5000     for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
  5001   5001       Table *pTab = pFrom->pTab;
  5002   5002       assert( pTab!=0 );
  5003   5003       if( (pTab->tabFlags & TF_Ephemeral)!=0 ){

Changes to test/window1.test.

   347    347         WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x) ORDER BY 1
   348    348   } {1 g g   2 i i   3 l l   4 g i   5 a l   6 m m}
   349    349   
   350    350   do_execsql_test 9.1.3 {
   351    351     SELECT * FROM t5 ORDER BY 1
   352    352   } {1 g g   2 i i   3 l l   4 g i   5 a l   6 m m}
   353    353   
          354  +do_execsql_test 9.2 {
          355  +  WITH aaa(x, y, z) AS (
          356  +    SELECT x, y, max(y) OVER xyz FROM t4
          357  +    WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x)
          358  +  )
          359  +  SELECT * FROM aaa ORDER BY 1;
          360  +} {1 g g   2 i i   3 l l   4 g i   5 a l   6 m m}
          361  +
          362  +do_execsql_test 9.3 {
          363  +  WITH aaa(x, y, z) AS (
          364  +    SELECT x, y, max(y) OVER xyz FROM t4
          365  +    WINDOW xyz AS (ORDER BY x)
          366  +  )
          367  +  SELECT *, min(z) OVER (ORDER BY x) FROM aaa ORDER BY 1;
          368  +} {1 g g g   2 i i g   3 l l g   4 g l g   5 a l g   6 m m g}
   354    369   
   355    370   finish_test
   356    371