diff --git a/manifest b/manifest index ba52ca7541..0ed9054d08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\ssqlite3_bind_zeroblob().\sOnly\sinclude\ssqlite3Utf8To8\sin\sbuilds\sif\sSQLITE_DEBUG\sis\sdefined.\s(CVS\s4363) -D 2007-09-01T11:04:26 +C Remove\sthe\ssyncOk\sargument\sto\spager_recycle.\sNow\sthat\ssqlite3_memory_release\suses\sa\sglobal\slru\slist\sof\spage,\sit\sis\sno\slonger\srequired.\s(CVS\s4364) +D 2007-09-01T16:16:15 F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -116,11 +116,11 @@ F src/os_os2.c 8769301bff502de642ad2634cedcb77d967ce199 F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 -F src/os_unix.c 9043705193a53f9ba8aca9284b5788ce6cda0010 +F src/os_unix.c 3b1b9c6d1b09b9cddd19287e6f842d712bf07602 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c ce778c06afcbfd120ede237befece4655e83c8d0 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c 9b898267587e660a1eed124e95c8fa48b2d7966c +F src/pager.c ac52bb1e22f7ce203e1eec8fa666be2cdd695ee9 F src/pager.h f204c1a9fe0574953fba89c56d9d9bd1ddfa604a F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590 F src/pragma.c 363e548dafb52327face8d99757ab56a7b1c1b26 @@ -401,7 +401,7 @@ F test/select5.test 0b47058d3e916c1fc9fe81f44b438e02bade21ce F test/select6.test 399f14b9ba37b768afe5d2cd8c12e4f340a69db8 F test/select7.test 45606f9afbe2056058c7d75fc33e5092e65ec770 F test/server1.test f5b790d4c0498179151ca8a7715a65a7802c859c -F test/shared.test 08b30d5f1939efff0517e7ff8ec7b74ad31c151b +F test/shared.test 90ab9f5492168bf7ee5c0c3b3bc0d0d287cebc00 F test/shared2.test 0ee9de8964d70e451936a48c41cb161d9134ccf4 F test/shared3.test 01e3e124dbb3859788aabc7cfb82f7ea04421749 F test/shared_err.test 68455ec2f7f250d2e89f17b0c98ecf94009e6800 @@ -411,7 +411,7 @@ F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded F test/speed3.test 55e039b34d505aa442cee415f83c451ae28b3123 -F test/sqllimits1.test 573788829a361c2a115c46e2424183d0525ba6b6 +F test/sqllimits1.test b4b2afd7d75622fd183d4b7875f1fcfed0cf3f34 F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797 F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4 F test/substr.test 9f26cfca74397b26ab217fb838c3d0549eb4bcf3 @@ -488,7 +488,7 @@ F test/where2.test 3249d426b3fc7a106713d784e1628307fc308d2e F test/where3.test 0a30fe9808b0fa01c46d0fcf4fac0bf6cf75bb30 F test/where4.test f80207a4ea6504f3d0962f3ecebc7db274ea50c0 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 -F test/zeroblob.test d4d36287b07332d5214fa3ffea20ac8d704d4e6a +F test/zeroblob.test 987cc5e565dc0a905eaf87897ad958855d755f69 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/lemon.c 0ab4cca47950da4dc04cf957db0c0ed54b464aa9 @@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 7571345d2078fb52029f9b9924d833ec36d443e6 -R 0c7389a2063dc14d52226e56b9777f30 +P fde6142b7bb33198b3d6b65cfbddfad61694b1fb +R 5e0055f11989e9e05101c27a19df02f2 U danielk1977 -Z cf841d7dca9b6d93f2cc7d05120bc95f +Z 10eb73331132f5b8e253fba21e5676db diff --git a/manifest.uuid b/manifest.uuid index cfdb898387..47282e2c2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fde6142b7bb33198b3d6b65cfbddfad61694b1fb \ No newline at end of file +fb27692ab10b22851b265348bb6b3e1dececd60f \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 46a176182e..f4a9ffe158 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2484,6 +2484,13 @@ static int unixGetTempName(sqlite3_vfs *pVfs, char *zBuf){ int i, j; struct stat buf; const char *zDir = "."; + + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ + SimulateIOError( return SQLITE_ERROR ); + azDirs[0] = sqlite3_temp_directory; for(i=0; imxPathname==MAX_PATHNAME ); zOut[MAX_PATHNAME-1] = '\0'; if( zPath[0]=='/' ){ diff --git a/src/pager.c b/src/pager.c index 2559a4cdd6..13fbd39c85 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.383 2007/08/31 18:34:59 drh Exp $ +** @(#) $Id: pager.c,v 1.384 2007/09/01 16:16:15 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -2995,11 +2995,15 @@ static int hasHotJournal(Pager *pPager){ ** This routine may return SQLITE_IOERR, SQLITE_FULL or SQLITE_OK. It ** does not set the pPager->errCode variable. */ -static int pager_recycle(Pager *pPager, int syncOk, PgHdr **ppPg){ +static int pager_recycle(Pager *pPager, PgHdr **ppPg){ PgHdr *pPg; *ppPg = 0; + /* It is illegal to call this function unless the pager object + ** pointed to by pPager has at least one free page (page with nRef==0). + */ assert(!MEMDB); + assert(pPager->lru.pFirst); /* Find a page to recycle. Try to locate a page that does not ** require us to do an fsync() on the journal. @@ -3011,7 +3015,7 @@ static int pager_recycle(Pager *pPager, int syncOk, PgHdr **ppPg){ ** very slow operation, so we work hard to avoid it. But sometimes ** it can't be helped. */ - if( pPg==0 && pPager->lru.pFirst && syncOk && !MEMDB){ + if( pPg==0 && pPager->lru.pFirst){ int iDc = sqlite3OsDeviceCharacteristics(pPager->fd); int rc = syncJournal(pPager); if( rc!=0 ){ @@ -3034,9 +3038,6 @@ static int pager_recycle(Pager *pPager, int syncOk, PgHdr **ppPg){ } pPg = pPager->lru.pFirst; } - if( pPg==0 ){ - return SQLITE_OK; - } assert( pPg->nRef==0 ); @@ -3136,7 +3137,7 @@ int sqlite3PagerReleaseMemory(int nReq){ assert(!pPg->needSync || pPg==pPager->lru.pFirst); assert(pPg->needSync || pPg==pPager->lru.pFirstSynced); - rc = pager_recycle(pPager, 1, &pRecycled); + rc = pager_recycle(pPager, &pRecycled); assert(pRecycled==pPg || rc!=SQLITE_OK); if( rc==SQLITE_OK ){ /* We've found a page to free. At this point the page has been @@ -3433,7 +3434,7 @@ static int pagerAllocatePage(Pager *pPager, PgHdr **ppPg){ pPager->nPage++; }else{ /* Recycle an existing page with a zero ref-count. */ - rc = pager_recycle(pPager, 1, &pPg); + rc = pager_recycle(pPager, &pPg); if( rc==SQLITE_BUSY ){ rc = SQLITE_IOERR_BLOCKED; } diff --git a/test/shared.test b/test/shared.test index 0985d92f11..bbacd11977 100644 --- a/test/shared.test +++ b/test/shared.test @@ -9,7 +9,7 @@ # #*********************************************************************** # -# $Id: shared.test,v 1.25 2007/08/03 07:33:10 danielk1977 Exp $ +# $Id: shared.test,v 1.26 2007/09/01 16:16:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -863,6 +863,46 @@ do_test shared-$av.11.11 { db2 close } {} +# This tests that if it is impossible to free any pages, SQLite will +# exceed the limit set by PRAGMA cache_size. +do_test shared-$av.12.1 { + file delete -force test.db test.db-journal + sqlite3 db test.db + execsql { + PRAGMA cache_size = 10; + PRAGMA cache_size; + } +} {10} +do_test shared-$av.12.2 { + set ::db_handles [list] + for {set i 1} {$i < 15} {incr i} { + lappend ::db_handles db$i + sqlite3 db$i test.db + execsql "CREATE TABLE db${i}(a, b, c)" db$i + execsql "INSERT INTO db${i} VALUES(1, 2, 3)" + } +} {} +proc nested_select {handles} { + [lindex $handles 0] eval "SELECT * FROM [lindex $handles 0]" { + lappend ::res $a $b $c + if {[llength $handles]>1} { + nested_select [lrange $handles 1 end] + } + } +} +do_test shared-$av.12.3 { + set ::res [list] + nested_select $::db_handles + set ::res +} [string range [string repeat "1 2 3 " [llength $::db_handles]] 0 end-1] + +do_test shared-$av.12.X { + db close + foreach h $::db_handles { + $h close + } +} {} + } sqlite3_enable_shared_cache $::enable_shared_cache diff --git a/test/sqllimits1.test b/test/sqllimits1.test index 80904ccc67..7184c9178b 100644 --- a/test/sqllimits1.test +++ b/test/sqllimits1.test @@ -12,7 +12,7 @@ # This file contains tests to verify that the limits defined in # sqlite source file limits.h are enforced. # -# $Id: sqllimits1.test,v 1.13 2007/09/01 11:04:28 danielk1977 Exp $ +# $Id: sqllimits1.test,v 1.14 2007/09/01 16:16:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -101,6 +101,12 @@ do_test sqllimits-1.10 { catchsql { SELECT strftime($::str, '2003-10-31') } } {1 {string or blob too big}} +do_test sqllimits-1.11 { + set ::str1 [string repeat A [expr {$SQLITE_MAX_LENGTH - 10}]] + set ::str2 [string repeat B [expr {$SQLITE_MAX_LENGTH - 10}]] + catchsql { SELECT $::str1 || $::str2 } +} {1 {string or blob too big}} + #-------------------------------------------------------------------- # Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit # is enforced. @@ -195,6 +201,49 @@ do_test sqllimits1-3.6 { } } {0 7} +# Now check the response of the library to opening a file larger than +# the current max_page_count value. The response is to change the +# internal max_page_count value to match the actual size of the file. +do_test sqllimits1-3.7.1 { + execsql { + PRAGMA max_page_count = 1000000; + CREATE TABLE abc(a, b, c); + INSERT INTO abc VALUES(1, 2, 3); + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc; + INSERT INTO abc SELECT a, b, c FROM abc; + INSERT INTO abc SELECT b, a, c FROM abc; + INSERT INTO abc SELECT c, b, a FROM abc; + } + expr [file size test.db] / 1024 +} {1691} +do_test sqllimits1-3.7.2 { + db close + sqlite3 db test.db + execsql { + PRAGMA max_page_count = 1000; + } + execsql { + SELECT count(*) FROM sqlite_master; + } +} {6} +do_test sqllimits1-3.7.3 { + execsql { + PRAGMA max_page_count; + } +} {1691} +do_test sqllimits1-3.7.4 { + execsql { + DROP TABLE abc; + } +} {} + #-------------------------------------------------------------------- # Test cases sqllimits1-4.* test the SQLITE_MAX_COLUMN limit. # diff --git a/test/zeroblob.test b/test/zeroblob.test index 04a668ed9f..4232693464 100644 --- a/test/zeroblob.test +++ b/test/zeroblob.test @@ -13,7 +13,7 @@ # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(), # and the built-in zeroblob() SQL function. # -# $Id: zeroblob.test,v 1.7 2007/09/01 11:04:28 danielk1977 Exp $ +# $Id: zeroblob.test,v 1.8 2007/09/01 16:16:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -190,4 +190,14 @@ do_test zeroblob-7.3 { sqlite3_finalize $::STMT } {SQLITE_OK} +# Test that MakeRecord can handle a value with some real content +# and a zero-blob tail. +# +do_test zeroblob-8.1 { + llength [execsql { + SELECT 'hello' AS a, zeroblob(10) as b from t1 ORDER BY a, b; + }] +} {8} + + finish_test