/ Check-in [06a48da6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Disable the alter2 tests if there is a codec compiled into the library. (CVS 2370)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:06a48da67b142e92624cdfd46947bd4ccc6842b7
User & Date: drh 2005-03-10 12:52:47
Context
2005-03-10
12:58
Disable the use of ./crashtest in builds that include a codec. (CVS 2371) check-in: 7e4af622 user: drh tags: trunk
12:52
Disable the alter2 tests if there is a codec compiled into the library. (CVS 2370) check-in: 06a48da6 user: drh tags: trunk
12:35
Fix a #ifdef in util.c. (CVS 2369) check-in: f426c625 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/alter2.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23





24
25
26
27
28
29
30
..
59
60
61
62
63
64
65

66
67
68
69
70

71

72

73
74
75
76
77
78
79
..
83
84
85
86
87
88
89

90
91
92
93
94
95
96
...
422
423
424
425
426
427
428
429
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter2.test,v 1.3 2005/03/09 12:26:51 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# We have to have pragmas in order to do this test
ifcapable {!pragma} return






# The file format change affects the way row-records stored in tables (but 
# not indices) are interpreted. Before version 3.1.3, a row-record for a 
# table with N columns was guaranteed to contain exactly N fields. As
# of version 3.1.3, the record may contain up to N fields. In this case
# the M fields that are present are the values for the left-most M 
# columns. The (N-M) rightmost columns contain NULL.
................................................................................
# This procedure sets the SQL statement stored for table $tbl in the
# sqlite_master table of file 'test.db' to $sql. Also set the file format
# to the supplied value. This is 2 if the added column has a default that is
# NULL, or 3 otherwise. 
#
proc alter_table {tbl sql {file_format 2}} {
  sqlite3 dbat test.db

  dbat eval {
    PRAGMA writable_schema = 1;
    UPDATE sqlite_master SET sql = $sql WHERE name = $tbl AND type = 'table';
    PRAGMA writable_schema = 0;
  }

  dbat close

  set_file_format 2

}

#-----------------------------------------------------------------------
# Some basic tests to make sure short rows are handled.
#
do_test alter2-1.1 {
  execsql {
................................................................................
    INSERT INTO abc VALUES(5, 6);
  }
} {}
do_test alter2-1.2 {
  # ALTER TABLE abc ADD COLUMN c;
  alter_table abc {CREATE TABLE abc(a, b, c);}
} {}

do_test alter2-1.3 {
  execsql {
    SELECT * FROM abc;
  }
} {1 2 {} 3 4 {} 5 6 {}}
do_test alter2-1.4 {
  execsql {
................................................................................
do_test alter2-10.4 {
  execsql {
    SELECT count(b) FROM t2 WHERE b = X'ABCD';
  }
} {3}

finish_test








|







>
>
>
>
>







 







>





>

>

>







 







>







 







<
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
...
432
433
434
435
436
437
438

#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter2.test,v 1.4 2005/03/10 12:52:47 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# We have to have pragmas in order to do this test
ifcapable {!pragma} return

# These tests do not work if there is a codec.  The
# btree_open command does not know how to handle codecs.
#
if {[catch {sqlite3 -has_codec} r] || $r} return

# The file format change affects the way row-records stored in tables (but 
# not indices) are interpreted. Before version 3.1.3, a row-record for a 
# table with N columns was guaranteed to contain exactly N fields. As
# of version 3.1.3, the record may contain up to N fields. In this case
# the M fields that are present are the values for the left-most M 
# columns. The (N-M) rightmost columns contain NULL.
................................................................................
# This procedure sets the SQL statement stored for table $tbl in the
# sqlite_master table of file 'test.db' to $sql. Also set the file format
# to the supplied value. This is 2 if the added column has a default that is
# NULL, or 3 otherwise. 
#
proc alter_table {tbl sql {file_format 2}} {
  sqlite3 dbat test.db
puts one
  dbat eval {
    PRAGMA writable_schema = 1;
    UPDATE sqlite_master SET sql = $sql WHERE name = $tbl AND type = 'table';
    PRAGMA writable_schema = 0;
  }
puts two
  dbat close
puts three
  set_file_format 2
puts four
}

#-----------------------------------------------------------------------
# Some basic tests to make sure short rows are handled.
#
do_test alter2-1.1 {
  execsql {
................................................................................
    INSERT INTO abc VALUES(5, 6);
  }
} {}
do_test alter2-1.2 {
  # ALTER TABLE abc ADD COLUMN c;
  alter_table abc {CREATE TABLE abc(a, b, c);}
} {}
exit
do_test alter2-1.3 {
  execsql {
    SELECT * FROM abc;
  }
} {1 2 {} 3 4 {} 5 6 {}}
do_test alter2-1.4 {
  execsql {
................................................................................
do_test alter2-10.4 {
  execsql {
    SELECT count(b) FROM t2 WHERE b = X'ABCD';
  }
} {3}

finish_test