#At file:///opt/local/work/trunk-11918/ based on revid:alik@stripped
2993 Konstantin Osipov 2010-03-15
A fix for Bug#11918 "SP does not accept variables in LIMIT clause"
Pending tests, including tests of replication.
modified:
sql/share/errmsg-utf8.txt
sql/sql_yacc.yy
=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt 2010-03-03 19:22:02 +0000
+++ b/sql/share/errmsg-utf8.txt 2010-03-15 20:47:54 +0000
@@ -6321,3 +6321,6 @@ ER_SPATIAL_MUST_HAVE_GEOM_COL 42000
ER_TOO_LONG_INDEX_COMMENT
eng "Comment for index '%-.64s' is too long (max = %lu)"
+
+ER_WRONG_SPVAR_TYPE_IN_LIMIT
+ eng "A non-integer type in LIMIT clause"
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2010-03-02 14:34:50 +0000
+++ b/sql/sql_yacc.yy 2010-03-15 20:47:54 +0000
@@ -713,6 +713,46 @@ static bool add_create_index (LEX *lex,
return FALSE;
}
+
+/**
+ Construct an Item to represent one stored routine
+ variable.
+*/
+
+Item_splocal *
+create_item_splocal(THD *thd, LEX_STRING &name)
+{
+ LEX *lex= thd->lex;
+ Lex_input_stream *lip= & thd->m_parser_state->m_lip;
+ sp_variable_t *spv;
+ sp_pcontext *spc = lex->spcont;
+ if (spc && (spv = spc->find_variable(&name)))
+ {
+ /* We're compiling a stored procedure and found a variable */
+ if (! lex->parsing_options.allows_variable)
+ {
+ my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
+ goto end;
+ }
+
+ Item_splocal *splocal;
+ splocal= new (thd->mem_root)
+ Item_splocal(name, spv->offset, spv->type,
+ lip->get_tok_start_prev() - lex->sphead->m_tmp_query,
+ lip->get_tok_end() - lip->get_tok_start_prev());
+ if (splocal == NULL)
+ goto end;
+#ifndef DBUG_OFF
+ splocal->m_sp= lex->sphead;
+#endif
+ lex->safe_to_cache_query=0;
+ return splocal;
+ }
+end:
+ return NULL;
+}
+
+
%}
%union {
int num;
@@ -9823,7 +9863,19 @@ limit_options:
;
limit_option:
- param_marker
+ ident
+ {
+ Item_splocal *splocal= create_item_splocal(YYTHD, $1);
+ if (! splocal)
+ MYSQL_YYABORT;
+ if (splocal->type() != INT_ITEM)
+ {
+ my_error(ER_WRONG_SPVAR_TYPE_IN_LIMIT);
+ MYSQL_YYABORT;
+ }
+ $$= splocal;
+ i
+ } | param_marker
{
((Item_param *) $1)->limit_clause_param= TRUE;
}
@@ -11733,33 +11785,7 @@ simple_ident:
ident
{
THD *thd= YYTHD;
- LEX *lex= thd->lex;
- Lex_input_stream *lip= YYLIP;
- sp_variable_t *spv;
- sp_pcontext *spc = lex->spcont;
- if (spc && (spv = spc->find_variable(&$1)))
- {
- /* We're compiling a stored procedure and found a variable */
- if (! lex->parsing_options.allows_variable)
- {
- my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
- MYSQL_YYABORT;
- }
-
- Item_splocal *splocal;
- splocal= new (thd->mem_root)
- Item_splocal($1, spv->offset, spv->type,
- lip->get_tok_start_prev() - lex->sphead->m_tmp_query,
- lip->get_tok_end() - lip->get_tok_start_prev());
- if (splocal == NULL)
- MYSQL_YYABORT;
-#ifndef DBUG_OFF
- splocal->m_sp= lex->sphead;
-#endif
- $$= splocal;
- lex->safe_to_cache_query=0;
- }
- else
+ if (! ($$= create_item_splocal(thd, $1)))
{
SELECT_LEX *sel=Select;
if ((sel->parsing_place != IN_HAVING) ||
Attachment: [text/bzr-bundle] bzr/kostja@sun.com-20100315204754-uuaz5jj4jcnzh3y7.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk-bugfixing branch (kostja:2993) Bug#11918 | Konstantin Osipov | 15 Mar |