Commit fa7faa29 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-5009 don't look inside /*!50700 ... */ comments

parent 768751c7
......@@ -40,6 +40,43 @@ select 2 /*M!999999 +1 */;
2
select 2 /*M!0000 +1 */;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0000 +1 */' at line 1
#
# Testing that MySQL versions >= 5.7.x and < 10.0.0 are ignored (MDEV-5009)
#
SELECT 1 /*!50699 +1*/;
1 +1
2
SELECT 1 /*!50700 +1*/;
1
1
SELECT 1 /*!50999 +1*/;
1
1
SELECT 1 /*!99999 +1*/;
1
1
#
# Tesing that versions >= 5.7.x and < 10.0.0 are not ignored
# when used with the MariaDB executable comment syntax.
#
SELECT 1 /*M!50699 +1*/;
1 +1
2
SELECT 1 /*M!50700 +1*/;
1 +1
2
SELECT 1 /*M!50999 +1*/;
1 +1
2
SELECT 1 /*M!99999 +1*/;
1 +1
2
SELECT 1 /*M!100000 +1*/;
1 +1
2
SELECT 1 /*M!110000 +1*/;
1
1
select 1/*!2*/;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2*/' at line 1
select 1/*!0000002*/;
......
......@@ -31,6 +31,25 @@ select 2 /*M!999999 +1 */;
--error ER_PARSE_ERROR
select 2 /*M!0000 +1 */;
--echo #
--echo # Testing that MySQL versions >= 5.7.x and < 10.0.0 are ignored (MDEV-5009)
--echo #
SELECT 1 /*!50699 +1*/;
SELECT 1 /*!50700 +1*/;
SELECT 1 /*!50999 +1*/;
SELECT 1 /*!99999 +1*/;
--echo #
--echo # Tesing that versions >= 5.7.x and < 10.0.0 are not ignored
--echo # when used with the MariaDB executable comment syntax.
--echo #
SELECT 1 /*M!50699 +1*/;
SELECT 1 /*M!50700 +1*/;
SELECT 1 /*M!50999 +1*/;
SELECT 1 /*M!99999 +1*/;
SELECT 1 /*M!100000 +1*/;
SELECT 1 /*M!110000 +1*/;
#
# Bug#25411 (trigger code truncated)
#
......
......@@ -1515,19 +1515,14 @@ int lex_one_token(void *arg, THD *thd)
lip->save_in_comment_state();
if (lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!')
{
/* Skip MariaDB unique marker */
lip->set_echo(FALSE);
lip->yySkip();
/* The following if will be true */
}
if (lip->yyPeekn(2) == '!')
if (lip->yyPeekn(2) == '!' ||
(lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!'))
{
bool maria_comment_syntax= lip->yyPeekn(2) == 'M';
lip->in_comment= DISCARD_COMMENT;
/* Accept '/' '*' '!', but do not keep this marker. */
lip->set_echo(FALSE);
lip->yySkipn(3);
lip->yySkipn(maria_comment_syntax ? 4 : 3);
/*
The special comment format is very strict:
......@@ -1557,7 +1552,14 @@ int lex_one_token(void *arg, THD *thd)
version= (ulong) my_strtoll10(lip->get_ptr(), &end_ptr, &error);
if (version <= MYSQL_VERSION_ID)
/*
MySQL-5.7 has new features and might have new SQL syntax that
MariaDB-10.0 does not understand. Ignore all versioned comments
with MySQL versions in the range 50700–999999, but
do not ignore MariaDB specific comments for the same versions.
*/
if (version <= MYSQL_VERSION_ID &&
(version < 50700 || version > 999999 || maria_comment_syntax))
{
/* Accept 'M' 'm' 'm' 'd' 'd' */
lip->yySkipn(length);
......
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