Commit 8f9a72a1 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25501 routine_definition in information_schema.routines loses tablename...

MDEV-25501 routine_definition in information_schema.routines loses tablename if it starts with an _ and is not backticked

remove code duplication in Lex_input_stream::scan_ident_middle(),
make sure identifiers are always use the same code path whether
they start form an underscore or not.
parent 64b74337
...@@ -130,7 +130,9 @@ Warnings: ...@@ -130,7 +130,9 @@ Warnings:
Note 1050 Table 't2' already exists Note 1050 Table 't2' already exists
DROP DATABASE testdb; DROP DATABASE testdb;
USE test; USE test;
End of 5.1 tests #
# End of 5.1 tests
#
# #
# BUG#13489996 valgrind:conditional jump or move depends on # BUG#13489996 valgrind:conditional jump or move depends on
# uninitialised values-field_blob # uninitialised values-field_blob
...@@ -342,3 +344,26 @@ FOR i IN 1..10 DO ...@@ -342,3 +344,26 @@ FOR i IN 1..10 DO
RETURN 1; RETURN 1;
END FOR END FOR
DROP FUNCTION f1; DROP FUNCTION f1;
#
# End of 10.2 tests
#
#
# MDEV-25501 routine_definition in information_schema.routines loses tablename if it starts with an _ and is not backticked
#
create table _t1 (a int);
create procedure p1() select * from _t1;
show create procedure p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
select * from _t1 latin1 latin1_swedish_ci latin1_swedish_ci
select routine_definition from information_schema.routines where routine_schema=database() and specific_name='p1';
routine_definition
select * from _t1
select body, body_utf8 from mysql.proc where name='p1';
body body_utf8
select * from _t1 select * from _t1
drop procedure p1;
drop table _t1;
#
# End of 10.3 tests
#
...@@ -164,7 +164,9 @@ CALL p1(); ...@@ -164,7 +164,9 @@ CALL p1();
DROP DATABASE testdb; DROP DATABASE testdb;
USE test; USE test;
--echo End of 5.1 tests --echo #
--echo # End of 5.1 tests
--echo #
--echo # --echo #
--echo # BUG#13489996 valgrind:conditional jump or move depends on --echo # BUG#13489996 valgrind:conditional jump or move depends on
...@@ -371,3 +373,22 @@ DELIMITER ;$$ ...@@ -371,3 +373,22 @@ DELIMITER ;$$
SELECT f1(); SELECT f1();
SELECT body FROM mysql.proc WHERE db='test' AND specific_name='f1'; SELECT body FROM mysql.proc WHERE db='test' AND specific_name='f1';
DROP FUNCTION f1; DROP FUNCTION f1;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-25501 routine_definition in information_schema.routines loses tablename if it starts with an _ and is not backticked
--echo #
create table _t1 (a int);
create procedure p1() select * from _t1;
show create procedure p1;
select routine_definition from information_schema.routines where routine_schema=database() and specific_name='p1';
select body, body_utf8 from mysql.proc where name='p1';
drop procedure p1;
drop table _t1;
--echo #
--echo # End of 10.3 tests
--echo #
...@@ -2161,6 +2161,11 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, ...@@ -2161,6 +2161,11 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str,
yySkip(); // next state does a unget yySkip(); // next state does a unget
} }
yyUnget(); // ptr points now after last token char
str->set_ident(m_tok_start, length, is_8bit);
m_cpp_text_start= m_cpp_tok_start;
m_cpp_text_end= m_cpp_text_start + length;
/* /*
Note: "SELECT _bla AS 'alias'" Note: "SELECT _bla AS 'alias'"
_bla should be considered as a IDENT if charset haven't been found. _bla should be considered as a IDENT if charset haven't been found.
...@@ -2170,28 +2175,17 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, ...@@ -2170,28 +2175,17 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str,
DBUG_ASSERT(length > 0); DBUG_ASSERT(length > 0);
if (resolve_introducer && m_tok_start[0] == '_') if (resolve_introducer && m_tok_start[0] == '_')
{ {
yyUnget(); // ptr points now after last token char
str->set_ident(m_tok_start, length, false);
m_cpp_text_start= m_cpp_tok_start;
m_cpp_text_end= m_cpp_text_start + length;
body_utf8_append(m_cpp_text_start, m_cpp_tok_start + length);
ErrConvString csname(str->str + 1, str->length - 1, &my_charset_bin); ErrConvString csname(str->str + 1, str->length - 1, &my_charset_bin);
CHARSET_INFO *cs= get_charset_by_csname(csname.ptr(), CHARSET_INFO *cs= get_charset_by_csname(csname.ptr(),
MY_CS_PRIMARY, MYF(0)); MY_CS_PRIMARY, MYF(0));
if (cs) if (cs)
{ {
body_utf8_append(m_cpp_text_start, m_cpp_tok_start + length);
*introducer= cs; *introducer= cs;
return UNDERSCORE_CHARSET; return UNDERSCORE_CHARSET;
} }
return IDENT;
} }
yyUnget(); // ptr points now after last token char
str->set_ident(m_tok_start, length, is_8bit);
m_cpp_text_start= m_cpp_tok_start;
m_cpp_text_end= m_cpp_text_start + length;
body_utf8_append(m_cpp_text_start); body_utf8_append(m_cpp_text_start);
body_utf8_append_ident(thd, str, m_cpp_text_end); body_utf8_append_ident(thd, str, m_cpp_text_end);
return is_8bit ? IDENT_QUOTED : IDENT; return is_8bit ? IDENT_QUOTED : IDENT;
......
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