-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
test_multiline_statements.tcl
121 lines (100 loc) · 2.4 KB
/
test_multiline_statements.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#! /usr/bin/env expect -f
source [file join [file dirname $argv0] common.tcl]
start_server $argv
# we force TERM to xterm, otherwise we can't
# test bracketed paste below.
set env(TERM) xterm
spawn $argv sql
eexpect root@
start_test "Test that a multi-line entry can be recalled escaped."
send "select 'foo\r"
eexpect " ->"
send "bar';\r"
eexpect "1 row"
eexpect "root@"
# Send up-arrow.
send "\033\[A"
eexpect "select 'foo"
eexpect " -> bar';"
send "\r"
eexpect "1 row"
eexpect "root@"
send "select 1,\r"
eexpect " ->"
send "2, 3\r"
eexpect " ->"
end_test
#start_test "Test that \p does what it says."
#send "\\p\r"
#eexpect "select 1,"
#eexpect "2, 3"
#eexpect " ->"
#end_test
start_test "Test finishing the multi-line statement."
send ";\r"
eexpect "1 row"
eexpect "root@"
# Send up-arrow.
send "\033\[A"
eexpect "select 1,"
eexpect "2, 3"
eexpect ";"
end_test
#start_test "Test that \r does what it says."
## backspace to erase the semicolon
#send "\010"
## newline to get a prompt
#send "\r"
#eexpect " ->"
## Now send \r followed by a carriage return.
#send "\\r\r"
#eexpect root@
#end_test
start_test "Test that Ctrl+C after the first line merely cancels the statement and presents the prompt."
send "\r"
eexpect root@
send "select\r"
eexpect " ->"
interrupt
eexpect root@
end_test
# start_test "Test that \p does what it says."
# send "select\r"
# eexpect " ->"
# send "\\p\r"
# eexpect "select\r\n*->"
# interrupt
# eexpect root@
# end_test
start_test "Test that a dangling table creation can be committed, and that other non-DDL, non-DML statements can be issued in the same txn. (#15283)"
send "create database if not exists t;"
send "drop table if exists t.blih;"
send "create table if not exists t.kv(k int primary key, v int);\r"
eexpect "CREATE TABLE"
eexpect root@
send "begin; create table t.blih(x INT REFERENCES t.kv(k));\r\r"
eexpect "CREATE TABLE"
eexpect root@
eexpect OPEN
send "show all cluster settings;\r"
eexpect "rows"
eexpect root@
eexpect OPEN
send "commit;\r"
eexpect COMMIT
eexpect root@
end_test
# Pending the bubbletea changes here: https://github.com/charmbracelet/bubbletea/issues/404
# start_test "Test that a multi-line bracketed paste is handled properly."
# send "\033\[200~"
# send "\\set display_format csv\r\n"
# send "values (1,'a'), (2,'b'), (3,'c');\r\n"
# send "\033\[201~\r\n"
# eexpect "1,a"
# eexpect "2,b"
# eexpect "3,c"
# eexpect root@
# end_test
send_eof
eexpect eof
stop_server $argv