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 file is testing the sqlite3_column_count() API.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix columncount
19 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
20 ifcapable !altertable {
25 proc do_ccsql_test {tn sql res} {
27 uplevel [list do_test $tn [subst -nocommands {
28 set stmt [sqlite3_prepare_v2 db {$sql} -1 dummy]
29 set res [sqlite3_column_count [set stmt]]
30 while {[sqlite3_step [set stmt]]=="SQLITE_ROW"} {
31 for {set i 0} {[set i] < [sqlite3_data_count [set stmt]]} {incr i} {
32 lappend res [sqlite3_column_text [set stmt] [set i]]
36 set rc [sqlite3_finalize [set stmt]]
37 if {[set rc]!="SQLITE_OK"} {
38 error [sqlite3_errmsg db]
47 CREATE TABLE t1(x, y, z);
48 INSERT INTO t1 VALUES('a', 'b', 'c');
51 do_ccsql_test 1.1 { SELECT * FROM t1 } {3 a b c}
52 do_ccsql_test 1.2 { CREATE TABLE t2(a, b) } {0}
54 do_ccsql_test 1.3 { ALTER TABLE t2 RENAME TO t3 } {0}
55 do_ccsql_test 1.4 { ALTER TABLE t3 RENAME b TO ccc } {0}
56 do_ccsql_test 1.5 { ALTER TABLE t3 ADD COLUMN d } {0}
58 do_ccsql_test 1.6 { DROP TABLE t3 } {0}