xref: /sqlite-3.40.0/test/shell1.test (revision 697c50b9)
1# 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#
14#
15
16# Test plan:
17#
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.
21#   shell1-{4-8}.*: Test various "dot" commands's functionality.
22#   shell1-9.*: Basic test that "dot" commands and SQL intermix ok.
23#
24set testdir [file dirname $argv0]
25source $testdir/tester.tcl
26set CLI [test_find_cli]
27db close
28forcedelete test.db test.db-journal test.db-wal
29sqlite3 db test.db
30
31#----------------------------------------------------------------------------
32# Test cases shell1-1.*: Basic command line option handling.
33#
34
35# invalid option
36do_test shell1-1.1.1 {
37  set res [catchcmd "-bad test.db" ""]
38  set rc [lindex $res 0]
39  list $rc \
40       [regexp {Error: unknown option: -bad} $res]
41} {1 1}
42do_test shell1-1.1.1b {
43  set res [catchcmd "test.db -bad" ""]
44  set rc [lindex $res 0]
45  list $rc \
46       [regexp {Error: unknown option: -bad} $res]
47} {1 1}
48# error on extra options
49do_test shell1-1.1.2 {
50  catchcmd "test.db \"select+3\" \"select+4\"" ""
51} {0 {3
524}}
53# error on extra options
54do_test shell1-1.1.3 {
55  catchcmd "test.db FOO test.db BAD" ".quit"
56} {/1 .Error: in prepare, near "FOO": syntax error (1)*/}
57
58# -help
59do_test shell1-1.2.1 {
60  set res [catchcmd "-help test.db" ""]
61  set rc [lindex $res 0]
62  list $rc \
63       [regexp {Usage} $res] \
64       [regexp {\-init} $res] \
65       [regexp {\-version} $res]
66} {1 1 1 1}
67
68# -init filename       read/process named file
69forcedelete FOO
70set out [open FOO w]
71puts $out ""
72close $out
73do_test shell1-1.3.1 {
74  catchcmd "-init FOO test.db" ""
75} {0 {}}
76do_test shell1-1.3.2 {
77  catchcmd "-init FOO test.db .quit BAD" ""
78} {0 {}}
79do_test shell1-1.3.3 {
80  catchcmd "-init FOO test.db BAD .quit" ""
81} {/1 .Error: in prepare, near "BAD": syntax error (1)*/}
82
83# -echo                print commands before execution
84do_test shell1-1.4.1 {
85  catchcmd "-echo test.db" ""
86} {0 {}}
87
88# -[no]header          turn headers on or off
89do_test shell1-1.5.1 {
90  catchcmd "-header test.db" ""
91} {0 {}}
92do_test shell1-1.5.2 {
93  catchcmd "-noheader test.db" ""
94} {0 {}}
95
96# -bail                stop after hitting an error
97do_test shell1-1.6.1 {
98  catchcmd "-bail test.db" ""
99} {0 {}}
100
101# -interactive         force interactive I/O
102do_test shell1-1.7.1 {
103  set res [catchcmd "-interactive test.db" ".quit"]
104  set rc [lindex $res 0]
105  list $rc \
106       [regexp {SQLite version} $res] \
107       [regexp {Enter ".help" for usage hints} $res]
108} {0 1 1}
109
110# -batch               force batch I/O
111do_test shell1-1.8.1 {
112  catchcmd "-batch test.db" ""
113} {0 {}}
114
115# -column              set output mode to 'column'
116do_test shell1-1.9.1 {
117  catchcmd "-column test.db" ""
118} {0 {}}
119
120# -csv                 set output mode to 'csv'
121do_test shell1-1.10.1 {
122  catchcmd "-csv test.db" ""
123} {0 {}}
124
125# -html                set output mode to HTML
126do_test shell1-1.11.1 {
127  catchcmd "-html test.db" ""
128} {0 {}}
129
130# -line                set output mode to 'line'
131do_test shell1-1.12.1 {
132  catchcmd "-line test.db" ""
133} {0 {}}
134
135# -list                set output mode to 'list'
136do_test shell1-1.13.1 {
137  catchcmd "-list test.db" ""
138} {0 {}}
139
140# -separator 'x'       set output field separator (|)
141do_test shell1-1.14.1 {
142  catchcmd "-separator 'x' test.db" ""
143} {0 {}}
144do_test shell1-1.14.2 {
145  catchcmd "-separator x test.db" ""
146} {0 {}}
147do_test shell1-1.14.3 {
148  set res [catchcmd "-separator" ""]
149  set rc [lindex $res 0]
150  list $rc \
151       [regexp {Error: missing argument to -separator} $res]
152} {1 1}
153
154# -stats               print memory stats before each finalize
155do_test shell1-1.14b.1 {
156  catchcmd "-stats test.db" ""
157} {0 {}}
158
159# -nullvalue 'text'    set text string for NULL values
160do_test shell1-1.15.1 {
161  catchcmd "-nullvalue 'x' test.db" ""
162} {0 {}}
163do_test shell1-1.15.2 {
164  catchcmd "-nullvalue x test.db" ""
165} {0 {}}
166do_test shell1-1.15.3 {
167  set res [catchcmd "-nullvalue" ""]
168  set rc [lindex $res 0]
169  list $rc \
170       [regexp {Error: missing argument to -nullvalue} $res]
171} {1 1}
172
173# -version             show SQLite version
174do_test shell1-1.16.1 {
175  set x [catchcmd "-version test.db" ""]
176} {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/}
177
178#----------------------------------------------------------------------------
179# Test cases shell1-2.*: Basic "dot" command token parsing.
180#
181
182# check first token handling
183do_test shell1-2.1.1 {
184  catchcmd "test.db" ".foo"
185} {1 {Error: unknown command or invalid arguments:  "foo". Enter ".help" for help}}
186do_test shell1-2.1.2 {
187  catchcmd "test.db" ".\"foo OFF\""
188} {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
189do_test shell1-2.1.3 {
190  catchcmd "test.db" ".\'foo OFF\'"
191} {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
192
193# unbalanced quotes
194do_test shell1-2.2.1 {
195  catchcmd "test.db" ".\"foo OFF"
196} {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
197do_test shell1-2.2.2 {
198  catchcmd "test.db" ".\'foo OFF"
199} {1 {Error: unknown command or invalid arguments:  "foo OFF". Enter ".help" for help}}
200do_test shell1-2.2.3 {
201  catchcmd "test.db" ".explain \"OFF"
202} {0 {}}
203do_test shell1-2.2.4 {
204  catchcmd "test.db" ".explain \'OFF"
205} {0 {}}
206do_test shell1-2.2.5 {
207  catchcmd "test.db" ".mode \"insert FOO"
208} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
209do_test shell1-2.2.6 {
210  catchcmd "test.db" ".mode \'insert FOO"
211} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
212
213# check multiple tokens, and quoted tokens
214do_test shell1-2.3.1 {
215  catchcmd "test.db" ".explain 1"
216} {0 {}}
217do_test shell1-2.3.2 {
218  catchcmd "test.db" ".explain on"
219} {0 {}}
220do_test shell1-2.3.3 {
221  catchcmd "test.db" ".explain \"1 2 3\""
222} {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
223do_test shell1-2.3.4 {
224  catchcmd "test.db" ".explain \"OFF\""
225} {0 {}}
226do_test shell1-2.3.5 {
227  catchcmd "test.db" ".\'explain\' \'OFF\'"
228} {0 {}}
229do_test shell1-2.3.6 {
230  catchcmd "test.db" ".explain \'OFF\'"
231} {0 {}}
232do_test shell1-2.3.7 {
233  catchcmd "test.db" ".\'explain\' \'OFF\'"
234} {0 {}}
235
236# check quoted args are unquoted
237do_test shell1-2.4.1 {
238  catchcmd "test.db" ".mode FOO"
239} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
240do_test shell1-2.4.2 {
241  catchcmd "test.db" ".mode csv"
242} {0 {}}
243do_test shell1-2.4.2 {
244  catchcmd "test.db" ".mode \"csv\""
245} {0 {}}
246
247
248#----------------------------------------------------------------------------
249# Test cases shell1-3.*: Basic test that "dot" command can be called.
250#
251
252# .backup ?DB? FILE      Backup DB (default "main") to FILE
253do_test shell1-3.1.1 {
254  catchcmd "test.db" ".backup"
255} {1 {missing FILENAME argument on .backup}}
256forcedelete FOO
257do_test shell1-3.1.2 {
258  catchcmd "test.db" ".backup FOO"
259} {0 {}}
260do_test shell1-3.1.3 {
261  catchcmd "test.db" ".backup FOO BAR"
262} {1 {Error: unknown database FOO}}
263do_test shell1-3.1.4 {
264  # too many arguments
265  catchcmd "test.db" ".backup FOO BAR BAD"
266} {1 {Usage: .backup ?DB? ?OPTIONS? FILENAME}}
267
268# .bail ON|OFF           Stop after hitting an error.  Default OFF
269do_test shell1-3.2.1 {
270  catchcmd "test.db" ".bail"
271} {1 {Usage: .bail on|off}}
272do_test shell1-3.2.2 {
273  catchcmd "test.db" ".bail ON"
274} {0 {}}
275do_test shell1-3.2.3 {
276  catchcmd "test.db" ".bail OFF"
277} {0 {}}
278do_test shell1-3.2.4 {
279  # too many arguments
280  catchcmd "test.db" ".bail OFF BAD"
281} {1 {Usage: .bail on|off}}
282
283ifcapable vtab {
284# .databases             List names and files of attached databases
285do_test shell1-3.3.1 {
286  catchcmd "-csv test.db" ".databases"
287} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
288do_test shell1-3.3.2 {
289  # extra arguments ignored
290  catchcmd "test.db" ".databases BAD"
291} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
292}
293
294# .dump ?TABLE? ...      Dump the database in an SQL text format
295#                          If TABLE specified, only dump tables matching
296#                          LIKE pattern TABLE.
297do_test shell1-3.4.1 {
298  set res [catchcmd "test.db" ".dump"]
299  list [regexp {BEGIN TRANSACTION;} $res] \
300       [regexp {COMMIT;} $res]
301} {1 1}
302do_test shell1-3.4.2 {
303  set res [catchcmd "test.db" ".dump FOO"]
304  list [regexp {BEGIN TRANSACTION;} $res] \
305       [regexp {COMMIT;} $res]
306} {1 1}
307# The .dump command now accepts multiple arguments
308#do_test shell1-3.4.3 {
309#  # too many arguments
310#  catchcmd "test.db" ".dump FOO BAD"
311#} {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}
312
313# .echo ON|OFF           Turn command echo on or off
314do_test shell1-3.5.1 {
315  catchcmd "test.db" ".echo"
316} {1 {Usage: .echo on|off}}
317do_test shell1-3.5.2 {
318  catchcmd "test.db" ".echo ON"
319} {0 {}}
320do_test shell1-3.5.3 {
321  catchcmd "test.db" ".echo OFF"
322} {0 {}}
323do_test shell1-3.5.4 {
324  # too many arguments
325  catchcmd "test.db" ".echo OFF BAD"
326} {1 {Usage: .echo on|off}}
327
328# .exit                  Exit this program
329do_test shell1-3.6.1 {
330  catchcmd "test.db" ".exit"
331} {0 {}}
332
333# .explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.
334do_test shell1-3.7.1 {
335  catchcmd "test.db" ".explain"
336  # explain is the exception to the booleans.  without an option, it turns it on.
337} {0 {}}
338do_test shell1-3.7.2 {
339  catchcmd "test.db" ".explain ON"
340} {0 {}}
341do_test shell1-3.7.3 {
342  catchcmd "test.db" ".explain OFF"
343} {0 {}}
344do_test shell1-3.7.4 {
345  # extra arguments ignored
346  catchcmd "test.db" ".explain OFF BAD"
347} {0 {}}
348
349
350# .header(s) ON|OFF      Turn display of headers on or off
351do_test shell1-3.9.1 {
352  catchcmd "test.db" ".header"
353} {1 {Usage: .headers on|off}}
354do_test shell1-3.9.2 {
355  catchcmd "test.db" ".header ON"
356} {0 {}}
357do_test shell1-3.9.3 {
358  catchcmd "test.db" ".header OFF"
359} {0 {}}
360do_test shell1-3.9.4 {
361  # too many arguments
362  catchcmd "test.db" ".header OFF BAD"
363} {1 {Usage: .headers on|off}}
364
365do_test shell1-3.9.5 {
366  catchcmd "test.db" ".headers"
367} {1 {Usage: .headers on|off}}
368do_test shell1-3.9.6 {
369  catchcmd "test.db" ".headers ON"
370} {0 {}}
371do_test shell1-3.9.7 {
372  catchcmd "test.db" ".headers OFF"
373} {0 {}}
374do_test shell1-3.9.8 {
375  # too many arguments
376  catchcmd "test.db" ".headers OFF BAD"
377} {1 {Usage: .headers on|off}}
378
379# .help                  Show this message
380do_test shell1-3.10.1 {
381  set res [catchcmd "test.db" ".help"]
382  # 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}
387do_test shell1-3.10.2 {
388  # we allow .help to take extra args (it is help after all)
389  set res [catchcmd "test.db" ".help *"]
390  # look for a few of the possible help commands
391  list [regexp {.help} $res] \
392       [regexp {.quit} $res] \
393       [regexp {.show} $res]
394} {1 1 1}
395
396# .import FILE TABLE     Import data from FILE into TABLE
397do_test shell1-3.11.1 {
398  catchcmd "test.db" ".import"
399} {/1 .ERROR: missing FILE argument.*/}
400do_test shell1-3.11.2 {
401  catchcmd "test.db" ".import FOO"
402} {/1 .ERROR: missing TABLE argument.*/}
403do_test shell1-3.11.3 {
404  # too many arguments
405  catchcmd "test.db" ".import FOO BAR BAD"
406} {/1 .ERROR: extra argument: "BAD".*./}
407
408# .indexes ?TABLE?       Show names of all indexes
409#                          If TABLE specified, only show indexes for tables
410#                          matching LIKE pattern TABLE.
411do_test shell1-3.12.1 {
412  catchcmd "test.db" ".indexes"
413} {0 {}}
414do_test shell1-3.12.2 {
415  catchcmd "test.db" ".indexes FOO"
416} {0 {}}
417do_test shell1-3.12.2-legacy {
418  catchcmd "test.db" ".indices FOO"
419} {0 {}}
420do_test shell1-3.12.3 {
421  # too many arguments
422  catchcmd "test.db" ".indexes FOO BAD"
423} {1 {Usage: .indexes ?LIKE-PATTERN?}}
424
425# .mode MODE ?TABLE?     Set output mode where MODE is one of:
426#                          ascii    Columns/rows delimited by 0x1F and 0x1E
427#                          csv      Comma-separated values
428#                          column   Left-aligned columns.  (See .width)
429#                          html     HTML <table> code
430#                          insert   SQL insert statements for TABLE
431#                          line     One value per line
432#                          list     Values delimited by .separator strings
433#                          tabs     Tab-separated values
434#                          tcl      TCL list elements
435do_test shell1-3.13.1 {
436  catchcmd "test.db" ".mode"
437} {0 {current output mode: list}}
438do_test shell1-3.13.2 {
439  catchcmd "test.db" ".mode FOO"
440} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
441do_test shell1-3.13.3 {
442  catchcmd "test.db" ".mode csv"
443} {0 {}}
444do_test shell1-3.13.4 {
445  catchcmd "test.db" ".mode column"
446} {0 {}}
447do_test shell1-3.13.5 {
448  catchcmd "test.db" ".mode html"
449} {0 {}}
450do_test shell1-3.13.6 {
451  catchcmd "test.db" ".mode insert"
452} {0 {}}
453do_test shell1-3.13.7 {
454  catchcmd "test.db" ".mode line"
455} {0 {}}
456do_test shell1-3.13.8 {
457  catchcmd "test.db" ".mode list"
458} {0 {}}
459do_test shell1-3.13.9 {
460  catchcmd "test.db" ".mode tabs"
461} {0 {}}
462do_test shell1-3.13.10 {
463  catchcmd "test.db" ".mode tcl"
464} {0 {}}
465do_test shell1-3.13.11 {
466  # extra arguments ignored
467  catchcmd "test.db" ".mode tcl BAD"
468} {0 {}}
469
470# .nullvalue STRING      Print STRING in place of NULL values
471do_test shell1-3.14.1 {
472  catchcmd "test.db" ".nullvalue"
473} {1 {Usage: .nullvalue STRING}}
474do_test shell1-3.14.2 {
475  catchcmd "test.db" ".nullvalue FOO"
476} {0 {}}
477do_test shell1-3.14.3 {
478  # too many arguments
479  catchcmd "test.db" ".nullvalue FOO BAD"
480} {1 {Usage: .nullvalue STRING}}
481
482# .output FILENAME       Send output to FILENAME
483do_test shell1-3.15.1 {
484  catchcmd "test.db" ".output"
485} {0 {}}
486do_test shell1-3.15.2 {
487  catchcmd "test.db" ".output FOO"
488} {0 {}}
489do_test shell1-3.15.3 {
490  # too many arguments
491  catchcmd "test.db" ".output FOO BAD"
492} {1 {ERROR: extra parameter: "BAD".  Usage:
493.output ?FILE?           Send output to FILE or stdout if FILE is omitted
494   If FILE begins with '|' then open it as a pipe.
495   Options:
496     --bom                 Prefix output with a UTF8 byte-order mark
497     -e                    Send output to the system text editor
498     -x                    Send output as CSV to a spreadsheet
499child process exited abnormally}}
500
501# .output stdout         Send output to the screen
502do_test shell1-3.16.1 {
503  catchcmd "test.db" ".output stdout"
504} {0 {}}
505do_test shell1-3.16.2 {
506  # too many arguments
507  catchcmd "test.db" ".output stdout BAD"
508} {1 {ERROR: extra parameter: "BAD".  Usage:
509.output ?FILE?           Send output to FILE or stdout if FILE is omitted
510   If FILE begins with '|' then open it as a pipe.
511   Options:
512     --bom                 Prefix output with a UTF8 byte-order mark
513     -e                    Send output to the system text editor
514     -x                    Send output as CSV to a spreadsheet
515child process exited abnormally}}
516
517# .prompt MAIN CONTINUE  Replace the standard prompts
518do_test shell1-3.17.1 {
519  catchcmd "test.db" ".prompt"
520} {0 {}}
521do_test shell1-3.17.2 {
522  catchcmd "test.db" ".prompt FOO"
523} {0 {}}
524do_test shell1-3.17.3 {
525  catchcmd "test.db" ".prompt FOO BAR"
526} {0 {}}
527do_test shell1-3.17.4 {
528  # too many arguments
529  catchcmd "test.db" ".prompt FOO BAR BAD"
530} {0 {}}
531
532# .quit                  Exit this program
533do_test shell1-3.18.1 {
534  catchcmd "test.db" ".quit"
535} {0 {}}
536do_test shell1-3.18.2 {
537  # too many arguments
538  catchcmd "test.db" ".quit BAD"
539} {0 {}}
540
541# .read FILENAME         Execute SQL in FILENAME
542do_test shell1-3.19.1 {
543  catchcmd "test.db" ".read"
544} {1 {Usage: .read FILE}}
545do_test shell1-3.19.2 {
546  forcedelete FOO
547  catchcmd "test.db" ".read FOO"
548} {1 {Error: cannot open "FOO"}}
549do_test shell1-3.19.3 {
550  # too many arguments
551  catchcmd "test.db" ".read FOO BAD"
552} {1 {Usage: .read FILE}}
553
554# .restore ?DB? FILE     Restore content of DB (default "main") from FILE
555do_test shell1-3.20.1 {
556  catchcmd "test.db" ".restore"
557} {1 {Usage: .restore ?DB? FILE}}
558do_test shell1-3.20.2 {
559  catchcmd "test.db" ".restore FOO"
560} {0 {}}
561do_test shell1-3.20.3 {
562  catchcmd "test.db" ".restore FOO BAR"
563} {1 {Error: unknown database FOO}}
564do_test shell1-3.20.4 {
565  # too many arguments
566  catchcmd "test.db" ".restore FOO BAR BAD"
567} {1 {Usage: .restore ?DB? FILE}}
568
569ifcapable vtab {
570# .schema ?TABLE?        Show the CREATE statements
571#                          If TABLE specified, only show tables matching
572#                          LIKE pattern TABLE.
573do_test shell1-3.21.1 {
574  catchcmd "test.db" ".schema"
575} {0 {}}
576do_test shell1-3.21.2 {
577  catchcmd "test.db" ".schema FOO"
578} {0 {}}
579do_test shell1-3.21.3 {
580  # too many arguments
581  catchcmd "test.db" ".schema FOO BAD"
582} {1 {Usage: .schema ?--indent? ?--nosys? ?LIKE-PATTERN?}}
583
584do_test shell1-3.21.4 {
585  catchcmd "test.db" {
586     CREATE TABLE t1(x);
587     CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
588     CREATE VIEW v1 AS SELECT y+1 FROM v2;
589  }
590  catchcmd "test.db" ".schema"
591} {0 {CREATE TABLE t1(x);
592CREATE VIEW v2 AS SELECT x+1 AS y FROM t1
593/* v2(y) */;
594CREATE VIEW v1 AS SELECT y+1 FROM v2
595/* v1("y+1") */;}}
596db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}
597}
598
599# .separator STRING  Change column separator used by output and .import
600do_test shell1-3.22.1 {
601  catchcmd "test.db" ".separator"
602} {1 {Usage: .separator COL ?ROW?}}
603do_test shell1-3.22.2 {
604  catchcmd "test.db" ".separator FOO"
605} {0 {}}
606do_test shell1-3.22.3 {
607  catchcmd "test.db" ".separator ABC XYZ"
608} {0 {}}
609do_test shell1-3.22.4 {
610  # too many arguments
611  catchcmd "test.db" ".separator FOO BAD BAD2"
612} {1 {Usage: .separator COL ?ROW?}}
613
614# .show                  Show the current values for various settings
615do_test shell1-3.23.1 {
616  set res [catchcmd "test.db" ".show"]
617  list [regexp {echo:} $res] \
618       [regexp {explain:} $res] \
619       [regexp {headers:} $res] \
620       [regexp {mode:} $res] \
621       [regexp {nullvalue:} $res] \
622       [regexp {output:} $res] \
623       [regexp {colseparator:} $res] \
624       [regexp {rowseparator:} $res] \
625       [regexp {stats:} $res] \
626       [regexp {width:} $res]
627} {1 1 1 1 1 1 1 1 1 1}
628do_test shell1-3.23.2 {
629  # too many arguments
630  catchcmd "test.db" ".show BAD"
631} {1 {Usage: .show}}
632
633# .stats ON|OFF          Turn stats on or off
634#do_test shell1-3.23b.1 {
635#  catchcmd "test.db" ".stats"
636#} {1 {Usage: .stats on|off|stmt|vmstep}}
637do_test shell1-3.23b.2 {
638  catchcmd "test.db" ".stats ON"
639} {0 {}}
640do_test shell1-3.23b.3 {
641  catchcmd "test.db" ".stats OFF"
642} {0 {}}
643do_test shell1-3.23b.4 {
644  # too many arguments
645  catchcmd "test.db" ".stats OFF BAD"
646} {1 {Usage: .stats ?on|off|stmt|vmstep?}}
647
648# Ticket 7be932dfa60a8a6b3b26bcf7623ec46e0a403ddb 2018-06-07
649# Adverse interaction between .stats and .eqp
650#
651do_test shell1-3.23b.5 {
652  catchcmd "test.db" [string map {"\n    " "\n"} {
653    CREATE TEMP TABLE t1(x);
654    INSERT INTO t1 VALUES(1),(2);
655    .stats on
656    .eqp full
657    SELECT * FROM t1;
658  }]
659} {/1\n2\n/}
660
661# .tables ?TABLE?        List names of tables
662#                          If TABLE specified, only list tables matching
663#                          LIKE pattern TABLE.
664do_test shell1-3.24.1 {
665  catchcmd "test.db" ".tables"
666} {0 {}}
667do_test shell1-3.24.2 {
668  catchcmd "test.db" ".tables FOO"
669} {0 {}}
670do_test shell1-3.24.3 {
671  # too many arguments
672  catchcmd "test.db" ".tables FOO BAD"
673} {0 {}}
674
675# .timeout MS            Try opening locked tables for MS milliseconds
676do_test shell1-3.25.1 {
677  catchcmd "test.db" ".timeout"
678} {0 {}}
679do_test shell1-3.25.2 {
680  catchcmd "test.db" ".timeout zzz"
681  # this should be treated the same as a '0' timeout
682} {0 {}}
683do_test shell1-3.25.3 {
684  catchcmd "test.db" ".timeout 1"
685} {0 {}}
686do_test shell1-3.25.4 {
687  # too many arguments
688  catchcmd "test.db" ".timeout 1 BAD"
689} {0 {}}
690
691# .width NUM NUM ...     Set column widths for "column" mode
692do_test shell1-3.26.1 {
693  catchcmd "test.db" ".width"
694} {0 {}}
695do_test shell1-3.26.2 {
696  catchcmd "test.db" ".width xxx"
697  # this should be treated the same as a '0' width for col 1
698} {0 {}}
699do_test shell1-3.26.3 {
700  catchcmd "test.db" ".width xxx yyy"
701  # this should be treated the same as a '0' width for col 1 and 2
702} {0 {}}
703do_test shell1-3.26.4 {
704  catchcmd "test.db" ".width 1 1"
705  # this should be treated the same as a '1' width for col 1 and 2
706} {0 {}}
707do_test shell1-3.26.5 {
708  catchcmd "test.db" ".mode column\n.header off\n.width 10 -10\nSELECT 'abcdefg', 123456;"
709  # this should be treated the same as a '1' width for col 1 and 2
710} {0 {abcdefg         123456}}
711do_test shell1-3.26.6 {
712  catchcmd "test.db" ".mode column\n.header off\n.width -10 10\nSELECT 'abcdefg', 123456;"
713  # this should be treated the same as a '1' width for col 1 and 2
714} {0 {   abcdefg  123456    }}
715
716
717# .timer ON|OFF          Turn the CPU timer measurement on or off
718do_test shell1-3.27.1 {
719  catchcmd "test.db" ".timer"
720} {1 {Usage: .timer on|off}}
721do_test shell1-3.27.2 {
722  catchcmd "test.db" ".timer ON"
723} {0 {}}
724do_test shell1-3.27.3 {
725  catchcmd "test.db" ".timer OFF"
726} {0 {}}
727do_test shell1-3.27.4 {
728  # too many arguments
729  catchcmd "test.db" ".timer OFF BAD"
730} {1 {Usage: .timer on|off}}
731
732do_test shell1-3-28.1 {
733  catchcmd test.db \
734     ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
735} "0 {(123) hello\n456}"
736
737do_test shell1-3-29.1 {
738  catchcmd "test.db" ".print this is a test"
739} {0 {this is a test}}
740
741# dot-command argument quoting
742do_test shell1-3-30.1 {
743  catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'}
744} {0 {this"is'a-test this\"is\\a\055test}}
745do_test shell1-3-31.1 {
746  catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'}
747} [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"]
748
749
750# Test the output of the ".dump" command
751#
752do_test shell1-4.1 {
753  db close
754  forcedelete test.db
755  sqlite3 db test.db
756  db eval {
757    PRAGMA encoding=UTF16;
758    CREATE TABLE t1(x);
759    INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
760    CREATE TABLE t3(x,y);
761    INSERT INTO t3 VALUES(1,null), (2,''), (3,1),
762                         (4,2.25), (5,'hello'), (6,x'807f');
763  }
764  catchcmd test.db {.dump}
765} {0 {PRAGMA foreign_keys=OFF;
766BEGIN TRANSACTION;
767CREATE TABLE t1(x);
768INSERT INTO t1 VALUES(NULL);
769INSERT INTO t1 VALUES('');
770INSERT INTO t1 VALUES(1);
771INSERT INTO t1 VALUES(2.25);
772INSERT INTO t1 VALUES('hello');
773INSERT INTO t1 VALUES(X'807f');
774CREATE TABLE t3(x,y);
775INSERT INTO t3 VALUES(1,NULL);
776INSERT INTO t3 VALUES(2,'');
777INSERT INTO t3 VALUES(3,1);
778INSERT INTO t3 VALUES(4,2.25);
779INSERT INTO t3 VALUES(5,'hello');
780INSERT INTO t3 VALUES(6,X'807f');
781COMMIT;}}
782
783
784ifcapable vtab {
785
786# The --preserve-rowids option to .dump
787#
788do_test shell1-4.1.1 {
789  catchcmd test.db {.dump --preserve-rowids}
790} {0 {PRAGMA foreign_keys=OFF;
791BEGIN TRANSACTION;
792CREATE TABLE t1(x);
793INSERT INTO t1(rowid,x) VALUES(1,NULL);
794INSERT INTO t1(rowid,x) VALUES(2,'');
795INSERT INTO t1(rowid,x) VALUES(3,1);
796INSERT INTO t1(rowid,x) VALUES(4,2.25);
797INSERT INTO t1(rowid,x) VALUES(5,'hello');
798INSERT INTO t1(rowid,x) VALUES(6,X'807f');
799CREATE TABLE t3(x,y);
800INSERT INTO t3(rowid,x,y) VALUES(1,1,NULL);
801INSERT INTO t3(rowid,x,y) VALUES(2,2,'');
802INSERT INTO t3(rowid,x,y) VALUES(3,3,1);
803INSERT INTO t3(rowid,x,y) VALUES(4,4,2.25);
804INSERT INTO t3(rowid,x,y) VALUES(5,5,'hello');
805INSERT INTO t3(rowid,x,y) VALUES(6,6,X'807f');
806COMMIT;}}
807
808# If the table contains an INTEGER PRIMARY KEY, do not record a separate
809# rowid column in the output.
810#
811do_test shell1-4.1.2 {
812  db close
813  forcedelete test2.db
814  sqlite3 db test2.db
815  db eval {
816    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
817    INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
818                         (4,2.25), (5,'hello'), (6,x'807f');
819  }
820  catchcmd test2.db {.dump --preserve-rowids}
821} {0 {PRAGMA foreign_keys=OFF;
822BEGIN TRANSACTION;
823CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
824INSERT INTO t1 VALUES(1,NULL);
825INSERT INTO t1 VALUES(2,'');
826INSERT INTO t1 VALUES(3,1);
827INSERT INTO t1 VALUES(4,2.25);
828INSERT INTO t1 VALUES(5,'hello');
829INSERT INTO t1 VALUES(6,X'807f');
830COMMIT;}}
831
832# Verify that the table named [table] is correctly quoted and that
833# an INTEGER PRIMARY KEY DESC is not an alias for the rowid.
834#
835do_test shell1-4.1.3 {
836  db close
837  forcedelete test2.db
838  sqlite3 db test2.db
839  db eval {
840    CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
841    INSERT INTO [table] VALUES(1,null), (12,''), (23,1),
842                         (34,2.25), (45,'hello'), (56,x'807f');
843  }
844  catchcmd test2.db {.dump --preserve-rowids}
845} {0 {PRAGMA foreign_keys=OFF;
846BEGIN TRANSACTION;
847CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
848INSERT INTO "table"(rowid,x,y) VALUES(1,1,NULL);
849INSERT INTO "table"(rowid,x,y) VALUES(2,12,'');
850INSERT INTO "table"(rowid,x,y) VALUES(3,23,1);
851INSERT INTO "table"(rowid,x,y) VALUES(4,34,2.25);
852INSERT INTO "table"(rowid,x,y) VALUES(5,45,'hello');
853INSERT INTO "table"(rowid,x,y) VALUES(6,56,X'807f');
854COMMIT;}}
855
856# Do not record rowids for a WITHOUT ROWID table.  Also check correct quoting
857# of table names that contain odd characters.
858#
859do_test shell1-4.1.4 {
860  db close
861  forcedelete test2.db
862  sqlite3 db test2.db
863  db eval {
864    CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
865    INSERT INTO [ta<>ble] VALUES(1,null), (12,''), (23,1),
866                         (34,2.25), (45,'hello'), (56,x'807f');
867  }
868  catchcmd test2.db {.dump --preserve-rowids}
869} {0 {PRAGMA foreign_keys=OFF;
870BEGIN TRANSACTION;
871CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
872INSERT INTO "ta<>ble" VALUES(1,NULL);
873INSERT INTO "ta<>ble" VALUES(12,'');
874INSERT INTO "ta<>ble" VALUES(23,1);
875INSERT INTO "ta<>ble" VALUES(34,2.25);
876INSERT INTO "ta<>ble" VALUES(45,'hello');
877INSERT INTO "ta<>ble" VALUES(56,X'807f');
878COMMIT;}}
879
880# Do not record rowids if the rowid is inaccessible
881#
882do_test shell1-4.1.5 {
883  db close
884  forcedelete test2.db
885  sqlite3 db test2.db
886  db eval {
887    CREATE TABLE t1(_ROWID_,rowid,oid);
888    INSERT INTO t1 VALUES(1,null,'alpha'), (12,'',99), (23,1,x'b0b1b2');
889  }
890  catchcmd test2.db {.dump --preserve-rowids}
891} {0 {PRAGMA foreign_keys=OFF;
892BEGIN TRANSACTION;
893CREATE TABLE t1(_ROWID_,rowid,oid);
894INSERT INTO t1 VALUES(1,NULL,'alpha');
895INSERT INTO t1 VALUES(12,'',99);
896INSERT INTO t1 VALUES(23,1,X'b0b1b2');
897COMMIT;}}
898
899} else {
900
901do_test shell1-4.1.6 {
902  db close
903  forcedelete test2.db
904  sqlite3 db test2.db
905  db eval {
906    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
907    INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
908                         (4,2.25), (5,'hello'), (6,x'807f');
909  }
910  catchcmd test2.db {.dump --preserve-rowids}
911} {1 {The --preserve-rowids option is not compatible with SQLITE_OMIT_VIRTUALTABLE}}
912
913}
914
915
916# Test the output of ".mode insert"
917#
918do_test shell1-4.2.1 {
919  catchcmd test.db ".mode insert t1\nselect * from t1;"
920} {0 {INSERT INTO t1 VALUES(NULL);
921INSERT INTO t1 VALUES('');
922INSERT INTO t1 VALUES(1);
923INSERT INTO t1 VALUES(2.25);
924INSERT INTO t1 VALUES('hello');
925INSERT INTO t1 VALUES(X'807f');}}
926
927# Test the output of ".mode insert" with headers
928#
929do_test shell1-4.2.2 {
930  catchcmd test.db ".mode insert t1\n.headers on\nselect * from t1;"
931} {0 {INSERT INTO t1(x) VALUES(NULL);
932INSERT INTO t1(x) VALUES('');
933INSERT INTO t1(x) VALUES(1);
934INSERT INTO t1(x) VALUES(2.25);
935INSERT INTO t1(x) VALUES('hello');
936INSERT INTO t1(x) VALUES(X'807f');}}
937
938# Test the output of ".mode insert"
939#
940do_test shell1-4.2.3 {
941  catchcmd test.db ".mode insert t3\nselect * from t3;"
942} {0 {INSERT INTO t3 VALUES(1,NULL);
943INSERT INTO t3 VALUES(2,'');
944INSERT INTO t3 VALUES(3,1);
945INSERT INTO t3 VALUES(4,2.25);
946INSERT INTO t3 VALUES(5,'hello');
947INSERT INTO t3 VALUES(6,X'807f');}}
948
949# Test the output of ".mode insert" with headers
950#
951do_test shell1-4.2.4 {
952  catchcmd test.db ".mode insert t3\n.headers on\nselect * from t3;"
953} {0 {INSERT INTO t3(x,y) VALUES(1,NULL);
954INSERT INTO t3(x,y) VALUES(2,'');
955INSERT INTO t3(x,y) VALUES(3,1);
956INSERT INTO t3(x,y) VALUES(4,2.25);
957INSERT INTO t3(x,y) VALUES(5,'hello');
958INSERT INTO t3(x,y) VALUES(6,X'807f');}}
959
960# Test the output of ".mode tcl"
961#
962do_test shell1-4.3 {
963  db close
964  forcedelete test.db
965  sqlite3 db test.db
966  db eval {
967    PRAGMA encoding=UTF8;
968    CREATE TABLE t1(x);
969    INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
970  }
971  catchcmd test.db ".mode tcl\nselect * from t1;"
972} {0 {""
973""
974"1"
975"2.25"
976"hello"
977"\200\177"}}
978
979# Test the output of ".mode tcl" with multiple columns
980#
981do_test shell1-4.4 {
982  db eval {
983    CREATE TABLE t2(x,y);
984    INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f');
985  }
986  catchcmd test.db ".mode tcl\nselect * from t2;"
987} {0 {"" ""
988"1" "2.25"
989"hello" "\200\177"}}
990
991# Test the output of ".mode tcl" with ".nullvalue"
992#
993do_test shell1-4.5 {
994  catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;"
995} {0 {"NULL" ""
996"1" "2.25"
997"hello" "\200\177"}}
998
999# Test the output of ".mode tcl" with Tcl reserved characters
1000#
1001do_test shell1-4.6 {
1002  db eval {
1003    CREATE TABLE tcl1(x);
1004    INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$');
1005  }
1006  foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break
1007  list $x $y [llength $y]
1008} {0 {"\""
1009"["
1010"]"
1011"\\{"
1012"\\}"
1013";"
1014"$"} 7}
1015
1016# Test the output of ".mode quote"
1017#
1018do_test shell1-4.7 {
1019  catchcmd test.db ".mode quote\nselect x'0123456789ABCDEF';"
1020} {0 X'0123456789abcdef'}
1021
1022# Test using arbitrary byte data with the shell via standard input/output.
1023#
1024do_test shell1-5.0 {
1025  #
1026  # NOTE: Skip NUL byte because it appears to be incompatible with command
1027  #       shell argument parsing.
1028  #
1029  for {set i 1} {$i < 256} {incr i} {
1030    #
1031    # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats
1032    #       command channels opened for it as textual ones), the carriage
1033    #       return character (and on Windows, the end-of-file character)
1034    #       cannot be used here.
1035    #
1036    if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
1037      continue
1038    }
1039    # Tcl 8.7 maps 0x80 through 0x9f into valid UTF8.  So skip those tests.
1040    if {$i>=0x80 && $i<=0x9f} continue
1041    if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"}  continue
1042    if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"}  continue
1043    set hex [format %02X $i]
1044    set char [subst \\x$hex]; set oldChar $char
1045    set escapes [list]
1046    if {$tcl_platform(platform)=="windows"} {
1047      #
1048      # NOTE: On Windows, we need to escape all the whitespace characters,
1049      #       the alarm (\a) character, and those with special meaning to
1050      #       the SQLite shell itself.
1051      #
1052      set escapes [list \
1053          \a \\a \b \\b \t \\t \n \\n \v \\v \f \\f \r \\r \
1054          " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
1055    } else {
1056      #
1057      # NOTE: On Unix, we need to escape most of the whitespace characters
1058      #       and those with special meaning to the SQLite shell itself.
1059      #       The alarm (\a), backspace (\b), and carriage-return (\r)
1060      #       characters do not appear to require escaping on Unix.  For
1061      #       the alarm and backspace characters, this is probably due to
1062      #       differences in the command shell.  For the carriage-return,
1063      #       it is probably due to differences in how Tcl handles command
1064      #       channel end-of-line translations.
1065      #
1066      set escapes [list \
1067          \t \\t \n \\n \v \\v \f \\f \
1068          " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
1069    }
1070    set char [string map $escapes $char]
1071    set x [catchcmdex test.db ".print $char\n"]
1072    set code [lindex $x 0]
1073    set res [lindex $x 1]
1074    if {$code ne "0"} {
1075      error "failed with error: $res"
1076    }
1077    if {$res ne "$oldChar\n"} {
1078      if {[llength $res] > 0} {
1079        set got [format %02X [scan $res %c]]
1080      } else {
1081        set got <empty>
1082      }
1083      error "failed with byte $hex mismatch, got $got"
1084    }
1085  }
1086} {}
1087
1088# These test cases do not work on MinGW
1089if 0 {
1090
1091# The string used here is the word "test" in Chinese.
1092# In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95
1093set test \u6D4B\u8BD5
1094
1095do_test shell1-6.0 {
1096  set fileName $test; append fileName .db
1097  catch {forcedelete $fileName}
1098  set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"]
1099  set code [lindex $x 0]
1100  set res [string trim [lindex $x 1]]
1101  if {$code ne "0"} {
1102    error "failed with error: $res"
1103  }
1104  if {$res ne "CREATE TABLE t1(x);"} {
1105    error "failed with mismatch: $res"
1106  }
1107  if {![file exists $fileName]} {
1108    error "file \"$fileName\" (Unicode) does not exist"
1109  }
1110  forcedelete $fileName
1111} {}
1112
1113do_test shell1-6.1 {
1114  catch {forcedelete test3.db}
1115  set x [catchcmdex test3.db \
1116      "CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"]
1117  set code [lindex $x 0]
1118  set res [string trim [lindex $x 1]]
1119  if {$code ne "0"} {
1120    error "failed with error: $res"
1121  }
1122  if {$res ne "CREATE TABLE ${test}(x);"} {
1123    error "failed with mismatch: $res"
1124  }
1125  forcedelete test3.db
1126} {}
1127}
1128
1129db close
1130forcedelete test.db test.db-journal test.db-wal
1131sqlite3 db test.db
1132
1133# The shell tool ".schema" command uses virtual table "pragma_database_list"
1134#
1135ifcapable vtab {
1136
1137do_test shell1-7.1.1 {
1138  db eval {
1139    CREATE TABLE Z (x TEXT PRIMARY KEY);
1140    CREATE TABLE _ (x TEXT PRIMARY KEY);
1141    CREATE TABLE YY (x TEXT PRIMARY KEY);
1142    CREATE TABLE __ (x TEXT PRIMARY KEY);
1143    CREATE TABLE WWW (x TEXT PRIMARY KEY);
1144    CREATE TABLE ___ (x TEXT PRIMARY KEY);
1145  }
1146} {}
1147do_test shell1-7.1.2 {
1148  catchcmd "test.db" ".schema _"
1149} {0 {CREATE TABLE Z (x TEXT PRIMARY KEY);
1150CREATE TABLE _ (x TEXT PRIMARY KEY);}}
1151do_test shell1-7.1.3 {
1152  catchcmd "test.db" ".schema \\\\_"
1153} {0 {CREATE TABLE _ (x TEXT PRIMARY KEY);}}
1154do_test shell1-7.1.4 {
1155  catchcmd "test.db" ".schema __"
1156} {0 {CREATE TABLE YY (x TEXT PRIMARY KEY);
1157CREATE TABLE __ (x TEXT PRIMARY KEY);}}
1158do_test shell1-7.1.5 {
1159  catchcmd "test.db" ".schema \\\\_\\\\_"
1160} {0 {CREATE TABLE __ (x TEXT PRIMARY KEY);}}
1161do_test shell1-7.1.6 {
1162  catchcmd "test.db" ".schema ___"
1163} {0 {CREATE TABLE WWW (x TEXT PRIMARY KEY);
1164CREATE TABLE ___ (x TEXT PRIMARY KEY);}}
1165do_test shell1-7.1.7 {
1166  catchcmd "test.db" ".schema \\\\_\\\\_\\\\_"
1167} {0 {CREATE TABLE ___ (x TEXT PRIMARY KEY);}}
1168
1169}
1170
1171# Test case for the ieee754 and decimal extensions in the shell.
1172# See the "floatingpoint.html" file in the documentation for more
1173# information.
1174#
1175do_test shell1-8.1 {
1176  catchcmd ":memory:" {
1177    -- The pow2 table will hold all the necessary powers of two.
1178    CREATE TABLE pow2(x INTEGER PRIMARY KEY, v TEXT);
1179    WITH RECURSIVE c(x,v) AS (
1180      VALUES(0,'1')
1181      UNION ALL
1182      SELECT x+1, decimal_mul(v,'2') FROM c WHERE x+1<=971
1183    ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
1184    WITH RECURSIVE c(x,v) AS (
1185      VALUES(-1,'0.5')
1186      UNION ALL
1187      SELECT x-1, decimal_mul(v,'0.5') FROM c WHERE x-1>=-1075
1188    ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
1189
1190    -- This query finds the decimal representation of each value in the "c" table.
1191    WITH c(n) AS (VALUES(47.49))
1192                     ----XXXXX----------- Replace with whatever you want
1193    SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
1194      FROM pow2, c WHERE pow2.x=ieee754_exponent(c.n);
1195  }
1196} {0 47.49000000000000198951966012828052043914794921875}
1197do_test shell1-8.2 {
1198  catchcmd :memory: {
1199.mode box
1200SELECT ieee754(47.49) AS x;
1201  }
1202} {0 {┌───────────────────────────────┐
1203│               x               │
1204├───────────────────────────────┤
1205│ ieee754(6683623321994527,-47) │
1206└───────────────────────────────┘}}
1207do_test shell1-8.3 {
1208  catchcmd ":memory: --box" {
1209    select ieee754(6683623321994527,-47) as x;
1210  }
1211} {0 {┌───────┐
1212│   x   │
1213├───────┤
1214│ 47.49 │
1215└───────┘}}
1216do_test shell1-8.4 {
1217  catchcmd ":memory: --table" {SELECT ieee754_mantissa(47.49) AS M, ieee754_exponent(47.49) AS E;}
1218} {0 {+------------------+-----+
1219|        M         |  E  |
1220+------------------+-----+
1221| 6683623321994527 | -47 |
1222+------------------+-----+}}
1223
1224#----------------------------------------------------------------------------
1225# Test cases shell1-9.*: Basic test that "dot" commands and SQL intermix ok.
1226#
1227do_test shell1-9.1 {
1228  catchcmd :memory: {
1229.mode csv
1230/*
1231x */ select 1,2; --x
1232 -- .nada
1233;
1234.mode csv
1235--x
1236select 2,1; select 3,4;
1237}
1238} {0 {1,2
12392,1
12403,4}}
1241
1242finish_test
1243