Commit fa807c50 authored by malff/marcsql@weblab.(none)'s avatar malff/marcsql@weblab.(none)

Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-runtime

into  weblab.(none):/home/marcsql/TREE/mysql-5.1-21513
parents 62fd6aa6 012f841f
...@@ -7146,6 +7146,17 @@ SELECT bug5274_f2()| ...@@ -7146,6 +7146,17 @@ SELECT bug5274_f2()|
DROP FUNCTION bug5274_f1| DROP FUNCTION bug5274_f1|
DROP FUNCTION bug5274_f2| DROP FUNCTION bug5274_f2|
#
# Bug#21513 (SP having body starting with quoted label rendered unusable)
#
--disable_warnings
drop procedure if exists proc_21513|
--enable_warnings
create procedure proc_21513()`my_label`:BEGIN END|
show create procedure proc_21513|
drop procedure proc_21513|
### ###
--echo End of 5.0 tests. --echo End of 5.0 tests.
......
...@@ -4711,7 +4711,6 @@ inline uint char_val(char X) ...@@ -4711,7 +4711,6 @@ inline uint char_val(char X)
Item_hex_string::Item_hex_string(const char *str, uint str_length) Item_hex_string::Item_hex_string(const char *str, uint str_length)
{ {
name=(char*) str-2; // Lex makes this start with 0x
max_length=(str_length+1)/2; max_length=(str_length+1)/2;
char *ptr=(char*) sql_alloc(max_length+1); char *ptr=(char*) sql_alloc(max_length+1);
if (!ptr) if (!ptr)
...@@ -4822,7 +4821,6 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length) ...@@ -4822,7 +4821,6 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length)
uchar bits= 0; uchar bits= 0;
uint power= 1; uint power= 1;
name= (char*) str - 2;
max_length= (str_length + 7) >> 3; max_length= (str_length + 7) >> 3;
char *ptr= (char*) sql_alloc(max_length + 1); char *ptr= (char*) sql_alloc(max_length + 1);
if (!ptr) if (!ptr)
......
...@@ -302,12 +302,12 @@ bool is_lex_native_function(const LEX_STRING *name) ...@@ -302,12 +302,12 @@ bool is_lex_native_function(const LEX_STRING *name)
/* make a copy of token before ptr and set yytoklen */ /* make a copy of token before ptr and set yytoklen */
static LEX_STRING get_token(Lex_input_stream *lip, uint length) static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
{ {
LEX_STRING tmp; LEX_STRING tmp;
yyUnget(); // ptr points now after last token char yyUnget(); // ptr points now after last token char
tmp.length=lip->yytoklen=length; tmp.length=lip->yytoklen=length;
tmp.str= lip->m_thd->strmake(lip->tok_start, tmp.length); tmp.str= lip->m_thd->strmake(lip->tok_start + skip, tmp.length);
return tmp; return tmp;
} }
...@@ -319,6 +319,7 @@ static LEX_STRING get_token(Lex_input_stream *lip, uint length) ...@@ -319,6 +319,7 @@ static LEX_STRING get_token(Lex_input_stream *lip, uint length)
*/ */
static LEX_STRING get_quoted_token(Lex_input_stream *lip, static LEX_STRING get_quoted_token(Lex_input_stream *lip,
uint skip,
uint length, char quote) uint length, char quote)
{ {
LEX_STRING tmp; LEX_STRING tmp;
...@@ -327,9 +328,10 @@ static LEX_STRING get_quoted_token(Lex_input_stream *lip, ...@@ -327,9 +328,10 @@ static LEX_STRING get_quoted_token(Lex_input_stream *lip,
yyUnget(); // ptr points now after last token char yyUnget(); // ptr points now after last token char
tmp.length= lip->yytoklen=length; tmp.length= lip->yytoklen=length;
tmp.str=(char*) lip->m_thd->alloc(tmp.length+1); tmp.str=(char*) lip->m_thd->alloc(tmp.length+1);
for (from= lip->tok_start, to= tmp.str, end= to+length ; from= lip->tok_start + skip
to != end ; to= tmp.str;
) end= to+length;
for ( ; to != end; )
{ {
if ((*to++= *from++) == quote) if ((*to++= *from++) == quote)
from++; // Skip double quotes from++; // Skip double quotes
...@@ -709,7 +711,7 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -709,7 +711,7 @@ int MYSQLlex(void *arg, void *yythd)
} }
yySkip(); // next state does a unget yySkip(); // next state does a unget
} }
yylval->lex_str=get_token(lip, length); yylval->lex_str=get_token(lip, 0, length);
/* /*
Note: "SELECT _bla AS 'alias'" Note: "SELECT _bla AS 'alias'"
...@@ -751,7 +753,7 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -751,7 +753,7 @@ int MYSQLlex(void *arg, void *yythd)
{ {
yySkip(); yySkip();
while (my_isdigit(cs,yyGet())) ; while (my_isdigit(cs,yyGet())) ;
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 0, yyLength());
return(FLOAT_NUM); return(FLOAT_NUM);
} }
} }
...@@ -763,10 +765,8 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -763,10 +765,8 @@ int MYSQLlex(void *arg, void *yythd)
while (my_isxdigit(cs,(c = yyGet()))) ; while (my_isxdigit(cs,(c = yyGet()))) ;
if ((lip->ptr - lip->tok_start) >= 4 && !ident_map[c]) if ((lip->ptr - lip->tok_start) >= 4 && !ident_map[c])
{ {
yylval->lex_str=get_token(lip, yyLength()); /* skip '0x' */
yylval->lex_str.str+=2; // Skip 0x yylval->lex_str=get_token(lip, 2, yyLength()-2);
yylval->lex_str.length-=2;
lip->yytoklen-=2;
return (HEX_NUM); return (HEX_NUM);
} }
yyUnget(); yyUnget();
...@@ -777,10 +777,8 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -777,10 +777,8 @@ int MYSQLlex(void *arg, void *yythd)
while (my_isxdigit(cs,(c = yyGet()))) ; while (my_isxdigit(cs,(c = yyGet()))) ;
if ((lip->ptr - lip->tok_start) >= 4 && !ident_map[c]) if ((lip->ptr - lip->tok_start) >= 4 && !ident_map[c])
{ {
yylval->lex_str= get_token(lip, yyLength()); /* Skip '0b' */
yylval->lex_str.str+= 2; // Skip 0x yylval->lex_str= get_token(lip, 2, yyLength()-2);
yylval->lex_str.length-= 2;
lip->yytoklen-= 2;
return (BIN_NUM); return (BIN_NUM);
} }
yyUnget(); yyUnget();
...@@ -813,14 +811,13 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -813,14 +811,13 @@ int MYSQLlex(void *arg, void *yythd)
if (c == '.' && ident_map[yyPeek()]) if (c == '.' && ident_map[yyPeek()])
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.' lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
yylval->lex_str= get_token(lip, yyLength()); yylval->lex_str= get_token(lip, 0, yyLength());
return(result_state); return(result_state);
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
{ {
uint double_quotes= 0; uint double_quotes= 0;
char quote_char= c; // Used char char quote_char= c; // Used char
lip->tok_start=lip->ptr; // Skip first `
while ((c=yyGet())) while ((c=yyGet()))
{ {
int var_length; int var_length;
...@@ -842,19 +839,20 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -842,19 +839,20 @@ int MYSQLlex(void *arg, void *yythd)
#endif #endif
} }
if (double_quotes) if (double_quotes)
yylval->lex_str=get_quoted_token(lip, yyLength() - double_quotes, yylval->lex_str=get_quoted_token(lip, 1,
yyLength() - double_quotes -1,
quote_char); quote_char);
else else
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 1, yyLength() -1);
if (c == quote_char) if (c == quote_char)
yySkip(); // Skip end ` yySkip(); // Skip end `
lip->next_state= MY_LEX_START; lip->next_state= MY_LEX_START;
return(IDENT_QUOTED); return(IDENT_QUOTED);
} }
case MY_LEX_INT_OR_REAL: // Compleat int or incompleat real case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
if (c != '.') if (c != '.')
{ // Found complete integer number. { // Found complete integer number.
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 0, yyLength());
return int_token(yylval->lex_str.str,yylval->lex_str.length); return int_token(yylval->lex_str.str,yylval->lex_str.length);
} }
// fall through // fall through
...@@ -872,10 +870,10 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -872,10 +870,10 @@ int MYSQLlex(void *arg, void *yythd)
break; break;
} }
while (my_isdigit(cs,yyGet())) ; while (my_isdigit(cs,yyGet())) ;
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 0, yyLength());
return(FLOAT_NUM); return(FLOAT_NUM);
} }
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 0, yyLength());
return(DECIMAL_NUM); return(DECIMAL_NUM);
case MY_LEX_HEX_NUMBER: // Found x'hexstring' case MY_LEX_HEX_NUMBER: // Found x'hexstring'
...@@ -887,10 +885,9 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -887,10 +885,9 @@ int MYSQLlex(void *arg, void *yythd)
return(ABORT_SYM); // Illegal hex constant return(ABORT_SYM); // Illegal hex constant
} }
yyGet(); // get_token makes an unget yyGet(); // get_token makes an unget
yylval->lex_str=get_token(lip, length); yylval->lex_str=get_token(lip,
yylval->lex_str.str+=2; // Skip x' 2, // skip x'
yylval->lex_str.length-=3; // Don't count x' and last ' length-3); // don't count x' and last '
lip->yytoklen-=3;
return (HEX_NUM); return (HEX_NUM);
case MY_LEX_BIN_NUMBER: // Found b'bin-string' case MY_LEX_BIN_NUMBER: // Found b'bin-string'
...@@ -900,11 +897,10 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -900,11 +897,10 @@ int MYSQLlex(void *arg, void *yythd)
if (c != '\'') if (c != '\'')
return(ABORT_SYM); // Illegal hex constant return(ABORT_SYM); // Illegal hex constant
yyGet(); // get_token makes an unget yyGet(); // get_token makes an unget
yylval->lex_str= get_token(lip, length); yylval->lex_str= get_token(lip,
yylval->lex_str.str+= 2; // Skip b' 2, // skip b'
yylval->lex_str.length-= 3; // Don't count b' and last ' length-3); // don't count b' and last '
lip->yytoklen-= 3; return (BIN_NUM);
return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator case MY_LEX_CMP_OP: // Incomplete comparison operator
if (state_map[yyPeek()] == MY_LEX_CMP_OP || if (state_map[yyPeek()] == MY_LEX_CMP_OP ||
...@@ -1076,7 +1072,7 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -1076,7 +1072,7 @@ int MYSQLlex(void *arg, void *yythd)
for (c=yyGet() ; for (c=yyGet() ;
my_isalnum(cs,c) || c == '.' || c == '_' || c == '$'; my_isalnum(cs,c) || c == '.' || c == '_' || c == '$';
c= yyGet()) ; c= yyGet()) ;
yylval->lex_str=get_token(lip, yyLength()); yylval->lex_str=get_token(lip, 0, yyLength());
return(LEX_HOSTNAME); return(LEX_HOSTNAME);
case MY_LEX_SYSTEM_VAR: case MY_LEX_SYSTEM_VAR:
yylval->lex_str.str=(char*) lip->ptr; yylval->lex_str.str=(char*) lip->ptr;
...@@ -1108,7 +1104,7 @@ int MYSQLlex(void *arg, void *yythd) ...@@ -1108,7 +1104,7 @@ int MYSQLlex(void *arg, void *yythd)
yyUnget(); // Put back 'c' yyUnget(); // Put back 'c'
return(tokval); // Was keyword return(tokval); // Was keyword
} }
yylval->lex_str=get_token(lip, length); yylval->lex_str=get_token(lip, 0, length);
return(result_state); return(result_state);
} }
} }
......
...@@ -6210,21 +6210,23 @@ select_item_list: ...@@ -6210,21 +6210,23 @@ select_item_list:
select_item: select_item:
remember_name select_item2 remember_end select_alias remember_name select_item2 remember_end select_alias
{ {
if (add_item_to_list(YYTHD, $2)) THD *thd= YYTHD;
DBUG_ASSERT($1 < $3);
if (add_item_to_list(thd, $2))
MYSQL_YYABORT; MYSQL_YYABORT;
if ($4.str) if ($4.str)
{ {
$2->is_autogenerated_name= FALSE; $2->is_autogenerated_name= FALSE;
$2->set_name($4.str, $4.length, system_charset_info); $2->set_name($4.str, $4.length, system_charset_info);
} }
else if (!$2->name) { else if (!$2->name)
char *str = $1; {
if (str[-1] == '`') $2->set_name($1, (uint) ($3 - $1), thd->charset());
str--;
$2->set_name(str,(uint) ($3 - str), YYTHD->charset());
} }
}; };
remember_name: remember_name:
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
......
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