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 #***********************************************************************
12 # The focus of this file is testing the CLI shell tool.
18 # 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.
22 set testdir [file dirname $argv0]
23 source $testdir/tester.tcl
24 if {$tcl_platform(platform)=="windows"} {
29 if {![file executable $CLI]} {
34 forcedelete test.db test.db-journal test.db-wal
37 #----------------------------------------------------------------------------
38 # Test cases shell1-1.*: Basic command line option handling.
42 do_test shell1-1.1.1 {
43 set res [catchcmd "-bad test.db" ""]
44 set rc [lindex $res 0]
46 [regexp {Error: unknown option: -bad} $res]
48 # error on extra options
49 do_test shell1-1.1.2 {
50 set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""]
51 set rc [lindex $res 0]
53 [regexp {Error: too many options: "select 4"} $res]
55 # error on extra options
56 do_test shell1-1.1.3 {
57 set res [catchcmd "-bad FOO test.db BAD" ".quit"]
58 set rc [lindex $res 0]
60 [regexp {Error: too many options: "BAD"} $res]
64 do_test shell1-1.2.1 {
65 set res [catchcmd "-help test.db" ""]
66 set rc [lindex $res 0]
68 [regexp {Usage} $res] \
69 [regexp {\-init} $res] \
70 [regexp {\-version} $res]
73 # -init filename read/process named file
74 do_test shell1-1.3.1 {
75 catchcmd "-init FOO test.db" ""
77 do_test shell1-1.3.2 {
78 set res [catchcmd "-init FOO test.db .quit BAD" ""]
79 set rc [lindex $res 0]
81 [regexp {Error: too many options: "BAD"} $res]
84 # -echo print commands before execution
85 do_test shell1-1.4.1 {
86 catchcmd "-echo test.db" ""
89 # -[no]header turn headers on or off
90 do_test shell1-1.5.1 {
91 catchcmd "-header test.db" ""
93 do_test shell1-1.5.2 {
94 catchcmd "-noheader test.db" ""
97 # -bail stop after hitting an error
98 do_test shell1-1.6.1 {
99 catchcmd "-bail test.db" ""
102 # -interactive force interactive I/O
103 do_test shell1-1.7.1 {
104 set res [catchcmd "-interactive test.db" ".quit"]
105 set rc [lindex $res 0]
107 [regexp {SQLite version} $res] \
108 [regexp {Enter ".help" for usage hints} $res]
111 # -batch force batch I/O
112 do_test shell1-1.8.1 {
113 catchcmd "-batch test.db" ""
116 # -column set output mode to 'column'
117 do_test shell1-1.9.1 {
118 catchcmd "-column test.db" ""
121 # -csv set output mode to 'csv'
122 do_test shell1-1.10.1 {
123 catchcmd "-csv test.db" ""
126 # -html set output mode to HTML
127 do_test shell1-1.11.1 {
128 catchcmd "-html test.db" ""
131 # -line set output mode to 'line'
132 do_test shell1-1.12.1 {
133 catchcmd "-line test.db" ""
136 # -list set output mode to 'list'
137 do_test shell1-1.13.1 {
138 catchcmd "-list test.db" ""
141 # -separator 'x' set output field separator (|)
142 do_test shell1-1.14.1 {
143 catchcmd "-separator 'x' test.db" ""
145 do_test shell1-1.14.2 {
146 catchcmd "-separator x test.db" ""
148 do_test shell1-1.14.3 {
149 set res [catchcmd "-separator" ""]
150 set rc [lindex $res 0]
152 [regexp {Error: missing argument to -separator} $res]
155 # -stats print memory stats before each finalize
156 do_test shell1-1.14b.1 {
157 catchcmd "-stats test.db" ""
160 # -nullvalue 'text' set text string for NULL values
161 do_test shell1-1.15.1 {
162 catchcmd "-nullvalue 'x' test.db" ""
164 do_test shell1-1.15.2 {
165 catchcmd "-nullvalue x test.db" ""
167 do_test shell1-1.15.3 {
168 set res [catchcmd "-nullvalue" ""]
169 set rc [lindex $res 0]
171 [regexp {Error: missing argument to -nullvalue} $res]
174 # -version show SQLite version
175 do_test shell1-1.16.1 {
176 set x [catchcmd "-version test.db" ""]
177 } {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/}
179 #----------------------------------------------------------------------------
180 # Test cases shell1-2.*: Basic "dot" command token parsing.
183 # check first token handling
184 do_test shell1-2.1.1 {
185 catchcmd "test.db" ".foo"
186 } {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
187 do_test shell1-2.1.2 {
188 catchcmd "test.db" ".\"foo OFF\""
189 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
190 do_test shell1-2.1.3 {
191 catchcmd "test.db" ".\'foo OFF\'"
192 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
195 do_test shell1-2.2.1 {
196 catchcmd "test.db" ".\"foo OFF"
197 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
198 do_test shell1-2.2.2 {
199 catchcmd "test.db" ".\'foo OFF"
200 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
201 do_test shell1-2.2.3 {
202 catchcmd "test.db" ".explain \"OFF"
204 do_test shell1-2.2.4 {
205 catchcmd "test.db" ".explain \'OFF"
207 do_test shell1-2.2.5 {
208 catchcmd "test.db" ".mode \"insert FOO"
209 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
210 do_test shell1-2.2.6 {
211 catchcmd "test.db" ".mode \'insert FOO"
212 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
214 # check multiple tokens, and quoted tokens
215 do_test shell1-2.3.1 {
216 catchcmd "test.db" ".explain 1"
218 do_test shell1-2.3.2 {
219 catchcmd "test.db" ".explain on"
221 do_test shell1-2.3.3 {
222 catchcmd "test.db" ".explain \"1 2 3\""
223 } {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
224 do_test shell1-2.3.4 {
225 catchcmd "test.db" ".explain \"OFF\""
227 do_test shell1-2.3.5 {
228 catchcmd "test.db" ".\'explain\' \'OFF\'"
230 do_test shell1-2.3.6 {
231 catchcmd "test.db" ".explain \'OFF\'"
233 do_test shell1-2.3.7 {
234 catchcmd "test.db" ".\'explain\' \'OFF\'"
237 # check quoted args are unquoted
238 do_test shell1-2.4.1 {
239 catchcmd "test.db" ".mode FOO"
240 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
241 do_test shell1-2.4.2 {
242 catchcmd "test.db" ".mode csv"
244 do_test shell1-2.4.2 {
245 catchcmd "test.db" ".mode \"csv\""
249 #----------------------------------------------------------------------------
250 # Test cases shell1-3.*: Basic test that "dot" command can be called.
253 # .backup ?DB? FILE Backup DB (default "main") to FILE
254 do_test shell1-3.1.1 {
255 catchcmd "test.db" ".backup"
256 } {1 {missing FILENAME argument on .backup}}
257 do_test shell1-3.1.2 {
258 catchcmd "test.db" ".backup FOO"
260 do_test shell1-3.1.3 {
261 catchcmd "test.db" ".backup FOO BAR"
262 } {1 {Error: unknown database FOO}}
263 do_test shell1-3.1.4 {
265 catchcmd "test.db" ".backup FOO BAR BAD"
266 } {1 {too many arguments to .backup}}
268 # .bail ON|OFF Stop after hitting an error. Default OFF
269 do_test shell1-3.2.1 {
270 catchcmd "test.db" ".bail"
271 } {1 {Usage: .bail on|off}}
272 do_test shell1-3.2.2 {
273 catchcmd "test.db" ".bail ON"
275 do_test shell1-3.2.3 {
276 catchcmd "test.db" ".bail OFF"
278 do_test shell1-3.2.4 {
280 catchcmd "test.db" ".bail OFF BAD"
281 } {1 {Usage: .bail on|off}}
283 # .databases List names and files of attached databases
284 do_test shell1-3.3.1 {
285 catchcmd "-csv test.db" ".databases"
286 } "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/"
287 do_test shell1-3.3.2 {
288 # extra arguments ignored
289 catchcmd "test.db" ".databases BAD"
290 } "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/"
292 # .dump ?TABLE? ... Dump the database in an SQL text format
293 # If TABLE specified, only dump tables matching
294 # LIKE pattern TABLE.
295 do_test shell1-3.4.1 {
296 set res [catchcmd "test.db" ".dump"]
297 list [regexp {BEGIN TRANSACTION;} $res] \
298 [regexp {COMMIT;} $res]
300 do_test shell1-3.4.2 {
301 set res [catchcmd "test.db" ".dump FOO"]
302 list [regexp {BEGIN TRANSACTION;} $res] \
303 [regexp {COMMIT;} $res]
305 do_test shell1-3.4.3 {
307 catchcmd "test.db" ".dump FOO BAD"
308 } {1 {Usage: .dump ?LIKE-PATTERN?}}
310 # .echo ON|OFF Turn command echo on or off
311 do_test shell1-3.5.1 {
312 catchcmd "test.db" ".echo"
313 } {1 {Usage: .echo on|off}}
314 do_test shell1-3.5.2 {
315 catchcmd "test.db" ".echo ON"
317 do_test shell1-3.5.3 {
318 catchcmd "test.db" ".echo OFF"
320 do_test shell1-3.5.4 {
322 catchcmd "test.db" ".echo OFF BAD"
323 } {1 {Usage: .echo on|off}}
325 # .exit Exit this program
326 do_test shell1-3.6.1 {
327 catchcmd "test.db" ".exit"
330 # .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
331 do_test shell1-3.7.1 {
332 catchcmd "test.db" ".explain"
333 # explain is the exception to the booleans. without an option, it turns it on.
335 do_test shell1-3.7.2 {
336 catchcmd "test.db" ".explain ON"
338 do_test shell1-3.7.3 {
339 catchcmd "test.db" ".explain OFF"
341 do_test shell1-3.7.4 {
342 # extra arguments ignored
343 catchcmd "test.db" ".explain OFF BAD"
347 # .header(s) ON|OFF Turn display of headers on or off
348 do_test shell1-3.9.1 {
349 catchcmd "test.db" ".header"
350 } {1 {Usage: .headers on|off}}
351 do_test shell1-3.9.2 {
352 catchcmd "test.db" ".header ON"
354 do_test shell1-3.9.3 {
355 catchcmd "test.db" ".header OFF"
357 do_test shell1-3.9.4 {
359 catchcmd "test.db" ".header OFF BAD"
360 } {1 {Usage: .headers on|off}}
362 do_test shell1-3.9.5 {
363 catchcmd "test.db" ".headers"
364 } {1 {Usage: .headers on|off}}
365 do_test shell1-3.9.6 {
366 catchcmd "test.db" ".headers ON"
368 do_test shell1-3.9.7 {
369 catchcmd "test.db" ".headers OFF"
371 do_test shell1-3.9.8 {
373 catchcmd "test.db" ".headers OFF BAD"
374 } {1 {Usage: .headers on|off}}
376 # .help Show this message
377 do_test shell1-3.10.1 {
378 set res [catchcmd "test.db" ".help"]
379 # look for a few of the possible help commands
380 list [regexp {.help} $res] \
381 [regexp {.quit} $res] \
382 [regexp {.show} $res]
384 do_test shell1-3.10.2 {
385 # we allow .help to take extra args (it is help after all)
386 set res [catchcmd "test.db" ".help BAD"]
387 # look for a few of the possible help commands
388 list [regexp {.help} $res] \
389 [regexp {.quit} $res] \
390 [regexp {.show} $res]
393 # .import FILE TABLE Import data from FILE into TABLE
394 do_test shell1-3.11.1 {
395 catchcmd "test.db" ".import"
396 } {1 {Usage: .import FILE TABLE}}
397 do_test shell1-3.11.2 {
398 catchcmd "test.db" ".import FOO"
399 } {1 {Usage: .import FILE TABLE}}
400 #do_test shell1-3.11.2 {
401 # catchcmd "test.db" ".import FOO BAR"
402 #} {1 {Error: no such table: BAR}}
403 do_test shell1-3.11.3 {
405 catchcmd "test.db" ".import FOO BAR BAD"
406 } {1 {Usage: .import FILE TABLE}}
408 # .indices ?TABLE? Show names of all indices
409 # If TABLE specified, only show indices for tables
410 # matching LIKE pattern TABLE.
411 do_test shell1-3.12.1 {
412 catchcmd "test.db" ".indices"
414 do_test shell1-3.12.2 {
415 catchcmd "test.db" ".indices FOO"
417 do_test shell1-3.12.3 {
419 catchcmd "test.db" ".indices FOO BAD"
420 } {1 {Usage: .indices ?LIKE-PATTERN?}}
422 # .mode MODE ?TABLE? Set output mode where MODE is one of:
423 # csv Comma-separated values
424 # column Left-aligned columns. (See .width)
425 # html HTML <table> code
426 # insert SQL insert statements for TABLE
427 # line One value per line
428 # list Values delimited by .separator string
429 # tabs Tab-separated values
430 # tcl TCL list elements
431 do_test shell1-3.13.1 {
432 catchcmd "test.db" ".mode"
433 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
434 do_test shell1-3.13.2 {
435 catchcmd "test.db" ".mode FOO"
436 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
437 do_test shell1-3.13.3 {
438 catchcmd "test.db" ".mode csv"
440 do_test shell1-3.13.4 {
441 catchcmd "test.db" ".mode column"
443 do_test shell1-3.13.5 {
444 catchcmd "test.db" ".mode html"
446 do_test shell1-3.13.6 {
447 catchcmd "test.db" ".mode insert"
449 do_test shell1-3.13.7 {
450 catchcmd "test.db" ".mode line"
452 do_test shell1-3.13.8 {
453 catchcmd "test.db" ".mode list"
455 do_test shell1-3.13.9 {
456 catchcmd "test.db" ".mode tabs"
458 do_test shell1-3.13.10 {
459 catchcmd "test.db" ".mode tcl"
461 do_test shell1-3.13.11 {
462 # extra arguments ignored
463 catchcmd "test.db" ".mode tcl BAD"
466 # don't allow partial mode type matches
467 do_test shell1-3.13.12 {
468 catchcmd "test.db" ".mode l"
469 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
470 do_test shell1-3.13.13 {
471 catchcmd "test.db" ".mode li"
472 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
473 do_test shell1-3.13.14 {
474 catchcmd "test.db" ".mode lin"
477 # .nullvalue STRING Print STRING in place of NULL values
478 do_test shell1-3.14.1 {
479 catchcmd "test.db" ".nullvalue"
480 } {1 {Usage: .nullvalue STRING}}
481 do_test shell1-3.14.2 {
482 catchcmd "test.db" ".nullvalue FOO"
484 do_test shell1-3.14.3 {
486 catchcmd "test.db" ".nullvalue FOO BAD"
487 } {1 {Usage: .nullvalue STRING}}
489 # .output FILENAME Send output to FILENAME
490 do_test shell1-3.15.1 {
491 catchcmd "test.db" ".output"
493 do_test shell1-3.15.2 {
494 catchcmd "test.db" ".output FOO"
496 do_test shell1-3.15.3 {
498 catchcmd "test.db" ".output FOO BAD"
499 } {1 {Usage: .output FILE}}
501 # .output stdout Send output to the screen
502 do_test shell1-3.16.1 {
503 catchcmd "test.db" ".output stdout"
505 do_test shell1-3.16.2 {
507 catchcmd "test.db" ".output stdout BAD"
508 } {1 {Usage: .output FILE}}
510 # .prompt MAIN CONTINUE Replace the standard prompts
511 do_test shell1-3.17.1 {
512 catchcmd "test.db" ".prompt"
514 do_test shell1-3.17.2 {
515 catchcmd "test.db" ".prompt FOO"
517 do_test shell1-3.17.3 {
518 catchcmd "test.db" ".prompt FOO BAR"
520 do_test shell1-3.17.4 {
522 catchcmd "test.db" ".prompt FOO BAR BAD"
525 # .quit Exit this program
526 do_test shell1-3.18.1 {
527 catchcmd "test.db" ".quit"
529 do_test shell1-3.18.2 {
531 catchcmd "test.db" ".quit BAD"
534 # .read FILENAME Execute SQL in FILENAME
535 do_test shell1-3.19.1 {
536 catchcmd "test.db" ".read"
537 } {1 {Usage: .read FILE}}
538 do_test shell1-3.19.2 {
540 catchcmd "test.db" ".read FOO"
541 } {1 {Error: cannot open "FOO"}}
542 do_test shell1-3.19.3 {
544 catchcmd "test.db" ".read FOO BAD"
545 } {1 {Usage: .read FILE}}
547 # .restore ?DB? FILE Restore content of DB (default "main") from FILE
548 do_test shell1-3.20.1 {
549 catchcmd "test.db" ".restore"
550 } {1 {Usage: .restore ?DB? FILE}}
551 do_test shell1-3.20.2 {
552 catchcmd "test.db" ".restore FOO"
554 do_test shell1-3.20.3 {
555 catchcmd "test.db" ".restore FOO BAR"
556 } {1 {Error: unknown database FOO}}
557 do_test shell1-3.20.4 {
559 catchcmd "test.db" ".restore FOO BAR BAD"
560 } {1 {Usage: .restore ?DB? FILE}}
562 # .schema ?TABLE? Show the CREATE statements
563 # If TABLE specified, only show tables matching
564 # LIKE pattern TABLE.
565 do_test shell1-3.21.1 {
566 catchcmd "test.db" ".schema"
568 do_test shell1-3.21.2 {
569 catchcmd "test.db" ".schema FOO"
571 do_test shell1-3.21.3 {
573 catchcmd "test.db" ".schema FOO BAD"
574 } {1 {Usage: .schema ?LIKE-PATTERN?}}
576 do_test shell1-3.21.4 {
579 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
580 CREATE VIEW v1 AS SELECT y+1 FROM v2;
582 catchcmd "test.db" ".schema"
583 } {0 {CREATE TABLE t1(x);
584 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
585 CREATE VIEW v1 AS SELECT y+1 FROM v2;}}
586 db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}
588 # .separator STRING Change separator used by output mode and .import
589 do_test shell1-3.22.1 {
590 catchcmd "test.db" ".separator"
591 } {1 {Usage: .separator SEPARATOR ?NEWLINE?}}
592 do_test shell1-3.22.2 {
593 catchcmd "test.db" ".separator FOO"
595 do_test shell1-3.22.3 {
596 catchcmd "test.db" ".separator ABC XYZ"
598 do_test shell1-3.22.4 {
600 catchcmd "test.db" ".separator FOO BAD BAD2"
601 } {1 {Usage: .separator SEPARATOR ?NEWLINE?}}
603 # .show Show the current values for various settings
604 do_test shell1-3.23.1 {
605 set res [catchcmd "test.db" ".show"]
606 list [regexp {echo:} $res] \
607 [regexp {explain:} $res] \
608 [regexp {headers:} $res] \
609 [regexp {mode:} $res] \
610 [regexp {nullvalue:} $res] \
611 [regexp {output:} $res] \
612 [regexp {separator:} $res] \
613 [regexp {stats:} $res] \
614 [regexp {width:} $res]
615 } {1 1 1 1 1 1 1 1 1}
616 do_test shell1-3.23.2 {
618 catchcmd "test.db" ".show BAD"
621 # .stats ON|OFF Turn stats on or off
622 do_test shell1-3.23b.1 {
623 catchcmd "test.db" ".stats"
624 } {1 {Usage: .stats on|off}}
625 do_test shell1-3.23b.2 {
626 catchcmd "test.db" ".stats ON"
628 do_test shell1-3.23b.3 {
629 catchcmd "test.db" ".stats OFF"
631 do_test shell1-3.23b.4 {
633 catchcmd "test.db" ".stats OFF BAD"
634 } {1 {Usage: .stats on|off}}
636 # .tables ?TABLE? List names of tables
637 # If TABLE specified, only list tables matching
638 # LIKE pattern TABLE.
639 do_test shell1-3.24.1 {
640 catchcmd "test.db" ".tables"
642 do_test shell1-3.24.2 {
643 catchcmd "test.db" ".tables FOO"
645 do_test shell1-3.24.3 {
647 catchcmd "test.db" ".tables FOO BAD"
650 # .timeout MS Try opening locked tables for MS milliseconds
651 do_test shell1-3.25.1 {
652 catchcmd "test.db" ".timeout"
654 do_test shell1-3.25.2 {
655 catchcmd "test.db" ".timeout zzz"
656 # this should be treated the same as a '0' timeout
658 do_test shell1-3.25.3 {
659 catchcmd "test.db" ".timeout 1"
661 do_test shell1-3.25.4 {
663 catchcmd "test.db" ".timeout 1 BAD"
666 # .width NUM NUM ... Set column widths for "column" mode
667 do_test shell1-3.26.1 {
668 catchcmd "test.db" ".width"
670 do_test shell1-3.26.2 {
671 catchcmd "test.db" ".width xxx"
672 # this should be treated the same as a '0' width for col 1
674 do_test shell1-3.26.3 {
675 catchcmd "test.db" ".width xxx yyy"
676 # this should be treated the same as a '0' width for col 1 and 2
678 do_test shell1-3.26.4 {
679 catchcmd "test.db" ".width 1 1"
680 # this should be treated the same as a '1' width for col 1 and 2
682 do_test shell1-3.26.5 {
683 catchcmd "test.db" ".mode column\n.width 10 -10\nSELECT 'abcdefg', 123456;"
684 # this should be treated the same as a '1' width for col 1 and 2
685 } {0 {abcdefg 123456}}
686 do_test shell1-3.26.6 {
687 catchcmd "test.db" ".mode column\n.width -10 10\nSELECT 'abcdefg', 123456;"
688 # this should be treated the same as a '1' width for col 1 and 2
689 } {0 { abcdefg 123456 }}
692 # .timer ON|OFF Turn the CPU timer measurement on or off
693 do_test shell1-3.27.1 {
694 catchcmd "test.db" ".timer"
695 } {1 {Usage: .timer on|off}}
696 do_test shell1-3.27.2 {
697 catchcmd "test.db" ".timer ON"
699 do_test shell1-3.27.3 {
700 catchcmd "test.db" ".timer OFF"
702 do_test shell1-3.27.4 {
704 catchcmd "test.db" ".timer OFF BAD"
705 } {1 {Usage: .timer on|off}}
707 do_test shell1-3-28.1 {
709 ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
710 } "0 {(123) hello\n456}"
712 do_test shell1-3-29.1 {
713 catchcmd "test.db" ".print this is a test"
714 } {0 {this is a test}}
716 # dot-command argument quoting
717 do_test shell1-3-30.1 {
718 catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'}
719 } {0 {this"is'a-test this\"is\\a\055test}}
720 do_test shell1-3-31.1 {
721 catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'}
722 } [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"]
725 # Test the output of the ".dump" command
732 PRAGMA encoding=UTF16;
734 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
736 catchcmd test.db {.dump}
737 } {0 {PRAGMA foreign_keys=OFF;
740 INSERT INTO "t1" VALUES(NULL);
741 INSERT INTO "t1" VALUES('');
742 INSERT INTO "t1" VALUES(1);
743 INSERT INTO "t1" VALUES(2.25);
744 INSERT INTO "t1" VALUES('hello');
745 INSERT INTO "t1" VALUES(X'807F');
748 # Test the output of ".mode insert"
751 catchcmd test.db ".mode insert t1\nselect * from t1;"
752 } {0 {INSERT INTO t1 VALUES(NULL);
753 INSERT INTO t1 VALUES('');
754 INSERT INTO t1 VALUES(1);
755 INSERT INTO t1 VALUES(2.25);
756 INSERT INTO t1 VALUES('hello');
757 INSERT INTO t1 VALUES(X'807f');}}
759 # Test the output of ".mode tcl"
766 PRAGMA encoding=UTF8;
768 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
770 catchcmd test.db ".mode tcl\nselect * from t1;"
778 # Test the output of ".mode tcl" with multiple columns
782 CREATE TABLE t2(x,y);
783 INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f');
785 catchcmd test.db ".mode tcl\nselect * from t2;"
790 # Test the output of ".mode tcl" with ".nullvalue"
793 catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;"
798 # Test the output of ".mode tcl" with Tcl reserved characters
802 CREATE TABLE tcl1(x);
803 INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$');
805 foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break
806 list $x $y [llength $y]