Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix bugs in temp database handling introduced by the prevous check-in. (CVS 4288) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
300038be9368556a29efce7cf3657fab |
User & Date: | drh 2007-08-24 16:29:24.000 |
Context
2007-08-24
| ||
17:52 | Rework the win32 OS driver to use malloc()/free() directly rather than going through the SQLite memory allocation layer. With this change, the complete quick.test script now runs on windows. There are a few errors, but no segfaults. Progress. (CVS 4289) (check-in: 75aad31698 user: drh tags: trunk) | |
16:29 | Fix bugs in temp database handling introduced by the prevous check-in. (CVS 4288) (check-in: 300038be93 user: drh tags: trunk) | |
16:08 | Remove nRef and vfsMutex from the sqlite3_vfs structure. Omit the sqlite3_vfs_release() interface. Less memory allocated for a pager in the common case where the size of the pathname is less than MAX_PATH. (CVS 4287) (check-in: b8451da378 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.376 2007/08/24 16:29:24 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* |
︙ | ︙ | |||
1804 1805 1806 1807 1808 1809 1810 | /* ** Open a temporary file. ** ** Write the file descriptor into *fd. Return SQLITE_OK on success or some ** other error code if we fail. The OS will automatically delete the temporary ** file when it is closed. ** | > | > > | | < | | > > > > > < < < | < < | 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 | /* ** Open a temporary file. ** ** Write the file descriptor into *fd. Return SQLITE_OK on success or some ** other error code if we fail. The OS will automatically delete the temporary ** file when it is closed. ** ** If zFilename is 0, then an appropriate temporary filename is ** generated automatically and SQLITE_OPEN_SUBJOURNAL is passed to ** the OS layer as the file type. ** ** If zFilename is not 0, SQLITE_OPEN_TEMP_DB is passed as the file type. */ static int sqlite3PagerOpentemp( sqlite3_vfs *pVfs, sqlite3_file *pFile, char *zFilename ){ int rc; int flags = ( SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE| SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_DELETEONCLOSE ); char *zFree = 0; if( zFilename==0 ){ zFree = (char *)sqlite3_malloc(pVfs->mxPathname); if( !zFree ){ return SQLITE_NOMEM; } zFilename = zFree; flags |= SQLITE_OPEN_SUBJOURNAL; rc = sqlite3OsGetTempName(pVfs, zFilename); if( rc!=SQLITE_OK ){ sqlite3_free(zFree); return rc; } }else{ flags |= SQLITE_OPEN_TEMP_DB; } #ifdef SQLITE_TEST sqlite3_opentemp_count++; /* Used for testing and analysis only */ #endif rc = sqlite3OsOpen(pVfs, zFilename, pFile, flags, 0); assert( rc!=SQLITE_OK || pFile->pMethods ); sqlite3_free(zFree); return rc; } /* ** Create a new page cache and put a pointer to the page cache in *ppPager. ** The file to be cached need not exist. The file is not locked until |
︙ | ︙ | |||
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 | if( strcmp(zFilename,":memory:")==0 ){ memDb = 1; zPathname[0] = 0; }else #endif { rc = sqlite3OsFullPathname(pVfs, zFilename, zPathname); if( rc!=SQLITE_OK ){ sqlite3_free(zPathname); return rc; } | > > > > < < < < | 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 | if( strcmp(zFilename,":memory:")==0 ){ memDb = 1; zPathname[0] = 0; }else #endif { rc = sqlite3OsFullPathname(pVfs, zFilename, zPathname); } }else{ rc = sqlite3OsGetTempName(pVfs, zPathname); } if( rc!=SQLITE_OK ){ sqlite3_free(zPathname); return rc; } nPathname = strlen(zPathname); /* Allocate memory for the pager structure */ pPager = sqlite3MallocZero( sizeof(*pPager) + /* Pager structure */ journalFileSize + /* The journal file structure */ pVfs->szOsFile * 2 + /* The db and stmt journal files */ |
︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 | pPager->zJournal = &pPager->zDirectory[nPathname+1]; pPager->pVfs = pVfs; memcpy(pPager->zFilename, zPathname, nPathname+1); sqlite3_free(zPathname); /* Open the pager file. */ | | | 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | pPager->zJournal = &pPager->zDirectory[nPathname+1]; pPager->pVfs = pVfs; memcpy(pPager->zFilename, zPathname, nPathname+1); sqlite3_free(zPathname); /* Open the pager file. */ if( zFilename && zFilename[0] && !memDb ){ if( nPathname>(pVfs->mxPathname - sizeof("-journal")) ){ rc = SQLITE_CANTOPEN; }else{ /*** FIXME: Might need to be SQLITE_OPEN_TEMP_DB. Need to pass in **** a flag from higher up. ****/ int oflag = |
︙ | ︙ |
Changes to test/pager.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is page cache subsystem. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is page cache subsystem. # # $Id: pager.test,v 1.30 2007/08/24 16:29:24 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl if {[info commands pager_open]!=""} { db close |
︙ | ︙ | |||
405 406 407 408 409 410 411 | do_test pager-4.6.1 { pager_close [pager_open ptf2.db -15] } {} # Test truncate on an in-memory database is Ok. ifcapable memorydb { do_test pager-4.6.2 { | < | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | do_test pager-4.6.1 { pager_close [pager_open ptf2.db -15] } {} # Test truncate on an in-memory database is Ok. ifcapable memorydb { do_test pager-4.6.2 { set ::p2 [pager_open :memory: 10] pager_truncate $::p2 5 } {} do_test pager-4.6.3 { for {set i 1} {$i<5} {incr i} { set p [page_get $::p2 $i] page_write $p "Page $i" |
︙ | ︙ |