Skip to content

Commit a81c1b2

Browse files
author
kroki/tomash@mysql.com/moonlight.intranet
committed
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.
1 parent 73eb784 commit a81c1b2

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

mysql-test/r/sp-code.result

+9-2
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ Pos Instruction
155155
0 stmt 9 "drop temporary table if exists sudoku..."
156156
1 stmt 1 "create temporary table sudoku_work ( ..."
157157
2 stmt 1 "create temporary table sudoku_schedul..."
158-
3 stmt 95 "call sudoku_init("
158+
3 stmt 95 "call sudoku_init()"
159159
4 jump_if_not 7(8) p_naive@0
160160
5 stmt 4 "update sudoku_work set cnt = 0 where ..."
161161
6 jump 8
162-
7 stmt 95 "call sudoku_count("
162+
7 stmt 95 "call sudoku_count()"
163163
8 stmt 6 "insert into sudoku_schedule (row,col)..."
164164
9 set v_scounter@2 0
165165
10 set v_i@3 1
@@ -199,3 +199,10 @@ Pos Instruction
199199
44 jump 14
200200
45 stmt 9 "drop temporary table sudoku_work, sud..."
201201
drop procedure sudoku_solve;
202+
DROP PROCEDURE IF EXISTS p1;
203+
CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
204+
SHOW PROCEDURE CODE p1;
205+
Pos Instruction
206+
0 stmt 2 "CREATE INDEX idx ON t1 (c1)"
207+
DROP PROCEDURE p1;
208+
End of 5.0 tests.

mysql-test/t/sp-code.test

+22
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,25 @@ delimiter ;//
190190
show procedure code sudoku_solve;
191191

192192
drop procedure sudoku_solve;
193+
194+
195+
#
196+
# Bug#19207: Final parenthesis omitted for CREATE INDEX in Stored
197+
# Procedure
198+
#
199+
# Wrong criteria was used to distinguish the case when there was no
200+
# lookahead performed in the parser. Bug affected only statements
201+
# ending in one-character token without any optional tail, like CREATE
202+
# INDEX and CALL.
203+
#
204+
--disable_warnings
205+
DROP PROCEDURE IF EXISTS p1;
206+
--enable_warnings
207+
208+
CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
209+
SHOW PROCEDURE CODE p1;
210+
211+
DROP PROCEDURE p1;
212+
213+
214+
--echo End of 5.0 tests.

sql/sql_yacc.yy

+12-4
Original file line numberDiff line numberDiff line change
@@ -1911,9 +1911,12 @@ sp_proc_stmt:
19111911
sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
19121912
lex->spcont, lex);
19131913

1914-
/* Extract the query statement from the tokenizer:
1915-
The end is either lex->tok_end or tok->ptr. */
1916-
if (lex->ptr - lex->tok_end > 1)
1914+
/*
1915+
Extract the query statement from the tokenizer. The
1916+
end is either lex->ptr, if there was no lookahead,
1917+
lex->tok_end otherwise.
1918+
*/
1919+
if (yychar == YYEMPTY)
19171920
i->m_query.length= lex->ptr - sp->m_tmp_query;
19181921
else
19191922
i->m_query.length= lex->tok_end - sp->m_tmp_query;
@@ -7841,7 +7844,12 @@ option_type_value:
78417844
lex)))
78427845
YYABORT;
78437846

7844-
if (lex->ptr - lex->tok_end > 1)
7847+
/*
7848+
Extract the query statement from the tokenizer. The
7849+
end is either lex->ptr, if there was no lookahead,
7850+
lex->tok_end otherwise.
7851+
*/
7852+
if (yychar == YYEMPTY)
78457853
qbuff.length= lex->ptr - sp->m_tmp_query;
78467854
else
78477855
qbuff.length= lex->tok_end - sp->m_tmp_query;

0 commit comments

Comments
 (0)