/ Check-in [04ef40a8]
Login

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

Overview
Comment:Better names for subqueries in EXPLAIN comments.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 04ef40a8fea88776e0d8b73d942922d45d0c038fbfac1a9a82b9322181b4ad92
User & Date: drh 2017-09-29 12:12:52
Context
2017-09-29
12:44
Make sure the 6th parameter to the authorizer callback for view subqueries has the correct view name. check-in: 2a45bbc9 user: drh tags: trunk
12:12
Better names for subqueries in EXPLAIN comments. check-in: 04ef40a8 user: drh tags: trunk
2017-09-28
17:29
Remove the (undocumented) query-planner control that prevents a "SELECT ALL" subquery in FROM clause from being implemented as a co-routine. This control was added by [a29e117d7ec], where it was called a "stop-gap". check-in: ff2f5a31 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/select.c.

  4372   4372         /* A sub-query in the FROM clause of a SELECT */
  4373   4373         assert( pSel!=0 );
  4374   4374         assert( pFrom->pTab==0 );
  4375   4375         if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
  4376   4376         pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
  4377   4377         if( pTab==0 ) return WRC_Abort;
  4378   4378         pTab->nTabRef = 1;
  4379         -      pTab->zName = sqlite3MPrintf(db, "sqlite_sq_%p", (void*)pTab);
         4379  +      if( pFrom->zAlias ){
         4380  +        pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);
         4381  +      }else{
         4382  +        pTab->zName = sqlite3MPrintf(db, "subquery_%p", (void*)pTab);
         4383  +      }
  4380   4384         while( pSel->pPrior ){ pSel = pSel->pPrior; }
  4381   4385         sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
  4382   4386         pTab->iPKey = -1;
  4383   4387         pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
  4384   4388         pTab->tabFlags |= TF_Ephemeral;
  4385   4389   #endif
  4386   4390       }else{

Changes to test/select1.test.

   541    541        SELECT * FROM test1 a, test1 b LIMIT 1
   542    542     }
   543    543   } {a.f1 11 a.f2 22 b.f1 11 b.f2 22}
   544    544   do_test select1-6.9.7 {
   545    545     set x [execsql2 {
   546    546        SELECT * FROM test1 a, (select 5, 6) LIMIT 1
   547    547     }]
   548         -  regsub -all {sq_[0-9a-fA-F_]+} $x {subquery} x
          548  +  regsub -all {subquery_[0-9a-fA-F_]+} $x {subquery} x
   549    549     set x
   550         -} {a.f1 11 a.f2 22 sqlite_subquery.5 5 sqlite_subquery.6 6}
          550  +} {a.f1 11 a.f2 22 subquery.5 5 subquery.6 6}
   551    551   do_test select1-6.9.8 {
   552    552     set x [execsql2 {
   553    553        SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1
   554    554     }]
   555    555     regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x
   556    556     set x
   557    557   } {a.f1 11 a.f2 22 b.x 5 b.y 6}