/ Check-in [6d818052]
Login

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

Overview
Comment:Avoid closing a pseudo-table associated with sorting in a co-routine since that pseudo-table might be used again in an outer loop.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6d81805298ea882f5fee99504d5a95f1a762a90b
User & Date: drh 2014-06-03 14:42:34
Context
2014-06-04
14:06
Version 3.8.5 check-in: b1ed4f2a user: drh tags: trunk, release, version-3.8.5
2014-06-03
20:09
Merge the 3.8.5 release candidate changes into the sessions branch. check-in: 09e75d82 user: drh tags: sessions
14:42
Avoid closing a pseudo-table associated with sorting in a co-routine since that pseudo-table might be used again in an outer loop. check-in: 6d818052 user: drh tags: trunk
11:32
Add a test to double-check that [1cbe7a0883] did not affect anything. check-in: c6b512a7 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  1222   1222     if( pSort->sortFlags & SORTFLAG_UseSorter ){
  1223   1223       sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr); VdbeCoverage(v);
  1224   1224     }else{
  1225   1225       sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); VdbeCoverage(v);
  1226   1226     }
  1227   1227     if( pSort->regReturn ) sqlite3VdbeAddOp1(v, OP_Return, pSort->regReturn);
  1228   1228     sqlite3VdbeResolveLabel(v, addrBreak);
  1229         -  if( eDest==SRT_Output || eDest==SRT_Coroutine ){
  1230         -    sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0);
  1231         -  }
  1232   1229   }
  1233   1230   
  1234   1231   /*
  1235   1232   ** Return a pointer to a string containing the 'declaration type' of the
  1236   1233   ** expression pExpr. The string may be treated as static by the caller.
  1237   1234   **
  1238   1235   ** Also try to estimate the size of the returned value and return that

Changes to test/orderby1.test.

   459    459   } {}
   460    460   do_execsql_test 5.1 {
   461    461     EXPLAIN QUERY PLAN SELECT 5 UNION ALL SELECT 3 ORDER BY 1
   462    462   } {~/B-TREE/}
   463    463   do_execsql_test 5.2 {
   464    464     SELECT 5 UNION ALL SELECT 3 ORDER BY 1
   465    465   } {3 5}
          466  +
          467  +# The following test (originally derived from a single test within fuzz.test)
          468  +# verifies that a PseudoTable cursor is not closed prematurely in a deeply
          469  +# nested query.  This test caused a segfault on 3.8.5 beta.
          470  +#
          471  +do_execsql_test 6.0 {
          472  +  CREATE TABLE abc(a, b, c);
          473  +  INSERT INTO abc VALUES(1, 2, 3);
          474  +  INSERT INTO abc VALUES(4, 5, 6);
          475  +  INSERT INTO abc VALUES(7, 8, 9);
          476  +  SELECT (
          477  +    SELECT 'hardware' FROM ( 
          478  +      SELECT 'software' ORDER BY 'firmware' ASC, 'sportswear' DESC 
          479  +    ) GROUP BY 1 HAVING length(b)
          480  +  )
          481  +  FROM abc;
          482  +} {hardware hardware hardware}
          483  +
   466    484   
   467    485   finish_test