On 9/4/17, zhiting zhu <zhiti...@cs.utexas.edu> wrote: > Hi, > > I send this email to the dev mailing list but no response. It seems this > mailing list has more activity and attention. I have a question about how > dbSize is calculated when I was reading the source code of sqlite3. In the > description of the dbSize, it said: "If the size of the file is not an > integer multiple of the page-size, the value stored in dbSize is rounded > down (i.e. a 5KB file with 2K page-size has dbSize==2). > Except, any file that is greater than 0 bytes in size is considered to have > at least one page. (i.e. a 1KB file with 2K page-size leads to dbSize==1)." > > But in the pagerPagecount function: the comment said: " If the size of the > database file is not an integer multiple of the page-size, round up the > result." The pagerPagecount function is used to set dbSize in > sqlite3PagerSharedLock function. > > The comment at the top is contradicted with the latter. I wonder which way > should be correct? Should it be round up or round down? Thanks!
If the file size is not an integer multiple of the page size, then the database is corrupt. So I'm not sure it matters if it rounds up or down. I do not recall what the code does or what it should do. I will need to do some research to figure out the answer. I am on travel this week and do not have time to work on that at the moment. I will strive to fix the discrepency next week some time. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users