SQLite

Check-in [3de19ee2]
Login

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

Overview
Comment:Avoid no-op calls to sqlite3SelectPrep() when processing sqlite3Select() for subqueries. This simplifies the ".selecttrace" debugging output.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | early-winfunc-rewrite-dev
Files: files | file ages | folders
SHA3-256: 3de19ee22a1793790f299c5755d52f6e5fff819825a71f0ee5b19ea41953c795
User & Date: drh 2020-06-06 13:29:30
Context
2020-06-06
20:48
Merge multiple changes from trunk to address concerns with window-function parse-tree rewriting. (check-in: 05418b2a user: drh tags: branch-3.32-early-winfunc-rewrite)
14:29
Fix an assert() failure that could occur if an ORDER BY expression attached to a compound query contains a subquery that (a) is itself a compound query, (b) uses window functions and (c) has an ORDER BY clause that includes another sub-query. (check-in: c96914ea user: dan tags: early-winfunc-rewrite-dev)
13:29
Avoid no-op calls to sqlite3SelectPrep() when processing sqlite3Select() for subqueries. This simplifies the ".selecttrace" debugging output. (check-in: 3de19ee2 user: drh tags: early-winfunc-rewrite-dev)
2020-06-05
21:36
Improved tracing of window function parse tree rewrites. (check-in: 7e8060cf user: drh tags: early-winfunc-rewrite-dev)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
void sqlite3SelectPrep(
  Parse *pParse,         /* The parser context */
  Select *p,             /* The SELECT statement being coded. */
  NameContext *pOuterNC  /* Name context for container */
){
  assert( p!=0 || pParse->db->mallocFailed );
  if( pParse->db->mallocFailed ) return;
  if( p->selFlags & SF_HasTypeInfo ) return;
  sqlite3SelectExpand(pParse, p);
  if( pParse->nErr || pParse->db->mallocFailed ) return;
  sqlite3ResolveSelectNames(pParse, p, pOuterNC);
  if( pParse->nErr || pParse->db->mallocFailed ) return;
  sqlite3SelectAddTypeInfo(pParse, p);
}








|







5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
void sqlite3SelectPrep(
  Parse *pParse,         /* The parser context */
  Select *p,             /* The SELECT statement being coded. */
  NameContext *pOuterNC  /* Name context for container */
){
  assert( p!=0 || pParse->db->mallocFailed );
  if( pParse->db->mallocFailed ) return;
  assert( (p->selFlags & SF_HasTypeInfo)==0 );
  sqlite3SelectExpand(pParse, p);
  if( pParse->nErr || pParse->db->mallocFailed ) return;
  sqlite3ResolveSelectNames(pParse, p, pOuterNC);
  if( pParse->nErr || pParse->db->mallocFailed ) return;
  sqlite3SelectAddTypeInfo(pParse, p);
}

5775
5776
5777
5778
5779
5780
5781

5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792

5793
5794
5795
5796
5797
5798
5799
           pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);
    /* If ORDER BY makes no difference in the output then neither does
    ** DISTINCT so it can be removed too. */
    sqlite3ExprListDelete(db, p->pOrderBy);
    p->pOrderBy = 0;
    p->selFlags &= ~SF_Distinct;
  }

  sqlite3SelectPrep(pParse, p, 0);
  if( pParse->nErr || db->mallocFailed ){
    goto select_end;
  }
  assert( p->pEList!=0 );
#if SELECTTRACE_ENABLED
  if( sqlite3SelectTrace & 0x104 ){
    SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif


  if( pDest->eDest==SRT_Output ){
    generateColumnNames(pParse, p);
  }

  pTabList = p->pSrc;
  isAgg = (p->selFlags & SF_Aggregate)!=0;







>
|
|
|
|
|

|
|
|
|

>







5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
           pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);
    /* If ORDER BY makes no difference in the output then neither does
    ** DISTINCT so it can be removed too. */
    sqlite3ExprListDelete(db, p->pOrderBy);
    p->pOrderBy = 0;
    p->selFlags &= ~SF_Distinct;
  }
  if( (p->selFlags & SF_HasTypeInfo)==0 ){
    sqlite3SelectPrep(pParse, p, 0);
    if( pParse->nErr || db->mallocFailed ){
      goto select_end;
    }
    assert( p->pEList!=0 );
#if SELECTTRACE_ENABLED
    if( sqlite3SelectTrace & 0x104 ){
      SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif
  }

  if( pDest->eDest==SRT_Output ){
    generateColumnNames(pParse, p);
  }

  pTabList = p->pSrc;
  isAgg = (p->selFlags & SF_Aggregate)!=0;