mirror of
https://github.com/MariaDB/server.git
synced 2025-10-22 19:52:58 +03:00
The auto-inc unsafe warning makes sense even though it's just one auto-inc table could be involved via a trigger or a stored function. However its content was not updated by bug@45677 fixes continuing to mention two tables whereas the fixes refined semantics of replication of auto_increment in stored routine. Fixed with updating the error message, renaming the error and an internal unsafe-condition constants. A documentation notice ====================== Inserting into an autoincrement column in a stored function or a trigger is unsafe for replication. Even with just one autoincrement column, if the routine is invoked more than once slave is not guaranteed to execute the statement graph same way as the master. And since it's impossible to estimate how many times a routine can be invoked at the query pre-execution phase (see lock_tables), the statement is marked pessimistically unsafe. mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result: results updated to include the expected unsafe warning. mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test: regression test for bug#50192 to diplaying the unsafe warning comes out to the user warning stack. sql/share/errmsg-utf8.txt: Updating the auto-inc unsafe message to correspond to bug@45677 fixes' new sematics. sql/share/errmsg.txt: Updating the auto-inc unsafe message to correspond to bug@45677 fixes' new sematics. sql/sql_base.cc: changing a symbolic name to correspond to updated by bug@45677 fixes new sematics. sql/sql_lex.cc: changing a symbolic name to correspond to updated by bug@45677 fixes new sematics. sql/sql_lex.h: changing a symbolic name to correspond to updated by bug@45677 fixes new sematics and description comments.
80 lines
4.5 KiB
Plaintext
80 lines
4.5 KiB
Plaintext
call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. .*");
|
|
call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. .*");
|
|
call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement invokes a trigger or a stored function that inserts into AUTO_INCREMENT column");
|
|
### NOT filtered database => assertion: warnings ARE shown
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (a int, b int, primary key (a));
|
|
INSERT INTO t1 VALUES (1,2), (2,3);
|
|
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
|
|
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
|
|
DROP TABLE t1;
|
|
### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
|
|
SET SQL_LOG_BIN= 0;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (a int, b int, primary key (a));
|
|
INSERT INTO t1 VALUES (1,2), (2,3);
|
|
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
|
|
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
|
|
DROP TABLE t1;
|
|
SET SQL_LOG_BIN= 1;
|
|
### FILTERED database => assertion: warnings ARE NOT shown
|
|
CREATE DATABASE b42851;
|
|
USE b42851;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (a int, b int, primary key (a));
|
|
INSERT INTO t1 VALUES (1,2), (2,3);
|
|
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
|
|
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
|
|
DROP TABLE t1;
|
|
DROP DATABASE b42851;
|
|
USE test;
|
|
#
|
|
# Bug#46265: Can not disable warning about unsafe statements for binary logging
|
|
#
|
|
SET @old_log_warnings = @@log_warnings;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10));
|
|
SET GLOBAL LOG_WARNINGS = 0;
|
|
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave.
|
|
SET GLOBAL LOG_WARNINGS = 1;
|
|
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave.
|
|
DROP TABLE t1;
|
|
SET GLOBAL log_warnings = @old_log_warnings;
|
|
# Count the number of times the "Unsafe" message was printed
|
|
# to the error log.
|
|
Occurrences: 1
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
CREATE TABLE t1 (a int);
|
|
CREATE TABLE t2 (a int auto_increment primary key, b int);
|
|
CREATE TRIGGER tr_bug50192 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 (b) VALUES (1);
|
|
CREATE FUNCTION sf_bug50192() RETURNS INTEGER
|
|
BEGIN
|
|
INSERT INTO t2(b) VALUES(2);
|
|
RETURN 1;
|
|
END |
|
|
INSERT INTO t1 VALUES (0);
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement invokes a trigger or a stored function that inserts into AUTO_INCREMENT column which is unsafe to binlog in STATEMENT format because slave may execute it non-deterministically.
|
|
SHOW WARNINGS;
|
|
Level Code Message
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement invokes a trigger or a stored function that inserts into AUTO_INCREMENT column which is unsafe to binlog in STATEMENT format because slave may execute it non-deterministically.
|
|
SELECT sf_bug50192();
|
|
sf_bug50192()
|
|
1
|
|
Warnings:
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement invokes a trigger or a stored function that inserts into AUTO_INCREMENT column which is unsafe to binlog in STATEMENT format because slave may execute it non-deterministically.
|
|
SHOW WARNINGS;
|
|
Level Code Message
|
|
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement invokes a trigger or a stored function that inserts into AUTO_INCREMENT column which is unsafe to binlog in STATEMENT format because slave may execute it non-deterministically.
|
|
DROP FUNCTION sf_bug50192;
|
|
DROP TRIGGER tr_bug50192;
|
|
DROP TABLE t1, t2;
|