blob: ddd72c7180ae515b131a5ee21b5f7bbcac1a1762 [file] [log] [blame]
shaneha05e0c42009-11-06 03:22:54 +00001# 2009 Nov 11
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11#
12# The focus of this file is testing the CLI shell tool.
13#
shaneha05e0c42009-11-06 03:22:54 +000014#
15
16# Test plan:
17#
shaneh5fc25012009-11-11 04:17:07 +000018# shell1-1.*: Basic command line option handling.
19# shell1-2.*: Basic "dot" command token parsing.
20# shell1-3.*: Basic test that "dot" command can be called.
shaneha05e0c42009-11-06 03:22:54 +000021#
drh8df91852012-04-24 12:46:05 +000022set testdir [file dirname $argv0]
23source $testdir/tester.tcl
dan089555c2016-03-15 09:55:44 +000024set CLI [test_find_cli]
drh8df91852012-04-24 12:46:05 +000025db close
26forcedelete test.db test.db-journal test.db-wal
shaneha05e0c42009-11-06 03:22:54 +000027sqlite3 db test.db
28
shaneh5fc25012009-11-11 04:17:07 +000029#----------------------------------------------------------------------------
30# Test cases shell1-1.*: Basic command line option handling.
31#
32
33# invalid option
34do_test shell1-1.1.1 {
35 set res [catchcmd "-bad test.db" ""]
36 set rc [lindex $res 0]
37 list $rc \
38 [regexp {Error: unknown option: -bad} $res]
39} {1 1}
drhac5649a2014-11-28 13:35:03 +000040do_test shell1-1.1.1b {
41 set res [catchcmd "test.db -bad" ""]
42 set rc [lindex $res 0]
43 list $rc \
44 [regexp {Error: unknown option: -bad} $res]
45} {1 1}
shaneh5fc25012009-11-11 04:17:07 +000046# error on extra options
47do_test shell1-1.1.2 {
drh60c42492016-03-26 15:36:36 +000048 catchcmd "test.db \"select+3\" \"select+4\"" ""
drhac5649a2014-11-28 13:35:03 +000049} {0 {3
504}}
shaneh5fc25012009-11-11 04:17:07 +000051# error on extra options
shanehca7dfda2009-12-17 21:07:54 +000052do_test shell1-1.1.3 {
drhac5649a2014-11-28 13:35:03 +000053 catchcmd "test.db FOO test.db BAD" ".quit"
54} {1 {Error: near "FOO": syntax error}}
shaneh5fc25012009-11-11 04:17:07 +000055
56# -help
57do_test shell1-1.2.1 {
58 set res [catchcmd "-help test.db" ""]
59 set rc [lindex $res 0]
60 list $rc \
61 [regexp {Usage} $res] \
62 [regexp {\-init} $res] \
63 [regexp {\-version} $res]
64} {1 1 1 1}
65
66# -init filename read/process named file
67do_test shell1-1.3.1 {
shanehca7dfda2009-12-17 21:07:54 +000068 catchcmd "-init FOO test.db" ""
shaneh5fc25012009-11-11 04:17:07 +000069} {0 {}}
70do_test shell1-1.3.2 {
drhac5649a2014-11-28 13:35:03 +000071 catchcmd "-init FOO test.db .quit BAD" ""
72} {0 {}}
73do_test shell1-1.3.3 {
74 catchcmd "-init FOO test.db BAD .quit" ""
75} {1 {Error: near "BAD": syntax error}}
shaneh5fc25012009-11-11 04:17:07 +000076
77# -echo print commands before execution
78do_test shell1-1.4.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +000079 catchcmd "-echo test.db" ""
shaneh5fc25012009-11-11 04:17:07 +000080} {0 {}}
81
82# -[no]header turn headers on or off
83do_test shell1-1.5.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +000084 catchcmd "-header test.db" ""
shaneh5fc25012009-11-11 04:17:07 +000085} {0 {}}
86do_test shell1-1.5.2 {
mistachkin1fe36bb2016-04-04 02:16:44 +000087 catchcmd "-noheader test.db" ""
shaneh5fc25012009-11-11 04:17:07 +000088} {0 {}}
89
90# -bail stop after hitting an error
91do_test shell1-1.6.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +000092 catchcmd "-bail test.db" ""
shaneh5fc25012009-11-11 04:17:07 +000093} {0 {}}
94
95# -interactive force interactive I/O
96do_test shell1-1.7.1 {
97 set res [catchcmd "-interactive test.db" ".quit"]
98 set rc [lindex $res 0]
99 list $rc \
100 [regexp {SQLite version} $res] \
drh39a30882014-02-11 16:22:18 +0000101 [regexp {Enter ".help" for usage hints} $res]
shaneh5fc25012009-11-11 04:17:07 +0000102} {0 1 1}
103
104# -batch force batch I/O
105do_test shell1-1.8.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000106 catchcmd "-batch test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000107} {0 {}}
108
109# -column set output mode to 'column'
110do_test shell1-1.9.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000111 catchcmd "-column test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000112} {0 {}}
113
114# -csv set output mode to 'csv'
115do_test shell1-1.10.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000116 catchcmd "-csv test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000117} {0 {}}
118
119# -html set output mode to HTML
120do_test shell1-1.11.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000121 catchcmd "-html test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000122} {0 {}}
123
124# -line set output mode to 'line'
125do_test shell1-1.12.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000126 catchcmd "-line test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000127} {0 {}}
128
129# -list set output mode to 'list'
130do_test shell1-1.13.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000131 catchcmd "-list test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000132} {0 {}}
133
134# -separator 'x' set output field separator (|)
135do_test shell1-1.14.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000136 catchcmd "-separator 'x' test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000137} {0 {}}
138do_test shell1-1.14.2 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000139 catchcmd "-separator x test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000140} {0 {}}
141do_test shell1-1.14.3 {
142 set res [catchcmd "-separator" ""]
143 set rc [lindex $res 0]
144 list $rc \
drh98d312f2012-10-25 15:23:14 +0000145 [regexp {Error: missing argument to -separator} $res]
shaneh5fc25012009-11-11 04:17:07 +0000146} {1 1}
147
shaneh642d8b82010-07-28 16:05:34 +0000148# -stats print memory stats before each finalize
149do_test shell1-1.14b.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000150 catchcmd "-stats test.db" ""
shaneh642d8b82010-07-28 16:05:34 +0000151} {0 {}}
152
shaneh5fc25012009-11-11 04:17:07 +0000153# -nullvalue 'text' set text string for NULL values
154do_test shell1-1.15.1 {
155 catchcmd "-nullvalue 'x' test.db" ""
156} {0 {}}
157do_test shell1-1.15.2 {
158 catchcmd "-nullvalue x test.db" ""
159} {0 {}}
160do_test shell1-1.15.3 {
161 set res [catchcmd "-nullvalue" ""]
162 set rc [lindex $res 0]
163 list $rc \
drh98d312f2012-10-25 15:23:14 +0000164 [regexp {Error: missing argument to -nullvalue} $res]
shaneh5fc25012009-11-11 04:17:07 +0000165} {1 1}
166
167# -version show SQLite version
168do_test shell1-1.16.1 {
drh9fd301b2011-06-03 13:28:22 +0000169 set x [catchcmd "-version test.db" ""]
drhb24c61a2012-05-21 22:45:35 +0000170} {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/}
shanehe2aa9d72009-11-06 17:20:17 +0000171
shaneha05e0c42009-11-06 03:22:54 +0000172#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000173# Test cases shell1-2.*: Basic "dot" command token parsing.
shanehe2aa9d72009-11-06 17:20:17 +0000174#
175
176# check first token handling
shaneh5fc25012009-11-11 04:17:07 +0000177do_test shell1-2.1.1 {
mistachkin1fe36bb2016-04-04 02:16:44 +0000178 catchcmd "test.db" ".foo"
shanehe2aa9d72009-11-06 17:20:17 +0000179} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000180do_test shell1-2.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000181 catchcmd "test.db" ".\"foo OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000182} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000183do_test shell1-2.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000184 catchcmd "test.db" ".\'foo OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000185} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
186
187# unbalanced quotes
shaneh5fc25012009-11-11 04:17:07 +0000188do_test shell1-2.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000189 catchcmd "test.db" ".\"foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000190} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000191do_test shell1-2.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000192 catchcmd "test.db" ".\'foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000193} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000194do_test shell1-2.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000195 catchcmd "test.db" ".explain \"OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000196} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000197do_test shell1-2.2.4 {
shanehca7dfda2009-12-17 21:07:54 +0000198 catchcmd "test.db" ".explain \'OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000199} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000200do_test shell1-2.2.5 {
shanehca7dfda2009-12-17 21:07:54 +0000201 catchcmd "test.db" ".mode \"insert FOO"
drh36f49d02016-11-23 23:18:45 +0000202} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000203do_test shell1-2.2.6 {
shanehca7dfda2009-12-17 21:07:54 +0000204 catchcmd "test.db" ".mode \'insert FOO"
drh36f49d02016-11-23 23:18:45 +0000205} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shanehe2aa9d72009-11-06 17:20:17 +0000206
207# check multiple tokens, and quoted tokens
shaneh5fc25012009-11-11 04:17:07 +0000208do_test shell1-2.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000209 catchcmd "test.db" ".explain 1"
shanehe2aa9d72009-11-06 17:20:17 +0000210} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000211do_test shell1-2.3.2 {
shanehca7dfda2009-12-17 21:07:54 +0000212 catchcmd "test.db" ".explain on"
shanehe2aa9d72009-11-06 17:20:17 +0000213} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000214do_test shell1-2.3.3 {
shanehca7dfda2009-12-17 21:07:54 +0000215 catchcmd "test.db" ".explain \"1 2 3\""
drh173ba092013-01-28 18:18:26 +0000216} {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
shaneh5fc25012009-11-11 04:17:07 +0000217do_test shell1-2.3.4 {
shanehca7dfda2009-12-17 21:07:54 +0000218 catchcmd "test.db" ".explain \"OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000219} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000220do_test shell1-2.3.5 {
shanehca7dfda2009-12-17 21:07:54 +0000221 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000222} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000223do_test shell1-2.3.6 {
shanehca7dfda2009-12-17 21:07:54 +0000224 catchcmd "test.db" ".explain \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000225} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000226do_test shell1-2.3.7 {
shanehca7dfda2009-12-17 21:07:54 +0000227 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000228} {0 {}}
229
230# check quoted args are unquoted
shaneh5fc25012009-11-11 04:17:07 +0000231do_test shell1-2.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000232 catchcmd "test.db" ".mode FOO"
drh36f49d02016-11-23 23:18:45 +0000233} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000234do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000235 catchcmd "test.db" ".mode csv"
shanehe2aa9d72009-11-06 17:20:17 +0000236} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000237do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000238 catchcmd "test.db" ".mode \"csv\""
shanehe2aa9d72009-11-06 17:20:17 +0000239} {0 {}}
240
241
242#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000243# Test cases shell1-3.*: Basic test that "dot" command can be called.
shaneha05e0c42009-11-06 03:22:54 +0000244#
245
246# .backup ?DB? FILE Backup DB (default "main") to FILE
shaneh5fc25012009-11-11 04:17:07 +0000247do_test shell1-3.1.1 {
shanehca7dfda2009-12-17 21:07:54 +0000248 catchcmd "test.db" ".backup"
drhbc46f022013-01-23 18:53:23 +0000249} {1 {missing FILENAME argument on .backup}}
shaneh5fc25012009-11-11 04:17:07 +0000250do_test shell1-3.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000251 catchcmd "test.db" ".backup FOO"
252} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000253do_test shell1-3.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000254 catchcmd "test.db" ".backup FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000255} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000256do_test shell1-3.1.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000257 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000258 catchcmd "test.db" ".backup FOO BAR BAD"
drhbc46f022013-01-23 18:53:23 +0000259} {1 {too many arguments to .backup}}
shaneha05e0c42009-11-06 03:22:54 +0000260
261# .bail ON|OFF Stop after hitting an error. Default OFF
shaneh5fc25012009-11-11 04:17:07 +0000262do_test shell1-3.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000263 catchcmd "test.db" ".bail"
drhc2ce0be2014-05-29 12:36:14 +0000264} {1 {Usage: .bail on|off}}
shaneh5fc25012009-11-11 04:17:07 +0000265do_test shell1-3.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000266 catchcmd "test.db" ".bail ON"
shaneha05e0c42009-11-06 03:22:54 +0000267} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000268do_test shell1-3.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000269 catchcmd "test.db" ".bail OFF"
shaneha05e0c42009-11-06 03:22:54 +0000270} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000271do_test shell1-3.2.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000272 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000273 catchcmd "test.db" ".bail OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000274} {1 {Usage: .bail on|off}}
shaneha05e0c42009-11-06 03:22:54 +0000275
drhc5954192016-12-27 02:43:47 +0000276ifcapable vtab {
shaneha05e0c42009-11-06 03:22:54 +0000277# .databases List names and files of attached databases
shaneh5fc25012009-11-11 04:17:07 +0000278do_test shell1-3.3.1 {
drheaa544d2016-03-26 14:41:13 +0000279 catchcmd "-csv test.db" ".databases"
drh15707ac2016-03-26 13:26:35 +0000280} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
shaneh5fc25012009-11-11 04:17:07 +0000281do_test shell1-3.3.2 {
drhc2ce0be2014-05-29 12:36:14 +0000282 # extra arguments ignored
drheaa544d2016-03-26 14:41:13 +0000283 catchcmd "test.db" ".databases BAD"
drh15707ac2016-03-26 13:26:35 +0000284} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
drhc5954192016-12-27 02:43:47 +0000285}
shaneha05e0c42009-11-06 03:22:54 +0000286
287# .dump ?TABLE? ... Dump the database in an SQL text format
288# If TABLE specified, only dump tables matching
289# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000290do_test shell1-3.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000291 set res [catchcmd "test.db" ".dump"]
shaneha05e0c42009-11-06 03:22:54 +0000292 list [regexp {BEGIN TRANSACTION;} $res] \
293 [regexp {COMMIT;} $res]
294} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000295do_test shell1-3.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000296 set res [catchcmd "test.db" ".dump FOO"]
shaneha05e0c42009-11-06 03:22:54 +0000297 list [regexp {BEGIN TRANSACTION;} $res] \
298 [regexp {COMMIT;} $res]
299} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000300do_test shell1-3.4.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000301 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000302 catchcmd "test.db" ".dump FOO BAD"
drhdbc26722017-07-10 18:04:41 +0000303} {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}
shaneha05e0c42009-11-06 03:22:54 +0000304
305# .echo ON|OFF Turn command echo on or off
shaneh5fc25012009-11-11 04:17:07 +0000306do_test shell1-3.5.1 {
shanehca7dfda2009-12-17 21:07:54 +0000307 catchcmd "test.db" ".echo"
drhc2ce0be2014-05-29 12:36:14 +0000308} {1 {Usage: .echo on|off}}
shaneh5fc25012009-11-11 04:17:07 +0000309do_test shell1-3.5.2 {
shanehca7dfda2009-12-17 21:07:54 +0000310 catchcmd "test.db" ".echo ON"
shaneha05e0c42009-11-06 03:22:54 +0000311} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000312do_test shell1-3.5.3 {
shanehca7dfda2009-12-17 21:07:54 +0000313 catchcmd "test.db" ".echo OFF"
shaneha05e0c42009-11-06 03:22:54 +0000314} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000315do_test shell1-3.5.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000316 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000317 catchcmd "test.db" ".echo OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000318} {1 {Usage: .echo on|off}}
shaneha05e0c42009-11-06 03:22:54 +0000319
320# .exit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000321do_test shell1-3.6.1 {
shanehca7dfda2009-12-17 21:07:54 +0000322 catchcmd "test.db" ".exit"
shaneha05e0c42009-11-06 03:22:54 +0000323} {0 {}}
324
325# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
shaneh5fc25012009-11-11 04:17:07 +0000326do_test shell1-3.7.1 {
shanehca7dfda2009-12-17 21:07:54 +0000327 catchcmd "test.db" ".explain"
shanehe2aa9d72009-11-06 17:20:17 +0000328 # explain is the exception to the booleans. without an option, it turns it on.
329} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000330do_test shell1-3.7.2 {
shanehca7dfda2009-12-17 21:07:54 +0000331 catchcmd "test.db" ".explain ON"
shaneha05e0c42009-11-06 03:22:54 +0000332} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000333do_test shell1-3.7.3 {
shanehca7dfda2009-12-17 21:07:54 +0000334 catchcmd "test.db" ".explain OFF"
shaneha05e0c42009-11-06 03:22:54 +0000335} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000336do_test shell1-3.7.4 {
drhc2ce0be2014-05-29 12:36:14 +0000337 # extra arguments ignored
shanehca7dfda2009-12-17 21:07:54 +0000338 catchcmd "test.db" ".explain OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000339} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000340
shaneha05e0c42009-11-06 03:22:54 +0000341
342# .header(s) ON|OFF Turn display of headers on or off
shaneh5fc25012009-11-11 04:17:07 +0000343do_test shell1-3.9.1 {
shanehca7dfda2009-12-17 21:07:54 +0000344 catchcmd "test.db" ".header"
drhc2ce0be2014-05-29 12:36:14 +0000345} {1 {Usage: .headers on|off}}
shaneh5fc25012009-11-11 04:17:07 +0000346do_test shell1-3.9.2 {
shanehca7dfda2009-12-17 21:07:54 +0000347 catchcmd "test.db" ".header ON"
shaneha05e0c42009-11-06 03:22:54 +0000348} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000349do_test shell1-3.9.3 {
shanehca7dfda2009-12-17 21:07:54 +0000350 catchcmd "test.db" ".header OFF"
shaneha05e0c42009-11-06 03:22:54 +0000351} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000352do_test shell1-3.9.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000353 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000354 catchcmd "test.db" ".header OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000355} {1 {Usage: .headers on|off}}
shanehe2aa9d72009-11-06 17:20:17 +0000356
shaneh5fc25012009-11-11 04:17:07 +0000357do_test shell1-3.9.5 {
shanehca7dfda2009-12-17 21:07:54 +0000358 catchcmd "test.db" ".headers"
drhc2ce0be2014-05-29 12:36:14 +0000359} {1 {Usage: .headers on|off}}
shaneh5fc25012009-11-11 04:17:07 +0000360do_test shell1-3.9.6 {
shanehca7dfda2009-12-17 21:07:54 +0000361 catchcmd "test.db" ".headers ON"
shaneha05e0c42009-11-06 03:22:54 +0000362} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000363do_test shell1-3.9.7 {
shanehca7dfda2009-12-17 21:07:54 +0000364 catchcmd "test.db" ".headers OFF"
shaneha05e0c42009-11-06 03:22:54 +0000365} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000366do_test shell1-3.9.8 {
shanehe2aa9d72009-11-06 17:20:17 +0000367 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000368 catchcmd "test.db" ".headers OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000369} {1 {Usage: .headers on|off}}
shaneha05e0c42009-11-06 03:22:54 +0000370
371# .help Show this message
shaneh5fc25012009-11-11 04:17:07 +0000372do_test shell1-3.10.1 {
shanehca7dfda2009-12-17 21:07:54 +0000373 set res [catchcmd "test.db" ".help"]
shaneha05e0c42009-11-06 03:22:54 +0000374 # look for a few of the possible help commands
375 list [regexp {.help} $res] \
376 [regexp {.quit} $res] \
377 [regexp {.show} $res]
378} {1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000379do_test shell1-3.10.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000380 # we allow .help to take extra args (it is help after all)
shanehca7dfda2009-12-17 21:07:54 +0000381 set res [catchcmd "test.db" ".help BAD"]
shanehe2aa9d72009-11-06 17:20:17 +0000382 # look for a few of the possible help commands
383 list [regexp {.help} $res] \
384 [regexp {.quit} $res] \
385 [regexp {.show} $res]
386} {1 1 1}
shaneha05e0c42009-11-06 03:22:54 +0000387
388# .import FILE TABLE Import data from FILE into TABLE
shaneh5fc25012009-11-11 04:17:07 +0000389do_test shell1-3.11.1 {
shanehca7dfda2009-12-17 21:07:54 +0000390 catchcmd "test.db" ".import"
drhc2ce0be2014-05-29 12:36:14 +0000391} {1 {Usage: .import FILE TABLE}}
shaneh5fc25012009-11-11 04:17:07 +0000392do_test shell1-3.11.2 {
shanehca7dfda2009-12-17 21:07:54 +0000393 catchcmd "test.db" ".import FOO"
drhc2ce0be2014-05-29 12:36:14 +0000394} {1 {Usage: .import FILE TABLE}}
drhdb95f682013-06-26 22:46:00 +0000395#do_test shell1-3.11.2 {
396# catchcmd "test.db" ".import FOO BAR"
397#} {1 {Error: no such table: BAR}}
shaneh5fc25012009-11-11 04:17:07 +0000398do_test shell1-3.11.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000399 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000400 catchcmd "test.db" ".import FOO BAR BAD"
drhc2ce0be2014-05-29 12:36:14 +0000401} {1 {Usage: .import FILE TABLE}}
shaneha05e0c42009-11-06 03:22:54 +0000402
drh0e55db12015-02-06 14:51:13 +0000403# .indexes ?TABLE? Show names of all indexes
404# If TABLE specified, only show indexes for tables
shaneha05e0c42009-11-06 03:22:54 +0000405# matching LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000406do_test shell1-3.12.1 {
drh0e55db12015-02-06 14:51:13 +0000407 catchcmd "test.db" ".indexes"
shaneha05e0c42009-11-06 03:22:54 +0000408} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000409do_test shell1-3.12.2 {
drh0e55db12015-02-06 14:51:13 +0000410 catchcmd "test.db" ".indexes FOO"
411} {0 {}}
412do_test shell1-3.12.2-legacy {
shanehca7dfda2009-12-17 21:07:54 +0000413 catchcmd "test.db" ".indices FOO"
shaneha05e0c42009-11-06 03:22:54 +0000414} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000415do_test shell1-3.12.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000416 # too many arguments
drh0e55db12015-02-06 14:51:13 +0000417 catchcmd "test.db" ".indexes FOO BAD"
418} {1 {Usage: .indexes ?LIKE-PATTERN?}}
shaneha05e0c42009-11-06 03:22:54 +0000419
420# .mode MODE ?TABLE? Set output mode where MODE is one of:
mistachkine0d68852014-12-11 03:12:33 +0000421# ascii Columns/rows delimited by 0x1F and 0x1E
shaneha05e0c42009-11-06 03:22:54 +0000422# csv Comma-separated values
423# column Left-aligned columns. (See .width)
424# html HTML <table> code
425# insert SQL insert statements for TABLE
426# line One value per line
mistachkine0d68852014-12-11 03:12:33 +0000427# list Values delimited by .separator strings
shaneha05e0c42009-11-06 03:22:54 +0000428# tabs Tab-separated values
429# tcl TCL list elements
shaneh5fc25012009-11-11 04:17:07 +0000430do_test shell1-3.13.1 {
shanehca7dfda2009-12-17 21:07:54 +0000431 catchcmd "test.db" ".mode"
drha501f7d2017-06-29 21:33:25 +0000432} {0 {current output mode: list}}
shaneh5fc25012009-11-11 04:17:07 +0000433do_test shell1-3.13.2 {
shanehca7dfda2009-12-17 21:07:54 +0000434 catchcmd "test.db" ".mode FOO"
drh36f49d02016-11-23 23:18:45 +0000435} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000436do_test shell1-3.13.3 {
shanehca7dfda2009-12-17 21:07:54 +0000437 catchcmd "test.db" ".mode csv"
shaneha05e0c42009-11-06 03:22:54 +0000438} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000439do_test shell1-3.13.4 {
shanehca7dfda2009-12-17 21:07:54 +0000440 catchcmd "test.db" ".mode column"
shaneha05e0c42009-11-06 03:22:54 +0000441} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000442do_test shell1-3.13.5 {
shanehca7dfda2009-12-17 21:07:54 +0000443 catchcmd "test.db" ".mode html"
shaneha05e0c42009-11-06 03:22:54 +0000444} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000445do_test shell1-3.13.6 {
shanehca7dfda2009-12-17 21:07:54 +0000446 catchcmd "test.db" ".mode insert"
shaneha05e0c42009-11-06 03:22:54 +0000447} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000448do_test shell1-3.13.7 {
shanehca7dfda2009-12-17 21:07:54 +0000449 catchcmd "test.db" ".mode line"
shaneha05e0c42009-11-06 03:22:54 +0000450} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000451do_test shell1-3.13.8 {
shanehca7dfda2009-12-17 21:07:54 +0000452 catchcmd "test.db" ".mode list"
shaneha05e0c42009-11-06 03:22:54 +0000453} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000454do_test shell1-3.13.9 {
shanehca7dfda2009-12-17 21:07:54 +0000455 catchcmd "test.db" ".mode tabs"
shaneha05e0c42009-11-06 03:22:54 +0000456} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000457do_test shell1-3.13.10 {
shanehca7dfda2009-12-17 21:07:54 +0000458 catchcmd "test.db" ".mode tcl"
shaneha05e0c42009-11-06 03:22:54 +0000459} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000460do_test shell1-3.13.11 {
drhc2ce0be2014-05-29 12:36:14 +0000461 # extra arguments ignored
shanehca7dfda2009-12-17 21:07:54 +0000462 catchcmd "test.db" ".mode tcl BAD"
drhc2ce0be2014-05-29 12:36:14 +0000463} {0 {}}
shanehe2aa9d72009-11-06 17:20:17 +0000464
465# don't allow partial mode type matches
shaneh5fc25012009-11-11 04:17:07 +0000466do_test shell1-3.13.12 {
shanehca7dfda2009-12-17 21:07:54 +0000467 catchcmd "test.db" ".mode l"
drh36f49d02016-11-23 23:18:45 +0000468} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000469do_test shell1-3.13.13 {
shanehca7dfda2009-12-17 21:07:54 +0000470 catchcmd "test.db" ".mode li"
drh36f49d02016-11-23 23:18:45 +0000471} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000472do_test shell1-3.13.14 {
shanehca7dfda2009-12-17 21:07:54 +0000473 catchcmd "test.db" ".mode lin"
drhc2ce0be2014-05-29 12:36:14 +0000474} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000475
476# .nullvalue STRING Print STRING in place of NULL values
shaneh5fc25012009-11-11 04:17:07 +0000477do_test shell1-3.14.1 {
shanehca7dfda2009-12-17 21:07:54 +0000478 catchcmd "test.db" ".nullvalue"
drhc2ce0be2014-05-29 12:36:14 +0000479} {1 {Usage: .nullvalue STRING}}
shaneh5fc25012009-11-11 04:17:07 +0000480do_test shell1-3.14.2 {
shanehca7dfda2009-12-17 21:07:54 +0000481 catchcmd "test.db" ".nullvalue FOO"
shaneha05e0c42009-11-06 03:22:54 +0000482} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000483do_test shell1-3.14.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000484 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000485 catchcmd "test.db" ".nullvalue FOO BAD"
drhc2ce0be2014-05-29 12:36:14 +0000486} {1 {Usage: .nullvalue STRING}}
shaneha05e0c42009-11-06 03:22:54 +0000487
488# .output FILENAME Send output to FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000489do_test shell1-3.15.1 {
shanehca7dfda2009-12-17 21:07:54 +0000490 catchcmd "test.db" ".output"
drhc2ce0be2014-05-29 12:36:14 +0000491} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000492do_test shell1-3.15.2 {
shanehca7dfda2009-12-17 21:07:54 +0000493 catchcmd "test.db" ".output FOO"
shaneha05e0c42009-11-06 03:22:54 +0000494} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000495do_test shell1-3.15.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000496 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000497 catchcmd "test.db" ".output FOO BAD"
drhc2ce0be2014-05-29 12:36:14 +0000498} {1 {Usage: .output FILE}}
shaneha05e0c42009-11-06 03:22:54 +0000499
500# .output stdout Send output to the screen
shaneh5fc25012009-11-11 04:17:07 +0000501do_test shell1-3.16.1 {
shanehca7dfda2009-12-17 21:07:54 +0000502 catchcmd "test.db" ".output stdout"
shaneha05e0c42009-11-06 03:22:54 +0000503} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000504do_test shell1-3.16.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000505 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000506 catchcmd "test.db" ".output stdout BAD"
drhc2ce0be2014-05-29 12:36:14 +0000507} {1 {Usage: .output FILE}}
shaneha05e0c42009-11-06 03:22:54 +0000508
509# .prompt MAIN CONTINUE Replace the standard prompts
shaneh5fc25012009-11-11 04:17:07 +0000510do_test shell1-3.17.1 {
shanehca7dfda2009-12-17 21:07:54 +0000511 catchcmd "test.db" ".prompt"
drhc2ce0be2014-05-29 12:36:14 +0000512} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000513do_test shell1-3.17.2 {
shanehca7dfda2009-12-17 21:07:54 +0000514 catchcmd "test.db" ".prompt FOO"
shaneha05e0c42009-11-06 03:22:54 +0000515} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000516do_test shell1-3.17.3 {
shanehca7dfda2009-12-17 21:07:54 +0000517 catchcmd "test.db" ".prompt FOO BAR"
shaneha05e0c42009-11-06 03:22:54 +0000518} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000519do_test shell1-3.17.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000520 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000521 catchcmd "test.db" ".prompt FOO BAR BAD"
drhc2ce0be2014-05-29 12:36:14 +0000522} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000523
524# .quit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000525do_test shell1-3.18.1 {
shanehca7dfda2009-12-17 21:07:54 +0000526 catchcmd "test.db" ".quit"
shaneha05e0c42009-11-06 03:22:54 +0000527} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000528do_test shell1-3.18.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000529 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000530 catchcmd "test.db" ".quit BAD"
drhc2ce0be2014-05-29 12:36:14 +0000531} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000532
533# .read FILENAME Execute SQL in FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000534do_test shell1-3.19.1 {
shanehca7dfda2009-12-17 21:07:54 +0000535 catchcmd "test.db" ".read"
drhc2ce0be2014-05-29 12:36:14 +0000536} {1 {Usage: .read FILE}}
shaneh5fc25012009-11-11 04:17:07 +0000537do_test shell1-3.19.2 {
mistachkin9ac99312013-09-13 23:26:47 +0000538 forcedelete FOO
shanehca7dfda2009-12-17 21:07:54 +0000539 catchcmd "test.db" ".read FOO"
shaneha05e0c42009-11-06 03:22:54 +0000540} {1 {Error: cannot open "FOO"}}
shaneh5fc25012009-11-11 04:17:07 +0000541do_test shell1-3.19.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000542 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000543 catchcmd "test.db" ".read FOO BAD"
drhc2ce0be2014-05-29 12:36:14 +0000544} {1 {Usage: .read FILE}}
shaneha05e0c42009-11-06 03:22:54 +0000545
546# .restore ?DB? FILE Restore content of DB (default "main") from FILE
shaneh5fc25012009-11-11 04:17:07 +0000547do_test shell1-3.20.1 {
shanehca7dfda2009-12-17 21:07:54 +0000548 catchcmd "test.db" ".restore"
drhc2ce0be2014-05-29 12:36:14 +0000549} {1 {Usage: .restore ?DB? FILE}}
shaneh5fc25012009-11-11 04:17:07 +0000550do_test shell1-3.20.2 {
shanehca7dfda2009-12-17 21:07:54 +0000551 catchcmd "test.db" ".restore FOO"
552} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000553do_test shell1-3.20.3 {
shanehca7dfda2009-12-17 21:07:54 +0000554 catchcmd "test.db" ".restore FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000555} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000556do_test shell1-3.20.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000557 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000558 catchcmd "test.db" ".restore FOO BAR BAD"
drhc2ce0be2014-05-29 12:36:14 +0000559} {1 {Usage: .restore ?DB? FILE}}
shaneha05e0c42009-11-06 03:22:54 +0000560
drha22dd382017-06-24 19:21:48 +0000561ifcapable vtab {
shaneha05e0c42009-11-06 03:22:54 +0000562# .schema ?TABLE? Show the CREATE statements
563# If TABLE specified, only show tables matching
564# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000565do_test shell1-3.21.1 {
shanehca7dfda2009-12-17 21:07:54 +0000566 catchcmd "test.db" ".schema"
shaneha05e0c42009-11-06 03:22:54 +0000567} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000568do_test shell1-3.21.2 {
shanehca7dfda2009-12-17 21:07:54 +0000569 catchcmd "test.db" ".schema FOO"
shaneha05e0c42009-11-06 03:22:54 +0000570} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000571do_test shell1-3.21.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000572 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000573 catchcmd "test.db" ".schema FOO BAD"
drh4926fec2016-04-13 15:33:42 +0000574} {1 {Usage: .schema ?--indent? ?LIKE-PATTERN?}}
shaneha05e0c42009-11-06 03:22:54 +0000575
drhac43e982012-05-21 03:15:06 +0000576do_test shell1-3.21.4 {
577 catchcmd "test.db" {
578 CREATE TABLE t1(x);
579 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
580 CREATE VIEW v1 AS SELECT y+1 FROM v2;
581 }
582 catchcmd "test.db" ".schema"
583} {0 {CREATE TABLE t1(x);
584CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
585CREATE VIEW v1 AS SELECT y+1 FROM v2;}}
586db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}
drha22dd382017-06-24 19:21:48 +0000587}
drhac43e982012-05-21 03:15:06 +0000588
mistachkin636bf9f2014-07-19 20:15:16 +0000589# .separator STRING Change column separator used by output and .import
shaneh5fc25012009-11-11 04:17:07 +0000590do_test shell1-3.22.1 {
shanehca7dfda2009-12-17 21:07:54 +0000591 catchcmd "test.db" ".separator"
mistachkine0d68852014-12-11 03:12:33 +0000592} {1 {Usage: .separator COL ?ROW?}}
shaneh5fc25012009-11-11 04:17:07 +0000593do_test shell1-3.22.2 {
shanehca7dfda2009-12-17 21:07:54 +0000594 catchcmd "test.db" ".separator FOO"
shaneha05e0c42009-11-06 03:22:54 +0000595} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000596do_test shell1-3.22.3 {
drh6976c212014-07-24 12:09:47 +0000597 catchcmd "test.db" ".separator ABC XYZ"
598} {0 {}}
599do_test shell1-3.22.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000600 # too many arguments
drh6976c212014-07-24 12:09:47 +0000601 catchcmd "test.db" ".separator FOO BAD BAD2"
mistachkine0d68852014-12-11 03:12:33 +0000602} {1 {Usage: .separator COL ?ROW?}}
shaneha05e0c42009-11-06 03:22:54 +0000603
604# .show Show the current values for various settings
shaneh5fc25012009-11-11 04:17:07 +0000605do_test shell1-3.23.1 {
shanehca7dfda2009-12-17 21:07:54 +0000606 set res [catchcmd "test.db" ".show"]
shaneha05e0c42009-11-06 03:22:54 +0000607 list [regexp {echo:} $res] \
608 [regexp {explain:} $res] \
609 [regexp {headers:} $res] \
610 [regexp {mode:} $res] \
611 [regexp {nullvalue:} $res] \
612 [regexp {output:} $res] \
mistachkin636bf9f2014-07-19 20:15:16 +0000613 [regexp {colseparator:} $res] \
614 [regexp {rowseparator:} $res] \
shaneh642d8b82010-07-28 16:05:34 +0000615 [regexp {stats:} $res] \
shaneha05e0c42009-11-06 03:22:54 +0000616 [regexp {width:} $res]
mistachkine0d68852014-12-11 03:12:33 +0000617} {1 1 1 1 1 1 1 1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000618do_test shell1-3.23.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000619 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000620 catchcmd "test.db" ".show BAD"
drhc2ce0be2014-05-29 12:36:14 +0000621} {1 {Usage: .show}}
shaneha05e0c42009-11-06 03:22:54 +0000622
shaneh642d8b82010-07-28 16:05:34 +0000623# .stats ON|OFF Turn stats on or off
drh34784902016-02-27 17:12:36 +0000624#do_test shell1-3.23b.1 {
625# catchcmd "test.db" ".stats"
626#} {1 {Usage: .stats on|off}}
shaneh642d8b82010-07-28 16:05:34 +0000627do_test shell1-3.23b.2 {
628 catchcmd "test.db" ".stats ON"
629} {0 {}}
630do_test shell1-3.23b.3 {
631 catchcmd "test.db" ".stats OFF"
632} {0 {}}
633do_test shell1-3.23b.4 {
634 # too many arguments
635 catchcmd "test.db" ".stats OFF BAD"
drh34784902016-02-27 17:12:36 +0000636} {1 {Usage: .stats ?on|off?}}
shaneh642d8b82010-07-28 16:05:34 +0000637
shaneha05e0c42009-11-06 03:22:54 +0000638# .tables ?TABLE? List names of tables
639# If TABLE specified, only list tables matching
640# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000641do_test shell1-3.24.1 {
shanehca7dfda2009-12-17 21:07:54 +0000642 catchcmd "test.db" ".tables"
shaneha05e0c42009-11-06 03:22:54 +0000643} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000644do_test shell1-3.24.2 {
shanehca7dfda2009-12-17 21:07:54 +0000645 catchcmd "test.db" ".tables FOO"
shaneha05e0c42009-11-06 03:22:54 +0000646} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000647do_test shell1-3.24.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000648 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000649 catchcmd "test.db" ".tables FOO BAD"
drhc2ce0be2014-05-29 12:36:14 +0000650} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000651
652# .timeout MS Try opening locked tables for MS milliseconds
shaneh5fc25012009-11-11 04:17:07 +0000653do_test shell1-3.25.1 {
shanehca7dfda2009-12-17 21:07:54 +0000654 catchcmd "test.db" ".timeout"
drhc2ce0be2014-05-29 12:36:14 +0000655} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000656do_test shell1-3.25.2 {
shanehca7dfda2009-12-17 21:07:54 +0000657 catchcmd "test.db" ".timeout zzz"
shanehe2aa9d72009-11-06 17:20:17 +0000658 # this should be treated the same as a '0' timeout
shaneha05e0c42009-11-06 03:22:54 +0000659} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000660do_test shell1-3.25.3 {
shanehca7dfda2009-12-17 21:07:54 +0000661 catchcmd "test.db" ".timeout 1"
shaneha05e0c42009-11-06 03:22:54 +0000662} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000663do_test shell1-3.25.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000664 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000665 catchcmd "test.db" ".timeout 1 BAD"
drhc2ce0be2014-05-29 12:36:14 +0000666} {0 {}}
shaneha05e0c42009-11-06 03:22:54 +0000667
668# .width NUM NUM ... Set column widths for "column" mode
shaneh5fc25012009-11-11 04:17:07 +0000669do_test shell1-3.26.1 {
shanehca7dfda2009-12-17 21:07:54 +0000670 catchcmd "test.db" ".width"
drhc2ce0be2014-05-29 12:36:14 +0000671} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000672do_test shell1-3.26.2 {
shanehca7dfda2009-12-17 21:07:54 +0000673 catchcmd "test.db" ".width xxx"
shanehe2aa9d72009-11-06 17:20:17 +0000674 # this should be treated the same as a '0' width for col 1
shaneha05e0c42009-11-06 03:22:54 +0000675} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000676do_test shell1-3.26.3 {
shanehca7dfda2009-12-17 21:07:54 +0000677 catchcmd "test.db" ".width xxx yyy"
shanehe2aa9d72009-11-06 17:20:17 +0000678 # this should be treated the same as a '0' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000679} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000680do_test shell1-3.26.4 {
shanehca7dfda2009-12-17 21:07:54 +0000681 catchcmd "test.db" ".width 1 1"
shanehe2aa9d72009-11-06 17:20:17 +0000682 # this should be treated the same as a '1' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000683} {0 {}}
drh078b1fd2012-09-21 13:40:02 +0000684do_test shell1-3.26.5 {
685 catchcmd "test.db" ".mode column\n.width 10 -10\nSELECT 'abcdefg', 123456;"
686 # this should be treated the same as a '1' width for col 1 and 2
687} {0 {abcdefg 123456}}
688do_test shell1-3.26.6 {
689 catchcmd "test.db" ".mode column\n.width -10 10\nSELECT 'abcdefg', 123456;"
690 # this should be treated the same as a '1' width for col 1 and 2
691} {0 { abcdefg 123456 }}
692
shaneha05e0c42009-11-06 03:22:54 +0000693
694# .timer ON|OFF Turn the CPU timer measurement on or off
shaneh5fc25012009-11-11 04:17:07 +0000695do_test shell1-3.27.1 {
shanehca7dfda2009-12-17 21:07:54 +0000696 catchcmd "test.db" ".timer"
drhc2ce0be2014-05-29 12:36:14 +0000697} {1 {Usage: .timer on|off}}
shaneh5fc25012009-11-11 04:17:07 +0000698do_test shell1-3.27.2 {
shanehca7dfda2009-12-17 21:07:54 +0000699 catchcmd "test.db" ".timer ON"
shaneha05e0c42009-11-06 03:22:54 +0000700} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000701do_test shell1-3.27.3 {
shanehca7dfda2009-12-17 21:07:54 +0000702 catchcmd "test.db" ".timer OFF"
shaneha05e0c42009-11-06 03:22:54 +0000703} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000704do_test shell1-3.27.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000705 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000706 catchcmd "test.db" ".timer OFF BAD"
drhc2ce0be2014-05-29 12:36:14 +0000707} {1 {Usage: .timer on|off}}
shaneha05e0c42009-11-06 03:22:54 +0000708
drh53a9d152011-04-25 18:20:04 +0000709do_test shell1-3-28.1 {
710 catchcmd test.db \
711 ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
712} "0 {(123) hello\n456}"
713
drh078b1fd2012-09-21 13:40:02 +0000714do_test shell1-3-29.1 {
715 catchcmd "test.db" ".print this is a test"
716} {0 {this is a test}}
717
drh4c56b992013-06-27 13:26:55 +0000718# dot-command argument quoting
719do_test shell1-3-30.1 {
720 catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'}
721} {0 {this"is'a-test this\"is\\a\055test}}
722do_test shell1-3-31.1 {
723 catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'}
724} [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"]
725
726
drh5128e852012-04-24 13:14:49 +0000727# Test the output of the ".dump" command
728#
729do_test shell1-4.1 {
drh55a1b302013-09-04 16:08:50 +0000730 db close
731 forcedelete test.db
732 sqlite3 db test.db
drh5128e852012-04-24 13:14:49 +0000733 db eval {
drh55a1b302013-09-04 16:08:50 +0000734 PRAGMA encoding=UTF16;
drh5128e852012-04-24 13:14:49 +0000735 CREATE TABLE t1(x);
mistachkin585dcb22012-12-04 00:23:43 +0000736 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
mistachkin151c75a2015-04-07 21:16:40 +0000737 CREATE TABLE t3(x,y);
738 INSERT INTO t3 VALUES(1,null), (2,''), (3,1),
739 (4,2.25), (5,'hello'), (6,x'807f');
drh5128e852012-04-24 13:14:49 +0000740 }
741 catchcmd test.db {.dump}
742} {0 {PRAGMA foreign_keys=OFF;
743BEGIN TRANSACTION;
744CREATE TABLE t1(x);
drhf42d3182017-03-08 12:25:18 +0000745INSERT INTO t1 VALUES(NULL);
746INSERT INTO t1 VALUES('');
747INSERT INTO t1 VALUES(1);
748INSERT INTO t1 VALUES(2.25);
749INSERT INTO t1 VALUES('hello');
750INSERT INTO t1 VALUES(X'807f');
mistachkin151c75a2015-04-07 21:16:40 +0000751CREATE TABLE t3(x,y);
drhf42d3182017-03-08 12:25:18 +0000752INSERT INTO t3 VALUES(1,NULL);
753INSERT INTO t3 VALUES(2,'');
754INSERT INTO t3 VALUES(3,1);
755INSERT INTO t3 VALUES(4,2.25);
756INSERT INTO t3 VALUES(5,'hello');
757INSERT INTO t3 VALUES(6,X'807f');
drh5128e852012-04-24 13:14:49 +0000758COMMIT;}}
759
danb9cd86a2017-03-25 18:31:42 +0000760
761ifcapable vtab {
762
drhf42d3182017-03-08 12:25:18 +0000763# The --preserve-rowids option to .dump
764#
drhe611f142017-03-08 11:44:00 +0000765do_test shell1-4.1.1 {
766 catchcmd test.db {.dump --preserve-rowids}
767} {0 {PRAGMA foreign_keys=OFF;
768BEGIN TRANSACTION;
769CREATE TABLE t1(x);
drhf42d3182017-03-08 12:25:18 +0000770INSERT INTO t1(rowid,x) VALUES(1,NULL);
771INSERT INTO t1(rowid,x) VALUES(2,'');
772INSERT INTO t1(rowid,x) VALUES(3,1);
773INSERT INTO t1(rowid,x) VALUES(4,2.25);
774INSERT INTO t1(rowid,x) VALUES(5,'hello');
775INSERT INTO t1(rowid,x) VALUES(6,X'807f');
drhe611f142017-03-08 11:44:00 +0000776CREATE TABLE t3(x,y);
drhf42d3182017-03-08 12:25:18 +0000777INSERT INTO t3(rowid,x,y) VALUES(1,1,NULL);
778INSERT INTO t3(rowid,x,y) VALUES(2,2,'');
779INSERT INTO t3(rowid,x,y) VALUES(3,3,1);
780INSERT INTO t3(rowid,x,y) VALUES(4,4,2.25);
781INSERT INTO t3(rowid,x,y) VALUES(5,5,'hello');
782INSERT INTO t3(rowid,x,y) VALUES(6,6,X'807f');
drhe611f142017-03-08 11:44:00 +0000783COMMIT;}}
784
drhf42d3182017-03-08 12:25:18 +0000785# If the table contains an INTEGER PRIMARY KEY, do not record a separate
786# rowid column in the output.
787#
drhe611f142017-03-08 11:44:00 +0000788do_test shell1-4.1.2 {
789 db close
790 forcedelete test2.db
791 sqlite3 db test2.db
792 db eval {
793 CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
794 INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
795 (4,2.25), (5,'hello'), (6,x'807f');
796 }
797 catchcmd test2.db {.dump --preserve-rowids}
798} {0 {PRAGMA foreign_keys=OFF;
799BEGIN TRANSACTION;
800CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
drhf42d3182017-03-08 12:25:18 +0000801INSERT INTO t1 VALUES(1,NULL);
802INSERT INTO t1 VALUES(2,'');
803INSERT INTO t1 VALUES(3,1);
804INSERT INTO t1 VALUES(4,2.25);
805INSERT INTO t1 VALUES(5,'hello');
806INSERT INTO t1 VALUES(6,X'807f');
drhe611f142017-03-08 11:44:00 +0000807COMMIT;}}
808
drhf42d3182017-03-08 12:25:18 +0000809# Verify that the table named [table] is correctly quoted and that
810# an INTEGER PRIMARY KEY DESC is not an alias for the rowid.
811#
812do_test shell1-4.1.3 {
813 db close
814 forcedelete test2.db
815 sqlite3 db test2.db
816 db eval {
817 CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
818 INSERT INTO [table] VALUES(1,null), (12,''), (23,1),
819 (34,2.25), (45,'hello'), (56,x'807f');
820 }
821 catchcmd test2.db {.dump --preserve-rowids}
822} {0 {PRAGMA foreign_keys=OFF;
823BEGIN TRANSACTION;
824CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
825INSERT INTO "table"(rowid,x,y) VALUES(1,1,NULL);
826INSERT INTO "table"(rowid,x,y) VALUES(2,12,'');
827INSERT INTO "table"(rowid,x,y) VALUES(3,23,1);
828INSERT INTO "table"(rowid,x,y) VALUES(4,34,2.25);
829INSERT INTO "table"(rowid,x,y) VALUES(5,45,'hello');
830INSERT INTO "table"(rowid,x,y) VALUES(6,56,X'807f');
831COMMIT;}}
832
833# Do not record rowids for a WITHOUT ROWID table. Also check correct quoting
834# of table names that contain odd characters.
835#
836do_test shell1-4.1.4 {
837 db close
838 forcedelete test2.db
839 sqlite3 db test2.db
840 db eval {
841 CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
842 INSERT INTO [ta<>ble] VALUES(1,null), (12,''), (23,1),
843 (34,2.25), (45,'hello'), (56,x'807f');
844 }
845 catchcmd test2.db {.dump --preserve-rowids}
846} {0 {PRAGMA foreign_keys=OFF;
847BEGIN TRANSACTION;
848CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
849INSERT INTO "ta<>ble" VALUES(1,NULL);
850INSERT INTO "ta<>ble" VALUES(12,'');
851INSERT INTO "ta<>ble" VALUES(23,1);
852INSERT INTO "ta<>ble" VALUES(34,2.25);
853INSERT INTO "ta<>ble" VALUES(45,'hello');
854INSERT INTO "ta<>ble" VALUES(56,X'807f');
855COMMIT;}}
856
857# Do not record rowids if the rowid is inaccessible
858#
859do_test shell1-4.1.5 {
860 db close
861 forcedelete test2.db
862 sqlite3 db test2.db
863 db eval {
864 CREATE TABLE t1(_ROWID_,rowid,oid);
865 INSERT INTO t1 VALUES(1,null,'alpha'), (12,'',99), (23,1,x'b0b1b2');
866 }
867 catchcmd test2.db {.dump --preserve-rowids}
868} {0 {PRAGMA foreign_keys=OFF;
869BEGIN TRANSACTION;
870CREATE TABLE t1(_ROWID_,rowid,oid);
871INSERT INTO t1 VALUES(1,NULL,'alpha');
872INSERT INTO t1 VALUES(12,'',99);
873INSERT INTO t1 VALUES(23,1,X'b0b1b2');
874COMMIT;}}
drhe611f142017-03-08 11:44:00 +0000875
danb9cd86a2017-03-25 18:31:42 +0000876} else {
877
878do_test shell1-4.1.6 {
879 db close
880 forcedelete test2.db
881 sqlite3 db test2.db
882 db eval {
883 CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
884 INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
885 (4,2.25), (5,'hello'), (6,x'807f');
886 }
887 catchcmd test2.db {.dump --preserve-rowids}
888} {1 {The --preserve-rowids option is not compatible with SQLITE_OMIT_VIRTUALTABLE}}
889
890}
891
892
drh5128e852012-04-24 13:14:49 +0000893# Test the output of ".mode insert"
894#
mistachkin151c75a2015-04-07 21:16:40 +0000895do_test shell1-4.2.1 {
drh5128e852012-04-24 13:14:49 +0000896 catchcmd test.db ".mode insert t1\nselect * from t1;"
897} {0 {INSERT INTO t1 VALUES(NULL);
mistachkin585dcb22012-12-04 00:23:43 +0000898INSERT INTO t1 VALUES('');
drh5128e852012-04-24 13:14:49 +0000899INSERT INTO t1 VALUES(1);
900INSERT INTO t1 VALUES(2.25);
901INSERT INTO t1 VALUES('hello');
902INSERT INTO t1 VALUES(X'807f');}}
903
mistachkin151c75a2015-04-07 21:16:40 +0000904# Test the output of ".mode insert" with headers
905#
906do_test shell1-4.2.2 {
907 catchcmd test.db ".mode insert t1\n.headers on\nselect * from t1;"
908} {0 {INSERT INTO t1(x) VALUES(NULL);
909INSERT INTO t1(x) VALUES('');
910INSERT INTO t1(x) VALUES(1);
911INSERT INTO t1(x) VALUES(2.25);
912INSERT INTO t1(x) VALUES('hello');
913INSERT INTO t1(x) VALUES(X'807f');}}
914
915# Test the output of ".mode insert"
916#
917do_test shell1-4.2.3 {
918 catchcmd test.db ".mode insert t3\nselect * from t3;"
919} {0 {INSERT INTO t3 VALUES(1,NULL);
920INSERT INTO t3 VALUES(2,'');
921INSERT INTO t3 VALUES(3,1);
922INSERT INTO t3 VALUES(4,2.25);
923INSERT INTO t3 VALUES(5,'hello');
924INSERT INTO t3 VALUES(6,X'807f');}}
925
926# Test the output of ".mode insert" with headers
927#
mistachkincc445402015-04-07 21:17:53 +0000928do_test shell1-4.2.4 {
mistachkin151c75a2015-04-07 21:16:40 +0000929 catchcmd test.db ".mode insert t3\n.headers on\nselect * from t3;"
930} {0 {INSERT INTO t3(x,y) VALUES(1,NULL);
931INSERT INTO t3(x,y) VALUES(2,'');
932INSERT INTO t3(x,y) VALUES(3,1);
933INSERT INTO t3(x,y) VALUES(4,2.25);
934INSERT INTO t3(x,y) VALUES(5,'hello');
935INSERT INTO t3(x,y) VALUES(6,X'807f');}}
936
mistachkin585dcb22012-12-04 00:23:43 +0000937# Test the output of ".mode tcl"
938#
939do_test shell1-4.3 {
drh55a1b302013-09-04 16:08:50 +0000940 db close
941 forcedelete test.db
942 sqlite3 db test.db
943 db eval {
944 PRAGMA encoding=UTF8;
945 CREATE TABLE t1(x);
946 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
947 }
mistachkin585dcb22012-12-04 00:23:43 +0000948 catchcmd test.db ".mode tcl\nselect * from t1;"
949} {0 {""
950""
951"1"
952"2.25"
953"hello"
954"\200\177"}}
955
956# Test the output of ".mode tcl" with multiple columns
957#
958do_test shell1-4.4 {
959 db eval {
960 CREATE TABLE t2(x,y);
961 INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f');
962 }
963 catchcmd test.db ".mode tcl\nselect * from t2;"
964} {0 {"" ""
965"1" "2.25"
966"hello" "\200\177"}}
967
968# Test the output of ".mode tcl" with ".nullvalue"
969#
970do_test shell1-4.5 {
971 catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;"
972} {0 {"NULL" ""
973"1" "2.25"
974"hello" "\200\177"}}
975
976# Test the output of ".mode tcl" with Tcl reserved characters
977#
978do_test shell1-4.6 {
979 db eval {
980 CREATE TABLE tcl1(x);
981 INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$');
982 }
983 foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break
984 list $x $y [llength $y]
985} {0 {"\""
986"["
987"]"
988"\\{"
989"\\}"
990";"
991"$"} 7}
drh5128e852012-04-24 13:14:49 +0000992
mistachkinf21979d2015-01-18 05:35:01 +0000993# Test using arbitrary byte data with the shell via standard input/output.
994#
995do_test shell1-5.0 {
996 #
997 # NOTE: Skip NUL byte because it appears to be incompatible with command
998 # shell argument parsing.
999 #
1000 for {set i 1} {$i < 256} {incr i} {
1001 #
mistachkin46a6b992015-01-18 09:02:57 +00001002 # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats
1003 # command channels opened for it as textual ones), the carriage
1004 # return character (and on Windows, the end-of-file character)
1005 # cannot be used here.
mistachkinf21979d2015-01-18 05:35:01 +00001006 #
mistachkin46a6b992015-01-18 09:02:57 +00001007 if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
mistachkinf21979d2015-01-18 05:35:01 +00001008 continue
1009 }
drh01725682016-07-25 14:20:01 +00001010 if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
mistachkinbe56ad32016-07-29 04:12:18 +00001011 if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue
mistachkinf21979d2015-01-18 05:35:01 +00001012 set hex [format %02X $i]
1013 set char [subst \\x$hex]; set oldChar $char
mistachkin0acee512015-01-19 21:11:31 +00001014 set escapes [list]
1015 if {$tcl_platform(platform)=="windows"} {
1016 #
1017 # NOTE: On Windows, we need to escape all the whitespace characters,
1018 # the alarm (\a) character, and those with special meaning to
1019 # the SQLite shell itself.
1020 #
1021 set escapes [list \
1022 \a \\a \b \\b \t \\t \n \\n \v \\v \f \\f \r \\r \
1023 " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
1024 } else {
1025 #
1026 # NOTE: On Unix, we need to escape most of the whitespace characters
1027 # and those with special meaning to the SQLite shell itself.
1028 # The alarm (\a), backspace (\b), and carriage-return (\r)
1029 # characters do not appear to require escaping on Unix. For
1030 # the alarm and backspace characters, this is probably due to
1031 # differences in the command shell. For the carriage-return,
1032 # it is probably due to differences in how Tcl handles command
1033 # channel end-of-line translations.
1034 #
1035 set escapes [list \
1036 \t \\t \n \\n \v \\v \f \\f \
1037 " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
1038 }
1039 set char [string map $escapes $char]
mistachkinbfefa4c2015-01-19 21:27:46 +00001040 set x [catchcmdex test.db ".print $char\n"]
mistachkinf21979d2015-01-18 05:35:01 +00001041 set code [lindex $x 0]
1042 set res [lindex $x 1]
1043 if {$code ne "0"} {
1044 error "failed with error: $res"
1045 }
1046 if {$res ne "$oldChar\n"} {
mistachkin48dcf2b2016-04-04 17:59:37 +00001047 if {[llength $res] > 0} {
1048 set got [format %02X [scan $res %c]]
1049 } else {
1050 set got <empty>
1051 }
1052 error "failed with byte $hex mismatch, got $got"
mistachkinf21979d2015-01-18 05:35:01 +00001053 }
1054 }
1055} {}
1056
drh697c9ea2016-05-16 11:55:09 +00001057# These test cases do not work on MinGW
1058if 0 {
1059
mistachkin49e11252016-04-04 15:47:46 +00001060# The string used here is the word "test" in Chinese.
1061# In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95
1062set test \u6D4B\u8BD5
1063
mistachkin1fe36bb2016-04-04 02:16:44 +00001064do_test shell1-6.0 {
mistachkin49e11252016-04-04 15:47:46 +00001065 set fileName $test; append fileName .db
1066 catch {forcedelete $fileName}
mistachkin1fe36bb2016-04-04 02:16:44 +00001067 set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"]
1068 set code [lindex $x 0]
1069 set res [string trim [lindex $x 1]]
1070 if {$code ne "0"} {
1071 error "failed with error: $res"
1072 }
1073 if {$res ne "CREATE TABLE t1(x);"} {
1074 error "failed with mismatch: $res"
1075 }
1076 if {![file exists $fileName]} {
mistachkin1810f222016-04-04 02:33:34 +00001077 error "file \"$fileName\" (Unicode) does not exist"
mistachkin1fe36bb2016-04-04 02:16:44 +00001078 }
1079 forcedelete $fileName
1080} {}
1081
mistachkin49e11252016-04-04 15:47:46 +00001082do_test shell1-6.1 {
1083 catch {forcedelete test3.db}
1084 set x [catchcmdex test3.db \
1085 "CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"]
1086 set code [lindex $x 0]
1087 set res [string trim [lindex $x 1]]
1088 if {$code ne "0"} {
1089 error "failed with error: $res"
1090 }
1091 if {$res ne "CREATE TABLE ${test}(x);"} {
1092 error "failed with mismatch: $res"
1093 }
1094 forcedelete test3.db
1095} {}
drh697c9ea2016-05-16 11:55:09 +00001096}
mistachkin49e11252016-04-04 15:47:46 +00001097
drh8df91852012-04-24 12:46:05 +00001098finish_test