github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/interactive_tests/test_client_side_checking.tcl (about) 1 #! /usr/bin/env expect -f 2 3 source [file join [file dirname $argv0] common.tcl] 4 5 start_server $argv 6 7 spawn $argv sql 8 eexpect root@ 9 10 start_test "Check that syntax errors are handled client-side when running interactive." 11 send "begin;\r\r" 12 eexpect BEGIN 13 eexpect root@ 14 15 send "select 3+;\r" 16 eexpect "statement ignored" 17 eexpect root@ 18 19 send "select 1;\r" 20 eexpect "1 row" 21 eexpect root@ 22 23 send "commit;\r" 24 eexpect COMMIT 25 eexpect root@ 26 end_test 27 28 start_test "Check that the syntax checker does not get confused by empty inputs." 29 # (issue #22441.) 30 send ";\r" 31 eexpect "0 rows" 32 eexpect root@ 33 end_test 34 35 start_test "Check that the user can force server-side handling." 36 send "\\unset check_syntax\r" 37 eexpect root@ 38 39 send "begin;\r" 40 eexpect BEGIN 41 42 send "select 3+;\r" 43 eexpect "ERROR: at or near" 44 eexpect "syntax error" 45 eexpect root@ 46 47 send "select 1;\r" 48 eexpect "current transaction is aborted" 49 eexpect root@ 50 51 send "commit;\r" 52 eexpect "ROLLBACK" 53 eexpect root@ 54 55 interrupt 56 eexpect eof 57 end_test 58 59 start_test "Check that syntax errors are handled server-side by default when running non-interactive." 60 spawn /bin/bash 61 send "PS1=':''/# '\r" 62 eexpect ":/# " 63 64 send "(echo '\\unset errexit'; echo 'begin;'; echo 'select 1+;'; echo 'select 1;') | $argv sql\r" 65 eexpect "syntax error" 66 eexpect "current transaction is aborted" 67 eexpect ":/# " 68 send "echo \$?\r" 69 eexpect "1\r\n:/# " 70 71 send "(echo '\\unset errexit'; echo '\\set check_syntax'; echo 'begin;'; echo 'select 1+;'; echo 'select 1;'; echo 'commit;') | $argv sql\r" 72 eexpect "syntax error" 73 eexpect "1 row" 74 eexpect "COMMIT" 75 eexpect ":/# " 76 send "echo \$?\r" 77 eexpect "0\r\n:/# " 78 end_test 79 80 start_test "Check that --debug-sql-cli sets suitable simplified client-side options." 81 send "$argv sql --debug-sql-cli\r" 82 eexpect "Welcome" 83 eexpect "root@" 84 send "\\set display_format csv\r\\set\r" 85 eexpect "check_syntax,false" 86 eexpect "echo,true" 87 eexpect "prompt1,%n@%M>" 88 eexpect "root@" 89 send "\\q\r" 90 eexpect ":/# " 91 end_test 92 93 send "exit 0\r" 94 eexpect eof 95 96 stop_server $argv