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