-C Remove\sunnecessary\ssqlite3MallocDisallow()\sthat\swas\spreventing\swin32\sfrom\nrunning.\s(CVS\s4285)
-D 2007-08-24T11:43:37
+C Select\sthe\sdefault\spage\ssize\sfor\snew\sdatabases\sbased\son\sthe\ssector-size\sand\sIOCAP\sflags.\s(CVS\s4286)
+D 2007-08-24T11:52:29
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
-F src/btree.c fe9d292cee1a7fee1e5834ecaa3eb2103f7398bc
+F src/btree.c dbb8ec48e619fc4900f42cafffc7de90b4b21250
F src/btree.h 76c89673981cb77575300c0b78a76eaa00a28743
F src/btreeInt.h 7fc6e51dc3d4bbed15639a8ea1aae737631d6670
F src/build.c bc7406e2ea5bfa8276ee1abeae1db27a98fd0b33
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 1cb94dd33d38e01de82d77bef107c7f3323463ec
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c a46c807f6c00d8172ea7f17b8bfd2c870d2e9d98
+F src/pager.c 6c9622a14f9778efb575072737c7f68c1ab95fe2
F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
F src/sqlite.h.in 09a5256ee80dfc7cb4353739f78e4267be323574
F src/sqlite3ext.h 9a26028378c288af500d8b94ed079666fed5806b
F src/sqliteInt.h ea7a14a33c0a03479d2d98ce9ac83fe5e7f4bb55
-F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa
+F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
F src/table.c c725e47f6f3092b9a7b569fc58e408e2173ee008
F src/tclsqlite.c d76af53f45c9e9f7f7d39531fa4c7bee7d0adad6
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
F src/vdbe.h 001c5b257567c1d3de7feb2203aac71d0d7b16a3
F src/vdbeInt.h 39fb069ce04137545ca0bc790f80ddc64a8c99d9
F src/vdbeapi.c bdd0aea216744482dd1b7fab56de18ba5b6fbdf4
-F src/vdbeaux.c b040c3787ea1c32ba025b1c5822553469abe4efa
+F src/vdbeaux.c 692f0a7622057096476da552f1bbd88f59b852c6
F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 896fa3f8df9d2661eb15c7ce361857741b447268
F test/corrupt2.test 572f8df0303d0ce63ddad5c5c9101a83a345ae46
F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
F test/crash.test 24020168cc42977a4dd83ff78d2b5eb6577715db
-F test/crash2.test 423c6ec404d15b7d7d0e40aef0a26740cce6075f
-F test/crash3.test 96eee2301b000264d355591fe650a9ad5ac01be9
+F test/crash2.test 26d7a4c5520201e5de2c696ea51ab946b59dc0e9
+F test/crash3.test 0b09687ae1a3ccbcefdfaeb4b963e26e36255d76
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test b562aba1a65be49935fc43a04e90766e39231804
F test/date.test 4834d022b2fa5982cafed20938f7523a7475e4cd
F test/insert4.test 1e27f0a3e5670d5f03c1636f699aa44270945bca
F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2
F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30
-F test/io.test 689a16c1a4c9e42e132a02632a48fbe8c7b5cab6
+F test/io.test 29c016c1cc559520f8b76ed23e40d363a2c269d2
F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d
F test/ioerr2.test f938eadb12108048813869b86beee4a2f98e34b8
F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P bdf5cb8d25d93d48220ce46acad2ccf967a87843
-R d4ea6f4d31089ad72edb88e7f5cbf0e5
-U drh
-Z dae02e174444912f0bfaae25113ff79b
+P eb6c98fc1097b327453d7e8ec8877101ea8187c3
+R 33f9af4f9be6e647c8b59a027b74b510
+U danielk1977
+Z ea44b5abf05f45dd9f144b230dd5f4ae
-eb6c98fc1097b327453d7e8ec8877101ea8187c3
\ No newline at end of file
+13dda2e8e879835c21e539ba3ff8f96face1af4c
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.411 2007/08/24 03:51:33 drh Exp $
+** $Id: btree.c,v 1.412 2007/08/24 11:52:29 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
pBt->pageSize = get2byte(&zDbHeader[16]);
if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE
|| ((pBt->pageSize-1)&pBt->pageSize)!=0 ){
- pBt->pageSize = SQLITE_DEFAULT_PAGE_SIZE;
+ pBt->pageSize = sqlite3PagerSetPagesize(pBt->pPager, 0);
pBt->maxEmbedFrac = 64; /* 25% */
pBt->minEmbedFrac = 32; /* 12.5% */
pBt->minLeafFrac = 32; /* 12.5% */
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.373 2007/08/24 08:15:54 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.374 2007/08/24 11:52:29 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
** last page is released using sqlite3PagerUnref().
**
** If zFilename is NULL then a randomly-named temporary file is created
-** and used as the file to be cached. The file will be deleted
+** and
** automatically when it is closed.
**
** If zFilename is ":memory:" then all information is held in cache.
int useJournal = (flags & PAGER_OMIT_JOURNAL)==0;
int noReadlock = (flags & PAGER_NO_READLOCK)!=0;
int journalFileSize = sqlite3JournalSize(pVfs);
+ int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size. */
/* The default return is a NULL pointer */
*ppPager = 0;
int fout = 0;
rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, oflag, &fout);
readOnly = (fout&SQLITE_OPEN_READONLY);
+
+ /* If the file was successfully opened for read/write access,
+ ** choose a default page size in case we have to create the
+ ** database file. The default page size is the maximum of:
+ **
+ ** + SQLITE_DEFAULT_PAGE_SIZE,
+ ** + The value returned by sqlite3OsSectorSize()
+ ** + The largest page size that can be written atomically.
+ */
+ if( rc==SQLITE_OK && !readOnly ){
+ int iSectorSize = sqlite3OsSectorSize(pPager->fd);
+ if( nDefaultPage<iSectorSize ){
+ nDefaultPage = iSectorSize;
+ }
+#ifdef SQLITE_ENABLE_ATOMIC_WRITE
+ {
+ int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);
+ int ii;
+ assert(SQLITE_IOCAP_ATOMIC512==(512>>8));
+ assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));
+ assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);
+ for(ii=nDefaultPage; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){
+ if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ) nDefaultPage = ii;
+ }
+ }
+#endif
+ if( nDefaultPage>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
+ nDefaultPage = SQLITE_MAX_DEFAULT_PAGE_SIZE;
+ }
+ }
}
}
}
}
if( pPager && rc==SQLITE_OK ){
- pPager->pTmpSpace = (char *)sqlite3_malloc(SQLITE_DEFAULT_PAGE_SIZE);
+ pPager->pTmpSpace = (char *)sqlite3_malloc(nDefaultPage);
}
/* If an error occured in either of the blocks above.
/* pPager->stmtInUse = 0; */
/* pPager->nRef = 0; */
pPager->dbSize = memDb-1;
- pPager->pageSize = SQLITE_DEFAULT_PAGE_SIZE;
+ pPager->pageSize = nDefaultPage;
/* pPager->stmtSize = 0; */
/* pPager->stmtJSize = 0; */
/* pPager->nPage = 0; */
** and returned.
*/
int sqlite3PagerSetPagesize(Pager *pPager, int pageSize){
- assert( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE );
- if( !pPager->memDb && pPager->nRef==0 ){
+ assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );
+ if( pageSize && !pPager->memDb && pPager->nRef==0 ){
pagerEnter(pPager);
pager_reset(pPager);
pPager->pageSize = pageSize;
+ setSectorSize(pPager);
pagerLeave(pPager);
sqlite3_free(pPager->pTmpSpace);
pPager->pTmpSpace = sqlite3_malloc(pageSize);
pPager->pDirty = 0;
/* Sync the database file. */
- if( !pPager->noSync ){
+ if( !pPager->noSync ){
rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
}
IOTRACE(("DBSYNC %p\n", pPager))
**
** This file defines various limits of what SQLite can process.
**
-** @(#) $Id: sqliteLimit.h,v 1.1 2007/06/19 15:23:48 drh Exp $
+** @(#) $Id: sqliteLimit.h,v 1.2 2007/08/24 11:52:29 danielk1977 Exp $
*/
/*
# define SQLITE_DEFAULT_PAGE_SIZE 1024
#endif
+/*
+** Ordinarily, if no value is explicitly provided, SQLite creates databases
+** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
+** device characteristics (sector-size and atomic write() support),
+** SQLite may choose a larger value. This constant is the maximum value
+** SQLite will choose on it's own.
+*/
+#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
+# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
+#endif
+
/* Maximum page size. The upper bound on this value is 32768. This a limit
** imposed by the necessity of storing the value in a 2-byte unsigned integer
** and the fact that the page size must be a power of 2.
}
}
-
- /* Sync the master journal file. */
+ /* Sync the master journal file. If the IOCAP_SEQUENTIAL device
+ ** flag is set this is not required.
+ */
zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
if( (needSync
+ && (0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL))
&& (rc=sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))!=SQLITE_OK) ){
sqlite3OsCloseFree(pMaster);
sqlite3OsDelete(pVfs, zMaster, 0);
# specifically, the tests in this file verify this functionality
# for storage mediums with various sector sizes.
#
-# $Id: crash2.test,v 1.4 2007/04/06 21:42:22 drh Exp $
+# $Id: crash2.test,v 1.5 2007/08/24 11:52:29 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
return
}
+db close
+
# This test is designed to check that the crash-test infrastructure
# can create files that do not consist of an integer number of
# simulated disk blocks (i.e. 3KB file using 2KB disk blocks).
do_test crash2-1.1 {
crashsql -delay 500 -file test.db -blocksize 2048 {
PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
BEGIN;
CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;
# of different seeds for the random number generator.
#
do_test crash2-1.2.$ii {
- crashsql -file test.db -blocksize 2048 "
+ crashsql -file test.db -blocksize 2048 [subst {
[string repeat {SELECT random();} $ii]
CREATE TABLE hij(h, i, j);
- "
+ }]
+ sqlite3 db test.db
db eval {PRAGMA integrity_check}
} {ok}
}
for {set i 1} {$i < 30} {incr i} {
set sig [signature]
set sector [expr 1024 * 1<<($i%4)]
- do_test crash-2.$i.1 {
+ db close
+ do_test crash2-2.$i.1 {
crashsql -blocksize $sector -delay [expr $i%5 + 1] -file test.db-journal "
BEGIN;
SELECT random() FROM abc LIMIT $i;
COMMIT;
"
} {1 {child process exited abnormally}}
- do_test crash-2.$i.2 {
+ do_test crash2-2.$i.2 {
+ sqlite3 db test.db
signature
} $sig
}
for {set i 1} {$i < 10} {incr i} {
set sig [signature]
set sector [expr 1024 * 1<<($i%4)]
- do_test crash-3.$i.1 {
+ db close
+ do_test crash2-3.$i.1 {
crashsql -blocksize $sector -file test.db "
BEGIN;
SELECT random() FROM abc LIMIT $i;
COMMIT;
"
} {1 {child process exited abnormally}}
- do_test crash-3.$i.2 {
+ do_test crash2-3.$i.2 {
+ sqlite3 db test.db
signature
} $sig
}
# databases after crashes when using the special IO modes triggered
# by device IOCAP flags.
#
-# $Id: crash3.test,v 1.2 2007/08/24 08:15:54 danielk1977 Exp $
+# $Id: crash3.test,v 1.3 2007/08/24 11:52:29 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
sqlite3 db test.db
do_test crash3-1.$tn.1 {
execsql {
+ PRAGMA page_size = 1024;
BEGIN;
CREATE TABLE abc(a, b, c);
INSERT INTO abc VALUES(1, 2, 3);
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
-# $Id: io.test,v 1.5 2007/08/23 16:27:21 danielk1977 Exp $
+# $Id: io.test,v 1.6 2007/08/24 11:52:29 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# IOCAP_SAFE_APPEND device capability flag is set (fewer
# fsync() calls on the journal file, no need to set nRec
# field in the single journal header).
+#
+# io-5.* - Test that the default page size is selected and used
+# correctly.
#
set ::nWrite 0
do_test io-2.7.1 {
execsql {
ATTACH 'test2.db' AS aux;
+ PRAGMA aux.page_size = 1024;
CREATE TABLE aux.abc2(a, b);
BEGIN;
INSERT INTO abc VALUES(9, 10);
file size test.db-journal
} [expr 1024 + (1024+8)*41]
+#----------------------------------------------------------------------
+# Test cases io-5.* test that the default page size is selected and
+# used correctly.
+#
+set tn 0
+foreach {char sectorsize pgsize} {
+ {} 512 1024
+ {} 1024 1024
+ {} 2048 2048
+ {} 8192 8192
+ {} 16384 8192
+ {atomic} 512 8192
+ {atomic512} 512 1024
+ {atomic2K} 512 2048
+ {atomic2K} 4096 4096
+ {atomic2K atomic} 512 8192
+ {atomic64K} 512 1024
+} {
+ incr tn
+ db close
+ file delete -force test.db test.db-journal
+ sqlite3_simulate_device -char $char -sectorsize $sectorsize
+ sqlite3 db test.db
+ do_test io-5.$tn {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ }
+ expr {[file size test.db]/2}
+ } $pgsize
+}
+
sqlite3_simulate_device -char {} -sectorsize 0
finish_test