mirror of
https://github.com/MariaDB/server.git
synced 2025-05-07 04:01:59 +03:00
errors In the fix of BUG#39934 in 5.1-rep+3, errors are generated when binlog_format=row and a statement modifies a table restricted to statement-logging (ER_BINLOG_ROW_MODE_AND_STMT_ENGINE); or if binlog_format=statement and a statement modifies a table restricted to row-logging (ER_BINLOG_STMT_MODE_AND_ROW_ENGINE). However, some DDL statements that lock tables (e.g. ALTER TABLE, CREATE INDEX and CREATE TRIGGER) were causing spurious errors, although no row might be inserted into the binary log. To fix the problem, we tagged statements that may generate rows into the binary log and thence the warning messages are only printed out when the appropriate conditions hold and rows might be changed. sql/log_event.cc: Reorganized the Query_log_event's constructor based on the CF_CAN_GENERATE_ROW_EVENTS flag and as such any statement that has the associated flag should go through a cache before being written to the binary log. sql/share/errmsg-utf8.txt: Improved the error message ER_BINLOG_UNSAFE_MIXED_STATEMENT according to Paul's suggestion. sql/sql_class.cc: Created a hook to be used by innodb that checks if a statement may write rows to the binary log. In other words, if it has the CF_CAN_GENERATE_ROW_EVENTS flag associated. sql/sql_class.h: Defined the CF_CAN_GENERATE_ROW_EVENTS flag. sql/sql_parse.cc: Updated the sql_command_flags and added a function to check the CF_CAN_GENERATE_ROW_EVENTS. sql/sql_parse.h: Added a function to check the CF_CAN_GENERATE_ROW_EVENTS. storage/innobase/handler/ha_innodb.cc: Added a call to the hook thd_generates_rows(). storage/innobase/handler/ha_innodb.h: Defined an external reference to the hook thd_generates_rows().
54 lines
3.0 KiB
Plaintext
54 lines
3.0 KiB
Plaintext
SET @old_binlog_format= @@global.binlog_format;
|
|
INSTALL PLUGIN example SONAME 'ha_example.so';
|
|
################################################################################
|
|
# Verifies if ER_BINLOG_STMT_MODE_AND_ROW_ENGINE happens by setting the binlog
|
|
# format to STATEMENT and the transaction isolation level to READ COMMITTED as
|
|
# such changes force Innodb to accept changes in the row format.
|
|
#
|
|
# When CREATE TABLE, ALTER TABLE, CREATE INDEX and CREATE TRIGGER are executed
|
|
# any error should be triggered.
|
|
#
|
|
# In contrast, CREATE TABLE ... SELECT should trigger the following error:
|
|
# ER_BINLOG_STMT_MODE_AND_ROW_ENGINE.
|
|
################################################################################
|
|
SET binlog_format = STATEMENT;
|
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
CREATE TABLE t_row (a VARCHAR(100)) ENGINE = InnoDB;
|
|
ALTER TABLE t_row ADD COLUMN b INT;
|
|
CREATE TRIGGER trig_row BEFORE INSERT ON t_row FOR EACH ROW INSERT INTO t_stmt VALUES (1);
|
|
CREATE INDEX i ON t_row(a);
|
|
CREATE TABLE t_row_new ENGINE = InnoDB SELECT * FROM t_row;
|
|
ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
|
|
DROP TABLE t_row;
|
|
|
|
|
|
################################################################################
|
|
# Verifies if ER_BINLOG_ROW_MODE_AND_STMT_ENGINE happens by setting the binlog
|
|
# format to ROW and using a engine, i.e. EXAMPLE, that only supports STATEMENT.
|
|
#
|
|
# When CREATE TABLE, ALTER TABLE, CREATE INDEX and CREATE TRIGGER are executed
|
|
# the error ER_BINLOG_ROW_MODE_AND_STMT_ENGINE is not triggered. Note that other
|
|
# errors are triggered due to restrictions in the engine.
|
|
#
|
|
# In contrast, CREATE TABLE ... SELECT should trigger the following error:
|
|
# ER_BINLOG_ROW_MODE_AND_STMT_ENGINE.
|
|
################################################################################
|
|
SET binlog_format = ROW;
|
|
CREATE TABLE t_stmt (a VARCHAR(100)) ENGINE = EXAMPLE;
|
|
ALTER TABLE t_stmt ADD COLUMN b INT;
|
|
ERROR 42000: This version of MySQL doesn't yet support 'ALTER TABLE'
|
|
CREATE TRIGGER trig_stmt BEFORE INSERT ON t_stmt FOR EACH ROW INSERT INTO t_stmt VALUES (1);
|
|
CREATE INDEX i ON t_stmt(a);
|
|
ERROR 42000: Too many key parts specified; max 0 parts allowed
|
|
CREATE TABLE t_stmt_new ENGINE = EXAMPLE SELECT * FROM t_stmt;
|
|
ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = ROW and at least one table uses a storage engine limited to statement-based logging.
|
|
DROP TABLE t_stmt;
|
|
|
|
|
|
################################################################################
|
|
# CLEAN UP #
|
|
################################################################################
|
|
UNINSTALL PLUGIN example;
|
|
SET @@global.binlog_format = @old_binlog_format;
|
|
SET @@session.binlog_format = @old_binlog_format;
|