1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00
Files
mariadb/mysql-test/suite/compat/oracle/r/binlog_ptr_mysqlbinlog.result
Sujatha c86accc7ac 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'.
2020-07-22 11:34:50 +05:30

101 lines
2.7 KiB
Plaintext

SET @@SQL_MODE = 'ORACLE';
##########################################################################
# Test verifies Gtid_log_event/Xid_log_event specific print #
##########################################################################
CREATE TABLE tm (f INT) ENGINE=MYISAM;
INSERT INTO tm VALUES (10);
CREATE TABLE t(f INT) ENGINE=INNODB;
INSERT INTO t VALUES (10);
CREATE OR REPLACE PROCEDURE simpleproc (param1 OUT INT) AS
BEGIN
SELECT COUNT(*) INTO param1 FROM t;
END;
/
CREATE FUNCTION f1 RETURN INT
AS
BEGIN
RETURN 10;
END;
/
FLUSH LOGS;
##########################################################################
# Delete data from master so that it can be restored from binlog #
##########################################################################
DROP FUNCTION f1;
DROP PROCEDURE simpleproc;
DROP TABLE tm;
DROP TABLE t;
##########################################################################
# Post recovery using mysqlbinlog #
##########################################################################
SHOW TABLES;
Tables_in_test
t
tm
SELECT * FROM tm;
f
10
SELECT * FROM t;
f
10
SELECT f1();
f1()
10
CALL simpleproc(@a);
SELECT @a;
@a
1
"***** Clean Up *****"
DROP TABLE t,tm;
DROP PROCEDURE simpleproc;
DROP FUNCTION f1;
RESET MASTER;
##########################################################################
# Test verifies Gtid_log_event/Xid_log_event/Qery_log_event #
# specific print along with flashback option #
##########################################################################
CREATE TABLE tm(f INT) ENGINE=MYISAM;
INSERT INTO tm VALUES (10);
INSERT INTO tm VALUES (20);
CREATE TABLE t(f INT) ENGINE=INNODB;
INSERT INTO t VALUES (10);
INSERT INTO t VALUES (20);
##########################################################################
# Initial data #
##########################################################################
SELECT * FROM tm;
f
10
20
SELECT * FROM t;
f
10
20
FLUSH LOGS;
DELETE FROM tm WHERE f=20;
DELETE FROM t WHERE f=20;
FLUSH LOGS;
##########################################################################
# Data after deletion #
##########################################################################
SELECT * FROM tm;
f
10
SELECT * FROM t;
f
10
FOUND 2 /START TRANSACTION/ in test.sql
##########################################################################
# Data after recovery using flashback #
##########################################################################
SELECT * FROM tm;
f
10
20
SELECT * FROM t;
f
10
20
"***** Clean Up *****"
DROP TABLE t,tm;