Index: third_party/sqlite/sqlite-src-3080704/test/shell1.test |
diff --git a/third_party/sqlite/src/tool/shell1.test b/third_party/sqlite/sqlite-src-3080704/test/shell1.test |
similarity index 75% |
copy from third_party/sqlite/src/tool/shell1.test |
copy to third_party/sqlite/sqlite-src-3080704/test/shell1.test |
index 7acb3b3ffd8e541c71e906f83f34283658f04294..ab382e74cbe052807a24606e67291781e2a36f97 100644 |
--- a/third_party/sqlite/src/tool/shell1.test |
+++ b/third_party/sqlite/sqlite-src-3080704/test/shell1.test |
@@ -11,7 +11,6 @@ |
# |
# The focus of this file is testing the CLI shell tool. |
# |
-# $Id: shell1.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $ |
# |
# Test plan: |
@@ -20,44 +19,19 @@ |
# shell1-2.*: Basic "dot" command token parsing. |
# shell1-3.*: Basic test that "dot" command can be called. |
# |
- |
-package require sqlite3 |
- |
-set CLI "./sqlite3" |
- |
-proc do_test {name cmd expected} { |
- puts -nonewline "$name ..." |
- set res [uplevel $cmd] |
- if {$res eq $expected} { |
- puts Ok |
- } else { |
- puts Error |
- puts " Got: $res" |
- puts " Expected: $expected" |
- exit |
- } |
+set testdir [file dirname $argv0] |
+source $testdir/tester.tcl |
+if {$tcl_platform(platform)=="windows"} { |
+ set CLI "sqlite3.exe" |
+} else { |
+ set CLI "./sqlite3" |
} |
- |
-proc execsql {sql} { |
- uplevel [list db eval $sql] |
-} |
- |
-proc catchsql {sql} { |
- set rc [catch {uplevel [list db eval $sql]} msg] |
- list $rc $msg |
+if {![file executable $CLI]} { |
+ finish_test |
+ return |
} |
- |
-proc catchcmd {db {cmd ""}} { |
- global CLI |
- set out [open cmds.txt w] |
- puts $out $cmd |
- close $out |
- set line "exec $CLI $db < cmds.txt" |
- set rc [catch { eval $line } msg] |
- list $rc $msg |
-} |
- |
-file delete -force test.db test.db.journal |
+db close |
+forcedelete test.db test.db-journal test.db-wal |
sqlite3 db test.db |
#---------------------------------------------------------------------------- |
@@ -131,7 +105,7 @@ do_test shell1-1.7.1 { |
set rc [lindex $res 0] |
list $rc \ |
[regexp {SQLite version} $res] \ |
- [regexp {Enter SQL statements} $res] |
+ [regexp {Enter ".help" for usage hints} $res] |
} {0 1 1} |
# -batch force batch I/O |
@@ -175,7 +149,7 @@ do_test shell1-1.14.3 { |
set res [catchcmd "-separator" ""] |
set rc [lindex $res 0] |
list $rc \ |
- [regexp {Error: missing argument for option: -separator} $res] |
+ [regexp {Error: missing argument to -separator} $res] |
} {1 1} |
# -stats print memory stats before each finalize |
@@ -194,13 +168,13 @@ do_test shell1-1.15.3 { |
set res [catchcmd "-nullvalue" ""] |
set rc [lindex $res 0] |
list $rc \ |
- [regexp {Error: missing argument for option: -nullvalue} $res] |
+ [regexp {Error: missing argument to -nullvalue} $res] |
} {1 1} |
# -version show SQLite version |
do_test shell1-1.16.1 { |
- catchcmd "-version test.db" "" |
-} {0 3.7.6.3} |
+ set x [catchcmd "-version test.db" ""] |
+} {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/} |
#---------------------------------------------------------------------------- |
# Test cases shell1-2.*: Basic "dot" command token parsing. |
@@ -246,7 +220,7 @@ do_test shell1-2.3.2 { |
} {0 {}} |
do_test shell1-2.3.3 { |
catchcmd "test.db" ".explain \"1 2 3\"" |
-} {0 {}} |
+} {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}} |
do_test shell1-2.3.4 { |
catchcmd "test.db" ".explain \"OFF\"" |
} {0 {}} |
@@ -279,7 +253,7 @@ do_test shell1-2.4.2 { |
# .backup ?DB? FILE Backup DB (default "main") to FILE |
do_test shell1-3.1.1 { |
catchcmd "test.db" ".backup" |
-} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} |
+} {1 {missing FILENAME argument on .backup}} |
do_test shell1-3.1.2 { |
catchcmd "test.db" ".backup FOO" |
} {0 {}} |
@@ -289,12 +263,12 @@ do_test shell1-3.1.3 { |
do_test shell1-3.1.4 { |
# too many arguments |
catchcmd "test.db" ".backup FOO BAR BAD" |
-} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} |
+} {1 {too many arguments to .backup}} |
# .bail ON|OFF Stop after hitting an error. Default OFF |
do_test shell1-3.2.1 { |
catchcmd "test.db" ".bail" |
-} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} |
+} {1 {Usage: .bail on|off}} |
do_test shell1-3.2.2 { |
catchcmd "test.db" ".bail ON" |
} {0 {}} |
@@ -304,17 +278,16 @@ do_test shell1-3.2.3 { |
do_test shell1-3.2.4 { |
# too many arguments |
catchcmd "test.db" ".bail OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} |
+} {1 {Usage: .bail on|off}} |
# .databases List names and files of attached databases |
do_test shell1-3.3.1 { |
- set res [catchcmd "test.db" ".databases"] |
- regexp {0.*main.*test\.db} $res |
-} {1} |
+ catchcmd "-csv test.db" ".databases" |
+} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" |
do_test shell1-3.3.2 { |
- # too many arguments |
+ # extra arguments ignored |
catchcmd "test.db" ".databases BAD" |
-} {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}} |
+} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" |
# .dump ?TABLE? ... Dump the database in an SQL text format |
# If TABLE specified, only dump tables matching |
@@ -332,12 +305,12 @@ do_test shell1-3.4.2 { |
do_test shell1-3.4.3 { |
# too many arguments |
catchcmd "test.db" ".dump FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}} |
+} {1 {Usage: .dump ?LIKE-PATTERN?}} |
# .echo ON|OFF Turn command echo on or off |
do_test shell1-3.5.1 { |
catchcmd "test.db" ".echo" |
-} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} |
+} {1 {Usage: .echo on|off}} |
do_test shell1-3.5.2 { |
catchcmd "test.db" ".echo ON" |
} {0 {}} |
@@ -347,16 +320,12 @@ do_test shell1-3.5.3 { |
do_test shell1-3.5.4 { |
# too many arguments |
catchcmd "test.db" ".echo OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} |
+} {1 {Usage: .echo on|off}} |
# .exit Exit this program |
do_test shell1-3.6.1 { |
catchcmd "test.db" ".exit" |
} {0 {}} |
-do_test shell1-3.6.2 { |
- # too many arguments |
- catchcmd "test.db" ".exit BAD" |
-} {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}} |
# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. |
do_test shell1-3.7.1 { |
@@ -370,15 +339,15 @@ do_test shell1-3.7.3 { |
catchcmd "test.db" ".explain OFF" |
} {0 {}} |
do_test shell1-3.7.4 { |
- # too many arguments |
+ # extra arguments ignored |
catchcmd "test.db" ".explain OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}} |
+} {0 {}} |
# .header(s) ON|OFF Turn display of headers on or off |
do_test shell1-3.9.1 { |
catchcmd "test.db" ".header" |
-} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} |
+} {1 {Usage: .headers on|off}} |
do_test shell1-3.9.2 { |
catchcmd "test.db" ".header ON" |
} {0 {}} |
@@ -388,11 +357,11 @@ do_test shell1-3.9.3 { |
do_test shell1-3.9.4 { |
# too many arguments |
catchcmd "test.db" ".header OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} |
+} {1 {Usage: .headers on|off}} |
do_test shell1-3.9.5 { |
catchcmd "test.db" ".headers" |
-} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} |
+} {1 {Usage: .headers on|off}} |
do_test shell1-3.9.6 { |
catchcmd "test.db" ".headers ON" |
} {0 {}} |
@@ -402,7 +371,7 @@ do_test shell1-3.9.7 { |
do_test shell1-3.9.8 { |
# too many arguments |
catchcmd "test.db" ".headers OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} |
+} {1 {Usage: .headers on|off}} |
# .help Show this message |
do_test shell1-3.10.1 { |
@@ -424,17 +393,17 @@ do_test shell1-3.10.2 { |
# .import FILE TABLE Import data from FILE into TABLE |
do_test shell1-3.11.1 { |
catchcmd "test.db" ".import" |
-} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} |
+} {1 {Usage: .import FILE TABLE}} |
do_test shell1-3.11.2 { |
catchcmd "test.db" ".import FOO" |
-} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} |
-do_test shell1-3.11.2 { |
- catchcmd "test.db" ".import FOO BAR" |
-} {1 {Error: no such table: BAR}} |
+} {1 {Usage: .import FILE TABLE}} |
+#do_test shell1-3.11.2 { |
+# catchcmd "test.db" ".import FOO BAR" |
+#} {1 {Error: no such table: BAR}} |
do_test shell1-3.11.3 { |
# too many arguments |
catchcmd "test.db" ".import FOO BAR BAD" |
-} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} |
+} {1 {Usage: .import FILE TABLE}} |
# .indices ?TABLE? Show names of all indices |
# If TABLE specified, only show indices for tables |
@@ -448,7 +417,7 @@ do_test shell1-3.12.2 { |
do_test shell1-3.12.3 { |
# too many arguments |
catchcmd "test.db" ".indices FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}} |
+} {1 {Usage: .indices ?LIKE-PATTERN?}} |
# .mode MODE ?TABLE? Set output mode where MODE is one of: |
# csv Comma-separated values |
@@ -461,7 +430,7 @@ do_test shell1-3.12.3 { |
# tcl TCL list elements |
do_test shell1-3.13.1 { |
catchcmd "test.db" ".mode" |
-} {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}} |
+} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} |
do_test shell1-3.13.2 { |
catchcmd "test.db" ".mode FOO" |
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} |
@@ -490,9 +459,9 @@ do_test shell1-3.13.10 { |
catchcmd "test.db" ".mode tcl" |
} {0 {}} |
do_test shell1-3.13.11 { |
- # too many arguments |
+ # extra arguments ignored |
catchcmd "test.db" ".mode tcl BAD" |
-} {1 {Error: invalid arguments: "BAD". Enter ".help" for help}} |
+} {0 {}} |
# don't allow partial mode type matches |
do_test shell1-3.13.12 { |
@@ -503,31 +472,31 @@ do_test shell1-3.13.13 { |
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} |
do_test shell1-3.13.14 { |
catchcmd "test.db" ".mode lin" |
-} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} |
+} {0 {}} |
# .nullvalue STRING Print STRING in place of NULL values |
do_test shell1-3.14.1 { |
catchcmd "test.db" ".nullvalue" |
-} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} |
+} {1 {Usage: .nullvalue STRING}} |
do_test shell1-3.14.2 { |
catchcmd "test.db" ".nullvalue FOO" |
} {0 {}} |
do_test shell1-3.14.3 { |
# too many arguments |
catchcmd "test.db" ".nullvalue FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} |
+} {1 {Usage: .nullvalue STRING}} |
# .output FILENAME Send output to FILENAME |
do_test shell1-3.15.1 { |
catchcmd "test.db" ".output" |
-} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} |
+} {0 {}} |
do_test shell1-3.15.2 { |
catchcmd "test.db" ".output FOO" |
} {0 {}} |
do_test shell1-3.15.3 { |
# too many arguments |
catchcmd "test.db" ".output FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} |
+} {1 {Usage: .output FILE}} |
# .output stdout Send output to the screen |
do_test shell1-3.16.1 { |
@@ -536,12 +505,12 @@ do_test shell1-3.16.1 { |
do_test shell1-3.16.2 { |
# too many arguments |
catchcmd "test.db" ".output stdout BAD" |
-} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} |
+} {1 {Usage: .output FILE}} |
# .prompt MAIN CONTINUE Replace the standard prompts |
do_test shell1-3.17.1 { |
catchcmd "test.db" ".prompt" |
-} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} |
+} {0 {}} |
do_test shell1-3.17.2 { |
catchcmd "test.db" ".prompt FOO" |
} {0 {}} |
@@ -551,7 +520,7 @@ do_test shell1-3.17.3 { |
do_test shell1-3.17.4 { |
# too many arguments |
catchcmd "test.db" ".prompt FOO BAR BAD" |
-} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} |
+} {0 {}} |
# .quit Exit this program |
do_test shell1-3.18.1 { |
@@ -560,25 +529,25 @@ do_test shell1-3.18.1 { |
do_test shell1-3.18.2 { |
# too many arguments |
catchcmd "test.db" ".quit BAD" |
-} {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}} |
+} {0 {}} |
# .read FILENAME Execute SQL in FILENAME |
do_test shell1-3.19.1 { |
catchcmd "test.db" ".read" |
-} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} |
+} {1 {Usage: .read FILE}} |
do_test shell1-3.19.2 { |
- file delete -force FOO |
+ forcedelete FOO |
catchcmd "test.db" ".read FOO" |
} {1 {Error: cannot open "FOO"}} |
do_test shell1-3.19.3 { |
# too many arguments |
catchcmd "test.db" ".read FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} |
+} {1 {Usage: .read FILE}} |
# .restore ?DB? FILE Restore content of DB (default "main") from FILE |
do_test shell1-3.20.1 { |
catchcmd "test.db" ".restore" |
-} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} |
+} {1 {Usage: .restore ?DB? FILE}} |
do_test shell1-3.20.2 { |
catchcmd "test.db" ".restore FOO" |
} {0 {}} |
@@ -588,7 +557,7 @@ do_test shell1-3.20.3 { |
do_test shell1-3.20.4 { |
# too many arguments |
catchcmd "test.db" ".restore FOO BAR BAD" |
-} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} |
+} {1 {Usage: .restore ?DB? FILE}} |
# .schema ?TABLE? Show the CREATE statements |
# If TABLE specified, only show tables matching |
@@ -602,19 +571,34 @@ do_test shell1-3.21.2 { |
do_test shell1-3.21.3 { |
# too many arguments |
catchcmd "test.db" ".schema FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}} |
+} {1 {Usage: .schema ?LIKE-PATTERN?}} |
+ |
+do_test shell1-3.21.4 { |
+ catchcmd "test.db" { |
+ CREATE TABLE t1(x); |
+ CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; |
+ CREATE VIEW v1 AS SELECT y+1 FROM v2; |
+ } |
+ catchcmd "test.db" ".schema" |
+} {0 {CREATE TABLE t1(x); |
+CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; |
+CREATE VIEW v1 AS SELECT y+1 FROM v2;}} |
+db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;} |
# .separator STRING Change separator used by output mode and .import |
do_test shell1-3.22.1 { |
catchcmd "test.db" ".separator" |
-} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} |
+} {1 {Usage: .separator SEPARATOR ?NEWLINE?}} |
do_test shell1-3.22.2 { |
catchcmd "test.db" ".separator FOO" |
} {0 {}} |
do_test shell1-3.22.3 { |
+ catchcmd "test.db" ".separator ABC XYZ" |
+} {0 {}} |
+do_test shell1-3.22.4 { |
# too many arguments |
- catchcmd "test.db" ".separator FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} |
+ catchcmd "test.db" ".separator FOO BAD BAD2" |
+} {1 {Usage: .separator SEPARATOR ?NEWLINE?}} |
# .show Show the current values for various settings |
do_test shell1-3.23.1 { |
@@ -632,12 +616,12 @@ do_test shell1-3.23.1 { |
do_test shell1-3.23.2 { |
# too many arguments |
catchcmd "test.db" ".show BAD" |
-} {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}} |
+} {1 {Usage: .show}} |
# .stats ON|OFF Turn stats on or off |
do_test shell1-3.23b.1 { |
catchcmd "test.db" ".stats" |
-} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}} |
+} {1 {Usage: .stats on|off}} |
do_test shell1-3.23b.2 { |
catchcmd "test.db" ".stats ON" |
} {0 {}} |
@@ -647,7 +631,7 @@ do_test shell1-3.23b.3 { |
do_test shell1-3.23b.4 { |
# too many arguments |
catchcmd "test.db" ".stats OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}} |
+} {1 {Usage: .stats on|off}} |
# .tables ?TABLE? List names of tables |
# If TABLE specified, only list tables matching |
@@ -661,12 +645,12 @@ do_test shell1-3.24.2 { |
do_test shell1-3.24.3 { |
# too many arguments |
catchcmd "test.db" ".tables FOO BAD" |
-} {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}} |
+} {0 {}} |
# .timeout MS Try opening locked tables for MS milliseconds |
do_test shell1-3.25.1 { |
catchcmd "test.db" ".timeout" |
-} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} |
+} {0 {}} |
do_test shell1-3.25.2 { |
catchcmd "test.db" ".timeout zzz" |
# this should be treated the same as a '0' timeout |
@@ -677,12 +661,12 @@ do_test shell1-3.25.3 { |
do_test shell1-3.25.4 { |
# too many arguments |
catchcmd "test.db" ".timeout 1 BAD" |
-} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} |
+} {0 {}} |
# .width NUM NUM ... Set column widths for "column" mode |
do_test shell1-3.26.1 { |
catchcmd "test.db" ".width" |
-} {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}} |
+} {0 {}} |
do_test shell1-3.26.2 { |
catchcmd "test.db" ".width xxx" |
# this should be treated the same as a '0' width for col 1 |
@@ -695,11 +679,20 @@ do_test shell1-3.26.4 { |
catchcmd "test.db" ".width 1 1" |
# this should be treated the same as a '1' width for col 1 and 2 |
} {0 {}} |
+do_test shell1-3.26.5 { |
+ catchcmd "test.db" ".mode column\n.width 10 -10\nSELECT 'abcdefg', 123456;" |
+ # this should be treated the same as a '1' width for col 1 and 2 |
+} {0 {abcdefg 123456}} |
+do_test shell1-3.26.6 { |
+ catchcmd "test.db" ".mode column\n.width -10 10\nSELECT 'abcdefg', 123456;" |
+ # this should be treated the same as a '1' width for col 1 and 2 |
+} {0 { abcdefg 123456 }} |
+ |
# .timer ON|OFF Turn the CPU timer measurement on or off |
do_test shell1-3.27.1 { |
catchcmd "test.db" ".timer" |
-} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} |
+} {1 {Usage: .timer on|off}} |
do_test shell1-3.27.2 { |
catchcmd "test.db" ".timer ON" |
} {0 {}} |
@@ -709,6 +702,114 @@ do_test shell1-3.27.3 { |
do_test shell1-3.27.4 { |
# too many arguments |
catchcmd "test.db" ".timer OFF BAD" |
-} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} |
+} {1 {Usage: .timer on|off}} |
+ |
+do_test shell1-3-28.1 { |
+ catchcmd test.db \ |
+ ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');" |
+} "0 {(123) hello\n456}" |
+ |
+do_test shell1-3-29.1 { |
+ catchcmd "test.db" ".print this is a test" |
+} {0 {this is a test}} |
+ |
+# dot-command argument quoting |
+do_test shell1-3-30.1 { |
+ catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'} |
+} {0 {this"is'a-test this\"is\\a\055test}} |
+do_test shell1-3-31.1 { |
+ catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'} |
+} [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"] |
-puts "CLI tests completed successfully" |
+ |
+# Test the output of the ".dump" command |
+# |
+do_test shell1-4.1 { |
+ db close |
+ forcedelete test.db |
+ sqlite3 db test.db |
+ db eval { |
+ PRAGMA encoding=UTF16; |
+ CREATE TABLE t1(x); |
+ INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f'); |
+ } |
+ catchcmd test.db {.dump} |
+} {0 {PRAGMA foreign_keys=OFF; |
+BEGIN TRANSACTION; |
+CREATE TABLE t1(x); |
+INSERT INTO "t1" VALUES(NULL); |
+INSERT INTO "t1" VALUES(''); |
+INSERT INTO "t1" VALUES(1); |
+INSERT INTO "t1" VALUES(2.25); |
+INSERT INTO "t1" VALUES('hello'); |
+INSERT INTO "t1" VALUES(X'807F'); |
+COMMIT;}} |
+ |
+# Test the output of ".mode insert" |
+# |
+do_test shell1-4.2 { |
+ catchcmd test.db ".mode insert t1\nselect * from t1;" |
+} {0 {INSERT INTO t1 VALUES(NULL); |
+INSERT INTO t1 VALUES(''); |
+INSERT INTO t1 VALUES(1); |
+INSERT INTO t1 VALUES(2.25); |
+INSERT INTO t1 VALUES('hello'); |
+INSERT INTO t1 VALUES(X'807f');}} |
+ |
+# Test the output of ".mode tcl" |
+# |
+do_test shell1-4.3 { |
+ db close |
+ forcedelete test.db |
+ sqlite3 db test.db |
+ db eval { |
+ PRAGMA encoding=UTF8; |
+ CREATE TABLE t1(x); |
+ INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f'); |
+ } |
+ catchcmd test.db ".mode tcl\nselect * from t1;" |
+} {0 {"" |
+"" |
+"1" |
+"2.25" |
+"hello" |
+"\200\177"}} |
+ |
+# Test the output of ".mode tcl" with multiple columns |
+# |
+do_test shell1-4.4 { |
+ db eval { |
+ CREATE TABLE t2(x,y); |
+ INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f'); |
+ } |
+ catchcmd test.db ".mode tcl\nselect * from t2;" |
+} {0 {"" "" |
+"1" "2.25" |
+"hello" "\200\177"}} |
+ |
+# Test the output of ".mode tcl" with ".nullvalue" |
+# |
+do_test shell1-4.5 { |
+ catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;" |
+} {0 {"NULL" "" |
+"1" "2.25" |
+"hello" "\200\177"}} |
+ |
+# Test the output of ".mode tcl" with Tcl reserved characters |
+# |
+do_test shell1-4.6 { |
+ db eval { |
+ CREATE TABLE tcl1(x); |
+ INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$'); |
+ } |
+ foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break |
+ list $x $y [llength $y] |
+} {0 {"\"" |
+"[" |
+"]" |
+"\\{" |
+"\\}" |
+";" |
+"$"} 7} |
+ |
+finish_test |