/ Check-in [071f7f2d]
Login

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

Overview
Comment:Avoid calling sqlite3OsFetch() on a file-handle for which the xFetch method is NULL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ota-update
Files: files | file ages | folders
SHA1: 071f7f2decd2f786c0201a4219e9c2cc9d227085
User & Date: dan 2014-09-04 11:03:35
Context
2014-09-04
18:05
Fix showwal.c so that it works with 64KiB pages. check-in: fc4f7c11 user: dan tags: ota-update
11:03
Avoid calling sqlite3OsFetch() on a file-handle for which the xFetch method is NULL. check-in: 071f7f2d user: dan tags: ota-update
2014-09-03
19:30
Split part of "PRAGMA ota_mode" off into "PRAGMA pager_ota_mode". This allows some specialized custom VFS implementations to intercept and implement the expected pager-related effects of this pragma. check-in: 209f672e user: dan tags: ota-update
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/ota/ota.c.

    37     37   "  and the program exits. Subsequent invocations of this (or any other OTA)\n"
    38     38   "  application will use this state to resume applying the OTA update to the\n"
    39     39   "  target db.\n"
    40     40   "\n"
    41     41   , zArgv0);
    42     42     exit(1);
    43     43   }
           44  +
           45  +void report_default_vfs(){
           46  +  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
           47  +  fprintf(stdout, "using vfs \"%s\"\n", pVfs->zName);
           48  +}
    44     49   
    45     50   int main(int argc, char **argv){
    46     51     int i;
    47     52     const char *zTarget;            /* Target database to apply OTA to */
    48     53     const char *zOta;               /* Database containing OTA */
    49     54     char *zErrmsg;                  /* Error message, if any */
    50     55     sqlite3ota *pOta;               /* OTA handle */
................................................................................
    58     63       if( nArg1>5 || nArg1<2 || memcmp("-step", argv[1], nArg1) ) usage(argv[0]);
    59     64       nStep = atoi(argv[2]);
    60     65     }else if( argc!=3 ){
    61     66       usage(argv[0]);
    62     67     }
    63     68     zTarget = argv[argc-2];
    64     69     zOta = argv[argc-1];
           70  +
           71  +  report_default_vfs();
    65     72   
    66     73     /* Open an OTA handle. If nStep is less than or equal to zero, call
    67     74     ** sqlite3ota_step() until either the OTA has been completely applied
    68     75     ** or an error occurs. Or, if nStep is greater than zero, call
    69     76     ** sqlite3ota_step() a maximum of nStep times.  */
    70     77     pOta = sqlite3ota_open(zTarget, zOta);
    71     78     for(i=0; (nStep<=0 || i<nStep) && sqlite3ota_step(pOta)==SQLITE_OK; i++);

Changes to src/vdbesort.c.

   597    597   ** mmap), return SQLITE_OK and set *pp to NULL.
   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         -  if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){
          604  +  if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap)
          605  +   && pFile->pFd->pMethods->xFetch 
          606  +  ){
   605    607       rc = sqlite3OsFetch(pFile->pFd, 0, (int)pFile->iEof, (void**)pp);
   606    608       testcase( rc!=SQLITE_OK );
   607    609     }
   608    610     return rc;
   609    611   }
   610    612   
   611    613   /*
................................................................................
  1119   1121   **
  1120   1122   ** Whether or not the file does end up memory mapped of course depends on
  1121   1123   ** the specific VFS implementation.
  1122   1124   */
  1123   1125   static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){
  1124   1126     if( nByte<=(i64)(db->nMaxSorterMmap) ){
  1125   1127       int rc = sqlite3OsTruncate(pFd, nByte);
  1126         -    if( rc==SQLITE_OK ){
         1128  +    if( rc==SQLITE_OK && pFd->pMethods->xFetch ){
  1127   1129         void *p = 0;
  1128   1130         sqlite3OsFetch(pFd, 0, (int)nByte, &p);
  1129   1131         sqlite3OsUnfetch(pFd, 0, p);
  1130   1132       }
  1131   1133     }
  1132   1134   }
  1133   1135   #else