/ Check-in [a0910079]
Login

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

Overview
Comment:Merge all recent changes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | threads
Files: files | file ages | folders
SHA1: a0910079adde95245680dee59b43613b60903f10
User & Date: drh 2014-04-03 16:42:21
Context
2014-04-04
02:13
Change vdbeSorterExtendFile() so that it makes a best effort to create the PMA file of the desired size, but does not return an error if unable. check-in: 217814bc user: drh tags: threads
2014-04-03
16:42
Merge all recent changes from trunk. check-in: a0910079 user: drh tags: threads
16:29
Use OP_Copy instead of OP_SCopy when moving results out of a subquery, to prevent the subquery results from changing out from under the outer query. Fix for ticket [98825a79ce1456]. Problem introduced by check-in [1e64dd782a126f48d78]. check-in: d5513dfa user: drh tags: trunk
16:25
Fix an integer overflow problem in the sorter. check-in: 9d3351b8 user: dan tags: threads
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/mem5.c.

   244    244     /* Round nByte up to the next valid power of two */
   245    245     for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){}
   246    246   
   247    247     /* Make sure mem5.aiFreelist[iLogsize] contains at least one free
   248    248     ** block.  If not, then split a block of the next larger power of
   249    249     ** two in order to create a new free block of size iLogsize.
   250    250     */
   251         -  for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}
          251  +  for(iBin=iLogsize; iBin<=LOGMAX && mem5.aiFreelist[iBin]<0; iBin++){}
   252    252     if( iBin>LOGMAX ){
   253    253       testcase( sqlite3GlobalConfig.xLog!=0 );
   254    254       sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte);
   255    255       return 0;
   256    256     }
   257    257     i = mem5.aiFreelist[iBin];
   258    258     memsys5Unlink(i, iBin);

Changes to src/shell.c.

  2126   2126       return;
  2127   2127     }
  2128   2128     rc = sqlite3_open(zNewDb, &newDb);
  2129   2129     if( rc ){
  2130   2130       fprintf(stderr, "Cannot create output database: %s\n",
  2131   2131               sqlite3_errmsg(newDb));
  2132   2132     }else{
         2133  +    sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0);
  2133   2134       sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0);
  2134   2135       tryToCloneSchema(p, newDb, "type='table'", tryToCloneData);
  2135   2136       tryToCloneSchema(p, newDb, "type!='table'", 0);
  2136   2137       sqlite3_exec(newDb, "COMMIT;", 0, 0, 0);
         2138  +    sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
  2137   2139     }
  2138   2140     sqlite3_close(newDb);
  2139   2141   }
  2140   2142   
  2141   2143   /*
  2142   2144   ** If an input line begins with "." then invoke this routine to
  2143   2145   ** process that line.

Changes to src/vdbe.c.

  5947   5947     }
  5948   5948     break;
  5949   5949   }
  5950   5950   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  5951   5951   
  5952   5952   #ifndef SQLITE_OMIT_VIRTUALTABLE
  5953   5953   /* Opcode: VFilter P1 P2 P3 P4 *
  5954         -** Synopsis: iPlan=r[P3] zPlan='P4'
         5954  +** Synopsis: iplan=r[P3] zplan='P4'
  5955   5955   **
  5956   5956   ** P1 is a cursor opened using VOpen.  P2 is an address to jump to if
  5957   5957   ** the filtered result set is empty.
  5958   5958   **
  5959   5959   ** P4 is either NULL or a string that was generated by the xBestIndex
  5960   5960   ** method of the module.  The interpretation of the P4 string is left
  5961   5961   ** to the module implementation.

Changes to src/where.c.

  5920   5920       if( pTabItem->viaCoroutine && !db->mallocFailed ){
  5921   5921         last = sqlite3VdbeCurrentAddr(v);
  5922   5922         k = pLevel->addrBody;
  5923   5923         pOp = sqlite3VdbeGetOp(v, k);
  5924   5924         for(; k<last; k++, pOp++){
  5925   5925           if( pOp->p1!=pLevel->iTabCur ) continue;
  5926   5926           if( pOp->opcode==OP_Column ){
  5927         -          pOp->opcode = OP_SCopy;
         5927  +          pOp->opcode = OP_Copy;
  5928   5928             pOp->p1 = pOp->p2 + pTabItem->regResult;
  5929   5929             pOp->p2 = pOp->p3;
  5930   5930             pOp->p3 = 0;
  5931   5931           }else if( pOp->opcode==OP_Rowid ){
  5932   5932             pOp->opcode = OP_Null;
  5933   5933             pOp->p1 = 0;
  5934   5934             pOp->p3 = 0;

Changes to test/whereG.test.

   161    161   } {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}
   162    162   do_eqp_test whereG-3.3 {
   163    163     SELECT * FROM a, b WHERE a2=5 AND b1=a1;
   164    164   } {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}
   165    165   do_eqp_test whereG-3.4 {
   166    166     SELECT * FROM a, b WHERE a2=5 AND a1=b1;
   167    167   } {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}
          168  +
          169  +# Ticket [1e64dd782a126f48d78c43a664844a41d0e6334e]:
          170  +# Incorrect result in a nested GROUP BY/DISTINCT due to the use of an OP_SCopy
          171  +# where an OP_Copy was needed.
          172  +#
          173  +do_execsql_test whereG-4.0 {
          174  +  CREATE TABLE t4(x);
          175  +  INSERT INTO t4 VALUES('right'),('wrong');
          176  +  SELECT DISTINCT x
          177  +   FROM (SELECT x FROM t4 GROUP BY x)
          178  +   WHERE x='right'
          179  +   ORDER BY x;
          180  +} {right}
   168    181   
   169    182   
   170    183   finish_test