SQLite

Check-in [b8b7b8f9e9]
Login

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

Overview
Comment:Change the way the tcl crash-test code works to avoid triggering an assert() in os_unix.c.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d
User & Date: dan 2012-10-17 15:28:26.766
Context
2012-10-17
16:20
Add a test for the problem fixed by [bf44d73d3e]. (check-in: db9b1fa597 user: dan tags: trunk)
15:28
Change the way the tcl crash-test code works to avoid triggering an assert() in os_unix.c. (check-in: b8b7b8f9e9 user: dan tags: trunk)
13:15
Remove an incorrect "#ifndef SQLITE_OMIT_AUTOVACUUM" from pager. (check-in: bf44d73d3e user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test6.c.
624
625
626
627
628
629
630



631
632
633
634
635
636
637
638
639
640
641


642
643
644
645
646
647
648
649
    pWrapper->nData = (4096 + pWrapper->iSize);
    pWrapper->zData = crash_malloc(pWrapper->nData);
    if( pWrapper->zData ){
      /* os_unix.c contains an assert() that fails if the caller attempts
      ** to read data from the 512-byte locking region of a file opened
      ** with the SQLITE_OPEN_MAIN_DB flag. This region of a database file
      ** never contains valid data anyhow. So avoid doing such a read here.



      */
      const int isDb = (flags&SQLITE_OPEN_MAIN_DB);
      i64 iChunk = pWrapper->iSize;
      if( iChunk>PENDING_BYTE && isDb ){
        iChunk = PENDING_BYTE;
      }
      memset(pWrapper->zData, 0, pWrapper->nData);
      rc = sqlite3OsRead(pReal, pWrapper->zData, (int)iChunk, 0); 
      if( SQLITE_OK==rc && pWrapper->iSize>(PENDING_BYTE+512) && isDb ){
        i64 iOff = PENDING_BYTE+512;
        iChunk = pWrapper->iSize - iOff;


        rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], (int)iChunk, iOff);
      }
    }else{
      rc = SQLITE_NOMEM;
    }
  }
  if( rc!=SQLITE_OK && pWrapper->pMethod ){
    sqlite3OsClose(pFile);







>
>
>


|
<
<
|

<
|
<
|
>
>
|







624
625
626
627
628
629
630
631
632
633
634
635
636


637
638

639

640
641
642
643
644
645
646
647
648
649
650
    pWrapper->nData = (4096 + pWrapper->iSize);
    pWrapper->zData = crash_malloc(pWrapper->nData);
    if( pWrapper->zData ){
      /* os_unix.c contains an assert() that fails if the caller attempts
      ** to read data from the 512-byte locking region of a file opened
      ** with the SQLITE_OPEN_MAIN_DB flag. This region of a database file
      ** never contains valid data anyhow. So avoid doing such a read here.
      **
      ** UPDATE: It also contains an assert() verifying that each call
      ** to the xRead() method reads less than 128KB of data.
      */
      const int isDb = (flags&SQLITE_OPEN_MAIN_DB);
      i64 iOff;



      memset(pWrapper->zData, 0, pWrapper->nData);

      for(iOff=0; iOff<pWrapper->iSize; iOff += 512){

        int nRead = pWrapper->iSize - iOff;
        if( nRead>512 ) nRead = 512;
        if( isDb && iOff==PENDING_BYTE ) continue;
        rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], nRead, iOff);
      }
    }else{
      rc = SQLITE_NOMEM;
    }
  }
  if( rc!=SQLITE_OK && pWrapper->pMethod ){
    sqlite3OsClose(pFile);