Browse Source
Bug#26030 (Parsing fails for stored routine w/multi-statement execution
Bug#26030 (Parsing fails for stored routine w/multi-statement execution
enabled) Before this fix, the lexer and parser would treat the ';' character as a different token (either ';' or END_OF_INPUT), based on convoluted logic, which failed in simple cases where a stored procedure is implemented as a single statement, and used in a multi query. With this fix: - the character ';' is always parsed as a ';' token in the lexer, - parsing multi queries is implemented in the parser, in the 'query:' rules, - the value of thd->client_capabilities, which is the capabilities negotiated between the client and the server during bootstrap, is immutable and not arbitrarily modified during parsing (which was the root cause of the bug)pull/374/head
8 changed files with 186 additions and 65 deletions
-
2mysql-test/r/comments.result
-
68mysql-test/r/parser.result
-
4mysql-test/r/ps.result
-
59mysql-test/t/parser.test
-
1sql/sp_head.h
-
19sql/sql_lex.cc
-
5sql/sql_parse.cc
-
93sql/sql_yacc.yy
@ -0,0 +1,68 @@ |
|||
DROP PROCEDURE IF EXISTS p26030; |
|||
select "non terminated"$$ |
|||
non terminated |
|||
non terminated |
|||
select "terminated";$$ |
|||
terminated |
|||
terminated |
|||
select "non terminated, space" $$ |
|||
non terminated, space |
|||
non terminated, space |
|||
select "terminated, space"; $$ |
|||
terminated, space |
|||
terminated, space |
|||
select "non terminated, comment" /* comment */$$ |
|||
non terminated, comment |
|||
non terminated, comment |
|||
select "terminated, comment"; /* comment */$$ |
|||
terminated, comment |
|||
terminated, comment |
|||
select "stmt 1";select "stmt 2 non terminated"$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 non terminated |
|||
stmt 2 non terminated |
|||
select "stmt 1";select "stmt 2 terminated";$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 terminated |
|||
stmt 2 terminated |
|||
select "stmt 1";select "stmt 2 non terminated, space" $$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 non terminated, space |
|||
stmt 2 non terminated, space |
|||
select "stmt 1";select "stmt 2 terminated, space"; $$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 terminated, space |
|||
stmt 2 terminated, space |
|||
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 non terminated, comment |
|||
stmt 2 non terminated, comment |
|||
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
stmt 2 terminated, comment |
|||
stmt 2 terminated, comment |
|||
select "stmt 1"; select "space, stmt 2"$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
space, stmt 2 |
|||
space, stmt 2 |
|||
select "stmt 1";/* comment */select "comment, stmt 2"$$ |
|||
stmt 1 |
|||
stmt 1 |
|||
comment, stmt 2 |
|||
comment, stmt 2 |
|||
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030() |
|||
$$ |
|||
1 |
|||
1 |
|||
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030() |
|||
$$ |
|||
1 |
|||
1 |
|||
DROP PROCEDURE p26030; |
@ -0,0 +1,59 @@ |
|||
# |
|||
# This file contains tests covering the parser |
|||
# |
|||
|
|||
#============================================================================= |
|||
# LEXICAL PARSER (lex) |
|||
#============================================================================= |
|||
|
|||
# |
|||
# Maintainer: these tests are for the lexical parser, so every character, |
|||
# even whitespace or comments, is significant here. |
|||
# |
|||
|
|||
# |
|||
# Bug#26030 (Parsing fails for stored routine w/multi-statement execution |
|||
# enabled) |
|||
# |
|||
|
|||
--disable_warnings |
|||
DROP PROCEDURE IF EXISTS p26030; |
|||
--enable_warnings |
|||
|
|||
delimiter $$; |
|||
|
|||
select "non terminated"$$ |
|||
select "terminated";$$ |
|||
select "non terminated, space" $$ |
|||
select "terminated, space"; $$ |
|||
select "non terminated, comment" /* comment */$$ |
|||
select "terminated, comment"; /* comment */$$ |
|||
|
|||
# Multi queries can not be used in --ps-protocol test mode |
|||
--disable_ps_protocol |
|||
|
|||
select "stmt 1";select "stmt 2 non terminated"$$ |
|||
select "stmt 1";select "stmt 2 terminated";$$ |
|||
select "stmt 1";select "stmt 2 non terminated, space" $$ |
|||
select "stmt 1";select "stmt 2 terminated, space"; $$ |
|||
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$ |
|||
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$ |
|||
|
|||
select "stmt 1"; select "space, stmt 2"$$ |
|||
select "stmt 1";/* comment */select "comment, stmt 2"$$ |
|||
|
|||
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030() |
|||
$$ |
|||
|
|||
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030() |
|||
$$ |
|||
|
|||
--enable_ps_protocol |
|||
|
|||
delimiter ;$$ |
|||
DROP PROCEDURE p26030; |
|||
|
|||
#============================================================================r |
|||
# SYNTACTIC PARSER (bison) |
|||
#============================================================================= |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue