Browse Source
Merge polly.(none):/home/kaa/src/opt/bug26215/my50-bug26215
Merge polly.(none):/home/kaa/src/opt/bug26215/my50-bug26215
into polly.(none):/home/kaa/src/opt/bug26215/my51-bug26215 client/mysql.cc: Manual merge.pull/374/head
4 changed files with 389 additions and 43 deletions
-
168client/mysql.cc
-
50mysql-test/r/mysql_comments.result
-
177mysql-test/t/mysql_comments.sql
-
37mysql-test/t/mysql_comments.test
@ -0,0 +1,50 @@ |
|||
drop table if exists t1; |
|||
drop function if exists foofct; |
|||
drop procedure if exists empty; |
|||
drop procedure if exists foosp; |
|||
drop procedure if exists nicesp; |
|||
drop trigger if exists t1_empty; |
|||
drop trigger if exists t1_bi; |
|||
"Pass 1 : --disable-comments" |
|||
1 |
|||
1 |
|||
2 |
|||
2 |
|||
foofct("call 1") |
|||
call 1 |
|||
Function sql_mode Create Function |
|||
foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n\n\n\nx |
|||
foofct("call 2") |
|||
call 2 |
|||
Function sql_mode Create Function |
|||
foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n \n \n \n\n \n\n \n return x;\nend |
|||
Procedure sql_mode Create Procedure |
|||
empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend |
|||
id data |
|||
foo 42 |
|||
Procedure sql_mode Create Procedure |
|||
foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n\n\n\n\n \n\n \n values ("foo", 42) |
|||
Procedure sql_mode Create Procedure |
|||
nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n \n declare b int;\n declare c float;\n\n \n \n\n \nend |
|||
"Pass 2 : --enable-comments" |
|||
1 |
|||
1 |
|||
2 |
|||
2 |
|||
foofct("call 1") |
|||
call 1 |
|||
Function sql_mode Create Function |
|||
foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nreturn\n-- comment 1a\n# comment 1b\n/* comment 1c */\nx # after body, on same line |
|||
foofct("call 2") |
|||
call 2 |
|||
Function sql_mode Create Function |
|||
foofct CREATE DEFINER=`root`@`localhost` FUNCTION `foofct`(x char(20)) RETURNS char(20) CHARSET latin1\nbegin\n -- comment 1a\n # comment 1b\n /*\n comment 1c\n */\n\n -- empty line below\n\n -- empty line above\n return x;\nend |
|||
Procedure sql_mode Create Procedure |
|||
empty CREATE DEFINER=`root`@`localhost` PROCEDURE `empty`()\nbegin\nend |
|||
id data |
|||
foo 42 |
|||
Procedure sql_mode Create Procedure |
|||
foosp CREATE DEFINER=`root`@`localhost` PROCEDURE `foosp`()\ninsert into test.t1\n## These comments are part of the procedure body, and should be kept.\n# Comment 2a\n-- Comment 2b\n/* Comment 2c */\n -- empty line below\n\n -- empty line above\n values ("foo", 42) # comment 3, still part of the body |
|||
Procedure sql_mode Create Procedure |
|||
nicesp CREATE DEFINER=`root`@`localhost` PROCEDURE `nicesp`(a int)\nbegin\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\nend |
|||
End of 5.0 tests |
|||
@ -0,0 +1,177 @@ |
|||
##============================================================================ |
|||
## Notes |
|||
##============================================================================ |
|||
|
|||
# Test case for Bug#11230 |
|||
|
|||
# The point of this test is to make sure that '#', '-- ' and '/* ... */' |
|||
# comments, as well as empty lines, are sent from the client to the server. |
|||
# This is to ensure better error reporting, and to keep comments in the code |
|||
# for stored procedures / functions / triggers (Bug#11230). |
|||
# As a result, be careful when editing comments in this script, they do |
|||
# matter. |
|||
# |
|||
# Also, note that this is a script for **mysql**, not mysqltest. |
|||
# This is critical, as the mysqltest client interprets comments differently. |
|||
|
|||
##============================================================================ |
|||
## Setup |
|||
##============================================================================ |
|||
|
|||
## See mysql_comments.test for initial cleanup |
|||
|
|||
# Test tables |
|||
# |
|||
# t1 is reused throughout the file, and dropped at the end. |
|||
# |
|||
drop table if exists t1; |
|||
create table t1 ( |
|||
id char(16) not null default '', |
|||
data int not null |
|||
); |
|||
|
|||
##============================================================================ |
|||
## Comments outside statements |
|||
##============================================================================ |
|||
|
|||
# Ignored 1a |
|||
-- Ignored 1b |
|||
/* |
|||
Ignored 1c |
|||
*/ |
|||
|
|||
select 1; |
|||
|
|||
##============================================================================ |
|||
## Comments inside statements |
|||
##============================================================================ |
|||
|
|||
select # comment 1a |
|||
# comment 2a |
|||
-- comment 2b |
|||
/* |
|||
comment 2c |
|||
*/ |
|||
2 |
|||
; # not strictly inside, but on same line |
|||
# ignored |
|||
|
|||
##============================================================================ |
|||
## Comments inside functions |
|||
##============================================================================ |
|||
|
|||
drop function if exists foofct ; |
|||
|
|||
create function foofct (x char(20)) |
|||
returns char(20) |
|||
/* not inside the body yet */ |
|||
return |
|||
-- comment 1a |
|||
# comment 1b |
|||
/* comment 1c */ |
|||
x; # after body, on same line |
|||
|
|||
select foofct("call 1"); |
|||
|
|||
show create function foofct; |
|||
drop function foofct; |
|||
|
|||
delimiter | |
|||
|
|||
create function foofct(x char(20)) |
|||
returns char(20) |
|||
begin |
|||
-- comment 1a |
|||
# comment 1b |
|||
/* |
|||
comment 1c |
|||
*/ |
|||
|
|||
-- empty line below |
|||
|
|||
-- empty line above |
|||
return x; |
|||
end| |
|||
|
|||
delimiter ; |
|||
|
|||
select foofct("call 2"); |
|||
|
|||
show create function foofct; |
|||
drop function foofct; |
|||
|
|||
##============================================================================ |
|||
## Comments inside stored procedures |
|||
##============================================================================ |
|||
|
|||
# Empty statement |
|||
drop procedure if exists empty; |
|||
create procedure empty() |
|||
begin |
|||
end; |
|||
|
|||
call empty(); |
|||
show create procedure empty; |
|||
drop procedure empty; |
|||
|
|||
drop procedure if exists foosp; |
|||
|
|||
## These comments are before the create, and will be lost |
|||
# Comment 1a |
|||
-- Comment 1b |
|||
/* |
|||
Comment 1c |
|||
*/ |
|||
create procedure foosp() |
|||
/* Comment not quiet in the body yet */ |
|||
insert into test.t1 |
|||
## These comments are part of the procedure body, and should be kept. |
|||
# Comment 2a |
|||
-- Comment 2b |
|||
/* Comment 2c */ |
|||
-- empty line below |
|||
|
|||
-- empty line above |
|||
values ("foo", 42); # comment 3, still part of the body |
|||
## After the ';', therefore not part of the body |
|||
# comment 4a |
|||
-- Comment 4b |
|||
/* |
|||
Comment 4c |
|||
*/ |
|||
|
|||
call foosp(); |
|||
select * from t1; |
|||
delete from t1; |
|||
show create procedure foosp; |
|||
drop procedure foosp; |
|||
|
|||
drop procedure if exists nicesp; |
|||
|
|||
delimiter | |
|||
|
|||
create procedure nicesp(a int) |
|||
begin |
|||
-- declare some variables here |
|||
declare b int; |
|||
declare c float; |
|||
|
|||
-- do more stuff here |
|||
-- commented nicely and so on |
|||
|
|||
-- famous last words ... |
|||
end| |
|||
|
|||
delimiter ; |
|||
|
|||
show create procedure nicesp; |
|||
drop procedure nicesp; |
|||
|
|||
# Triggers can be tested only in 5.1, since 5.0 does not have |
|||
# SHOW CREATE TRIGGER |
|||
|
|||
##============================================================================ |
|||
## Cleanup |
|||
##============================================================================ |
|||
|
|||
drop table t1; |
|||
@ -0,0 +1,37 @@ |
|||
# This test should work in embedded server after we fix mysqltest |
|||
-- source include/not_embedded.inc |
|||
###################### mysql_comments.test ############################# |
|||
# # |
|||
# Testing of comments handling by the command line client (mysql) # |
|||
# # |
|||
# Creation: # |
|||
# 2007-10-29 akopytov Implemented this test as a part of fixes for # |
|||
# bug #26215 and bug #11230 # |
|||
# # |
|||
######################################################################## |
|||
|
|||
# |
|||
# Bug #11230: Keeping comments when storing stored procedures |
|||
# |
|||
|
|||
# See the content of mysql_comments.sql |
|||
# Set the test database to a known state before running the tests. |
|||
--disable_warnings |
|||
drop table if exists t1; |
|||
drop function if exists foofct; |
|||
drop procedure if exists empty; |
|||
drop procedure if exists foosp; |
|||
drop procedure if exists nicesp; |
|||
drop trigger if exists t1_empty; |
|||
drop trigger if exists t1_bi; |
|||
--enable_warnings |
|||
|
|||
# Test without comments |
|||
--echo "Pass 1 : --disable-comments" |
|||
--exec $MYSQL --disable-comments test 2>&1 < "./t/mysql_comments.sql" |
|||
|
|||
# Test with comments |
|||
--echo "Pass 2 : --enable-comments" |
|||
--exec $MYSQL --enable-comments test 2>&1 < "./t/mysql_comments.sql" |
|||
|
|||
--echo End of 5.0 tests |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue