]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Always transform error code SQLITE_IOERR_NOMEM to SQLITE_NOMEM before returning....
authordanielk1977 <danielk1977@noemail.net>
Tue, 23 Sep 2008 16:41:29 +0000 (16:41 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 23 Sep 2008 16:41:29 +0000 (16:41 +0000)
FossilOrigin-Name: 046ef07261d520c9399bd8cdfdfd5281956b7a27

manifest
manifest.uuid
src/malloc.c
src/os.c
src/pager.c
test/malloc.test
test/malloc_common.tcl

index c1d09bf535a758fe67979a9eb541a124df041edb..b8589fe47fbed6af6468c9de24902b99922cc430 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enable\sthe\sLOCKING_STYLE\sextensions\sby\sdefault\son\sa\sMac.\s\sLeave\sthem\ndisabled\son\sall\sother\sposix\splatforms.\s(CVS\s5737)
-D 2008-09-23T10:23:26
+C Always\stransform\serror\scode\sSQLITE_IOERR_NOMEM\sto\sSQLITE_NOMEM\sbefore\sreturning.\sThis\swas\salready\shappening\sin\smost\splaces.\s(CVS\s5738)
+D 2008-09-23T16:41:30
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -119,7 +119,7 @@ F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
 F src/loadext.c 6581a5bbc4d74fcd46dbbcfd695a6a5417f778a2
 F src/main.c 19953a54797208b5350d5dfe3f220734cca28af0
-F src/malloc.c 6c3bcae8ee8885f1705f36306062f82a64d96118
+F src/malloc.c 31f4ca218f4b664dce45ef9c4f1fcd2929c67a42
 F src/mem1.c 5a529ff121c55ab067be14de00f86f6dcc4f4fb9
 F src/mem2.c f87e681d0d1ed8436870d089332ed0d27d885b5c
 F src/mem3.c 1594f117fde4cf11a6c16521f3f30af8d04bbe68
@@ -131,13 +131,13 @@ F src/mutex.h e52ffa1dfc6a6077e8b1823d2c2b7dfcbcf85594
 F src/mutex_os2.c 9c5637aa4c307c552566d0f0b3bd206245b54a97
 F src/mutex_unix.c 29049a61755cccddb2ee53904e6906bb7674223c
 F src/mutex_w32.c f0d21ff1f6981e5aedc56796adf3a347423ef736
-F src/os.c 543976efc0b177b40779d5fc00f709d6888d6903
+F src/os.c 74ac327e8f82f53c9461466f46f736ac5d05b97e
 F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
 F src/os_os2.c e391fc95adc744bbdcefd4d11e3066998185a0a0
 F src/os_unix.c ee778087d7b73746598947a93d2e1de3f909c9c2
 F src/os_win.c 3209dc0ed734291764393ea8d534ba0d8696a540
-F src/pager.c 131746ea47383daf89fce08e0cb09b84cffa39eb
+F src/pager.c 7a3ba14e27cf134e54f0f4f58d307de13a7ea28d
 F src/pager.h 1ef5a3f8e0b4c8b30f19c8e01d4fca2db9bb5797
 F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
 F src/pcache.c e2a4dd0ae4118c95499b97806ea26ece8d12127a
@@ -405,7 +405,7 @@ F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90
 F test/lock5.test f4eeb0400cf65c37f733cb3c74401136f8c46acd
 F test/lookaside.test 8866ea41301d74993423c99e523322fca09c259e
 F test/main.test 187a9a1b5248ed74a83838c581c15ec6023b555b
-F test/malloc.test c5a70f6b9c1def3d49b108ebb487a5d522933cfd
+F test/malloc.test 6ff6063f750d30741bc6d8c01b6ae5f94f5cf6f6
 F test/malloc3.test 094f8195fe8e409bd4da0f1d769f7745faec62c8
 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
 F test/malloc5.test c8d0f7673337e8a29afa558735ae937a0d629751
@@ -423,7 +423,7 @@ F test/mallocF.test 2d5c590ebc2fc7f0dcebdf5aa8498b9aed69107e
 F test/mallocG.test 4584d0d8ddb8009f16ca0c8bab1fa37f6358efa2
 F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
 F test/mallocI.test 6e24fe6444bd2999ccc81f984977b44c0d6e5591
-F test/malloc_common.tcl e082fe4791dad22b49d2ad3f7dcf1dcbee1a4cec
+F test/malloc_common.tcl 984baeb6c6b185e798827d1187d426acc2bc4962
 F test/manydb.test 8de36b8d33aab5ef295b11d9e95310aeded31af8
 F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
 F test/memleak.test d2d2a1ff7105d32dc3fdf691458cf6cba58c7217
@@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 309ba380d985d77419a6e185373493e043823258
-R 2c9572d754434b5bfdf3e25c7b3dbb14
-U drh
-Z 1990ad5dc1d65a186d212ae883760b71
+P bae1d5b16948705b7dec7b139e3586b4b510cbfa
+R db54292f8698b50bed3c35887f235c9d
+U danielk1977
+Z a91424ad5a1c84801c087c9549103e38
index 3fc56fe4c6b4e2571e5cfdca8848dea44eabeec3..0b3146ba1db0c67f111da2540e78fe12896c33ac 100644 (file)
@@ -1 +1 @@
-bae1d5b16948705b7dec7b139e3586b4b510cbfa
\ No newline at end of file
+046ef07261d520c9399bd8cdfdfd5281956b7a27
\ No newline at end of file
index 439405d53e8a4fa87ba101be8bcc98bccb21a6b8..65fdc26d0f82182fb9e3358f52cddfb5730c9782 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** Memory allocation functions used throughout sqlite.
 **
-** $Id: malloc.c,v 1.41 2008/09/04 04:32:49 shane Exp $
+** $Id: malloc.c,v 1.42 2008/09/23 16:41:30 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -752,7 +752,7 @@ int sqlite3ApiExit(sqlite3* db, int rc){
   ** is unsafe, as is the call to sqlite3Error().
   */
   assert( !db || sqlite3_mutex_held(db->mutex) );
-  if( db && db->mallocFailed ){
+  if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){
     sqlite3Error(db, SQLITE_NOMEM, 0);
     db->mallocFailed = 0;
     rc = SQLITE_NOMEM;
index 22ea193186e5c75b4bd6f6b55f62204abf628542..676a25fe49f7ca1836a64bb6c93682d0c650175e 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -13,7 +13,7 @@
 ** This file contains OS interface code that is common to all
 ** architectures.
 **
-** $Id: os.c,v 1.122 2008/09/02 17:18:52 danielk1977 Exp $
+** $Id: os.c,v 1.123 2008/09/23 16:41:30 danielk1977 Exp $
 */
 #define _SQLITE_OS_C_ 1
 #include "sqliteInt.h"
@@ -36,7 +36,7 @@
 **     sqlite3OsLock()
 **
 */
-#if defined(SQLITE_TEST) && (SQLITE_OS_WIN==0) && 0
+#if defined(SQLITE_TEST) && (SQLITE_OS_WIN==0)
   #define DO_OS_MALLOC_TEST if (1) {            \
     void *pTstAlloc = sqlite3Malloc(10);       \
     if (!pTstAlloc) return SQLITE_IOERR_NOMEM;  \
index 7664efa37e310c893d39f6642112038e2574a1d9..5f05c5399fb4d85e50547c73ae688093f0319284 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.493 2008/09/19 09:14:44 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.494 2008/09/23 16:41:30 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -1495,7 +1495,7 @@ static int pager_playback(Pager *pPager, int isHot){
           ** going to end up being corrupt.  It is corrupt to us, anyhow.
           ** Perhaps the next process to come along can fix it....
           */
-          rc = SQLITE_CORRUPT;
+          rc = SQLITE_CORRUPT_BKPT;
           goto end_playback;
         }
       }
index 45349e8dc51291885faf67f67810a8cbd9c08dc7..dd3969f3d1abec8943ffa85bd55fd51d575520f0 100644 (file)
@@ -16,7 +16,7 @@
 # to see what happens in the library if a malloc were to really fail
 # due to an out-of-memory situation.
 #
-# $Id: malloc.test,v 1.66 2008/09/22 17:22:20 danielk1977 Exp $
+# $Id: malloc.test,v 1.67 2008/09/23 16:41:30 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -39,7 +39,6 @@ sqlite3_memdebug_dump $testdir
 puts "Memory dump to file memdump.txt..."
 sqlite3_memdebug_dump memdump.txt
 
-
 ifcapable bloblit&&subquery {
   do_malloc_test 1 -tclprep {
     db close
@@ -346,9 +345,14 @@ if {$tcl_platform(platform)!="windows"} {
   } -tclbody {
     sqlite3 db test.db
     sqlite3_extended_result_codes db 1
-    db eval {
-      SELECT * FROM t1;
-    }  
+
+    # If an out-of-memory occurs within a call to a VFS layer function during
+    # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit
+    # [5668] for details.
+    set rc [catch {db eval { SELECT * FROM t1 }} msg]
+    if {$msg eq "database disk image is malformed"} { set msg "out of memory" }
+    if {$rc} { error $msg }
+    set msg
   }
 }
 
@@ -568,8 +572,14 @@ ifcapable {pager_pragmas} {
     set ::sqlite_io_error_pending 10
     catch {db eval {ROLLBACK}} msg
 
-  } -sqlbody {
-    SELECT * FROM abc LIMIT 10;
+  } -tclbody {
+    # If an out-of-memory occurs within a call to a VFS layer function during
+    # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit
+    # [5668] for details.
+    set rc [catch {db eval { SELECT * FROM abc LIMIT 10 }} msg]
+    if {$msg eq "database disk image is malformed"} { set msg "out of memory" }
+    if {$rc} { error $msg }
+    set msg
   } -cleanup {
     set e [db eval {PRAGMA integrity_check}]
     if {$e ne "ok"} {error $e}
index 44985ae865266d065dcfb269ba48d09f28989a14..90f6b06726a850383645e77cb6cfa098383d6c85 100644 (file)
@@ -12,7 +12,7 @@
 # This file contains common code used by many different malloc tests
 # within the test suite.
 #
-# $Id: malloc_common.tcl,v 1.21 2008/08/04 20:13:27 drh Exp $
+# $Id: malloc_common.tcl,v 1.22 2008/09/23 16:41:30 danielk1977 Exp $
 
 # If we did not compile with malloc testing enabled, then do nothing.
 #
@@ -147,7 +147,6 @@ proc do_malloc_test {tn args} {
         } elseif {
           [info command db]=="" || 
           [db errorcode]==7 ||
-          [db errorcode]==[expr 10+(12<<8)] ||
           $msg=="out of memory"
         } {
           set v2 1