summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-04-28 21:27:04 +0200
committerSergei Golubchik <serg@mariadb.org>2021-04-28 21:27:04 +0200
commit8f9a72a1504c73a2d432cb5a521b9ca631d1e455 (patch)
tree7e38cabcb6a91ae37a87a9ff03fe2d3029586dd2
parent64b7433709dc5fb5080861018b13a0e1cf9d5238 (diff)
downloadmariadb-git-8f9a72a1504c73a2d432cb5a521b9ca631d1e455.tar.gz
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.
-rw-r--r--mysql-test/main/sp-bugs.result27
-rw-r--r--mysql-test/main/sp-bugs.test23
-rw-r--r--sql/sql_lex.cc18
3 files changed, 54 insertions, 14 deletions
diff --git a/mysql-test/main/sp-bugs.result b/mysql-test/main/sp-bugs.result
index 60cb6a89cde..f88b3b137d3 100644
--- a/mysql-test/main/sp-bugs.result
+++ b/mysql-test/main/sp-bugs.result
@@ -130,7 +130,9 @@ Warnings:
Note 1050 Table 't2' already exists
DROP DATABASE testdb;
USE test;
-End of 5.1 tests
+#
+# End of 5.1 tests
+#
#
# BUG#13489996 valgrind:conditional jump or move depends on
# uninitialised values-field_blob
@@ -342,3 +344,26 @@ FOR i IN 1..10 DO
RETURN 1;
END FOR
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
+#
diff --git a/mysql-test/main/sp-bugs.test b/mysql-test/main/sp-bugs.test
index d7b88bbeeec..0693ee5f2fc 100644
--- a/mysql-test/main/sp-bugs.test
+++ b/mysql-test/main/sp-bugs.test
@@ -164,7 +164,9 @@ CALL p1();
DROP DATABASE testdb;
USE test;
---echo End of 5.1 tests
+--echo #
+--echo # End of 5.1 tests
+--echo #
--echo #
--echo # BUG#13489996 valgrind:conditional jump or move depends on
@@ -371,3 +373,22 @@ DELIMITER ;$$
SELECT f1();
SELECT body FROM mysql.proc WHERE db='test' AND specific_name='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 #
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 56046584b8b..b1c5327d10c 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2161,6 +2161,11 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str,
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'"
_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,
DBUG_ASSERT(length > 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);
CHARSET_INFO *cs= get_charset_by_csname(csname.ptr(),
MY_CS_PRIMARY, MYF(0));
if (cs)
{
+ body_utf8_append(m_cpp_text_start, m_cpp_tok_start + length);
*introducer= cs;
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_ident(thd, str, m_cpp_text_end);
return is_8bit ? IDENT_QUOTED : IDENT;