blob: d9956b40f5b3c5232e6bd15904c09741145a4f31 (
plain)
1
2
3
4
5
6
7
8
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# 2021 February 15
#
# 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 implements regression tests for SQLite library. The
# focus of this file is testing the sqlite3_column_count() API.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix columncount
# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
finish_test
return
}
proc do_ccsql_test {tn sql res} {
uplevel [list do_test $tn [subst -nocommands {
set stmt [sqlite3_prepare_v2 db {$sql} -1 dummy]
set res [sqlite3_column_count [set stmt]]
while {[sqlite3_step [set stmt]]=="SQLITE_ROW"} {
for {set i 0} {[set i] < [sqlite3_data_count [set stmt]]} {incr i} {
lappend res [sqlite3_column_text [set stmt] [set i]]
}
}
set rc [sqlite3_finalize [set stmt]]
if {[set rc]!="SQLITE_OK"} {
error [sqlite3_errmsg db]
}
set res
}] [list {*}$res]]
}
do_execsql_test 1.0 {
CREATE TABLE t1(x, y, z);
INSERT INTO t1 VALUES('a', 'b', 'c');
}
do_ccsql_test 1.1 { SELECT * FROM t1 } {3 a b c}
do_ccsql_test 1.2 { CREATE TABLE t2(a, b) } {0}
do_ccsql_test 1.3 { ALTER TABLE t2 RENAME TO t3 } {0}
do_ccsql_test 1.4 { ALTER TABLE t3 RENAME b TO ccc } {0}
do_ccsql_test 1.5 { ALTER TABLE t3 ADD COLUMN d } {0}
do_ccsql_test 1.6 { DROP TABLE t3 } {0}
finish_test
|