/ Check-in [dedaa6fb]
Login

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

Overview
Comment:Avoid attempting to call the xFetch() method of an sqlite3_io_methods object with a version number less than 3.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dedaa6fb3d2e6e697d4a48649af5f42d9a11c333
User & Date: dan 2014-09-15 16:50:34
Context
2014-09-15
16:53
Fix tool/showwal.c so that it handles WAL files that contain 64KiB pages. check-in: 4060efb6 user: dan tags: trunk
16:50
Avoid attempting to call the xFetch() method of an sqlite3_io_methods object with a version number less than 3. check-in: dedaa6fb user: dan tags: trunk
14:59
Remove the EXPENSIVE_ASSERTS in pcache.c having to do with the pSynced field of the Pcache object, as they are incorrect, as revealed by recent pcache enhancements. check-in: 69a64560 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbesort.c.

   598    598   **
   599    599   ** Or, if an error occurs, return an SQLite error code. The final value of
   600    600   ** *pp is undefined in this case.
   601    601   */
   602    602   static int vdbeSorterMapFile(SortSubtask *pTask, SorterFile *pFile, u8 **pp){
   603    603     int rc = SQLITE_OK;
   604    604     if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){
   605         -    rc = sqlite3OsFetch(pFile->pFd, 0, (int)pFile->iEof, (void**)pp);
   606         -    testcase( rc!=SQLITE_OK );
          605  +    sqlite3_file *pFd = pFile->pFd;
          606  +    if( pFd->pMethods->iVersion>=3 ){
          607  +      rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp);
          608  +      testcase( rc!=SQLITE_OK );
          609  +    }
   607    610     }
   608    611     return rc;
   609    612   }
   610    613   
   611    614   /*
   612    615   ** Attach PmaReader pReadr to file pFile (if it is not already attached to
   613    616   ** that file) and seek it to offset iOff within the file.  Return SQLITE_OK 
................................................................................
  1119   1122   **
  1120   1123   ** Whether or not the file does end up memory mapped of course depends on
  1121   1124   ** the specific VFS implementation.
  1122   1125   */
  1123   1126   static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){
  1124   1127     if( nByte<=(i64)(db->nMaxSorterMmap) ){
  1125   1128       int rc = sqlite3OsTruncate(pFd, nByte);
  1126         -    if( rc==SQLITE_OK ){
         1129  +    if( rc==SQLITE_OK && pFd->pMethods->iVersion>=3 ){
  1127   1130         void *p = 0;
  1128   1131         sqlite3OsFetch(pFd, 0, (int)nByte, &p);
  1129   1132         sqlite3OsUnfetch(pFd, 0, p);
  1130   1133       }
  1131   1134     }
  1132   1135   }
  1133   1136   #else

Added test/sort5.test.

            1  +# 2014 September 15.
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. 
           12  +#
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +set testprefix sort5
           17  +
           18  +
           19  +#-------------------------------------------------------------------------
           20  +# Verify that sorting works with a version 1 sqlite3_io_methods structure.
           21  +#
           22  +testvfs tvfs -iversion 1 -default true
           23  +reset_db
           24  +do_execsql_test 1.0 {
           25  +  PRAGMA mmap_size = 10000000;
           26  +  PRAGMA cache_size = 10;
           27  +  CREATE TABLE t1(a, b);
           28  +} {0}
           29  +
           30  +do_test 1.1 {
           31  +  execsql BEGIN
           32  +  for {set i 0} {$i < 2000} {incr i} {
           33  +    execsql { INSERT INTO t1 VALUES($i, randomblob(2000)) }
           34  +  }
           35  +  execsql COMMIT
           36  +} {}
           37  +
           38  +do_execsql_test 1.2 {
           39  +  CREATE INDEX i1 ON t1(b);
           40  +}
           41  +
           42  +db close
           43  +tvfs delete
           44  +finish_test
           45  +