3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #*************************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the ALTER TABLE statement and
13 # specifically out-of-memory conditions within that command.
15 # $Id: altermalloc.test,v 1.10 2008/10/30 17:21:13 danielk1977 Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
22 ifcapable !altertable||!memdebug {
27 source $testdir/malloc_common.tcl
29 do_malloc_test altermalloc-1 -tclprep {
32 if {[catch {sqlite3 db test.db}]} {
35 sqlite3_db_config_lookaside db 0 0 0
36 sqlite3_extended_result_codes db 1
38 CREATE TABLE t1(a int);
39 ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL;
40 ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text';
41 ALTER TABLE t1 RENAME TO t2;
42 ALTER TABLE t2 ADD COLUMN d BLOB DEFAULT X'ABCD';
45 # Test malloc() failure on an ALTER TABLE on a virtual table.
48 do_malloc_test altermalloc-vtab -tclprep {
50 sqlite3_db_config_lookaside db2 0 0 0
51 sqlite3_extended_result_codes db2 1
52 register_echo_module [sqlite3_connection_pointer db2]
54 CREATE TABLE t1(a, b VARCHAR, c INTEGER);
55 CREATE VIRTUAL TABLE t1echo USING echo(t1);
59 register_echo_module [sqlite3_connection_pointer db]
61 set rc [catch {db eval { ALTER TABLE t1echo RENAME TO t1_echo }} msg]
62 if {$msg eq "vtable constructor failed: t1echo"} {
63 set msg "out of memory"