1
##============================================================================
3
##============================================================================
5
# Test case for Bug#11230
7
# The point of this test is to make sure that '#', '-- ' and '/* ... */'
8
# comments, as well as empty lines, are sent from the client to the server.
9
# This is to ensure better error reporting, and to keep comments in the code
10
# for stored procedures / functions / triggers (Bug#11230).
11
# As a result, be careful when editing comments in this script, they do
14
# Also, note that this is a script for **mysql**, not mysqltest.
15
# This is critical, as the mysqltest client interprets comments differently.
17
##============================================================================
19
##============================================================================
21
## See mysql_comments.test for initial cleanup
25
# t1 is reused throughout the file, and dropped at the end.
27
drop table if exists t1;
29
id char(16) not null default '',
33
##============================================================================
34
## Comments outside statements
35
##============================================================================
45
##============================================================================
46
## Comments inside statements
47
##============================================================================
56
; # not strictly inside, but on same line
59
##============================================================================
60
## Comments inside functions
61
##============================================================================
63
drop function if exists foofct ;
65
create function foofct (x char(20))
67
/* not inside the body yet */
72
x; # after body, on same line
74
select foofct("call 1");
76
show create function foofct;
81
create function foofct(x char(20))
98
select foofct("call 2");
100
show create function foofct;
101
drop function foofct;
103
##============================================================================
104
## Comments inside stored procedures
105
##============================================================================
108
drop procedure if exists empty;
109
create procedure empty()
114
show create procedure empty;
115
drop procedure empty;
117
drop procedure if exists foosp;
119
## These comments are before the create, and will be lost
125
create procedure foosp()
126
/* Comment not quiet in the body yet */
128
## These comments are part of the procedure body, and should be kept.
135
values ("foo", 42); # comment 3, still part of the body
136
## After the ';', therefore not part of the body
146
show create procedure foosp;
147
drop procedure foosp;
149
drop procedure if exists nicesp;
153
create procedure nicesp(a int)
155
-- declare some variables here
159
-- do more stuff here
160
-- commented nicely and so on
162
-- famous last words ...
167
show create procedure nicesp;
168
drop procedure nicesp;
170
##============================================================================
171
## Comments inside triggers
172
##============================================================================
174
drop trigger if exists t1_empty;
176
create trigger t1_empty after delete on t1
181
show create trigger t1_empty;
183
drop trigger if exists t1_bi;
187
create trigger t1_bi before insert on t1
195
-- declare some variables here
199
-- do more stuff here
200
-- commented nicely and so on
202
-- famous last words ...
208
show create trigger t1_bi;
210
# also make sure the trigger still works
211
insert into t1(id) value ("trig");
214
##============================================================================
216
##============================================================================