mirror of
https://github.com/MariaDB/server.git
synced 2025-07-26 07:02:12 +03:00
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'.
118 lines
3.9 KiB
Plaintext
118 lines
3.9 KiB
Plaintext
# ==== Purpose ====
|
|
#
|
|
# Test verifies that point in time recovery of binary log works when
|
|
# sql_mode='ORACLE'.
|
|
#
|
|
# BEGIN statement is printed in three places
|
|
# 1) "Gtid_log_event::print"
|
|
# 2) "Xid_log_event::print" if flashback is enabled
|
|
# 3) "Query_log_event::print" if flashback is enabled and engine is
|
|
# non-transacional.
|
|
#
|
|
# Test verifies all these cases.
|
|
#
|
|
# ==== References ====
|
|
#
|
|
# MDEV-23108: Point in time recovery of binary log fails when sql_mode=ORACLE
|
|
#
|
|
--source include/have_log_bin.inc
|
|
--source include/have_innodb.inc
|
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
SET @@SQL_MODE = 'ORACLE';
|
|
|
|
--echo ##########################################################################
|
|
--echo # Test verifies Gtid_log_event/Xid_log_event specific print #
|
|
--echo ##########################################################################
|
|
CREATE TABLE tm (f INT) ENGINE=MYISAM;
|
|
INSERT INTO tm VALUES (10);
|
|
|
|
CREATE TABLE t(f INT) ENGINE=INNODB;
|
|
INSERT INTO t VALUES (10);
|
|
|
|
DELIMITER /;
|
|
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;
|
|
/
|
|
DELIMITER ;/
|
|
|
|
FLUSH LOGS;
|
|
--echo ##########################################################################
|
|
--echo # Delete data from master so that it can be restored from binlog #
|
|
--echo ##########################################################################
|
|
DROP FUNCTION f1;
|
|
DROP PROCEDURE simpleproc;
|
|
DROP TABLE tm;
|
|
DROP TABLE t;
|
|
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/test.sql
|
|
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--echo ##########################################################################
|
|
--echo # Post recovery using mysqlbinlog #
|
|
--echo ##########################################################################
|
|
SHOW TABLES;
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
--horizontal_results
|
|
SELECT f1();
|
|
CALL simpleproc(@a);
|
|
SELECT @a;
|
|
|
|
--echo "***** Clean Up *****"
|
|
DROP TABLE t,tm;
|
|
DROP PROCEDURE simpleproc;
|
|
DROP FUNCTION f1;
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
|
|
RESET MASTER;
|
|
|
|
--echo ##########################################################################
|
|
--echo # Test verifies Gtid_log_event/Xid_log_event/Qery_log_event #
|
|
--echo # specific print along with flashback option #
|
|
--echo ##########################################################################
|
|
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);
|
|
--echo ##########################################################################
|
|
--echo # Initial data #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
FLUSH LOGS;
|
|
DELETE FROM tm WHERE f=20;
|
|
DELETE FROM t WHERE f=20;
|
|
FLUSH LOGS;
|
|
|
|
--echo ##########################################################################
|
|
--echo # Data after deletion #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
--exec $MYSQL_BINLOG --flashback $MYSQLD_DATADIR/master-bin.000002 > $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/test.sql
|
|
--let SEARCH_PATTERN=START TRANSACTION
|
|
--source include/search_pattern_in_file.inc
|
|
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--echo ##########################################################################
|
|
--echo # Data after recovery using flashback #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
|
|
--echo "***** Clean Up *****"
|
|
DROP TABLE t,tm;
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
|