Have "PRAGMA quick_check" compare the number of entries in tables and indexes.
[sqlite.git] / test / shell3.test
blobf8d69946e7cbdbdd5586acf0911df9d1e6bb759f
1 # 2009 Dec 16
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.
14 # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
17 # Test plan:
19 #   shell3-1.*: Basic tests for running SQL statments from command line.
20 #   shell3-2.*: Basic tests for running SQL file from command line.
21 #   shell3-3.*: Basic tests for processing odd SQL constructs.
23 set testdir [file dirname $argv0]
24 source $testdir/tester.tcl
25 set CLI [test_cli_invocation]
26 db close
27 forcedelete test.db test.db-journal test.db-wal
28 sqlite3 db test.db
31 # There are inconsistencies in command-line argument quoting on Windows.
32 # In particular, individual applications are responsible for command-line
33 # parsing in Windows, not the shell.  Depending on whether the sqlite3.exe
34 # program is compiled with MinGW or MSVC, the command-line parsing is
35 # different.  This causes problems for the tests below.  To avoid
36 # issues, these tests are disabled for windows.
38 if {$::tcl_platform(platform)=="windows"} {
39   finish_test
40   return
43 #----------------------------------------------------------------------------
44 #   shell3-1.*: Basic tests for running SQL statments from command line.
47 # Run SQL statement from command line
48 do_test shell3-1.1 {
49   forcedelete foo.db
50   set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
51   set fexist [file exist foo.db]
52   list $rc $fexist
53 } {{0 {}} 1}
54 do_test shell3-1.2 {
55   catchcmd "foo.db" ".tables"
56 } {0 t1}
57 do_test shell3-1.3 {
58   catchcmd "foo.db \"DROP TABLE t1;\""
59 } {0 {}}
60 do_test shell3-1.4 {
61   catchcmd "foo.db" ".tables"
62 } {0 {}}
63 do_test shell3-1.5 {
64   catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\""
65 } {0 {}}
66 do_test shell3-1.6 {
67   catchcmd "foo.db" ".tables"
68 } {0 {}}
69 do_test shell3-1.7 {
70   catchcmd "foo.db \"CREATE TABLE\""
71 } {1 {Error: in prepare, incomplete input}}
73 #----------------------------------------------------------------------------
74 #   shell3-2.*: Basic tests for running SQL file from command line.
77 # Run SQL file from command line
78 do_test shell3-2.1 {
79   forcedelete foo.db
80   set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
81   set fexist [file exist foo.db]
82   list $rc $fexist
83 } {{0 {}} 1}
84 do_test shell3-2.2 {
85   catchcmd "foo.db" ".tables"
86 } {0 t1}
87 do_test shell3-2.3 {
88   catchcmd "foo.db" "DROP TABLE t1;"
89 } {0 {}}
90 do_test shell3-2.4 {
91   catchcmd "foo.db" ".tables"
92 } {0 {}}
93 do_test shell3-2.5 {
94   catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;"
95 } {0 {}}
96 do_test shell3-2.6 {
97   catchcmd "foo.db" ".tables"
98 } {0 {}}
99 do_test shell3-2.7 {
100   catchcmd "foo.db" "CREATE TABLE"
101 } {1 {Parse error near line 1: incomplete input}}
104 #----------------------------------------------------------------------------
105 #   shell3-3.*: Basic tests for processing odd SQL constructs.
108 # Run combinations of odd identifiers, comments, semicolon placement
109 do_test shell3-3.1 {
110   forcedelete foo.db
111   set rc [ catchcmd "foo.db" {CREATE TABLE t1("
112 a--.
113 " --x
114 ); CREATE TABLE t2("a[""b""]");
115 .header on
116 INSERT INTO t1 VALUES ('
117 x''y');
118 INSERT INTO t2 VALUES ('
120 .*/ x
121 ''y');
122 SELECT * from t1 limit 1;
123 SELECT * from t2 limit 1;
124 } ]
125   set fexist [file exist foo.db]
126   list $rc $fexist
127 } {{0 {
128 a--.
132 a["b"]
135 .*/ x
136 'y}} 1}
138 finish_test