summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-12-18 01:08:39 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-12-18 01:08:39 +0400
commitfa7faa2955cf6d6c0af294c3ad6714e206ee2889 (patch)
treebb6268898464c17bda412046d441e369e4d37a4a
parent768751c786b32823d80c12966e74a12de42b75f6 (diff)
downloadmariadb-git-fa7faa2955cf6d6c0af294c3ad6714e206ee2889.tar.gz
MDEV-5009 don't look inside /*!50700 ... */ comments
-rw-r--r--mysql-test/r/comments.result37
-rw-r--r--mysql-test/t/comments.test19
-rw-r--r--sql/sql_lex.cc22
3 files changed, 68 insertions, 10 deletions
diff --git a/mysql-test/r/comments.result b/mysql-test/r/comments.result
index e65c886014d..1e94c6ee2eb 100644
--- a/mysql-test/r/comments.result
+++ b/mysql-test/r/comments.result
@@ -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*/;
diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test
index 2ae6e5a4e38..39d69ae0b4c 100644
--- a/mysql-test/t/comments.test
+++ b/mysql-test/t/comments.test
@@ -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)
#
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 9941c124f4d..9acbdc641eb 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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);