> All these codes are dealing with the header? They are not about header but they are essentially dealing with fatal errors. First example is (as comment says) executed when database tries to recover after a crashed process. And short read here means that journal is corrupted and should be ignored. In the second example if you follow the code further you'll see that SQLite assumes that short read means 0 bytes was read and the whole page is filled with zeros. That will mean that the page should be created.
Pavel On Thu, Apr 26, 2012 at 7:13 PM, BaiYang <baiy...@263.net.cn> wrote: >> It is a fatal error. The only time it is okay is after the file is first >> created (zero length) ... > Really? But I have seen many location seems not like you sad. For example: > > In pager_playback: > }else if( rc==SQLITE_IOERR_SHORT_READ ){ > /* If the journal has been truncated, simply stop reading and > ** processing the journal. This might happen if the journal was > ** not completely written and synced prior to a crash. In that > ** case, the database should have never been written in the > ** first place so it is OK to simply abandon the rollback. */ > rc = SQLITE_OK; > goto end_playback; > > In readDbPage: > if( rc==SQLITE_OK && !isInWal ){ > i64 iOffset = (pgno-1)*(i64)pPager->pageSize; > rc = sqlite3OsRead(pPager->fd, pPg->pData, pgsz, iOffset); > if( rc==SQLITE_IOERR_SHORT_READ ){ > rc = SQLITE_OK; > } > } > > And so on. > > All these codes are dealing with the header? > > -- > Best Regards > BaiYang > baiy...@263.net.cn > http://baiy.cn > **** < END OF EMAIL > **** > > From: Roger Binns > Date: 2012-04-27 07:06 > To: General Discussion of SQLite Database > Subject: Re: [sqlite] the xRead method in sqlite3_io_methods > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 26/04/12 15:27, BaiYang wrote: >> I'm confused, does you mean a xRead should NEVER return a >> "SQLITE_IOERR_SHORT_READ" ? > > It is a fatal error. The only time it is okay is after the file is first > created (zero length) and SQLite tries to read the header page which > doesn't exist at that point in time. > > At all other times a short error is fatal. The extended error code is so > that the caller has more details than just I/O error. > > Roger > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (GNU/Linux) > > iEYEARECAAYFAk+Z1O8ACgkQmOOfHg372QTyoACglrfe4j5Grsl2YzJ387bbquxE > U4YAoOCoFPF425QNlEB3/tYntK+vTbHk > =5wii > -----END PGP SIGNATURE----- > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users