185c23c61Sdrh# 2005 September 19 285c23c61Sdrh# 385c23c61Sdrh# The author disclaims copyright to this source code. In place of 485c23c61Sdrh# a legal notice, here is a blessing: 585c23c61Sdrh# 685c23c61Sdrh# May you do good and not evil. 785c23c61Sdrh# May you find forgiveness for yourself and forgive others. 885c23c61Sdrh# May you share freely, never taking more than you give. 985c23c61Sdrh# 1085c23c61Sdrh#************************************************************************* 1185c23c61Sdrh# This file implements regression tests for SQLite library. The 1285c23c61Sdrh# focus of this script is testing the ATTACH statement and 1385c23c61Sdrh# specifically out-of-memory conditions within that command. 1485c23c61Sdrh# 15*d207d808Sdanielk1977# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $ 1685c23c61Sdrh# 1785c23c61Sdrh 1885c23c61Sdrhset testdir [file dirname $argv0] 1985c23c61Sdrhsource $testdir/tester.tcl 2085c23c61Sdrh 215a8f9374Sdanielk1977ifcapable !memdebug||!attach { 22da57895fSdrh finish_test 23da57895fSdrh return 24da57895fSdrh} 25da57895fSdrh 26222a757dSdanielk1977source $testdir/malloc_common.tcl 2785c23c61Sdrh 2885c23c61Sdrhdo_malloc_test attachmalloc-1 -tclprep { 2985c23c61Sdrh db close 3085c23c61Sdrh for {set i 2} {$i<=4} {incr i} { 3185c23c61Sdrh file delete -force test$i.db 3285c23c61Sdrh file delete -force test$i.db-journal 3385c23c61Sdrh } 3485c23c61Sdrh} -tclbody { 3585c23c61Sdrh if {[catch {sqlite3 db test.db}]} { 3685c23c61Sdrh error "out of memory" 3785c23c61Sdrh } 38e9d1c720Sdrh sqlite3_db_config_lookaside db 0 0 0 39ae72d982Sdanielk1977 sqlite3_extended_result_codes db 1 4085c23c61Sdrh} -sqlbody { 4185c23c61Sdrh ATTACH 'test2.db' AS two; 4285c23c61Sdrh CREATE TABLE two.t1(x); 4385c23c61Sdrh ATTACH 'test3.db' AS three; 4485c23c61Sdrh CREATE TABLE three.t1(x); 4585c23c61Sdrh ATTACH 'test4.db' AS four; 4685c23c61Sdrh CREATE TABLE four.t1(x); 4785c23c61Sdrh} 4885c23c61Sdrh 49*d207d808Sdanielk1977do_malloc_test attachmalloc-2 -tclprep { 50*d207d808Sdanielk1977 file delete -force test2.db 51*d207d808Sdanielk1977 file delete -force test2.db-journal 52*d207d808Sdanielk1977 sqlite3 db2 test2.db 53*d207d808Sdanielk1977 db2 eval { 54*d207d808Sdanielk1977 CREATE TABLE t1(a, b, c); 55*d207d808Sdanielk1977 CREATE INDEX i1 ON t1(a, b); 56*d207d808Sdanielk1977 } 57*d207d808Sdanielk1977 db2 close 58*d207d808Sdanielk1977} -sqlbody { 59*d207d808Sdanielk1977 CREATE TABLE t1(d, e, f); 60*d207d808Sdanielk1977 ATTACH 'test2.db' AS db1; 61*d207d808Sdanielk1977} 62*d207d808Sdanielk1977 6385c23c61Sdrhfinish_test 64