SQLite

Changes On Branch filesize-debug
Login

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

Changes In Branch filesize-debug Excluding Merge-Ins

This is equivalent to a diff from 3e0da808 to d22c8142

2014-06-17
18:43
Experimental changes to use GetFileInformationByHandle instead of GetFileSize in the Win32 VFS. (Closed-Leaf check-in: d22c8142 user: mistachkin tags: filesize-debug)
2014-04-24
13:20
Add sqlite3_log() diagnostic messages for a specific type of corruption where the file size is reported to be too small relative to the size in the header. This branch is intended to help debug a specific problem reported from the wild and is not for general use. (check-in: 34155c40 user: drh tags: filesize-debug)
2011-09-19
20:56
Minor comment change in the description of the different memory allocator options. No changes to code. (check-in: 36be31ff user: drh tags: trunk)
20:36
Merge in all changes through the 3.7.8 release. (check-in: 9607600b user: drh tags: stat3-trunk)
20:32
Merge in all trunk changes through the 3.7.8 release. (check-in: ade72b18 user: drh tags: apple-osx)
20:28
Merge in all trunk changes through the version 3.7.8 release. (check-in: 98619a23 user: drh tags: sessions)
18:00
Version 3.7.8 (check-in: 3e0da808 user: drh tags: trunk, release, version-3.7.8)
13:01
Increase the default lookaside cache line size from 100 to 128 bytes. (check-in: db019465 user: drh tags: trunk)

Changes to src/btree.c.

2389
2390
2391
2392
2393
2394
2395


2396
2397
2398
2399
2400
2401
2402
      pBt->pageSize = pageSize;
      freeTempSpace(pBt);
      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
                                   pageSize-usableSize);
      return rc;
    }
    if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){


      rc = SQLITE_CORRUPT_BKPT;
      goto page1_init_failed;
    }
    if( usableSize<480 ){
      goto page1_init_failed;
    }
    pBt->pageSize = pageSize;







>
>







2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
      pBt->pageSize = pageSize;
      freeTempSpace(pBt);
      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
                                   pageSize-usableSize);
      return rc;
    }
    if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
      sqlite3_log(SQLITE_CORRUPT, "nPage=%d nPageFile=%d", nPage, nPageFile);
      sqlite3PagerLogDiagnostics(pBt->pPager);
      rc = SQLITE_CORRUPT_BKPT;
      goto page1_init_failed;
    }
    if( usableSize<480 ){
      goto page1_init_failed;
    }
    pBt->pageSize = pageSize;

Changes to src/os_win.c.

1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318





1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
#endif
}

/*
** Determine the current size of a file in bytes
*/
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  DWORD upperBits;
  DWORD lowerBits;
  winFile *pFile = (winFile*)id;
  DWORD error;

  assert( id!=0 );
  SimulateIOError(return SQLITE_IOERR_FSTAT);
  lowerBits = GetFileSize(pFile->h, &upperBits);
  if(   (lowerBits == INVALID_FILE_SIZE)
     && ((error = GetLastError()) != NO_ERROR) )
  {





    pFile->lastErrno = error;
    return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath);
  }
  *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
  return SQLITE_OK;
}

/*
** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
*/
#ifndef LOCKFILE_FAIL_IMMEDIATELY
# define LOCKFILE_FAIL_IMMEDIATELY 1







|
<

<



<
<
<
|
>
>
>
>
>
|


<
<







1301
1302
1303
1304
1305
1306
1307
1308

1309

1310
1311
1312



1313
1314
1315
1316
1317
1318
1319
1320
1321


1322
1323
1324
1325
1326
1327
1328
#endif
}

/*
** Determine the current size of a file in bytes
*/
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  BY_HANDLE_FILE_INFORMATION info;

  winFile *pFile = (winFile*)id;


  assert( id!=0 );
  SimulateIOError(return SQLITE_IOERR_FSTAT);




  memset(&info, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
  if( GetFileInformationByHandle(pFile->h, &info) ){
    *pSize = (((u64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
    return SQLITE_OK;
  }else{
    pFile->lastErrno = GetLastError();
    return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath);
  }


}

/*
** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
*/
#ifndef LOCKFILE_FAIL_IMMEDIATELY
# define LOCKFILE_FAIL_IMMEDIATELY 1

Changes to src/pager.c.

3087
3088
3089
3090
3091
3092
3093



















3094
3095
3096
3097
3098
3099
3100
  if( nPage>pPager->mxPgno ){
    pPager->mxPgno = (Pgno)nPage;
  }

  *pnPage = nPage;
  return SQLITE_OK;
}




















#ifndef SQLITE_OMIT_WAL
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
** not exist (by deleting it) if the database file is empty.
**







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
  if( nPage>pPager->mxPgno ){
    pPager->mxPgno = (Pgno)nPage;
  }

  *pnPage = nPage;
  return SQLITE_OK;
}

/* Log diagnostic information about the pager */
void sqlite3PagerLogDiagnostics(Pager *pPager){
  int rc;
  i64 n;
  sqlite3_log(SQLITE_INTERNAL, "Pager filename=[%s]", pPager->zFilename);
  sqlite3_log(SQLITE_INTERNAL, "Pager journal=[%s]", pPager->zJournal);
  sqlite3_log(SQLITE_INTERNAL,
    "Pager diagnostics: pWal=%p isOpen=%d pageSize=%d dbSize=%d eState=%d",
    pPager->pWal, isOpen(pPager->fd)!=0,
    pPager->pageSize, pPager->dbSize, pPager->eState
  );
  if( isOpen(pPager->fd) ){
    n = 0;
    rc = sqlite3OsFileSize(pPager->fd, &n);
    sqlite3_log(SQLITE_INTERNAL, "Pager OsFileSize: %lld (%d)", n, rc);
  }
}


#ifndef SQLITE_OMIT_WAL
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
** not exist (by deleting it) if the database file is empty.
**

Changes to src/pager.h.

151
152
153
154
155
156
157

158
159
160
161
162
163
164
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
sqlite3_file *sqlite3PagerFile(Pager*);
const char *sqlite3PagerJournalname(Pager*);
int sqlite3PagerNosync(Pager*);
void *sqlite3PagerTempSpace(Pager*);
int sqlite3PagerIsMemdb(Pager*);


/* Functions used to truncate the database file. */
void sqlite3PagerTruncateImage(Pager*,Pgno);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
void *sqlite3PagerCodec(DbPage *);
#endif







>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
sqlite3_file *sqlite3PagerFile(Pager*);
const char *sqlite3PagerJournalname(Pager*);
int sqlite3PagerNosync(Pager*);
void *sqlite3PagerTempSpace(Pager*);
int sqlite3PagerIsMemdb(Pager*);
void sqlite3PagerLogDiagnostics(Pager*);

/* Functions used to truncate the database file. */
void sqlite3PagerTruncateImage(Pager*,Pgno);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
void *sqlite3PagerCodec(DbPage *);
#endif

Changes to src/printf.c.

185
186
187
188
189
190
191

192
193
194
195
196
197
198
  }
}

/*
** On machines with a small stack size, you can redefine the
** SQLITE_PRINT_BUF_SIZE to be less than 350.
*/

#ifndef SQLITE_PRINT_BUF_SIZE
# if defined(SQLITE_SMALL_STACK)
#   define SQLITE_PRINT_BUF_SIZE 50
# else
#   define SQLITE_PRINT_BUF_SIZE 350
# endif
#endif







>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  }
}

/*
** On machines with a small stack size, you can redefine the
** SQLITE_PRINT_BUF_SIZE to be less than 350.
*/
#define SQLITE_PRINT_BUF_SIZE 2000
#ifndef SQLITE_PRINT_BUF_SIZE
# if defined(SQLITE_SMALL_STACK)
#   define SQLITE_PRINT_BUF_SIZE 50
# else
#   define SQLITE_PRINT_BUF_SIZE 350
# endif
#endif