Commit 7733615d authored by unknown's avatar unknown

Bug#19207: Final parenthesis omitted for CREATE INDEX in Stored Procedure

Wrong criteria was used to distinguish the case when there was no
lookahead performed in the parser.  Bug affected only statements
ending in one-character token without any optional tail, like CREATE
INDEX and CALL.


mysql-test/r/sp-code.result:
  Add result for bug#19207: Final parenthesis omitted for CREATE INDEX
  in Stored Procedure
mysql-test/t/sp-code.test:
  Add test case for bug#19207: Final parenthesis omitted for CREATE INDEX
  in Stored Procedure
sql/sql_yacc.yy:
  Use (yychar == YYEMPTY) as the criteria of whether lookahead was not
  performed.
parent d5d217c0
......@@ -155,11 +155,11 @@ Pos Instruction
0 stmt 9 "drop temporary table if exists sudoku..."
1 stmt 1 "create temporary table sudoku_work ( ..."
2 stmt 1 "create temporary table sudoku_schedul..."
3 stmt 95 "call sudoku_init("
3 stmt 95 "call sudoku_init()"
4 jump_if_not 7(8) p_naive@0
5 stmt 4 "update sudoku_work set cnt = 0 where ..."
6 jump 8
7 stmt 95 "call sudoku_count("
7 stmt 95 "call sudoku_count()"
8 stmt 6 "insert into sudoku_schedule (row,col)..."
9 set v_scounter@2 0
10 set v_i@3 1
......@@ -199,3 +199,10 @@ Pos Instruction
44 jump 14
45 stmt 9 "drop temporary table sudoku_work, sud..."
drop procedure sudoku_solve;
DROP PROCEDURE IF EXISTS p1;
CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
SHOW PROCEDURE CODE p1;
Pos Instruction
0 stmt 2 "CREATE INDEX idx ON t1 (c1)"
DROP PROCEDURE p1;
End of 5.0 tests.
......@@ -190,3 +190,25 @@ delimiter ;//
show procedure code sudoku_solve;
drop procedure sudoku_solve;
#
# Bug#19207: Final parenthesis omitted for CREATE INDEX in Stored
# Procedure
#
# Wrong criteria was used to distinguish the case when there was no
# lookahead performed in the parser. Bug affected only statements
# ending in one-character token without any optional tail, like CREATE
# INDEX and CALL.
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
SHOW PROCEDURE CODE p1;
DROP PROCEDURE p1;
--echo End of 5.0 tests.
......@@ -1911,9 +1911,12 @@ sp_proc_stmt:
sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
lex->spcont, lex);
/* Extract the query statement from the tokenizer:
The end is either lex->tok_end or tok->ptr. */
if (lex->ptr - lex->tok_end > 1)
/*
Extract the query statement from the tokenizer. The
end is either lex->ptr, if there was no lookahead,
lex->tok_end otherwise.
*/
if (yychar == YYEMPTY)
i->m_query.length= lex->ptr - sp->m_tmp_query;
else
i->m_query.length= lex->tok_end - sp->m_tmp_query;
......@@ -7841,7 +7844,12 @@ option_type_value:
lex)))
YYABORT;
if (lex->ptr - lex->tok_end > 1)
/*
Extract the query statement from the tokenizer. The
end is either lex->ptr, if there was no lookahead,
lex->tok_end otherwise.
*/
if (yychar == YYEMPTY)
qbuff.length= lex->ptr - sp->m_tmp_query;
else
qbuff.length= lex->tok_end - sp->m_tmp_query;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment