Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make sure we never try to "truncate" a file to a larger size. (CVS 4582) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7d2f6a1d6c5ab89a3b65fbcaf172abf6 |
User & Date: | drh 2007-11-29 18:44:27.000 |
Context
2007-11-30
| ||
01:06 | Add a few function requirements numbers to interfaces in the comments of sqlite3.h.in. This is experimental. (CVS 4583) (check-in: b829a64515 user: drh tags: trunk) | |
2007-11-29
| ||
18:44 | Make sure we never try to "truncate" a file to a larger size. (CVS 4582) (check-in: 7d2f6a1d6c user: drh tags: trunk) | |
18:36 | Add the optional (and experimental) mmap() memory allocator in the mem4.c module. (CVS 4581) (check-in: cfd683ac80 user: drh tags: trunk) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.397 2007/11/29 18:44:27 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* |
︙ | ︙ | |||
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | static void pager_truncate_cache(Pager *pPager); /* ** Truncate the main file of the given pager to the number of pages ** indicated. Also truncate the cached representation of the file. */ static int pager_truncate(Pager *pPager, int nPage){ int rc = SQLITE_OK; if( pPager->state>=PAGER_EXCLUSIVE && pPager->fd->pMethods ){ | > > > > > > > > > > > > | > | 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 | static void pager_truncate_cache(Pager *pPager); /* ** Truncate the main file of the given pager to the number of pages ** indicated. Also truncate the cached representation of the file. ** ** Might might be the case that the file on disk is smaller than nPage. ** This can happen, for example, if we are in the middle of a transaction ** which has extended the file size and the new pages are still all held ** in cache, then an INSERT or UPDATE does a statement rollback. Some ** operating system implementations can get confused if you try to ** truncate a file to some size that is larger than it currently is, ** so detect this case and do not do the truncation. */ static int pager_truncate(Pager *pPager, int nPage){ int rc = SQLITE_OK; if( pPager->state>=PAGER_EXCLUSIVE && pPager->fd->pMethods ){ i64 currentSize, newSize; rc = sqlite3OsFileSize(pPager->fd, ¤tSize); newSize = pPager->pageSize*(i64)nPage; if( rc==SQLITE_OK && currentSize>newSize ){ rc = sqlite3OsTruncate(pPager->fd, newSize); } } if( rc==SQLITE_OK ){ pPager->dbSize = nPage; pager_truncate_cache(pPager); } return rc; } |
︙ | ︙ |