diff options
author | Maheedhar PV <maheedhar.panchalamarri.venka@oracle.com> | 2019-11-26 09:39:35 +0530 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-04-29 14:08:54 +0200 |
commit | 4d1de554bbba09b4be64e7f1a9bd005e7168864b (patch) | |
tree | 0dde7bf3749708f2af72689b5650784f30bf5649 | |
parent | a13157a561d960604c0c8cfd23b79783cfe76861 (diff) | |
download | mariadb-git-4d1de554bbba09b4be64e7f1a9bd005e7168864b.tar.gz |
Bug#28388217 - SERVER CAN FAIL WHILE REPLICATING CONDITIONAL COMMENTS
Cause:
In case of version based condtional comments, if the condition evaluates
to false, it is converted to a regular comment for replication by
replacing "!" by " ".
Nested comment in a conditional comment is replicated as is. Nested
comments are supported only in case of conditional comments and when a
the comment on slave is no more a conditional comment, the statement
execution fails on the slave.
Fix:
Convert the nested comment, start from "/*" to "(*" and comment end from
"*/" to "*)" for replication.
Change-Id: I1a8e385a267b2370529eade094f0258fa96886c0
-rw-r--r-- | sql/sql_lex.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fe4dcfd1524..cb850e06ba6 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB Corporation +/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -940,17 +940,27 @@ static inline uint int_token(const char *str,uint length) */ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) { + // only one level of nested comments are allowed + DBUG_ASSERT(remaining_recursions_permitted == 0 || + remaining_recursions_permitted == 1); reg1 uchar c; while (! lip->eof()) { c= lip->yyGet(); - if (remaining_recursions_permitted > 0) + if (remaining_recursions_permitted == 1) { if ((c == '/') && (lip->yyPeek() == '*')) { + lip->yyUnput('('); // Replace nested "/*..." with "(*..." + lip->yySkip(); // and skip "(" + lip->yySkip(); /* Eat asterisk */ - consume_comment(lip, remaining_recursions_permitted-1); + if (consume_comment(lip, 0)) + return true; + + lip->yyUnput(')'); // Replace "...*/" with "...*)" + lip->yySkip(); // and skip ")" continue; } } |