2 #pragma ident "%Z%%M% %I% %E% SMI"
6 # The author disclaims copyright to this source code. In place of
7 # a legal notice, here is a blessing:
9 # May you do good and not evil.
10 # May you find forgiveness for yourself and forgive others.
11 # May you share freely, never taking more than you give.
13 #***********************************************************************
14 # This file implements regression tests for TCL interface to the
17 # Actually, all tests are based on the TCL interface, so the main
18 # interface is pretty well tested. This file contains some addition
19 # tests for fringe issues that the main test suite does not cover.
21 # $Id: tclsqlite.test,v 1.20.2.1 2004/07/19 19:30:50 drh Exp $
23 set testdir [file dirname $argv0]
24 source $testdir/tester.tcl
26 # Check the error messages generated by tclsqlite
28 if {[sqlite -has-codec]} {
29 set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
31 set r "sqlite HANDLE FILENAME ?MODE?"
34 set v [catch {sqlite bogus} msg]
36 } [list 1 "wrong # args: should be \"$r\""]
38 set v [catch {db bogus} msg]
40 } {1 {bad option "bogus": must be authorizer, busy, changes, close, commit_hook, complete, errorcode, eval, function, last_insert_rowid, last_statement_changes, onecolumn, progress, rekey, timeout, or trace}}
42 execsql {CREATE TABLE t1(a int, b int)}
43 execsql {INSERT INTO t1 VALUES(10,20)}
45 db eval {SELECT * FROM t1} data {
46 error "The error message"
50 } {1 {The error message}}
53 db eval {SELECT * FROM t2} data {
54 error "The error message"
58 } {1 {no such table: t2}}
61 db eval {SELECT * FROM t1} data {
69 db eval {SELECT * FROM t1} data {
73 regsub {:.*$} $msg {} msg
75 } {1 {syntax error in expression "x*"}}
77 if {[sqlite -encoding]=="UTF-8" && [sqlite -tcl-uses-utf]} {
78 catch {unset ::result}
80 execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
81 execsql "PRAGMA table_info(t\u0123x)"
82 } "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"
84 execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
85 db eval "SELECT * FROM t\u0123x" result break
90 if {[sqlite -encoding]=="iso8859" && [sqlite -tcl-uses-utf]} {
92 execsql "CREATE TABLE t\251x(a int, b\306 float)"
93 execsql "PRAGMA table_info(t\251x)"
94 } "0 a int 0 {} 0 1 b\306 float 0 {} 0"
96 execsql "INSERT INTO t\251x VALUES(1,2.3)"
97 db eval "SELECT * FROM t\251x" result break
102 # Test the onecolumn method
106 INSERT INTO t1 SELECT a*2, b*2 FROM t1;
107 INSERT INTO t1 SELECT a*2+1, b*2+1 FROM t1;
108 INSERT INTO t1 SELECT a*2+3, b*2+3 FROM t1;
110 set rc [catch {db onecolumn {SELECT * FROM t1 ORDER BY a}} msg]
114 db onecolumn {SELECT * FROM t1 WHERE a<0}
117 set rc [catch {db onecolumn} errmsg]
119 } {1 {wrong # args: should be "db onecolumn SQL"}}