1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-23108: Point in time recovery of binary log fails when sql_mode=ORACLE

Problem:
========
During point in time recovery of binary log syntax error is reported for
BEGIN statement and recovery fails.

Analysis:
=========
In MariaDB 10.3 and later, setting the sql_mode system variable to Oracle
allows the server to understand a subset of Oracle's PL/SQL language. When
sql_mode=ORACLE is set, it switches the parser from the MariaDB parser to
Oracle compatible parser. With this change 'BEGIN' is not considered as
'START TRANSACTION'. Hence the syntax error is reported.

Fix:
===
At preset 'BEGIN' query is generated from 'Gtid_log_event::print'. The current
session specific 'sql_mode' information is not present as part of
'Gtid_log_event'. If it was available then, mysqlbinlog tool can make use of
'sql_mode == ORACLE' and can output "START TRANSACTION" in this particular
mode and for other sql_modes it will write "BEGIN" as part of output. Since it
is not available 'mysqlbinlog' tool will output all 'BEGIN' statements as
'START TRANSACTION' irrespective of 'sql_mode'.
This commit is contained in:
Sujatha
2020-07-20 17:57:39 +05:30
parent b75563cdfd
commit c86accc7ac
28 changed files with 778 additions and 560 deletions

View File

@ -24,7 +24,7 @@ FLUSH LOGS;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
BEGIN
START TRANSACTION
/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -39,7 +39,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
INSERT INTO t1 VALUES (1)
/*!*/;
COMMIT/*!*/;
BEGIN
START TRANSACTION
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (2)
@ -55,7 +55,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
BEGIN
START TRANSACTION
/*!*/;
use `foo`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -70,7 +70,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
INSERT INTO t1 VALUES (1)
/*!*/;
COMMIT/*!*/;
BEGIN
START TRANSACTION
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (2)