Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Better handle a malloc() failure in sqlite3PagerSetPagesize(). (CVS 4332) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
41550d87c9395ab2fec5993655865e29 |
User & Date: | danielk1977 2007-08-30 10:07:39.000 |
Context
2007-08-30
| ||
10:49 | Fix some problems in async2.test. No code changes. (CVS 4333) (check-in: d80d87c239 user: danielk1977 tags: trunk) | |
10:07 | Better handle a malloc() failure in sqlite3PagerSetPagesize(). (CVS 4332) (check-in: 41550d87c9 user: danielk1977 tags: trunk) | |
08:27 | Fix a bug in a test file causing malloc5.test to crash. (CVS 4331) (check-in: ab09967bd2 user: danielk1977 tags: trunk) | |
Changes
Changes to src/pragma.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2003 April 6 ** ** 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 contains code used to implement the PRAGMA command. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2003 April 6 ** ** 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 contains code used to implement the PRAGMA command. ** ** $Id: pragma.c,v 1.148 2007/08/30 10:07:39 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* Ignore this whole file if pragmas are disabled */ #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) |
︙ | ︙ | |||
333 334 335 336 337 338 339 | */ if( sqlite3StrICmp(zLeft,"page_size")==0 ){ Btree *pBt = pDb->pBt; if( !zRight ){ int size = pBt ? sqlite3BtreeGetPageSize(pBt) : 0; returnSingleInt(pParse, "page_size", size); }else{ | > > > | > > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | */ if( sqlite3StrICmp(zLeft,"page_size")==0 ){ Btree *pBt = pDb->pBt; if( !zRight ){ int size = pBt ? sqlite3BtreeGetPageSize(pBt) : 0; returnSingleInt(pParse, "page_size", size); }else{ /* Malloc may fail when setting the page-size, as there is an internal ** buffer that the pager module resizes using sqlite3_realloc(). */ if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, atoi(zRight), -1) ){ db->mallocFailed = 1; } } }else /* ** PRAGMA [database.]max_page_count ** PRAGMA [database.]max_page_count=N ** |
︙ | ︙ |
Changes to test/shared_err.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # The focus of the tests in this file are IO errors that occur in a shared # cache context. What happens to connection B if one connection A encounters # an IO-error whilst reading or writing the file-system? # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # # The focus of the tests in this file are IO errors that occur in a shared # cache context. What happens to connection B if one connection A encounters # an IO-error whilst reading or writing the file-system? # # $Id: shared_err.test,v 1.16 2007/08/30 10:07:39 danielk1977 Exp $ proc skip {args} {} set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl |
︙ | ︙ | |||
428 429 430 431 432 433 434 435 436 437 438 | } {1} db2 close } do_test shared_malloc-8.X { # Test that one or more queries were aborted due to the malloc() failure. expr $::aborted>=1 } {1} catch {db close} sqlite3_enable_shared_cache $::enable_shared_cache finish_test | > > > > > > > > > > > > > > > > > > > > > > > > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | } {1} db2 close } do_test shared_malloc-8.X { # Test that one or more queries were aborted due to the malloc() failure. expr $::aborted>=1 } {1} # This test is designed to catch a specific bug that was present during # development of 3.5.0. If a malloc() failed while setting the page-size, # a buffer (Pager.pTmpSpace) was being freed. This could cause a seg-fault # later if another connection tried to use the pager. # # This test will crash 3.4.2. # do_malloc_test shared_err-9 -tclprep { sqlite3 db2 test.db } -sqlbody { PRAGMA page_size = 4096; PRAGMA page_size = 1024; } -cleanup { db2 eval { CREATE TABLE abc(a, b, c); BEGIN; INSERT INTO abc VALUES(1, 2, 3); ROLLBACK; } db2 close } catch {db close} catch {db2 close} sqlite3_enable_shared_cache $::enable_shared_cache finish_test |