From 924d54906727d3253e35b8205fe8f991bd69c514 Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Fri, 20 Jun 2008 15:00:11 +0200 Subject: [PATCH 01/17] No 'rc' status any more --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index af23b6035eb..1ef636ffa3c 100644 --- a/configure.in +++ b/configure.in @@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM # # When changing major version number please also check switch statement # in mysqlbinlog::check_master_version(). -AM_INIT_AUTOMAKE(mysql, 5.1.26-rc) +AM_INIT_AUTOMAKE(mysql, 5.1.26) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 98cf483064d1f176dc0d8219ac6563049de708b0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Jun 2008 18:08:24 +0300 Subject: [PATCH 02/17] Bug#33812: mysql client incorrectly parsing DELIMITER Remove unnecessary and incorrect code that tried to pull delimiter commands out of the middle of statements client/mysql.cc: Bug#33812: remove incorrect code mysql-test/r/mysql.result: Bug#33812: test case mysql-test/t/mysql_delimiter.sql: Bug#33812: test case --- client/mysql.cc | 31 ------------------------------- mysql-test/r/mysql.result | 2 ++ mysql-test/t/mysql_delimiter.sql | 6 ++++++ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2ef987492b7..20ad769e9b4 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2101,37 +2101,6 @@ static bool add_line(String &buffer,char *line,char *in_string, continue; } } - else if (!*ml_comment && !*in_string && - (end_of_line - pos) >= 10 && - !my_strnncoll(charset_info, (uchar*) pos, 10, - (const uchar*) "delimiter ", 10)) - { - // Flush previously accepted characters - if (out != line) - { - buffer.append(line, (uint32) (out - line)); - out= line; - } - - // Flush possible comments in the buffer - if (!buffer.is_empty()) - { - if (com_go(&buffer, 0) > 0) // < 0 is not fatal - DBUG_RETURN(1); - buffer.length(0); - } - - /* - Delimiter wants the get rest of the given line as argument to - allow one to change ';' to ';;' and back - */ - buffer.append(pos); - if (com_delimiter(&buffer, pos) > 0) - DBUG_RETURN(1); - - buffer.length(0); - break; - } else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter)) { // Found a statement. Continue parsing after the delimiter diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index a4d96c1c243..6fe35d5c9f9 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -38,6 +38,8 @@ t2 t3 Tables_in_test t1 +delimiter +1 _ Test delimiter : from command line a diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index db679c3b06b..8caa7cebc2f 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -59,3 +59,9 @@ source t/mysql_delimiter_19799.sql use test// show tables// delimiter ; # Reset delimiter + +# +# Bug #33812: mysql client incorrectly parsing DELIMITER +# +select a as delimiter from t1 +delimiter ; # Reset delimiter From 04eef88140312ab5206c6d1b21b58331b1d2c014 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Fri, 27 Jun 2008 12:58:07 +0200 Subject: [PATCH 03/17] Version number bump for 5.0.60sp1 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 9c35dbcc7c7..de0d199af96 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.60) +AM_INIT_AUTOMAKE(mysql, 5.0.60sp1) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=60 +NDB_VERSION_BUILD=60sp1 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From dc0e959a302d55825b6204c1cce63d7d73fd5b93 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 27 Jun 2008 18:22:23 +0500 Subject: [PATCH 04/17] buckport to 5.1.26 from 6.0 Bug#35658 (An empty binary value leads to mysqld crash) Before this fix, the following token b'' caused the parser to crash when reading the binary value from the empty string. The crash was caused by: ptr+= max_length - 1; because max_length is unsigned and was 0, causing an overflow. With this fix, an empty binary literal b'' is parsed as a binary value 0, in Item_bin_string. mysql-test/r/varbinary.result: Bug#35658 (An empty binary value leads to mysqld crash) mysql-test/t/varbinary.test: Bug#35658 (An empty binary value leads to mysqld crash) sql/item.cc: Bug#35658 (An empty binary value leads to mysqld crash) --- mysql-test/r/varbinary.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/varbinary.test | 28 ++++++++++++++++++++++++++++ sql/item.cc | 29 ++++++++++++++++++----------- 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index 6d39d8301c5..271d7a0fe8d 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -95,3 +95,34 @@ table_28127_b CREATE TABLE `table_28127_b` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table table_28127_a; drop table table_28127_b; +select 0b01000001; +0b01000001 +A +select 0x41; +0x41 +A +select b'01000001'; +b'01000001' +A +select x'41', 0+x'41'; +x'41' 0+x'41' +A 65 +select N'abc', length(N'abc'); +abc length(N'abc') +abc 3 +select N'', length(N''); + length(N'') + 0 +select '', length(''); + length('') + 0 +select b'', 0+b''; +b'' 0+b'' + 0 +select x'', 0+x''; +x'' 0+x'' + 0 +select 0x; +ERROR 42S22: Unknown column '0x' in 'field list' +select 0b; +ERROR 42S22: Unknown column '0b' in 'field list' diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index 9ccbac7cdda..1db561183a7 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -104,3 +104,31 @@ show create table table_28127_b; drop table table_28127_a; drop table table_28127_b; +# +# Bug#35658 (An empty binary value leads to mysqld crash) +# + +select 0b01000001; + +select 0x41; + +select b'01000001'; + +select x'41', 0+x'41'; + +select N'abc', length(N'abc'); + +select N'', length(N''); + +select '', length(''); + +select b'', 0+b''; + +select x'', 0+x''; + +--error ER_BAD_FIELD_ERROR +select 0x; + +--error ER_BAD_FIELD_ERROR +select 0b; + diff --git a/sql/item.cc b/sql/item.cc index 96408a70bdd..5ee394fcbe0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5172,21 +5172,28 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length) if (!ptr) return; str_value.set(ptr, max_length, &my_charset_bin); - ptr+= max_length - 1; - ptr[1]= 0; // Set end null for string - for (; end >= str; end--) + + if (max_length > 0) { - if (power == 256) + ptr+= max_length - 1; + ptr[1]= 0; // Set end null for string + for (; end >= str; end--) { - power= 1; - *ptr--= bits; - bits= 0; + if (power == 256) + { + power= 1; + *ptr--= bits; + bits= 0; + } + if (*end == '1') + bits|= power; + power<<= 1; } - if (*end == '1') - bits|= power; - power<<= 1; + *ptr= (char) bits; } - *ptr= (char) bits; + else + ptr[0]= 0; + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); fixed= 1; } From 2be5c627fc9efaaf0d95ce198975055fcaac7b6d Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Fri, 27 Jun 2008 18:13:50 +0200 Subject: [PATCH 05/17] Try different sp1 suffix for NDB. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index de0d199af96..695044fc03b 100644 --- a/configure.in +++ b/configure.in @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=60sp1 +NDB_VERSION_BUILD=60-sp1 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 3ba4523085b5bce6f667dfab5c3412fb9df4b4e9 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Fri, 27 Jun 2008 18:43:45 +0200 Subject: [PATCH 06/17] Revert NDB version bump completely. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 695044fc03b..02e5e936967 100644 --- a/configure.in +++ b/configure.in @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=60-sp1 +NDB_VERSION_BUILD=60 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 3033955068e20835666594c4afa3b4802b1bd594 Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Fri, 27 Jun 2008 19:12:42 +0200 Subject: [PATCH 07/17] OS X 10.5 is now a supported platform, so Apple's internal name ("darwin9") must be translated to ours ("osx10.5"). --- scripts/make_binary_distribution.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 50cff8578c9..af3db86af81 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -61,6 +61,7 @@ system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'` system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'` system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'` system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'` +system=`echo $system | sed -e 's/darwin9.*/osx10.5/g'` system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'` system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'` system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'` From 711305e2c5772d3fd1f555a27ebd5bcb94fd6a77 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Mon, 30 Jun 2008 22:11:18 +0200 Subject: [PATCH 08/17] BUG#37426: RBR breaks for CHAR() UTF-8 fields > 85 chars In order to handle CHAR() fields, 8 bits were reserved for the size of the CHAR field. However, instead of denoting the number of characters in the field, field_length was used which denotes the number of bytes in the field. Since UTF-8 fields can have three bytes per character (and has been extended to have four bytes per character in 6.0), an extra two bits have been encoded in the field metadata work for fields of type Field_string (i.e., CHAR fields). Since the metadata word is filled, the extra bits have been encoded in the upper 4 bits of the real type (the most significant byte of the metadata word) by computing the bitwise xor of the extra two bits. Since the upper 4 bits of the real type always is 1111 for Field_string, this means that for fields of length <256, the encoding is identical to the encoding used in pre-5.1.26 servers, but for lengths of 256 or more, an unrecognized type is formed, causing an old slave (that does not handle lengths of 256 or more) to stop. mysql-test/extra/rpl_tests/rpl_row_basic.test: Adding test cases for replicating UTF-8 fields of lengths of 256 or more (bytes). mysql-test/suite/binlog/r/binlog_base64_flag.result: Result file change. mysql-test/suite/binlog/t/binlog_base64_flag.test: Adding tests to trigger check that an error is generated when replicating from a 5.1.25 server for tables with a CHAR(128) but not when replicating a table with a CHAR(63). Although the bug indicates that the limit is 83, we elected to use CHAR(63) since 6.0 uses 4-byte UTF-8, and anything exceeding 63 would then cause the test to fail when the patch is merged to 6.0. mysql-test/suite/bugs/combinations: Adding combinations file to run all bug reports in all binlog modes (where applicable). mysql-test/suite/bugs/r/rpl_bug37426.result: Result file change. mysql-test/suite/bugs/t/rpl_bug37426.test: Added test for reported bug. mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result: Result file change. mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result: Result file change. sql/field.cc: Encoding an extra two bits in the most significant nibble (4 bits) of the metadata word. Adding assertions to ensure that no attempt is made to use lengths longer than supported. Extending compatible_field_size() function with an extra parameter holding a Relay_log_instace for error reporting. Field_string::compatible_field_size() now reports an error if field size for a CHAR is >255. sql/field.h: Field length is now computed from most significant 4 bits of metadata word, or is equal to the row pack length if there is no metadata. Extending compatible_field_size() function with an extra parameter holding a Relay_log_instace for error reporting. sql/rpl_utility.cc: Adding relay log parameter to compatible_field_size(). Minor refactoring to eliminate duplicate code. sql/slave.cc: Extending rpl_master_has_bug() with a single-argument predicate function and a parameter to the predicate function. The predicate function can be used to test for extra conditions for the bug before writing an error message. sql/slave.h: Extending rpl_master_has_bug() with a single-argument predicate function and a parameter to the predicate function. The predicate function can be used to test for extra conditions for the bug before writing an error message. Also removing gratuitous default argument. sql/sql_insert.cc: Changing calls to rpl_master_has_bug() to adapt to changed signature. --- mysql-test/extra/rpl_tests/rpl_row_basic.test | 149 +++++++++++++++++- .../suite/binlog/r/binlog_base64_flag.result | 26 ++- .../suite/binlog/t/binlog_base64_flag.test | 47 +++++- mysql-test/suite/bugs/combinations | 8 + mysql-test/suite/bugs/r/rpl_bug37426.result | 17 ++ mysql-test/suite/bugs/t/rpl_bug37426.test | 22 +++ .../suite/rpl/r/rpl_row_basic_2myisam.result | 65 +++++++- .../suite/rpl/r/rpl_row_basic_3innodb.result | 65 +++++++- sql/field.cc | 93 +++++++++-- sql/field.h | 20 ++- sql/rpl_utility.cc | 16 +- sql/slave.cc | 17 +- sql/slave.h | 3 +- sql/sql_insert.cc | 4 +- 14 files changed, 517 insertions(+), 35 deletions(-) create mode 100644 mysql-test/suite/bugs/combinations create mode 100644 mysql-test/suite/bugs/r/rpl_bug37426.result create mode 100644 mysql-test/suite/bugs/t/rpl_bug37426.test diff --git a/mysql-test/extra/rpl_tests/rpl_row_basic.test b/mysql-test/extra/rpl_tests/rpl_row_basic.test index 48ddbaf244a..59f049e2bfa 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_basic.test +++ b/mysql-test/extra/rpl_tests/rpl_row_basic.test @@ -259,7 +259,7 @@ DELETE FROM t1; query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2; sync_slave_with_master; set @@global.slave_exec_mode= default; -let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1); +let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); disable_query_log; eval SELECT "$last_error" AS Last_SQL_Error; enable_query_log; @@ -272,3 +272,150 @@ query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2; connection master; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; sync_slave_with_master; + +# +# BUG#37426: RBR breaks for CHAR() UTF8 fields > 85 chars +# + +# We have 4 combinations to test with respect to the field length +# (i.e., the number of bytes) of the CHAR fields: +# +# 1. Replicating from CHAR<256 to CHAR<256 +# 2. Replicating from CHAR<256 to CHAR>255 +# 3. Replicating from CHAR>255 to CHAR<256 +# 4. Replicating from CHAR>255 to CHAR>255 + +# We also make a special case of using the max size of a field on the +# master, i.e. CHAR(255) in UTF-8, giving another three cases. +# +# 5. Replicating UTF-8 CHAR(255) to CHAR(<256) +# 6. Replicating UTF-8 CHAR(255) to CHAR(>255) +# 7. Replicating UTF-8 CHAR(255) to CHAR(255) UTF-8 + +connection master; +CREATE TABLE t1 (i INT NOT NULL, + c CHAR(16) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); + +CREATE TABLE t2 (i INT NOT NULL, + c CHAR(16) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); + +sync_slave_with_master; +ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; + +connection master; +CREATE TABLE t3 (i INT NOT NULL, + c CHAR(128) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); +sync_slave_with_master; +ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; + +connection master; +CREATE TABLE t4 (i INT NOT NULL, + c CHAR(128) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); + +CREATE TABLE t5 (i INT NOT NULL, + c CHAR(255) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); +sync_slave_with_master; +ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; + +connection master; +CREATE TABLE t6 (i INT NOT NULL, + c CHAR(255) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); +sync_slave_with_master; +ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; + +connection master; +CREATE TABLE t7 (i INT NOT NULL, + c CHAR(255) CHARACTER SET utf8 NOT NULL, + j INT NOT NULL); + +--echo [expecting slave to replicate correctly] +connection master; +INSERT INTO t1 VALUES (1, "", 1); +INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2); + +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo [expecting slave to replicate correctly] +connection master; +INSERT INTO t2 VALUES (1, "", 1); +INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2); + +let $diff_table_1=master:test.t2; +let $diff_table_2=slave:test.t2; +source include/diff_tables.inc; + +--echo [expecting slave to stop] +connection master; +INSERT INTO t3 VALUES (1, "", 1); +INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2); + +connection slave; +source include/wait_for_slave_sql_to_stop.inc; +let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); +disable_query_log; +eval SELECT "$last_error" AS Last_SQL_Error; +enable_query_log; +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +source include/wait_for_slave_to_start.inc; + +--echo [expecting slave to replicate correctly] +connection master; +INSERT INTO t4 VALUES (1, "", 1); +INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2); + +let $diff_table_1=master:test.t4; +let $diff_table_2=slave:test.t4; +source include/diff_tables.inc; + +--echo [expecting slave to stop] +connection master; +INSERT INTO t5 VALUES (1, "", 1); +INSERT INTO t5 VALUES (2, repeat(_utf8'a', 255), 2); + +connection slave; +source include/wait_for_slave_sql_to_stop.inc; +let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); +disable_query_log; +eval SELECT "$last_error" AS Last_SQL_Error; +enable_query_log; +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +source include/wait_for_slave_to_start.inc; + +--echo [expecting slave to stop] +connection master; +INSERT INTO t6 VALUES (1, "", 1); +INSERT INTO t6 VALUES (2, repeat(_utf8'a', 255), 2); + +connection slave; +source include/wait_for_slave_sql_to_stop.inc; +let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); +disable_query_log; +eval SELECT "$last_error" AS Last_SQL_Error; +enable_query_log; +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +source include/wait_for_slave_to_start.inc; + +--echo [expecting slave to replicate correctly] +connection master; +INSERT INTO t7 VALUES (1, "", 1); +INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2); + +let $diff_table_1=master:test.t7; +let $diff_table_2=slave:test.t7; +source include/diff_tables.inc; + +connection master; +drop table t1, t2, t3, t4, t5, t6, t7; +sync_slave_with_master; + diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result index 72a16010031..fbc2b8344ee 100644 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result @@ -66,4 +66,28 @@ a 1 1 3 -drop table t1; +CREATE TABLE char128_utf8 ( +i1 INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +i2 INT NOT NULL); +CREATE TABLE char63_utf8 ( +i1 INT NOT NULL, +c CHAR(63) CHARACTER SET utf8 NOT NULL, +i2 INT NOT NULL); +BINLOG ' +MuNkSA8BAAAAZgAAAGoAAAAAAAQANS4xLjI1LXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAy42RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC +'; +BINLOG ' +3u9kSBMBAAAANgAAAJYBAAAAABAAAAAAAAAABHRlc3QAC2NoYXI2M191dGY4AAMD/gMC/r0A +3u9kSBcBAAAAKgAAAMABAAAQABAAAAAAAAEAA//4AQAAAAMxMjMBAAAA +'; +SELECT * FROM char63_utf8; +i1 c i2 +1 123 1 +BINLOG ' +iONkSBMBAAAANwAAAJkBAAAAABAAAAAAAAAABHRlc3QADGNoYXIxMjhfdXRmOAADA/4DAv6AAA== +iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA== +'; +ERROR HY000: master may suffer from http://bugs.mysql.com/bug.php?id=37426 so slave stops; check error log on slave for more info +drop table t1, char63_utf8, char128_utf8; diff --git a/mysql-test/suite/binlog/t/binlog_base64_flag.test b/mysql-test/suite/binlog/t/binlog_base64_flag.test index abf35a6bfd8..e6271ec6ccc 100644 --- a/mysql-test/suite/binlog/t/binlog_base64_flag.test +++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test @@ -104,6 +104,49 @@ Dl1YRxcBAAAAIgAAAFYBAAAQABAAAAAAAAEAAf/+BQAAAA== # the above line should fail and 5 should not be in the binlog. select * from t1; +# Test that BUG#37426 is triggered. -# clean up -drop table t1; +CREATE TABLE char128_utf8 ( + i1 INT NOT NULL, + c CHAR(128) CHARACTER SET utf8 NOT NULL, + i2 INT NOT NULL); +CREATE TABLE char63_utf8 ( + i1 INT NOT NULL, + c CHAR(63) CHARACTER SET utf8 NOT NULL, + i2 INT NOT NULL); + +# +# This is the format description log event +# + +BINLOG ' +MuNkSA8BAAAAZgAAAGoAAAAAAAQANS4xLjI1LXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAy42RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC +'; + +# ... this event corresponding to +# +# INSERT INTO char63_utf8 VALUES ( 1, "123", 1 ) +# +# The binlog event below shall not trigger the bug check + +BINLOG ' +3u9kSBMBAAAANgAAAJYBAAAAABAAAAAAAAAABHRlc3QAC2NoYXI2M191dGY4AAMD/gMC/r0A +3u9kSBcBAAAAKgAAAMABAAAQABAAAAAAAAEAA//4AQAAAAMxMjMBAAAA +'; +SELECT * FROM char63_utf8; + +# ... and this is an event corresponding to +# +# INSERT INTO char128_utf8 VALUES ( 1, "123", 1 ) +# +# The binlog event below shall trigger the bug check and produce an error +# + +error ER_UNKNOWN_ERROR; +BINLOG ' +iONkSBMBAAAANwAAAJkBAAAAABAAAAAAAAAABHRlc3QADGNoYXIxMjhfdXRmOAADA/4DAv6AAA== +iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA== +'; + +drop table t1, char63_utf8, char128_utf8; diff --git a/mysql-test/suite/bugs/combinations b/mysql-test/suite/bugs/combinations new file mode 100644 index 00000000000..ea25611a5d4 --- /dev/null +++ b/mysql-test/suite/bugs/combinations @@ -0,0 +1,8 @@ +[row] +--binlog-format=row + +[stmt] +--binlog-format=statement + +[mix] +--binlog-format=mixed diff --git a/mysql-test/suite/bugs/r/rpl_bug37426.result b/mysql-test/suite/bugs/r/rpl_bug37426.result new file mode 100644 index 00000000000..24dfd27ca01 --- /dev/null +++ b/mysql-test/suite/bugs/r/rpl_bug37426.result @@ -0,0 +1,17 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE char128_utf8 ( +i1 INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +i2 INT NOT NULL); +INSERT INTO char128_utf8 VALUES ( 1, "123", 1 ); +SELECT * FROM char128_utf8; +i1 c i2 +1 123 1 +SELECT * FROM char128_utf8; +i1 c i2 +1 123 1 diff --git a/mysql-test/suite/bugs/t/rpl_bug37426.test b/mysql-test/suite/bugs/t/rpl_bug37426.test new file mode 100644 index 00000000000..d2bad0fa0c1 --- /dev/null +++ b/mysql-test/suite/bugs/t/rpl_bug37426.test @@ -0,0 +1,22 @@ +############################################################# +# Author: Mats Kindahl +# Date: 2008-06-18 +# Purpose: Test for BUG#37426 +# RBR breaks for CHAR() UTF8 fields > 85 chars +############################################################# + +source include/master-slave.inc; +source include/have_binlog_format_row.inc; + +connection master; +CREATE TABLE char128_utf8 ( + i1 INT NOT NULL, + c CHAR(128) CHARACTER SET utf8 NOT NULL, + i2 INT NOT NULL); + +INSERT INTO char128_utf8 VALUES ( 1, "123", 1 ); + +SELECT * FROM char128_utf8; +sync_slave_with_master; + +SELECT * FROM char128_utf8; diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result index 22284a26412..3977e721212 100644 --- a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result +++ b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result @@ -437,7 +437,70 @@ SELECT COUNT(*) FROM t1 ORDER BY c1,c2; COUNT(*) 0 set @@global.slave_exec_mode= default; Last_SQL_Error -0 + SELECT COUNT(*) FROM t1 ORDER BY c1,c2; COUNT(*) 0 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; +CREATE TABLE t1 (i INT NOT NULL, +c CHAR(16) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +CREATE TABLE t2 (i INT NOT NULL, +c CHAR(16) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t3 (i INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t4 (i INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +CREATE TABLE t5 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t6 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t7 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +[expecting slave to replicate correctly] +INSERT INTO t1 VALUES (1, "", 1); +INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2); +Comparing tables master:test.t1 and slave:test.t1 +[expecting slave to replicate correctly] +INSERT INTO t2 VALUES (1, "", 1); +INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2); +Comparing tables master:test.t2 and slave:test.t2 +[expecting slave to stop] +INSERT INTO t3 VALUES (1, "", 1); +INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 384, test.t3 on slave has size 49. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to replicate correctly] +INSERT INTO t4 VALUES (1, "", 1); +INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2); +Comparing tables master:test.t4 and slave:test.t4 +[expecting slave to stop] +INSERT INTO t5 VALUES (1, "", 1); +INSERT INTO t5 VALUES (2, repeat(_utf8'a', 255), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 765, test.t5 on slave has size 49. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to stop] +INSERT INTO t6 VALUES (1, "", 1); +INSERT INTO t6 VALUES (2, repeat(_utf8'a', 255), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 765, test.t6 on slave has size 385. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to replicate correctly] +INSERT INTO t7 VALUES (1, "", 1); +INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2); +Comparing tables master:test.t7 and slave:test.t7 +drop table t1, t2, t3, t4, t5, t6, t7; diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result index f7b9e5d627a..d38d09fec00 100644 --- a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result +++ b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result @@ -437,7 +437,70 @@ SELECT COUNT(*) FROM t1 ORDER BY c1,c2; COUNT(*) 0 set @@global.slave_exec_mode= default; Last_SQL_Error -0 + SELECT COUNT(*) FROM t1 ORDER BY c1,c2; COUNT(*) 0 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; +CREATE TABLE t1 (i INT NOT NULL, +c CHAR(16) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +CREATE TABLE t2 (i INT NOT NULL, +c CHAR(16) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t3 (i INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t4 (i INT NOT NULL, +c CHAR(128) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +CREATE TABLE t5 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t6 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL; +CREATE TABLE t7 (i INT NOT NULL, +c CHAR(255) CHARACTER SET utf8 NOT NULL, +j INT NOT NULL); +[expecting slave to replicate correctly] +INSERT INTO t1 VALUES (1, "", 1); +INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2); +Comparing tables master:test.t1 and slave:test.t1 +[expecting slave to replicate correctly] +INSERT INTO t2 VALUES (1, "", 1); +INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2); +Comparing tables master:test.t2 and slave:test.t2 +[expecting slave to stop] +INSERT INTO t3 VALUES (1, "", 1); +INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 384, test.t3 on slave has size 49. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to replicate correctly] +INSERT INTO t4 VALUES (1, "", 1); +INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2); +Comparing tables master:test.t4 and slave:test.t4 +[expecting slave to stop] +INSERT INTO t5 VALUES (1, "", 1); +INSERT INTO t5 VALUES (2, repeat(_utf8'a', 255), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 765, test.t5 on slave has size 49. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to stop] +INSERT INTO t6 VALUES (1, "", 1); +INSERT INTO t6 VALUES (2, repeat(_utf8'a', 255), 2); +Last_SQL_Error +Table definition on master and slave does not match: Column 1 size mismatch - master has size 765, test.t6 on slave has size 385. Master's column size should be <= the slave's column size. +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; +START SLAVE; +[expecting slave to replicate correctly] +INSERT INTO t7 VALUES (1, "", 1); +INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2); +Comparing tables master:test.t7 and slave:test.t7 +drop table t1, t2, t3, t4, t5, t6, t7; diff --git a/sql/field.cc b/sql/field.cc index 9bf6df55b30..21e26b518e8 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -27,6 +27,8 @@ #include "mysql_priv.h" #include "sql_select.h" +#include "rpl_rli.h" // Pull in Relay_log_info +#include "slave.h" // Pull in rpl_master_has_bug() #include #include #ifdef HAVE_FCONVERT @@ -1375,7 +1377,8 @@ bool Field::send_binary(Protocol *protocol) @retval 0 if this field's size is < the source field's size @retval 1 if this field's size is >= the source field's size */ -int Field::compatible_field_size(uint field_metadata) +int Field::compatible_field_size(uint field_metadata, + const Relay_log_info *rli_arg __attribute__((unused))) { uint const source_size= pack_length_from_metadata(field_metadata); uint const destination_size= row_pack_length(); @@ -2837,7 +2840,8 @@ uint Field_new_decimal::pack_length_from_metadata(uint field_metadata) @retval 0 if this field's size is < the source field's size @retval 1 if this field's size is >= the source field's size */ -int Field_new_decimal::compatible_field_size(uint field_metadata) +int Field_new_decimal::compatible_field_size(uint field_metadata, + const Relay_log_info * __attribute__((unused))) { int compatible= 0; uint const source_precision= (field_metadata >> 8U) & 0x00ff; @@ -4037,7 +4041,6 @@ Field_real::pack(uchar *to, const uchar *from, { DBUG_ENTER("Field_real::pack"); DBUG_ASSERT(max_length >= pack_length()); - DBUG_PRINT("debug", ("pack_length(): %u", pack_length())); #ifdef WORDS_BIGENDIAN if (low_byte_first != table->s->db_low_byte_first) { @@ -4056,7 +4059,6 @@ Field_real::unpack(uchar *to, const uchar *from, uint param_data, bool low_byte_first) { DBUG_ENTER("Field_real::unpack"); - DBUG_PRINT("debug", ("pack_length(): %u", pack_length())); #ifdef WORDS_BIGENDIAN if (low_byte_first != table->s->db_low_byte_first) { @@ -6638,6 +6640,36 @@ my_decimal *Field_string::val_decimal(my_decimal *decimal_value) } +struct Check_field_param { + Field *field; +}; + +static bool +check_field_for_37426(const void *param_arg) +{ + Check_field_param *param= (Check_field_param*) param_arg; + DBUG_ASSERT(param->field->real_type() == MYSQL_TYPE_STRING); + DBUG_PRINT("debug", ("Field %s - type: %d, size: %d", + param->field->field_name, + param->field->real_type(), + param->field->row_pack_length())); + return param->field->row_pack_length() > 255; +} + + +int Field_string::compatible_field_size(uint field_metadata, + const Relay_log_info *rli_arg) +{ +#ifdef HAVE_REPLICATION + const Check_field_param check_param = { this }; + if (rpl_master_has_bug(rli_arg, 37426, TRUE, + check_field_for_37426, &check_param)) + return FALSE; // Not compatible field sizes +#endif + return Field::compatible_field_size(field_metadata, rli_arg); +} + + int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) { uint a_len, b_len; @@ -6724,6 +6756,9 @@ uchar *Field_string::pack(uchar *to, const uchar *from, @c param_data argument contains the result of field->real_type() from the master. + @note For information about how the length is packed, see @c + Field_string::do_save_field_metadata + @param to Destination of the data @param from Source of the data @param param_data Real type (upper) and length (lower) values @@ -6736,10 +6771,24 @@ Field_string::unpack(uchar *to, uint param_data, bool low_byte_first __attribute__((unused))) { - uint from_length= - param_data ? min(param_data & 0x00ff, field_length) : field_length; - uint length; + uint from_length, length; + /* + Compute the declared length of the field on the master. This is + used to decide if one or two bytes should be read as length. + */ + if (param_data) + from_length= (((param_data >> 4) & 0x300) ^ 0x300) + (param_data & 0x00ff); + else + from_length= field_length; + + DBUG_PRINT("debug", + ("param_data: 0x%x, field_length: %u, from_length: %u", + param_data, field_length, from_length)); + /* + Compute the actual length of the data by reading one or two bits + (depending on the declared field length on the master). + */ if (from_length > 255) { length= uint2korr(from); @@ -6762,14 +6811,37 @@ Field_string::unpack(uchar *to, second byte of the field metadata array at index of *metadata_ptr and *(metadata_ptr + 1). + @note In order to be able to handle lengths exceeding 255 and be + backwards-compatible with pre-5.1.26 servers, an extra two bits of + the length has been added to the metadata in such a way that if + they are set, a new unrecognized type is generated. This will + cause pre-5.1-26 servers to stop due to a field type mismatch, + while new servers will be able to extract the extra bits. If the + length is <256, there will be no difference and both a new and an + old server will be able to handle it. + + @note The extra two bits are added to bits 13 and 14 of the + parameter data (with 1 being the least siginficant bit and 16 the + most significant bit of the word) by xoring the extra length bits + with the real type. Since all allowable types have 0xF as most + significant bits of the metadata word, lengths <256 will not affect + the real type at all, while all other values will result in a + non-existant type in the range 17-244. + + @see Field_string::unpack + @param metadata_ptr First byte of field metadata @returns number of bytes written to metadata_ptr */ int Field_string::do_save_field_metadata(uchar *metadata_ptr) { - *metadata_ptr= real_type(); - *(metadata_ptr + 1)= field_length; + DBUG_ASSERT(field_length < 1024); + DBUG_ASSERT((real_type() & 0xF0) == 0xF0); + DBUG_PRINT("debug", ("field_length: %u, real_type: %u", + field_length, real_type())); + *metadata_ptr= (real_type() ^ ((field_length & 0x300) >> 4)); + *(metadata_ptr + 1)= field_length & 0xFF; return 2; } @@ -9118,7 +9190,8 @@ uint Field_bit::pack_length_from_metadata(uint field_metadata) @retval 0 if this field's size is < the source field's size @retval 1 if this field's size is >= the source field's size */ -int Field_bit::compatible_field_size(uint field_metadata) +int Field_bit::compatible_field_size(uint field_metadata, + const Relay_log_info * __attribute__((unused))) { int compatible= 0; uint const source_size= pack_length_from_metadata(field_metadata); diff --git a/sql/field.h b/sql/field.h index 479a71dfee5..6c6cab1e4f0 100644 --- a/sql/field.h +++ b/sql/field.h @@ -30,6 +30,8 @@ const uint32 max_field_size= (uint32) 4294967295U; class Send_field; class Protocol; class Create_field; +class Relay_log_info; + struct st_cache_field; int field_conv(Field *to,Field *from); @@ -162,7 +164,8 @@ public: table, which is located on disk). */ virtual uint32 pack_length_in_rec() const { return pack_length(); } - virtual int compatible_field_size(uint field_metadata); + virtual int compatible_field_size(uint field_metadata, + const Relay_log_info *); virtual uint pack_length_from_metadata(uint field_metadata) { return field_metadata; } /* @@ -716,7 +719,8 @@ public: uint32 pack_length() const { return (uint32) bin_size; } uint pack_length_from_metadata(uint field_metadata); uint row_pack_length() { return pack_length(); } - int compatible_field_size(uint field_metadata); + int compatible_field_size(uint field_metadata, + const Relay_log_info *rli); uint is_equal(Create_field *new_field); virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data, bool low_byte_first); @@ -1425,7 +1429,14 @@ public: virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data, bool low_byte_first); uint pack_length_from_metadata(uint field_metadata) - { return (field_metadata & 0x00ff); } + { + DBUG_PRINT("debug", ("field_metadata: 0x%04x", field_metadata)); + if (field_metadata == 0) + return row_pack_length(); + return (((field_metadata >> 4) & 0x300) ^ 0x300) + (field_metadata & 0x00ff); + } + int compatible_field_size(uint field_metadata, + const Relay_log_info *rli); uint row_pack_length() { return (field_length + 1); } int pack_cmp(const uchar *a,const uchar *b,uint key_length, my_bool insert_or_update); @@ -1878,7 +1889,8 @@ public: uint pack_length_from_metadata(uint field_metadata); uint row_pack_length() { return (bytes_in_rec + ((bit_len > 0) ? 1 : 0)); } - int compatible_field_size(uint field_metadata); + int compatible_field_size(uint field_metadata, + const Relay_log_info *rli); void sql_type(String &str) const; virtual uchar *pack(uchar *to, const uchar *from, uint max_length, bool low_byte_first); diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 4f4083d9b8f..e34f8561051 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -188,7 +188,8 @@ table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table) for (uint col= 0 ; col < cols_to_check ; ++col) { - if (table->field[col]->type() != type(col)) + Field *const field= table->field[col]; + if (field->type() != type(col)) { DBUG_ASSERT(col < size() && col < tsh->fields); DBUG_ASSERT(tsh->db.str && tsh->table_name.str); @@ -197,15 +198,15 @@ table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table) my_snprintf(buf, sizeof(buf), "Column %d type mismatch - " "received type %d, %s.%s has type %d", col, type(col), tsh->db.str, tsh->table_name.str, - table->field[col]->type()); + field->type()); rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF, ER(ER_BINLOG_ROW_WRONG_TABLE_DEF), buf); } /* Check the slave's field size against that of the master. */ - if (!error && - !table->field[col]->compatible_field_size(field_metadata(col))) + if (!error && + !field->compatible_field_size(field_metadata(col), rli_arg)) { error= 1; char buf[256]; @@ -213,10 +214,9 @@ table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table) "master has size %d, %s.%s on slave has size %d." " Master's column size should be <= the slave's " "column size.", col, - table->field[col]->pack_length_from_metadata( - m_field_metadata[col]), - tsh->db.str, tsh->table_name.str, - table->field[col]->row_pack_length()); + field->pack_length_from_metadata(m_field_metadata[col]), + tsh->db.str, tsh->table_name.str, + field->row_pack_length()); rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF, ER(ER_BINLOG_ROW_WRONG_TABLE_DEF), buf); } diff --git a/sql/slave.cc b/sql/slave.cc index a6d7758c8de..0040b69f8de 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4057,9 +4057,17 @@ end: @param rli Relay_log_info which tells the master's version @param bug_id Number of the bug as found in bugs.mysql.com @param report bool report error message, default TRUE + + @param pred Predicate function that will be called with @c param to + check for the bug. If the function return @c true, the bug is present, + otherwise, it is not. + + @param param State passed to @c pred function. + @return TRUE if master has the bug, FALSE if it does not. */ -bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id, bool report) +bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report, + bool (*pred)(const void *), const void *param) { struct st_version_range_for_one_bug { uint bug_id; @@ -4072,6 +4080,7 @@ bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id, bool report) {24432, { 5, 1, 12 }, { 5, 1, 17 } }, {33029, { 5, 0, 0 }, { 5, 0, 58 } }, {33029, { 5, 1, 0 }, { 5, 1, 12 } }, + {37426, { 5, 1, 0 }, { 5, 1, 26 } }, }; const uchar *master_ver= rli->relay_log.description_event_for_exec->server_version_split; @@ -4085,11 +4094,11 @@ bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id, bool report) *fixed_in= versions_for_all_bugs[i].fixed_in; if ((versions_for_all_bugs[i].bug_id == bug_id) && (memcmp(introduced_in, master_ver, 3) <= 0) && - (memcmp(fixed_in, master_ver, 3) > 0)) + (memcmp(fixed_in, master_ver, 3) > 0) && + (pred == NULL || (*pred)(param))) { if (!report) return TRUE; - // a short message for SHOW SLAVE STATUS (message length constraints) my_printf_error(ER_UNKNOWN_ERROR, "master may suffer from" " http://bugs.mysql.com/bug.php?id=%u" @@ -4137,7 +4146,7 @@ bool rpl_master_erroneous_autoinc(THD *thd) { Relay_log_info *rli= &active_mi->rli; DBUG_EXECUTE_IF("simulate_bug33029", return TRUE;); - return rpl_master_has_bug(rli, 33029, FALSE); + return rpl_master_has_bug(rli, 33029, FALSE, NULL, NULL); } return FALSE; } diff --git a/sql/slave.h b/sql/slave.h index 80d267e5b27..dc2d668c97b 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -165,7 +165,8 @@ int fetch_master_table(THD* thd, const char* db_name, const char* table_name, bool show_master_info(THD* thd, Master_info* mi); bool show_binlog_info(THD* thd); -bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id, bool report=TRUE); +bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report, + bool (*pred)(const void *), const void *param); bool rpl_master_erroneous_autoinc(THD* thd); const char *print_slave_db_safe(const char *db); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d1e5c26912d..c51c47ae431 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -695,7 +695,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (thd->slave_thread && (info.handle_duplicates == DUP_UPDATE) && (table->next_number_field != NULL) && - rpl_master_has_bug(&active_mi->rli, 24432)) + rpl_master_has_bug(&active_mi->rli, 24432, TRUE, NULL, NULL)) goto abort; #endif @@ -2967,7 +2967,7 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) if (thd->slave_thread && (info.handle_duplicates == DUP_UPDATE) && (table->next_number_field != NULL) && - rpl_master_has_bug(&active_mi->rli, 24432)) + rpl_master_has_bug(&active_mi->rli, 24432, TRUE, NULL, NULL)) DBUG_RETURN(1); #endif From 828d6a192b1f33e3d07120cbf88af5ccb0b3152e Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Mon, 30 Jun 2008 22:52:26 +0200 Subject: [PATCH 09/17] Version 5.1.26 is labeled "rc". --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 1ef636ffa3c..af23b6035eb 100644 --- a/configure.in +++ b/configure.in @@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM # # When changing major version number please also check switch statement # in mysqlbinlog::check_master_version(). -AM_INIT_AUTOMAKE(mysql, 5.1.26) +AM_INIT_AUTOMAKE(mysql, 5.1.26-rc) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 02577084372849f0fc5acf264b6cc971c36f3f9f Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Sat, 5 Jul 2008 09:44:10 +0200 Subject: [PATCH 10/17] ild can not be expected on all matching installs --- configure.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 247a17da940..c34cd661bbd 100644 --- a/configure.in +++ b/configure.in @@ -2812,9 +2812,15 @@ EOF case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc-$have_ndbcluster in *solaris*-i?86-no-yes) - # ndb fail for whatever strange reason to link Sun Forte/x86 - # unless using incremental linker - CXXFLAGS="$CXXFLAGS -xildon" + if $CC -xildon 2>&1 | grep "illegal option" >/dev/null + then + # This Solaris ld does not support -xildon + true + else + # ndb fail for whatever strange reason to link Sun Forte/x86 + # unless using incremental linker + CXXFLAGS="$CXXFLAGS -xildon" + fi ;; *) ;; esac From 1ee9ca9e46065ac7c506e568802cc05d1c475163 Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Tue, 8 Jul 2008 19:17:06 +0200 Subject: [PATCH 11/17] let's make a real honest attempt at finding the daemons in libexec --- mysql-test/mysql-test-run.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fa41d25a034..eb59fd94f0f 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1579,13 +1579,15 @@ sub executable_setup_ndb () { $exe_ndbd= mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd", - "$ndb_path/ndbd"); + "$ndb_path/ndbd", + "$glob_basedir/libexec/ndbd"); $exe_ndb_mgm= mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm", "$ndb_path/ndb_mgm"); $exe_ndb_mgmd= mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd", - "$ndb_path/ndb_mgmd"); + "$ndb_path/ndb_mgmd", + "$glob_basedir/libexec/ndb_mgmd"); $exe_ndb_waiter= mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter", "$ndb_path/ndb_waiter"); From 3bcbaf6cbf18dc04ee2495cc6cd2bf8aa399ebb5 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 9 Jul 2008 13:03:48 +0300 Subject: [PATCH 12/17] fixed a compilation warning on windows 64. --- mysys/default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/default.c b/mysys/default.c index bf32261129b..b7eb963e395 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -1017,7 +1017,7 @@ static const char *my_get_module_parent(char *buf, size_t size) { char *last= NULL; char *end; - if (!GetModuleFileName(NULL, buf, size)) + if (!GetModuleFileName(NULL, buf, (DWORD) size)) return NULL; end= strend(buf); From 207c2cc243a6443ea1eeee4b745d754167da407a Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Tue, 15 Jul 2008 18:43:25 +0200 Subject: [PATCH 13/17] test case fix --- mysql-test/mysql-test-run.pl | 5 +++-- mysql-test/t/system_mysql_db_fix50030.test | 7 +++++++ mysql-test/t/system_mysql_db_fix50117.test | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index eb59fd94f0f..75ee33e97c5 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -251,7 +251,7 @@ our $opt_sleep; our $opt_testcase_timeout; our $opt_suite_timeout; my $default_testcase_timeout= 15; # 15 min max -my $default_suite_timeout= 180; # 3 hours max +my $default_suite_timeout= 300; # 5 hours max our $opt_start_and_exit; our $opt_start_dirty; @@ -1684,7 +1684,8 @@ sub executable_setup () { # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", - "$glob_basedir/share/mysql_fix_privilege_tables.sql"); + "$glob_basedir/share/mysql_fix_privilege_tables.sql", + "$glob_basedir/share/mysql/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test index b4e0ed65242..80365cfdff4 100644 --- a/mysql-test/t/system_mysql_db_fix50030.test +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -1,6 +1,13 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc +# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set +# to the location of mysql_fix_privilege_tables.sql +if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`) +{ + skip Test needs MYSQL_FIX_PRIVILEGE_TABLES; +} + # # This is the test for mysql_fix_privilege_tables # It checks that a system tables from mysql 5.0.30 diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test index ea379757f26..1eed4d671ef 100644 --- a/mysql-test/t/system_mysql_db_fix50117.test +++ b/mysql-test/t/system_mysql_db_fix50117.test @@ -1,6 +1,13 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc +# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set +# to the location of mysql_fix_privilege_tables.sql +if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`) +{ + skip Test needs MYSQL_FIX_PRIVILEGE_TABLES; +} + # # This is the test for mysql_fix_privilege_tables # It checks that a system tables from mysql 5.1.17 From aa5731dad97ec8ac95d2e4cdd43211460d546b29 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 16 Jul 2008 16:58:45 -0600 Subject: [PATCH 14/17] Bug #38180 options are read from ~/my.cnf instead of ~/.my.cnf Pull out some of unpack_dirname() into normalize_dirname(); this new function does not expand "~" to the home directory. Use this function in unpack_dirname(), and use it during init_default_directories() to remove duplicate entries without losing track of which directory is a user's home dir. --- include/my_sys.h | 1 + mysys/default.c | 3 +- mysys/mf_pack.c | 79 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index d656326e968..db01223602d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -681,6 +681,7 @@ extern my_string fn_format(my_string to,const char *name,const char *dir, const char *form, uint flag); extern size_s strlength(const char *str); extern void pack_dirname(my_string to,const char *from); +extern uint normalize_dirname(char * to, const char *from); extern uint unpack_dirname(my_string to,const char *from); extern uint cleanup_dirname(my_string to,const char *from); extern uint system_filename(my_string to,const char *from); diff --git a/mysys/default.c b/mysys/default.c index b7eb963e395..b709b33e2f8 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -965,8 +965,7 @@ static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs) char *p; my_bool err __attribute__((unused)); - /* Normalize directory name */ - len= unpack_dirname(buf, dir); + len= normalize_dirname(buf, dir); if (!(p= strmake_root(alloc, buf, len))) return 1; /* Failure */ /* Should never fail if DEFAULT_DIRS_SIZE is correct size */ diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 9e8b6516f63..915c11ec51d 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -266,22 +266,64 @@ void symdirget(char *dir) #endif /* USE_SYMDIR */ -/* - Fixes a directroy name so that can be used by open() +/** + Convert a directory name to a format which can be compared as strings - SYNOPSIS - unpack_dirname() - to result-buffer, FN_REFLEN characters. may be == from - from 'Packed' directory name (may contain ~) + @param to result buffer, FN_REFLEN chars in length; may be == from + @param from 'packed' directory name, in whatever format + @returns size of the normalized name - IMPLEMENTATION - Make that last char of to is '/' if from not empty and - from doesn't end in FN_DEVCHAR - Uses cleanup_dirname and changes ~/.. to home_dir/.. + @details + - Ensures that last char is FN_LIBCHAR, unless it is FN_DEVCHAR + - Uses cleanup_dirname - Changes a UNIX filename to system filename (replaces / with \ on windows) + It does *not* expand ~/ (although, see cleanup_dirname). Nor does it do + any case folding. All case-insensitive normalization should be done by + the caller. +*/ - RETURN +uint normalize_dirname(char *to, const char *from) +{ + uint length; + char buff[FN_REFLEN]; + DBUG_ENTER("normalize_dirname"); + + /* + Despite the name, this actually converts the name to the system's + format (TODO: rip out the non-working VMS stuff and name this + properly). + */ + (void) intern_filename(buff, from); + length= (uint) strlen(buff); /* Fix that '/' is last */ + if (length && +#ifdef FN_DEVCHAR + buff[length - 1] != FN_DEVCHAR && +#endif + buff[length - 1] != FN_LIBCHAR && buff[length - 1] != '/') + { + buff[length]= FN_LIBCHAR; + buff[length + 1]= '\0'; + } + + length=cleanup_dirname(to, buff); + + DBUG_RETURN(length); +} + + +/** + Fixes a directory name so that can be used by open() + + @param to Result buffer, FN_REFLEN characters. May be == from + @param from 'Packed' directory name (may contain ~) + + @details + - Uses normalize_dirname() + - Expands ~/... to home_dir/... + - Resolves MySQL's fake "foo.sym" symbolic directory names (if USE_SYMDIR) + - Changes a UNIX filename to system filename (replaces / with \ on windows) + + @returns Length of new directory name (= length of to) */ @@ -291,19 +333,8 @@ uint unpack_dirname(my_string to, const char *from) char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion; DBUG_ENTER("unpack_dirname"); - (void) intern_filename(buff,from); /* Change to intern name */ - length= (uint) strlen(buff); /* Fix that '/' is last */ - if (length && -#ifdef FN_DEVCHAR - buff[length-1] != FN_DEVCHAR && -#endif - buff[length-1] != FN_LIBCHAR && buff[length-1] != '/') - { - buff[length]=FN_LIBCHAR; - buff[length+1]= '\0'; - } + length= normalize_dirname(buff, from); - length=cleanup_dirname(buff,buff); if (buff[0] == FN_HOMELIB) { suffix=buff+1; tilde_expansion=expand_tilde(&suffix); From 49f09f136f2264824909c1bda919aa8d18a6673a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Jul 2008 01:33:45 +0200 Subject: [PATCH 15/17] Set version to 5.0.66a --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 247a17da940..a1dc9d36d82 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.66) +AM_INIT_AUTOMAKE(mysql, 5.0.66a) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 6077ebea1c084ea57031ec94cb3ef9ec7a687306 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 21 Jul 2008 12:01:22 +0200 Subject: [PATCH 16/17] Bug#34409 LOCK_plugin contention via ha_release_temporary_latches/plugin_foreach use thread-local data structures in ha_release_temporary_latches() --- sql/handler.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index ebe5ea5d4fa..fe4944ed836 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1618,23 +1618,23 @@ bool mysql_xa_recover(THD *thd) @return always 0 */ -static my_bool release_temporary_latches(THD *thd, plugin_ref plugin, - void *unused) -{ - handlerton *hton= plugin_data(plugin, handlerton *); - - if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches) - hton->release_temporary_latches(hton, thd); - - return FALSE; -} - int ha_release_temporary_latches(THD *thd) { - plugin_foreach(thd, release_temporary_latches, MYSQL_STORAGE_ENGINE_PLUGIN, - NULL); + Ha_trx_info *info; + /* + Note that below we assume that only transactional storage engines + may need release_temporary_latches(). If this will ever become false, + we could iterate on thd->open_tables instead (and remove duplicates + as if (!seen[hton->slot]) { seen[hton->slot]=1; ... }). + */ + for (info= thd->transaction.stmt.ha_list; info; info= info->next()) + { + handlerton *hton= info->ht(); + if (hton && hton->release_temporary_latches) + hton->release_temporary_latches(hton, thd); + } return 0; } From 3a3894d2ca2e07b010985e9d27226709a4046e3b Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Tue, 22 Jul 2008 13:04:32 +0200 Subject: [PATCH 17/17] Disabled two test cases in 5.1 because of random failures. --- mysql-test/t/disabled.def | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 5c37e8333a7..c058992d795 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -94,3 +94,6 @@ tmp_table_size_basic_64 : Bug #36522: Some tests of system variabl transaction_alloc_block_size_basic_64 : Bug #36522: Some tests of system variables have diffs on 64bit platorms transaction_prealloc_size_basic_64 : Bug #36522: Some tests of system variables have diffs on 64bit platorms wait_timeout_basic_64 : Bug #36522: Some tests of system variables have diffs on 64bit platorms +log_tables.test : Bug #37798: main.log_tables fails randomly on powermacg5 and windows +slow_query_log_func.test : Bug #37962: *_func tests containing sleeps/race conditions +