From 17358074486eeefa95dc955b4fc21bbe1da407d9 Mon Sep 17 00:00:00 2001 From: Justin Jose Date: Thu, 27 Feb 2025 08:44:14 +0530 Subject: [PATCH] Bug#37117875 Binlog record error when delimiter is set to other symbols Description: ------------ When the delimiter is set to a non-default symbol and the SQL statement contains an unquoted semicolon (;) within a MySQL-specific comment, the SQL executes successfully in the source database. However, the binlog record becomes incomplete, leading to a syntax error in the replica database. Analysis: ------------ When the delimiter is set to a non-default symbol and an SQL statement contains an unquoted semicolon within a MySQL-specific comment, the client transmits the entire SQL statement, including the MySQL-specific comment, up to the delimiter to the server. During parsing, the server interprets the semicolon as the end of the command while processing the comment, resulting in the execution of a partial statement. The truncated statement is then recorded in the binary log and propagated to the replica, leading to an error. Fix: ------------ When the delimiter is set to a non-default symbol, treat MySQL-specific comments containing unquoted semicolons as syntax errors and return a parser error. Change-Id: I00d6b4ced89e79a7350c94218bf2527553054aed --- sql/sql_lex.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7923c137b77..3741184d8cb 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB Corporation. +/* Copyright (c) 2000, 2025, Oracle and/or its affiliates. + Copyright (c) 2009, 2025, 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 @@ -2564,6 +2564,8 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd) state=MY_LEX_CHAR; break; case MY_LEX_END: + /* Unclosed special comments result in a syntax error */ + if (in_comment == DISCARD_COMMENT) return (ABORT_SYM); next_state= MY_LEX_END; return(0); // We found end of input last time