Skip to content

Commit 4d1de55

Browse files
Maheedhar PVvuvova
authored andcommitted
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
1 parent a13157a commit 4d1de55

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sql/sql_lex.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
2-
Copyright (c) 2009, 2018, MariaDB Corporation
1+
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates.
2+
Copyright (c) 2009, 2020, MariaDB Corporation
33
44
This program is free software; you can redistribute it and/or modify
55
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)
940940
*/
941941
bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
942942
{
943+
// only one level of nested comments are allowed
944+
DBUG_ASSERT(remaining_recursions_permitted == 0 ||
945+
remaining_recursions_permitted == 1);
943946
reg1 uchar c;
944947
while (! lip->eof())
945948
{
946949
c= lip->yyGet();
947950

948-
if (remaining_recursions_permitted > 0)
951+
if (remaining_recursions_permitted == 1)
949952
{
950953
if ((c == '/') && (lip->yyPeek() == '*'))
951954
{
955+
lip->yyUnput('('); // Replace nested "/*..." with "(*..."
956+
lip->yySkip(); // and skip "("
957+
952958
lip->yySkip(); /* Eat asterisk */
953-
consume_comment(lip, remaining_recursions_permitted-1);
959+
if (consume_comment(lip, 0))
960+
return true;
961+
962+
lip->yyUnput(')'); // Replace "...*/" with "...*)"
963+
lip->yySkip(); // and skip ")"
954964
continue;
955965
}
956966
}

0 commit comments

Comments
 (0)