mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
bce4c76ae0
due to name_const substitution Problem: "In general, statements executed within a stored procedure are written to the binary log using the same rules that would apply were the statements to be executed in standalone fashion. Some special care is taken when logging procedure statements because statement execution within procedures is not quite the same as in non-procedure context". For example, each reference to a local variable in SP's statements is replaced by NAME_CONST(var_name, var_value). Queries like "CREATE TABLE ... SELECT FUNC(local_var ..." are logged as "CREATE TABLE ... SELECT FUNC(NAME_CONST("local_var", var_value) ..." that leads to differrent field names and might result in "Incorrect column name" if var_value is long enough. Fix: in 5.x we'll issue a warning in such a case. In 6.0 we should get rid of NAME_CONST(). Note: this issue and change should be described in the documentation ("Binary Logging of Stored Programs"). mysql-test/r/binlog.result: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - test result. mysql-test/t/binlog.test: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - test case. sql/sp_head.cc: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - set thd->query_name_consts if there's NAME_CONST() substitution(s). sql/sql_parse.cc: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - issue a warning if there's NAME_CONST() substitution and binary logging is on for "CREATE TABLE ... SELECT ...".
204 lines
4.7 KiB
Text
204 lines
4.7 KiB
Text
#
|
|
# misc binlogging tests that do not require a slave running
|
|
#
|
|
-- source include/have_log_bin.inc
|
|
-- source include/not_embedded.inc
|
|
-- source include/have_innodb.inc
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t2;
|
|
--enable_warnings
|
|
reset master;
|
|
|
|
create table t1 (a int) engine=innodb;
|
|
create table t2 (a int) engine=innodb;
|
|
begin;
|
|
insert t1 values (5);
|
|
commit;
|
|
begin;
|
|
insert t2 values (5);
|
|
commit;
|
|
# first COMMIT must be Query_log_event, second - Xid_log_event
|
|
--replace_column 2 # 5 #
|
|
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
|
|
show binlog events from 98;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# binlog rotation after one big transaction
|
|
#
|
|
reset master;
|
|
let $1=100;
|
|
|
|
create table t1 (n int) engine=innodb;
|
|
begin;
|
|
--disable_query_log
|
|
while ($1)
|
|
{
|
|
eval insert into t1 values($1 + 4);
|
|
dec $1;
|
|
}
|
|
--enable_query_log
|
|
commit;
|
|
drop table t1;
|
|
--replace_column 2 # 5 #
|
|
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
|
|
show binlog events in 'master-bin.000001' from 98;
|
|
--replace_column 2 # 5 #
|
|
show binlog events in 'master-bin.000002' from 98;
|
|
|
|
#
|
|
# Bug#22540 - Incorrect value in column End_log_pos of
|
|
# SHOW BINLOG EVENTS using InnoDB
|
|
#
|
|
|
|
# the following tests will show that certain queries now return
|
|
# absolute offsets (from binlog start, rather than relative to
|
|
# the beginning of the current transaction). under what
|
|
# conditions it should be allowed / is sensible to put the
|
|
# slider into the middle of a transaction is not our concern
|
|
# here; we just guarantee that if and when it's done, the
|
|
# user has valid offsets to use. if the setter function still
|
|
# wants to throw a "positioning into middle of transaction"
|
|
# warning, that's its prerogative and handled elsewhere.
|
|
|
|
set @ac = @@autocommit;
|
|
|
|
# first show this to work for SHOW BINLOG EVENTS
|
|
|
|
set autocommit= 0;
|
|
reset master;
|
|
create table t1(n int) engine=innodb;
|
|
begin;
|
|
insert into t1 values (1);
|
|
insert into t1 values (2);
|
|
insert into t1 values (3);
|
|
commit;
|
|
drop table t1;
|
|
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
|
|
show binlog events from 0;
|
|
|
|
# now show that nothing breaks if we need to read from the cache more
|
|
# than once, resulting in split event-headers
|
|
|
|
set @bcs = @@binlog_cache_size;
|
|
set global binlog_cache_size=4096;
|
|
reset master;
|
|
|
|
create table t1 (a int) engine=innodb;
|
|
|
|
let $1=400;
|
|
disable_query_log;
|
|
begin;
|
|
while ($1)
|
|
{
|
|
eval insert into t1 values( $1 );
|
|
dec $1;
|
|
}
|
|
commit;
|
|
enable_query_log;
|
|
|
|
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
|
|
show binlog events from 0;
|
|
|
|
drop table t1;
|
|
|
|
set global binlog_cache_size=@bcs;
|
|
set session autocommit = @ac;
|
|
|
|
#
|
|
# Bug#33798: prepared statements improperly handle large unsigned ints
|
|
#
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
reset master;
|
|
create table t1 (a bigint unsigned, b bigint(20) unsigned);
|
|
prepare stmt from "insert into t1 values (?,?)";
|
|
set @a= 9999999999999999;
|
|
set @b= 14632475938453979136;
|
|
execute stmt using @a, @b;
|
|
deallocate prepare stmt;
|
|
drop table t1;
|
|
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
|
|
show binlog events from 0;
|
|
|
|
|
|
#
|
|
# Bug #39182: Binary log producing incompatible character set query from
|
|
# stored procedure.
|
|
#
|
|
CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
|
|
USE bug39182;
|
|
CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci)
|
|
DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
|
|
DELIMITER //;
|
|
|
|
CREATE PROCEDURE p1()
|
|
BEGIN
|
|
DECLARE s1 VARCHAR(255);
|
|
SET s1= "test";
|
|
CREATE TEMPORARY TABLE tmp1
|
|
SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%");
|
|
SELECT
|
|
COLLATION(NAME_CONST('s1', _utf8'test')) c1,
|
|
COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2,
|
|
COLLATION(s1) c3,
|
|
COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1,
|
|
COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2,
|
|
COERCIBILITY(s1) d3;
|
|
DROP TEMPORARY TABLE tmp1;
|
|
END//
|
|
|
|
DELIMITER ;//
|
|
|
|
CALL p1();
|
|
SHOW BINLOG EVENTS FROM 1285;
|
|
|
|
DROP PROCEDURE p1;
|
|
DROP TABLE t1;
|
|
DROP DATABASE bug39182;
|
|
USE test;
|
|
|
|
#
|
|
# Bug#35383: binlog playback and replication breaks due to
|
|
# name_const substitution
|
|
#
|
|
DELIMITER //;
|
|
CREATE PROCEDURE p1(IN v1 INT)
|
|
BEGIN
|
|
CREATE TABLE t1 SELECT v1;
|
|
DROP TABLE t1;
|
|
END//
|
|
CREATE PROCEDURE p2()
|
|
BEGIN
|
|
DECLARE v1 INT;
|
|
CREATE TABLE t1 SELECT v1+1;
|
|
DROP TABLE t1;
|
|
END//
|
|
CREATE PROCEDURE p3(IN v1 INT)
|
|
BEGIN
|
|
CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
|
|
DROP TABLE t1;
|
|
END//
|
|
CREATE PROCEDURE p4(IN v1 INT)
|
|
BEGIN
|
|
DECLARE v2 INT;
|
|
CREATE TABLE t1 SELECT 1, v1, v2;
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 SELECT 1, v1+1, v2;
|
|
DROP TABLE t1;
|
|
END//
|
|
DELIMITER ;//
|
|
|
|
CALL p1(1);
|
|
CALL p2();
|
|
CALL p3(0);
|
|
CALL p4(0);
|
|
DROP PROCEDURE p1;
|
|
DROP PROCEDURE p2;
|
|
DROP PROCEDURE p3;
|
|
DROP PROCEDURE p4;
|
|
|
|
--echo End of 5.0 tests
|