From 53653dcef0d2fc5e9bd9f738b3d17f4ba75d1606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Bl=C3=A5udd?= Date: Wed, 7 Oct 2009 15:42:16 +0200 Subject: [PATCH 01/16] Bug#42589 mysql_fix_privilege_tables.sh to be deprecated - Remove remnants of "mysql_fix_privilege_tables.sh"(again) --- mysql-test/include/default_my.cnf | 8 - mysql-test/lib/v1/mysql-test-run.pl | 23 --- mysql-test/mysql-test-run.pl | 29 +-- mysql-test/t/system_mysql_db_fix30020.test | 108 ---------- scripts/Makefile.am | 3 - scripts/mysql_fix_privilege_tables.sh | 223 --------------------- scripts/mysql_system_tables_fix.sql | 4 - sql/udf_example.c | 2 +- support-files/mysql.spec.sh | 6 +- 9 files changed, 6 insertions(+), 400 deletions(-) delete mode 100644 mysql-test/t/system_mysql_db_fix30020.test delete mode 100644 scripts/mysql_fix_privilege_tables.sh diff --git a/mysql-test/include/default_my.cnf b/mysql-test/include/default_my.cnf index d77fee0e200..fc2bd5d1140 100644 --- a/mysql-test/include/default_my.cnf +++ b/mysql-test/include/default_my.cnf @@ -12,14 +12,6 @@ log-bin= master-bin [mysqlbinlog] disable-force-if-open -# mysql_fix_privilege_tables.sh does not read from [client] so it -# need its own section -[mysql_fix_privilege_tables] -socket= @client.socket -port= @client.port -user= @client.user -password= @client.password - [ENV] MASTER_MYPORT= @mysqld.1.port MASTER_MYSOCK= @mysqld.1.socket diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index 86ad5c485c1..c319036b193 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -152,7 +152,6 @@ our $exe_mysqldump; our $exe_mysqlslap; our $exe_mysqlimport; our $exe_mysqlshow; -our $exe_mysql_fix_system_tables; our $file_mysql_fix_privilege_tables; our $exe_mysqltest; our $exe_ndbd; @@ -1673,14 +1672,6 @@ sub executable_setup () { $exe_mysql_upgrade= ""; } - if ( ! $glob_win32 ) - { - # Look for mysql_fix_system_table script - $exe_mysql_fix_system_tables= - mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables", - "$path_client_bindir/mysql_fix_privilege_tables"); - } - # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", @@ -2152,20 +2143,6 @@ sub environment_setup () { $ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments(); } - # ---------------------------------------------------- - # Setup env so childs can execute mysql_fix_system_tables - # ---------------------------------------------------- - if ( !$opt_extern && ! $glob_win32 ) - { - my $cmdline_mysql_fix_system_tables= - "$exe_mysql_fix_system_tables --no-defaults --host=localhost " . - "--user=root --password= " . - "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'}"; - $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; - - } $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; # ---------------------------------------------------- diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 17102196f42..ba4fd1ad2b3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1635,26 +1635,8 @@ sub client_debug_arg($$) { } -sub mysql_fix_arguments () { - - return "" if ( IS_WINDOWS ); - - my $exe= - mtr_script_exists("$basedir/scripts/mysql_fix_privilege_tables", - "$path_client_bindir/mysql_fix_privilege_tables"); - my $args; - mtr_init_args(\$args); - mtr_add_arg($args, "--defaults-file=%s", $path_config_file); - - mtr_add_arg($args, "--basedir=%s", $basedir); - mtr_add_arg($args, "--bindir=%s", $path_client_bindir); - mtr_add_arg($args, "--verbose"); - return mtr_args2str($exe, @$args); -} - - sub client_arguments ($;$) { - my $client_name= shift; + my $client_name= shift; my $group_suffix= shift; my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name"); @@ -1943,7 +1925,6 @@ sub environment_setup { $ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade"); $ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin); $ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments(); - $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= mysql_fix_arguments(); $ENV{'EXE_MYSQL'}= $exe_mysql; # ---------------------------------------------------- @@ -2509,14 +2490,6 @@ sub create_config_file_for_extern { [mysqlbinlog] character-sets-dir= $path_charsetsdir -# mysql_fix_privilege_tables.sh don't read from [client] -[mysql_fix_privilege_tables] -socket = $opts{'socket'} -port = $opts{'port'} -user = $opts{'user'} -password = $opts{'password'} - - EOF ; diff --git a/mysql-test/t/system_mysql_db_fix30020.test b/mysql-test/t/system_mysql_db_fix30020.test deleted file mode 100644 index 0a7d9dad7c9..00000000000 --- a/mysql-test/t/system_mysql_db_fix30020.test +++ /dev/null @@ -1,108 +0,0 @@ -# Embedded server doesn't support external clients ---source include/not_embedded.inc - -# Don't run this test if $MYSQL_FIX_SYSTEM_TABLES isn't set -# to the location of mysql_fix_privilege_tables.sql -if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`) -{ - skip Test need MYSQL_FIX_SYSTEM_TABLES; -} -# check that CSV engine was compiled in, as the test relies on the presence -# of the log tables (which are CSV-based) ---source include/have_csv.inc - -# -# This is the test for mysql_fix_privilege_tables -# It checks that a system tables from mysql 3.20 -# can be upgraded to current system table format -# -# Note: If this test fails, don't be confused about the errors reported -# by mysql-test-run This shows warnings generated by -# mysql_fix_system_tables which should be ignored. -# Instead, concentrate on the errors in r/system_mysql_db.reject - --- disable_result_log --- disable_query_log - -use test; - -# create system tables as in mysql-3.20 - ---disable_warnings -CREATE TABLE db ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db,User), - KEY User (User) -) -engine=MyISAM; ---enable_warnings - -INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); -INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); - ---disable_warnings -CREATE TABLE host ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db) -) -engine=MyISAM; ---enable_warnings - ---disable_warnings -CREATE TABLE user ( - Host char(60) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Password char(16), - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,User) -) -engine=MyISAM; ---enable_warnings - -INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); - -# Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system --- system $MYSQL_FIX_SYSTEM_TABLES --database=test > $MYSQLTEST_VARDIR/log/system_mysql_db_fix30020.log 2>&1 --- enable_query_log --- enable_result_log - --- source include/system_db_struct.inc - --- disable_query_log - -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, -procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, -time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, -time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; - --- enable_query_log - -# check that we dropped all system tables -show tables; - -exit; -# End of 4.1 tests diff --git a/scripts/Makefile.am b/scripts/Makefile.am index cd758370388..09280aef2ab 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -23,7 +23,6 @@ EXTRA_PROGRAMS = comp_sql bin_SCRIPTS = @server_scripts@ \ msql2mysql \ mysql_config \ - mysql_fix_privilege_tables \ mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ @@ -45,7 +44,6 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ msql2mysql.sh \ mysql_config.sh \ mysql_config.pl.in \ - mysql_fix_privilege_tables.sh \ mysql_fix_extensions.sh \ mysql_install_db.sh \ mysql_install_db.pl.in \ @@ -82,7 +80,6 @@ CLEANFILES = @server_scripts@ \ make_sharedlib_distribution \ msql2mysql \ mysql_config \ - mysql_fix_privilege_tables \ mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh deleted file mode 100644 index 3b179957932..00000000000 --- a/scripts/mysql_fix_privilege_tables.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh -# Copyright (C) 2000-2006 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql -# through the mysql client program to the mysqld server - -# Default values (Can be changed in my.cnf) -password="" -host="localhost" -user="root" -sql_only=0 -basedir="@prefix@" -verbose=0 -args="" -# no elaborate fallback here; with no argument, it will happen in "mysql" -port="" -socket="" -database="mysql" -bindir="" -pkgdatadir="@pkgdatadir@" -print_defaults_bindir="." - -file=mysql_fix_privilege_tables.sql - -# The following test is to make this script compatible with the 4.0 where -# the single argument could be a password -if test "$#" = 1 -then - case "$1" in - --*) ;; - *) old_style_password="$1" ; shift ;; - esac -fi - -# The following code is almost identical to the code in mysql_install_db.sh - -case "$1" in - --no-defaults|--defaults-file=*|--defaults-extra-file=*) - defaults="$1"; shift - ;; -esac - -parse_arguments() { - # We only need to pass arguments through to the server if we don't - # handle them here. So, we collect unrecognized options (passed on - # the command line) into the args variable. - pick_args= - if test "$1" = PICK-ARGS-FROM-ARGV - then - pick_args=1 - shift - fi - - for arg do - case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --sql|--sql-only) sql_only=1 ;; - --verbose) verbose=1 ;; - --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;; - --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; - --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;; - --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"` - print_defaults_bindir=$bindir - ;; - *) - if test -n "$pick_args" - then - # This sed command makes sure that any special chars are quoted, - # so the arg gets passed exactly to the server. - args="$args "`echo "$arg" | sed -e 's,\([^=a-zA-Z0-9_.-]\),\\\\\1,g'` - fi - ;; - esac - done -} - -# Get first arguments from the my.cfg file, groups [mysqld] and -# [mysql_install_db], and then merge with the command line arguments - -print_defaults=my_print_defaults -for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra -do - if test -x $dir/my_print_defaults - then - print_defaults="$dir/my_print_defaults" - break - fi -done - -parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` -parse_arguments PICK-ARGS-FROM-ARGV "$@" - -if test -z "$password" -then - password=$old_style_password -fi - -# Find where 'mysql' command is located - -dirname=`dirname "$0"` - -if test -z "$bindir" -then - for i in @bindir@ $basedir/bin "$dirname/../client" - do - if test -f $i/mysql - then - bindir=$i - break - fi - done -fi - -if test -z "$bindir" -then - echo "Could not find MySQL command-line client (mysql)." - echo "Please use --basedir to specify the directory where MySQL is installed." - exit 1 -fi - -cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host" -if test ! -z "$port"; then - cmd="$cmd --port=$port" -fi -if test ! -z "$socket"; then - cmd="$cmd --socket=$socket" -fi -cmd="$cmd --database=$database" - -if test $sql_only = 1 -then - cmd="cat" -fi - -# Find where first mysql_fix_privilege_tables.sql is located -for i in $basedir/support-files $basedir/share $basedir/share/mysql \ - $basedir/scripts $pkgdatadir . "$dirname" -do - if test -f $i/$file - then - pkgdatadir=$i - break - fi -done - -sql_file="$pkgdatadir/$file" -if test ! -f $sql_file -then - echo "Could not find file '$file'." - echo "Please use --basedir to specify the directory where MySQL is installed" - exit 1 -fi - -s_echo() -{ - if test $sql_only = 0 - then - echo $1 - fi -} - -s_echo "This script updates all the mysql privilege tables to be usable by" -s_echo "the current version of MySQL" -s_echo "" - -if test $verbose = 1 -then - s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors" - s_echo "because these just mean that your tables are already up to date." - s_echo "This script is safe to run even if your tables are already up to date!" - s_echo "" -fi - -run_cmd() { - # Password argument is added here to allow for spaces in password. - - if test ! -z "$password" - then - cat $sql_file | $cmd --password="$password" - else - cat $sql_file | $cmd - fi -} - -if test $verbose = 0 -then - run_cmd > /dev/null 2>&1 -else - run_cmd > /dev/null -fi -if test $? = 0 -then - s_echo "done" -else - s_echo "Got a failure from command:" - s_echo "cat $sql_file | $cmd" - s_echo "Please check the above output and try again." - if test $verbose = 0 - then - s_echo "" - s_echo "Running the script with the --verbose option may give you some information" - s_echo "of what went wrong." - fi - s_echo "" - s_echo "If you get an 'Access denied' error, you should run this script again and" - s_echo "give the MySQL root user password as an argument with the --password= option" -fi diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index a6497f57f0a..8f6f6a38a68 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -5,10 +5,6 @@ # because these just mean that your tables are already up to date. # This script is safe to run even if your tables are already up to date! -# On unix, you should use the mysql_fix_privilege_tables script to execute -# this sql script. -# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' - set sql_mode=''; set storage_engine=MyISAM; diff --git a/sql/udf_example.c b/sql/udf_example.c index 30d85d95034..4e24735a93d 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -107,7 +107,7 @@ ** option. ** ** If you can't get AGGREGATES to work, check that you have the column -** 'type' in the mysql.func table. If not, run 'mysql_fix_privilege_tables'. +** 'type' in the mysql.func table. If not, run 'mysql_upgrade'. ** */ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 60bf9213362..b55040c7a0f 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -660,7 +660,6 @@ fi %doc %attr(644, root, man) %{_mandir}/man8/mysqld.8* %doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1* -%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1* @@ -683,7 +682,6 @@ fi %attr(755, root, root) %{_bindir}/myisampack %attr(755, root, root) %{_bindir}/mysql_convert_table_format %attr(755, root, root) %{_bindir}/mysql_fix_extensions -%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables %attr(755, root, root) %{_bindir}/mysql_install_db %attr(755, root, root) %{_bindir}/mysql_secure_installation %attr(755, root, root) %{_bindir}/mysql_setpermission @@ -867,6 +865,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Fri Oct 06 2009 Magnus Blaudd + +- Removed mysql_fix_privilege_tables + * Fri Aug 28 2009 Joerg Bruehe - Merge up from 5.1 to 5.4: Remove handling for the InnoDB plugin. From 84a6de3f1c745dcad6e41f3ca5e379041f8c7310 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Tue, 23 Feb 2010 17:26:56 +0800 Subject: [PATCH 02/16] Bug#49557 "semisync" plugin test fails on Windows The problem was because the gettimeofday function was incorrect implemented for Windows, and so the semisync master did not wait for slave reply properly on Windows. Fixed by removing the gettimeofday function for Windows, and using set_timespec function to get current time for all platforms. plugin/semisync/semisync_master.cc: removing the gettimeofday function for Windows, using set_timespec function to get current time for all platforms. --- plugin/semisync/semisync_master.cc | 209 ++++++++++++----------------- 1 file changed, 83 insertions(+), 126 deletions(-) diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index bbbc2a669c4..4614cafec24 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -43,19 +43,16 @@ unsigned long long rpl_semi_sync_master_trx_wait_time = 0; char rpl_semi_sync_master_wait_no_slave = 1; -static int getWaitTime(const struct timeval& start_tv); +static int getWaitTime(const struct timespec& start_ts); -#ifdef __WIN__ -static int gettimeofday(struct timeval *tv, void *tz) +static unsigned long long timespec_to_usec(const struct timespec *ts) { - unsigned int ticks; - ticks= GetTickCount(); - tv->tv_usec= ticks*1000; - tv->tv_sec= ticks/1000; - - return 0; -} +#ifndef __WIN__ + return (unsigned long long) ts->tv_sec * TIME_MILLION + ts->tv_nsec / TIME_THOUSAND; +#else + return ts->tv.i64 / 10; #endif /* __WIN__ */ +} /******************************************************************************* * @@ -604,12 +601,12 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, if (getMasterEnabled() && trx_wait_binlog_name) { - struct timeval start_tv; + struct timespec start_ts; struct timespec abstime; - int wait_result, start_time_err; + int wait_result; const char *old_msg= 0; - start_time_err = gettimeofday(&start_tv, 0); + set_timespec(start_ts, 0); /* Acquire the mutex. */ lock(); @@ -677,98 +674,71 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, kWho, wait_file_name_, (unsigned long)wait_file_pos_); } - if (start_time_err == 0) - { - int diff_usecs = start_tv.tv_usec + wait_timeout_ * TIME_THOUSAND; - - /* Calcuate the waiting period. */ + /* Calcuate the waiting period. */ #ifdef __WIN__ - abstime.tv.i64 = (__int64)start_tv.tv_sec * TIME_MILLION * 10; - abstime.tv.i64 += (__int64)diff_usecs * 10; - abstime.max_timeout_msec= (long)wait_timeout_; + abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10; + abstime.max_timeout_msec= (long)wait_timeout_; #else - abstime.tv_sec = start_tv.tv_sec; - if (diff_usecs < TIME_MILLION) - { - abstime.tv_nsec = diff_usecs * TIME_THOUSAND; - } - else - { - while (diff_usecs >= TIME_MILLION) - { - abstime.tv_sec++; - diff_usecs -= TIME_MILLION; - } - abstime.tv_nsec = diff_usecs * TIME_THOUSAND; - } + unsigned long diff_nsecs = start_ts.tv_nsec + wait_timeout_ * TIME_MILLION; + abstime.tv_sec = start_ts.tv_sec; + while (diff_nsecs >= TIME_BILLION) + { + abstime.tv_sec++; + diff_nsecs -= TIME_BILLION; + } + abstime.tv_nsec = diff_nsecs; #endif /* __WIN__ */ - - /* In semi-synchronous replication, we wait until the binlog-dump - * thread has received the reply on the relevant binlog segment from the - * replication slave. - * - * Let us suspend this thread to wait on the condition; - * when replication has progressed far enough, we will release - * these waiting threads. - */ - rpl_semi_sync_master_wait_sessions++; - - if (trace_level_ & kTraceDetail) - sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)", - kWho, wait_timeout_, - wait_file_name_, (unsigned long)wait_file_pos_); - - wait_result = cond_timewait(&abstime); - rpl_semi_sync_master_wait_sessions--; - - if (wait_result != 0) - { - /* This is a real wait timeout. */ - sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), " - "semi-sync up to file %s, position %lu.", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos, - reply_file_name_, (unsigned long)reply_file_pos_); - rpl_semi_sync_master_wait_timeouts++; - - /* switch semi-sync off */ - switch_off(); - } - else - { - int wait_time; - - wait_time = getWaitTime(start_tv); - if (wait_time < 0) - { - if (trace_level_ & kTraceGeneral) - { - /* This is a time/gettimeofday function call error. */ - sql_print_error("Replication semi-sync gettimeofday fail1 at " - "wait position (%s, %lu)", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); - } - rpl_semi_sync_master_timefunc_fails++; - } - else - { - rpl_semi_sync_master_trx_wait_num++; - rpl_semi_sync_master_trx_wait_time += wait_time; - } - } + + /* In semi-synchronous replication, we wait until the binlog-dump + * thread has received the reply on the relevant binlog segment from the + * replication slave. + * + * Let us suspend this thread to wait on the condition; + * when replication has progressed far enough, we will release + * these waiting threads. + */ + rpl_semi_sync_master_wait_sessions++; + + if (trace_level_ & kTraceDetail) + sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)", + kWho, wait_timeout_, + wait_file_name_, (unsigned long)wait_file_pos_); + + wait_result = cond_timewait(&abstime); + rpl_semi_sync_master_wait_sessions--; + + if (wait_result != 0) + { + /* This is a real wait timeout. */ + sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), " + "semi-sync up to file %s, position %lu.", + trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos, + reply_file_name_, (unsigned long)reply_file_pos_); + rpl_semi_sync_master_wait_timeouts++; + + /* switch semi-sync off */ + switch_off(); } else { - if (trace_level_ & kTraceGeneral) - { - /* This is a gettimeofday function call error. */ - sql_print_error("Replication semi-sync gettimeofday fail2 at " - "wait position (%s, %lu)", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); + int wait_time; + + wait_time = getWaitTime(start_ts); + if (wait_time < 0) + { + if (trace_level_ & kTraceGeneral) + { + sql_print_error("Replication semi-sync getWaitTime fail at " + "wait position (%s, %lu)", + trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); + } + rpl_semi_sync_master_timefunc_fails++; + } + else + { + rpl_semi_sync_master_trx_wait_num++; + rpl_semi_sync_master_trx_wait_time += wait_time; } - rpl_semi_sync_master_timefunc_fails++; - - /* switch semi-sync off */ - switch_off(); } } @@ -1078,8 +1048,7 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, ulong packet_len; int result = -1; - struct timeval start_tv; - int start_time_err= 0; + struct timespec start_ts; ulong trc_level = trace_level_; function_enter(kWho); @@ -1093,7 +1062,7 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, } if (trc_level & kTraceNetWait) - start_time_err = gettimeofday(&start_tv, 0); + set_timespec(start_ts, 0); /* We flush to make sure that the current event is sent to the network, * instead of being buffered in the TCP/IP stack. @@ -1118,28 +1087,17 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, if (trc_level & kTraceNetWait) { - if (start_time_err != 0) + int wait_time = getWaitTime(start_ts); + if (wait_time < 0) { sql_print_error("Semi-sync master wait for reply " - "gettimeofday fail to get start time"); + "fail to get wait time."); rpl_semi_sync_master_timefunc_fails++; } else { - int wait_time; - - wait_time = getWaitTime(start_tv); - if (wait_time < 0) - { - sql_print_error("Semi-sync master wait for reply " - "gettimeofday fail to get wait time."); - rpl_semi_sync_master_timefunc_fails++; - } - else - { - rpl_semi_sync_master_net_wait_num++; - rpl_semi_sync_master_net_wait_time += wait_time; - } + rpl_semi_sync_master_net_wait_num++; + rpl_semi_sync_master_net_wait_time += wait_time; } } @@ -1228,24 +1186,23 @@ void ReplSemiSyncMaster::setExportStats() * * Return: * >= 0: the waiting time in microsecons(us) - * < 0: error in gettimeofday or time back traverse + * < 0: error in get time or time back traverse */ -static int getWaitTime(const struct timeval& start_tv) +static int getWaitTime(const struct timespec& start_ts) { unsigned long long start_usecs, end_usecs; - struct timeval end_tv; - int end_time_err; - + struct timespec end_ts; + /* Starting time in microseconds(us). */ - start_usecs = start_tv.tv_sec * TIME_MILLION + start_tv.tv_usec; + start_usecs = timespec_to_usec(&start_ts); /* Get the wait time interval. */ - end_time_err = gettimeofday(&end_tv, 0); + set_timespec(end_ts, 0); /* Ending time in microseconds(us). */ - end_usecs = end_tv.tv_sec * TIME_MILLION + end_tv.tv_usec; + end_usecs = timespec_to_usec(&end_ts); - if (end_time_err != 0 || end_usecs < start_usecs) + if (end_usecs < start_usecs) return -1; return (int)(end_usecs - start_usecs); From bd6cce8a7cdca95f448055c46a031f9b387c1cb2 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Wed, 10 Mar 2010 18:32:21 +0800 Subject: [PATCH 03/16] Post fix for Bug#49557 --- plugin/semisync/semisync_master.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 4614cafec24..5b06180662e 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -679,7 +679,8 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10; abstime.max_timeout_msec= (long)wait_timeout_; #else - unsigned long diff_nsecs = start_ts.tv_nsec + wait_timeout_ * TIME_MILLION; + unsigned long long diff_nsecs = + start_ts.tv_nsec + (unsigned long long)wait_timeout_ * TIME_MILLION; abstime.tv_sec = start_ts.tv_sec; while (diff_nsecs >= TIME_BILLION) { From 3139b904948e72f9d7a6ed5849c8aeadc0d8c7fa Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Wed, 10 Mar 2010 14:36:27 +0100 Subject: [PATCH 04/16] Part of the fixes for bug#49022 Plugins included into bin release cannot be installed on debug version of server Ensure that the plugin files of the debug build get into the optimized tree, so that they find their way into the final RPMs. support-files/mysql.spec.sh: Use "make install" in the debug build tree to get the debug plugin files to a temporary location, then move them to "plugin/debug/" in the optimized build tree so that the install hook in "plugin/Makefile.am" forwards them into the final installation. This fixes bug#49022 for the generic RPMs. Unrelated: The plugin objects were listed twice in the file list, do a cleanup. --- support-files/mysql.spec.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 7c7f841bd37..f02773e73b9 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -561,6 +561,14 @@ install -d $RBR%{_libdir} install -d $RBR%{_mandir} install -d $RBR%{_sbindir} +# Get the plugin files from the debug build +mkdir $RBR/tmp-debug-plugin $MBD/plugin/debug +( cd $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/plugin + make install DESTDIR=$RBR/tmp-debug-plugin + mv $RBR/tmp-debug-plugin/usr/local/mysql/lib/mysql/plugin/* $MBD/plugin/debug/ + # From here, the install hook in "plugin/Makefile.am" will do the rest. +) +rmdir -p $RBR/tmp-debug-plugin/usr/local/mysql/lib/mysql/plugin # Install all binaries (cd $MBD && make install DESTDIR=$RBR testroot=%{_datadir}) @@ -859,10 +867,6 @@ fi %attr(755, root, root) %{_bindir}/resolve_stack_dump %attr(755, root, root) %{_bindir}/resolveip -%attr(755, root, root) %{_libdir}/mysql/plugin/ha_example.so* -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so* -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so* - %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} %endif @@ -873,6 +877,9 @@ fi %attr(755, root, root) %{_libdir}/mysql/plugin/ha_example.so* %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so* %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_example.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so* %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} @@ -1007,6 +1014,12 @@ fi %{_libdir}/mysql/plugin/semisync_master.la %{_libdir}/mysql/plugin/semisync_slave.a %{_libdir}/mysql/plugin/semisync_slave.la +%{_libdir}/mysql/plugin/debug/ha_example.a +%{_libdir}/mysql/plugin/debug/ha_example.la +%{_libdir}/mysql/plugin/debug/semisync_master.a +%{_libdir}/mysql/plugin/debug/semisync_master.la +%{_libdir}/mysql/plugin/debug/semisync_slave.a +%{_libdir}/mysql/plugin/debug/semisync_slave.la %files shared %defattr(-, root, root, 0755) @@ -1042,6 +1055,12 @@ fi # merging BK trees) ############################################################################## %changelog +* Wed Mar 10 2010 Joerg Bruehe + +- Take the result of the debug plugin build and put it into the optimized tree, + so that it becomes part of the final installation; + include the files in the packlist. Part of the fixes for bug#49022. + * Mon Mar 01 2010 Joerg Bruehe - Set "Oracle and/or its affiliates" as the vendor and copyright owner, From 7fe455a6bcbb2ba528bf77fc0f718b0c240895d0 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 10 Mar 2010 17:35:25 +0300 Subject: [PATCH 05/16] A fix and a test case for Bug#51710 FLUSH TABLES WITH READ LOCK kills the server. Prohibit FLUSH TABLES WITH READ LOCK application to views or temporary tables. Fix a subtle bug in the implementation when we actually did not remove table share objects from the table cache after acquiring exclusive locks. mysql-test/r/flush.result: Update results (Bug#51710) mysql-test/t/flush.test: Add a test case for Bug#51710. sql/sql_parse.cc: Fix Bug#51710 "FLUSH TABLES WITH READ LOCK killes the server. Ensure we don't open views and temporary tables. Fix a yet another bug in the implementation which did not actually remove the tables from cache after acquiring exclusive locks. --- mysql-test/r/flush.result | 27 +++++++++++++++++++++++++++ mysql-test/t/flush.test | 31 +++++++++++++++++++++++++++++++ sql/sql_parse.cc | 23 +++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index fd23bfa0562..3702443d04a 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -207,3 +207,30 @@ insert into t2 (a) values (3); unlock tables; # --> connection con1 drop table t1, t2, t3; +# +# Bug#51710 FLUSH TABLES WITH READ LOCK kills the server +# +drop view if exists v1, v2, v3; +drop table if exists t1, v1; +create table t1 (a int); +create view v1 as select 1; +create view v2 as select * from t1; +create view v3 as select * from v2; +flush table v1, v2, v3 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +flush table v1 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +flush table v2 with read lock; +ERROR HY000: 'test.v2' is not BASE TABLE +flush table v3 with read lock; +ERROR HY000: 'test.v3' is not BASE TABLE +create temporary table v1 (a int); +flush table v1 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +create table v1 (a int); +flush table v1 with read lock; +drop temporary table v1; +unlock tables; +drop view v2, v3; +drop table t1, v1; diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 582d2562fc6..0d406338394 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -324,3 +324,34 @@ disconnect con1; --source include/wait_until_disconnected.inc connection default; drop table t1, t2, t3; + +--echo # +--echo # Bug#51710 FLUSH TABLES WITH READ LOCK kills the server +--echo # +--disable_warnings +drop view if exists v1, v2, v3; +drop table if exists t1, v1; +--enable_warnings +create table t1 (a int); +create view v1 as select 1; +create view v2 as select * from t1; +create view v3 as select * from v2; + +--error ER_WRONG_OBJECT +flush table v1, v2, v3 with read lock; +--error ER_WRONG_OBJECT +flush table v1 with read lock; +--error ER_WRONG_OBJECT +flush table v2 with read lock; +--error ER_WRONG_OBJECT +flush table v3 with read lock; +create temporary table v1 (a int); +--error ER_WRONG_OBJECT +flush table v1 with read lock; +drop view v1; +create table v1 (a int); +flush table v1 with read lock; +drop temporary table v1; +unlock tables; +drop view v2, v3; +drop table t1, v1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6403ad99282..23e0d8c0d70 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1631,6 +1631,14 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, - you can't flush WITH READ LOCK a non-existent table - you can't flush WITH READ LOCK under LOCK TABLES - currently incompatible with the GRL (@todo: fix) + + Effect on views and temporary tables. + ------------------------------------ + You can only apply this command to existing base tables. + If a view with such name exists, ER_WRONG_OBJECT is returned. + If a temporary table with such name exists, it's ignored: + if there is a base table, it's used, otherwise ER_NO_SUCH_TABLE + is returned. */ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) @@ -1665,6 +1673,21 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) if (lock_table_names(thd, all_tables)) goto error; + for (table_list= all_tables; table_list; + table_list= table_list->next_global) + { + /* Remove the table from cache. */ + mysql_mutex_lock(&LOCK_open); + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, + table_list->db, + table_list->table_name); + mysql_mutex_unlock(&LOCK_open); + + /* Skip views and temporary tables. */ + table_list->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */ + table_list->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */ + } + if (open_and_lock_tables(thd, all_tables, FALSE, MYSQL_OPEN_HAS_MDL_LOCK, &lock_tables_prelocking_strategy) || From ade4977c1eae39cc15686d1b39497a16af4c6df3 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Wed, 10 Mar 2010 17:33:51 +0000 Subject: [PATCH 06/16] Fix for BUG#51716 and BUG#51787. In BUG#51787 we were using the wrong charset to print out the data. We were using the field charset for the string that would hold the information. This caused the assertion, because the string length was not aligned with UTF32 bytes requirements for storage. We fix this by using &my_charset_latin1 in the string object instead of the field->charset(). As a side-effect, we needed to extend the show_sql_type interface so that it took the field charset is now passed as a parameter, so that one is able to calculate the correct field size. In BUG#51716 we had issues with Field_string::pack and Field_string::unpack. When packing, the length was incorrectly calculated. When unpacking, the padding the string would be padded with the wrong bytes (a few bytes less than it should). We fix this by resorting to charset abstractions (functions) that calculate the correct length when packing and pad correctly the string when unpacking. --- mysql-test/suite/rpl/r/rpl_row_charset.result | 42 ++++++++++++ mysql-test/suite/rpl/t/rpl_row_charset.test | 68 +++++++++++++++++++ sql/field.cc | 5 +- sql/rpl_utility.cc | 16 ++--- 4 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_row_charset.result create mode 100644 mysql-test/suite/rpl/t/rpl_row_charset.test diff --git a/mysql-test/suite/rpl/r/rpl_row_charset.result b/mysql-test/suite/rpl/r/rpl_row_charset.result new file mode 100644 index 00000000000..b7ef02b93bb --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_charset.result @@ -0,0 +1,42 @@ +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; +SET SQL_LOG_BIN=0; +CREATE TABLE t1 (c1 char(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +SET SQL_LOG_BIN=1; +SET @saved_slave_type_conversions= @@global.slave_type_conversions; +include/stop_slave.inc +SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; +include/start_slave.inc +SET SQL_LOG_BIN=0; +CREATE TABLE t1 ( c1 varchar(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +SET SQL_LOG_BIN=1; +INSERT INTO t1(c1) VALUES ('insert into t1'); +DROP TABLE t1; +SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; +include/stop_slave.inc +include/start_slave.inc +CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES (); +#### ON MASTER +SELECT c1, hex(c1) from t1; ; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +#### ON SLAVE +SELECT c1, hex(c1) FROM t1; ; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +Comparing tables master:test.t1 and slave:test.t1 +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_row_charset.test b/mysql-test/suite/rpl/t/rpl_row_charset.test new file mode 100644 index 00000000000..b5108541b6f --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_charset.test @@ -0,0 +1,68 @@ +-- source include/master-slave.inc +-- source include/have_binlog_format_row.inc + +# +# BUG#51787 Assertion `(n % 4) == 0' on slave upon INSERT into a table with UTF32 +# + +SET SQL_LOG_BIN=0; +CREATE TABLE t1 (c1 char(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +SET SQL_LOG_BIN=1; + +-- connection slave + +-- let $reset_slave_type_conversions= 0 + +SET @saved_slave_type_conversions= @@global.slave_type_conversions; + +# +# Force test to cover conversion execution path in the +# slave, which also makes use of sql_type method, thence +# can ultimately trigger the assertion. +# +-- source include/stop_slave.inc +SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; +-- source include/start_slave.inc + +SET SQL_LOG_BIN=0; +CREATE TABLE t1 ( c1 varchar(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +SET SQL_LOG_BIN=1; + +-- connection master + +INSERT INTO t1(c1) VALUES ('insert into t1'); +DROP TABLE t1; + +--sync_slave_with_master + +# assertion: the slave woul hit an/several assertions: +# before and during slave conversion procedure +# Now that is fixed, it wont. + +SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; +-- source include/stop_slave.inc +-- source include/start_slave.inc +-- connection master + +# +# BUG#51716: Char column with utf16 character set gives wrong padding on slave +# + +CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); # explicit value is inserted and encoded correctly +INSERT INTO t1 VALUES (); # default value is inserted and encoded correctly + +-- echo #### ON MASTER +--query_vertical SELECT c1, hex(c1) from t1; + +-- sync_slave_with_master + +-- echo #### ON SLAVE +--query_vertical SELECT c1, hex(c1) FROM t1; + +# assertion: tables don't differ +-- let $diff_table_1=master:test.t1 +-- let $diff_table_2=slave:test.t1 +-- source include/diff_tables.inc + +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 51235d9f0e8..e339b0f071a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6613,8 +6613,7 @@ uchar *Field_string::pack(uchar *to, const uchar *from, local_char_length= my_charpos(field_charset, from, from+length, local_char_length); set_if_smaller(length, local_char_length); - while (length && from[length-1] == field_charset->pad_char) - length--; + length= field_charset->cset->lengthsp(field_charset, (const char*) from, length); // Length always stored little-endian *to++= (uchar) length; @@ -6680,7 +6679,7 @@ Field_string::unpack(uchar *to, memcpy(to, from, length); // Pad the string with the pad character of the fields charset - bfill(to + length, field_length - length, field_charset->pad_char); + field_charset->cset->fill(field_charset, (char*) to + length, field_length - length, field_charset->pad_char); return from+length; } diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index feb35527b62..8171d028326 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -340,7 +340,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const /** */ -void show_sql_type(enum_field_types type, uint16 metadata, String *str) +void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_INFO *field_cs) { DBUG_ENTER("show_sql_type"); DBUG_PRINT("enter", ("type: %d, metadata: 0x%x", type, metadata)); @@ -489,7 +489,7 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str) uint bytes= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff); uint32 length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), - "char(%d)", bytes / cs->mbmaxlen); + "char(%d)", bytes / field_cs->mbmaxlen); str->length(length); } break; @@ -579,7 +579,7 @@ can_convert_field_to(Field *field, DBUG_ENTER("can_convert_field_to"); #ifndef DBUG_OFF char field_type_buf[MAX_FIELD_WIDTH]; - String field_type(field_type_buf, sizeof(field_type_buf), field->charset()); + String field_type(field_type_buf, sizeof(field_type_buf), &my_charset_latin1); field->sql_type(field_type); DBUG_PRINT("enter", ("field_type: %s, target_type: %d, source_type: %d, source_metadata: 0x%x", field_type.c_ptr_safe(), field->real_type(), source_type, metadata)); @@ -822,9 +822,9 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, const char *tbl_name= table->s->table_name.str; char source_buf[MAX_FIELD_WIDTH]; char target_buf[MAX_FIELD_WIDTH]; - String source_type(source_buf, sizeof(source_buf), field->charset()); - String target_type(target_buf, sizeof(target_buf), field->charset()); - show_sql_type(type(col), field_metadata(col), &source_type); + String source_type(source_buf, sizeof(source_buf), &my_charset_latin1); + String target_type(target_buf, sizeof(target_buf), &my_charset_latin1); + show_sql_type(type(col), field_metadata(col), &source_type, field->charset()); field->sql_type(target_type); rli->report(ERROR_LEVEL, ER_SLAVE_CONVERSION_FAILED, ER(ER_SLAVE_CONVERSION_FAILED), @@ -842,8 +842,8 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, { char source_buf[MAX_FIELD_WIDTH]; char target_buf[MAX_FIELD_WIDTH]; - String source_type(source_buf, sizeof(source_buf), table->field[col]->charset()); - String target_type(target_buf, sizeof(target_buf), table->field[col]->charset()); + String source_type(source_buf, sizeof(source_buf), &my_charset_latin1); + String target_type(target_buf, sizeof(target_buf), &my_charset_latin1); tmp_table->field[col]->sql_type(source_type); table->field[col]->sql_type(target_type); DBUG_PRINT("debug", ("Field %s - conversion required." From 092d50389e57ac1c280c4bae470491a4f409da8a Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Wed, 10 Mar 2010 22:20:39 +0000 Subject: [PATCH 07/16] Fix for BUG#51716 and BUG#51787: test case improvements. Split rpl_row_charset into: - rpl_row_utf16. - rpl_row_utf32. This way these tests can run independently if server supports either one of the charsets but not both. Cleaned up rpl_row_utf32 which had a spurious instruction: -- let $reset_slave_type_conversions= 0 --- mysql-test/suite/rpl/r/rpl_row_utf16.result | 23 ++++++++++++++++ ...ow_charset.result => rpl_row_utf32.result} | 17 ------------ mysql-test/suite/rpl/t/rpl_row_utf16.test | 26 +++++++++++++++++++ ...pl_row_charset.test => rpl_row_utf32.test} | 26 +------------------ 4 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_row_utf16.result rename mysql-test/suite/rpl/r/{rpl_row_charset.result => rpl_row_utf32.result} (69%) create mode 100644 mysql-test/suite/rpl/t/rpl_row_utf16.test rename mysql-test/suite/rpl/t/{rpl_row_charset.test => rpl_row_utf32.test} (63%) diff --git a/mysql-test/suite/rpl/r/rpl_row_utf16.result b/mysql-test/suite/rpl/r/rpl_row_utf16.result new file mode 100644 index 00000000000..f7e66dd92ee --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_utf16.result @@ -0,0 +1,23 @@ +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 t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES (); +#### ON MASTER +SELECT c1, hex(c1) from t1; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +#### ON SLAVE +SELECT c1, hex(c1) FROM t1; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +Comparing tables master:test.t1 and slave:test.t1 +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/r/rpl_row_charset.result b/mysql-test/suite/rpl/r/rpl_row_utf32.result similarity index 69% rename from mysql-test/suite/rpl/r/rpl_row_charset.result rename to mysql-test/suite/rpl/r/rpl_row_utf32.result index b7ef02b93bb..e07db9c9e48 100644 --- a/mysql-test/suite/rpl/r/rpl_row_charset.result +++ b/mysql-test/suite/rpl/r/rpl_row_utf32.result @@ -23,20 +23,3 @@ DROP TABLE t1; SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; include/stop_slave.inc include/start_slave.inc -CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); -INSERT INTO t1 VALUES ('abc'); -INSERT INTO t1 VALUES (); -#### ON MASTER -SELECT c1, hex(c1) from t1; ; -c1 abc -hex(c1) 006100620063 -c1 ola -hex(c1) 006F006C0061 -#### ON SLAVE -SELECT c1, hex(c1) FROM t1; ; -c1 abc -hex(c1) 006100620063 -c1 ola -hex(c1) 006F006C0061 -Comparing tables master:test.t1 and slave:test.t1 -DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_row_utf16.test b/mysql-test/suite/rpl/t/rpl_row_utf16.test new file mode 100644 index 00000000000..b8f7b724ea1 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_utf16.test @@ -0,0 +1,26 @@ +-- source include/master-slave.inc +-- source include/have_binlog_format_row.inc +-- source include/have_utf16.inc + +# +# BUG#51716: Char column with utf16 character set gives wrong padding on slave +# + +CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); # explicit value is inserted and encoded correctly +INSERT INTO t1 VALUES (); # default value is inserted and encoded correctly + +-- echo #### ON MASTER +--query_vertical SELECT c1, hex(c1) from t1 + +-- sync_slave_with_master + +-- echo #### ON SLAVE +--query_vertical SELECT c1, hex(c1) FROM t1 + +# assertion: tables don't differ +-- let $diff_table_1=master:test.t1 +-- let $diff_table_2=slave:test.t1 +-- source include/diff_tables.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_row_charset.test b/mysql-test/suite/rpl/t/rpl_row_utf32.test similarity index 63% rename from mysql-test/suite/rpl/t/rpl_row_charset.test rename to mysql-test/suite/rpl/t/rpl_row_utf32.test index b5108541b6f..44ca4b345c0 100644 --- a/mysql-test/suite/rpl/t/rpl_row_charset.test +++ b/mysql-test/suite/rpl/t/rpl_row_utf32.test @@ -1,5 +1,6 @@ -- source include/master-slave.inc -- source include/have_binlog_format_row.inc +-- source include/have_utf32.inc # # BUG#51787 Assertion `(n % 4) == 0' on slave upon INSERT into a table with UTF32 @@ -11,8 +12,6 @@ SET SQL_LOG_BIN=1; -- connection slave --- let $reset_slave_type_conversions= 0 - SET @saved_slave_type_conversions= @@global.slave_type_conversions; # @@ -43,26 +42,3 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; -- source include/stop_slave.inc -- source include/start_slave.inc -- connection master - -# -# BUG#51716: Char column with utf16 character set gives wrong padding on slave -# - -CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); -INSERT INTO t1 VALUES ('abc'); # explicit value is inserted and encoded correctly -INSERT INTO t1 VALUES (); # default value is inserted and encoded correctly - --- echo #### ON MASTER ---query_vertical SELECT c1, hex(c1) from t1; - --- sync_slave_with_master - --- echo #### ON SLAVE ---query_vertical SELECT c1, hex(c1) FROM t1; - -# assertion: tables don't differ --- let $diff_table_1=master:test.t1 --- let $diff_table_2=slave:test.t1 --- source include/diff_tables.inc - -DROP TABLE t1; From 7f76b4d36c129678b3d78df895deda3080ddb4c5 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Thu, 11 Mar 2010 10:56:46 +0800 Subject: [PATCH 08/16] Enable rpl_semi_sync test on Windows --- mysql-test/suite/rpl/t/rpl_semi_sync.test | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync.test index c6c4096f0fc..b04541aba21 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test @@ -3,10 +3,6 @@ source include/not_embedded.inc; source include/have_innodb.inc; source include/master-slave.inc; -# -- [DISABLED Bug#49557] -# This test case fails on Windows due to Bug#49557. -source include/not_windows.inc; - let $engine_type= InnoDB; #let $engine_type= MyISAM; From b0ed7a5499ab81919dfb9605f1304bb16bd7deac Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 11 Mar 2010 14:34:11 +0400 Subject: [PATCH 09/16] An additional fix for WL#1213 4-byte UTF8 - Fixing crash on attempt to create a fulltext index with an utf8mb4 column - fixing wrong border width for supplementary characters in mysql client: mysql --default-character-set=utf8mb4 -e "select concat(_utf32 0x20000,'a')" --- mysql-test/r/ctype_utf8mb4.result | 3 +++ mysql-test/t/ctype_utf8mb4.test | 7 +++++++ strings/ctype-mb.c | 14 +++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index d43f3b0e0bd..4de7a192546 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2438,6 +2438,9 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1(subject) VALUES ('abcd'); INSERT INTO t1(subject) VALUES(x'f0909080'); DROP TABLE t1; +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, FULLTEXT INDEX(a)); +INSERT INTO t1 VALUES (0xF0A08080 /* U+20000 */ ); +DROP TABLE t1; # # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 8916de670c1..f396d36e5b0 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1763,6 +1763,13 @@ INSERT INTO t1(subject) VALUES ('abcd'); INSERT INTO t1(subject) VALUES(x'f0909080'); DROP TABLE t1; +# +# Make sure fulltext does not crash on supplementary characters +# +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, FULLTEXT INDEX(a)); +INSERT INTO t1 VALUES (0xF0A08080 /* U+20000 */ ); +DROP TABLE t1; + --echo # --echo # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column --echo # diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 98b598c3c2c..b1b381da59e 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1123,8 +1123,16 @@ size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) continue; } b+= mb_len; - pg= (wc >> 8) & 0xFF; - clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page; + if (wc > 0xFFFF) + { + if (wc >= 0x20000 && wc <= 0x3FFFD) /* CJK Ideograph Extension B, C */ + clen+= 1; + } + else + { + pg= (wc >> 8) & 0xFF; + clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page; + } clen++; } return clen; @@ -1136,7 +1144,7 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, { my_wc_t wc; int res= cs->cset->mb_wc(cs, &wc, s, e); - if (res <= 0) + if (res <= 0 || wc > 0xFFFF) *ctype= 0; else *ctype= my_uni_ctype[wc>>8].ctype ? From ea70b6a20a7fe27bdfe5ed0a828cdddf72b8a5d2 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Thu, 11 Mar 2010 16:47:34 +0300 Subject: [PATCH 10/16] A fix for Bug#49972 "Crash in prepared statements": The problem is introduced by WL#4435 "Support OUT-parameters in prepared statements". When a statement that has out parameters was reprepared, the reprepare request error was ignored, and an attempt to send out parameters to the client was made. Since the out parameter list was not initialized in case of an error, this attempt led to a crash. Don't try to send out parameters to the client if an error occurred in statement execution. sql/sql_prepare.cc: Don't try to send out parameters if error. tests/mysql_client_test.c: Re-enable the test case for Bug#49972. --- sql/sql_prepare.cc | 3 +-- tests/mysql_client_test.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 31e3baca764..94a35db3a2d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3769,7 +3769,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (state == Query_arena::PREPARED) state= Query_arena::EXECUTED; - if (this->lex->sql_command == SQLCOM_CALL) + if (error == 0 && this->lex->sql_command == SQLCOM_CALL) { if (is_sql_prepare()) thd->protocol_text.send_out_parameters(&this->lex->param_list); @@ -3777,7 +3777,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->protocol->send_out_parameters(&this->lex->param_list); } - /* Log COM_EXECUTE to the general log. Note, that in case of SQL prepared statements this causes two records to be output: diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 8f4c44e2c82..8112a2a3c0d 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19373,7 +19373,7 @@ static struct my_tests_st my_tests[]= { #endif { "test_bug41078", test_bug41078 }, { "test_bug44495", test_bug44495 }, - /* XXX { "test_bug49972", test_bug49972 }, */ + { "test_bug49972", test_bug49972 }, { 0, 0 } }; From f59c7267f2dd46c935d9f40657435151f99fb2c8 Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Thu, 11 Mar 2010 16:37:51 +0100 Subject: [PATCH 11/16] Fix for the bug#49022 patch, detected by further testing. --- plugin/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/Makefile.am b/plugin/Makefile.am index bddd0c929fc..30ccd1236dd 100644 --- a/plugin/Makefile.am +++ b/plugin/Makefile.am @@ -27,7 +27,7 @@ DIST_SUBDIRS = @mysql_pg_distdirs@ # As of 5.5.3-m3, we want to include the plugin files of a debug build in the package install-exec-hook: $(mkinstalldirs) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(pkglibdir)/plugin - test ! -d debug || $(TAR) cf - debug | ( cd $(DESTDIR)$(pkglibdir) && $(TAR) xvf - ) + test ! -d debug || $(TAR) cf - debug | ( cd $(DESTDIR)$(pkglibdir)/plugin && $(TAR) xvf - ) # Don't update the files from bitkeeper %::SCCS/s.% From b7b9b4536664121ee9c0fd006bcc6fa046ed8caa Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 12 Mar 2010 12:42:30 +0000 Subject: [PATCH 12/16] BUG#51716 post push fix. There are two issues fixed here: 1. We needed to update the result file, for some of mysqlbinlog_* tests, because now the some padding chars are not output anymore. 2. We needed to change the Field_string::pack so that for BINARY types the padding chars are not packed (lengthsp will return full length for these types). --- mysql-test/r/mysqlbinlog_row_innodb.result | 24 +++++++++++----------- mysql-test/r/mysqlbinlog_row_myisam.result | 24 +++++++++++----------- sql/field.cc | 15 +++++++++++++- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/mysql-test/r/mysqlbinlog_row_innodb.result b/mysql-test/r/mysqlbinlog_row_innodb.result index dd98a12a0de..00a3eb79b64 100644 --- a/mysql-test/r/mysqlbinlog_row_innodb.result +++ b/mysql-test/r/mysqlbinlog_row_innodb.result @@ -2405,10 +2405,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -2767,10 +2767,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3020,10 +3020,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3552,10 +3552,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ diff --git a/mysql-test/r/mysqlbinlog_row_myisam.result b/mysql-test/r/mysqlbinlog_row_myisam.result index 87f9ab877e1..7b0112d0a91 100644 --- a/mysql-test/r/mysqlbinlog_row_myisam.result +++ b/mysql-test/r/mysqlbinlog_row_myisam.result @@ -2405,10 +2405,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -2773,10 +2773,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3028,10 +3028,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3568,10 +3568,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ diff --git a/sql/field.cc b/sql/field.cc index e339b0f071a..8efa765a4bc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6613,7 +6613,20 @@ uchar *Field_string::pack(uchar *to, const uchar *from, local_char_length= my_charpos(field_charset, from, from+length, local_char_length); set_if_smaller(length, local_char_length); - length= field_charset->cset->lengthsp(field_charset, (const char*) from, length); + + /* + TODO: change charset interface to add a new function that does + the following or add a flag to lengthsp to do it itself + (this is for not packing padding adding bytes in BINARY + fields). + */ + if (field_charset->mbmaxlen == 1) + { + while (length && from[length-1] == field_charset->pad_char) + length --; + } + else + length= field_charset->cset->lengthsp(field_charset, (const char*) from, length); // Length always stored little-endian *to++= (uchar) length; From a3bc225ecf757c866e9406a28e5b88ab22f57e6b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Mar 2010 21:18:20 +0100 Subject: [PATCH 13/16] Raise version number after cloning 5.5.3-m3 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 0a040cc60ee..32acbfd3dad 100644 --- a/configure.in +++ b/configure.in @@ -27,7 +27,7 @@ AC_PREREQ(2.59) # Remember to also update version.c in ndb. # When changing major version number please also check switch statement # in client/mysqlbinlog.cc:check_master_version(). -AC_INIT([MySQL Server], [5.5.3-m3], [], [mysql]) +AC_INIT([MySQL Server], [5.5.4-m3], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM # USTAR format gives us the possibility to store longer path names in From c7c1f2198fe96a67cd90a73ee0f844c4a83cf2fa Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 15 Mar 2010 14:52:25 +0100 Subject: [PATCH 14/16] Bug #51160 Deadlock around SET GLOBAL EVENT_SCHEDULER = ON|OFF This deadlock could occour betweeen one connection executing SET GLOBAL EVENT_SCHEDULER= ON and another executing SET GLOBAL EVENT_SCHEDULER= OFF. The bug was introduced by WL#4738. The first connection would hold LOCK_event_metadata (protecting the global variable) while trying to lock LOCK_global_system_variables starting the event scheduler thread (in THD:init()). The second connection would hold LOCK_global_system_variables while trying to get LOCK_event_scheduler after stopping the event scheduler inside event_scheduler_update(). This patch fixes the problem by not using LOCK_event_metadata to protect the event_scheduler variable. It is still protected using LOCK_global_system_variables. This fixes the deadlock as it removes one of the two mutexes used to produce it. However, this patch opens up the possibility that the event_scheduler variable and the real event_scheduler state can become out of sync (e.g. variable = OFF, but scheduler running). But this can only happen under very unlikely conditions - two concurrent SET GLOBAL statments, with one thread interrupted at the exact wrong moment. This is preferable to having the possibility of a deadlock. This patch also fixes a bug where it was possible to exit create_event() without releasing LOCK_event_metadata if running out of memory during its exection. No test case added since a repeatable test case would have required excessive use of new sync points. Instead we rely on the fact that this bug was easily reproduceable using RGQ tests. --- sql/events.cc | 27 +++++++++++++++------------ sql/events.h | 8 +++----- sql/sys_vars.cc | 24 ++++++++++++++++-------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/sql/events.cc b/sql/events.cc index d8bf549321e..a2375b1274b 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysql_priv.h" #include "events.h" @@ -367,15 +367,14 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, { sql_print_error("Event Error: An error occurred while creating query string, " "before writing it into binary log."); - /* Restore the state of binlog format */ - DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); - if (save_binlog_row_based) - thd->set_current_stmt_binlog_format_row(); - DBUG_RETURN(TRUE); + ret= TRUE; + } + else + { + /* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER + will be written into the binary log as the definer for the SQL thread. */ + ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); } - /* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER - will be written into the binary log as the definer for the SQL thread. */ - ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); } } mysql_mutex_unlock(&LOCK_event_metadata); @@ -1017,7 +1016,11 @@ Events::dump_internal_status() puts("LLA = Last Locked At LUA = Last Unlocked At"); puts("WOC = Waiting On Condition DL = Data Locked"); - mysql_mutex_lock(&LOCK_event_metadata); + /* + opt_event_scheduler should only be accessed while + holding LOCK_global_system_variables. + */ + mysql_mutex_lock(&LOCK_global_system_variables); if (opt_event_scheduler == EVENTS_DISABLED) puts("The Event Scheduler is disabled"); else @@ -1026,7 +1029,7 @@ Events::dump_internal_status() event_queue->dump_internal_status(); } - mysql_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_global_system_variables); DBUG_VOID_RETURN; } diff --git a/sql/events.h b/sql/events.h index 881ade37cbf..380b0d97f0a 100644 --- a/sql/events.h +++ b/sql/events.h @@ -1,6 +1,6 @@ #ifndef _EVENT_H_ #define _EVENT_H_ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @defgroup Event_Scheduler Event Scheduler @@ -83,6 +83,7 @@ public: See sys_var.cc */ enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED }; + /* Protected using LOCK_global_system_variables only. */ static uint opt_event_scheduler; static mysql_mutex_t LOCK_event_metadata; static bool check_if_system_tables_error(); @@ -106,9 +107,6 @@ public: static void destroy_mutexes(); - static bool - switch_event_scheduler_state(enum enum_opt_event_scheduler new_state); - static bool create_event(THD *thd, Event_parse_data *parse_data, bool if_exists); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 2e239a9161c..e14286210b4 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* How to add new variables: @@ -647,32 +647,40 @@ static bool event_scheduler_check(sys_var *self, THD *thd, set_var *var) } static bool event_scheduler_update(sys_var *self, THD *thd, enum_var_type type) { + uint opt_event_scheduler_value= Events::opt_event_scheduler; mysql_mutex_unlock(&LOCK_global_system_variables); /* Events::start() is heavyweight. In particular it creates a new THD, which takes LOCK_global_system_variables internally. Thus we have to release it here. We need to re-take it before returning, though. - And we need to take it *without* holding Events::LOCK_event_metadata. + + Note that since we release LOCK_global_system_variables before calling + start/stop, there is a possibility that the server variable + can become out of sync with the real event scheduler state. + + This can happen with two concurrent statments if the first gets + interrupted after start/stop but before retaking + LOCK_global_system_variables. However, this problem should be quite + rare and it's difficult to avoid it without opening up possibilities + for deadlocks. See bug#51160. */ - bool ret= Events::opt_event_scheduler == Events::EVENTS_ON + bool ret= opt_event_scheduler_value == Events::EVENTS_ON ? Events::start() : Events::stop(); - mysql_mutex_unlock(&Events::LOCK_event_metadata); mysql_mutex_lock(&LOCK_global_system_variables); - mysql_mutex_lock(&Events::LOCK_event_metadata); if (ret) my_error(ER_EVENT_SET_VAR_ERROR, MYF(0)); return ret; } -static PolyLock_mutex PLock_event_metadata(&Events::LOCK_event_metadata); + static Sys_var_enum Sys_event_scheduler( "event_scheduler", "Enable the event scheduler. Possible values are " "ON, OFF, and DISABLED (keep the event scheduler completely " "deactivated, it cannot be activated run-time)", GLOBAL_VAR(Events::opt_event_scheduler), CMD_LINE(OPT_ARG), event_scheduler_names, DEFAULT(Events::EVENTS_OFF), - &PLock_event_metadata, NOT_IN_BINLOG, + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(event_scheduler_check), ON_UPDATE(event_scheduler_update)); #endif From 6be830e14bea8ec7c1707b0c505752bee6587203 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 15 Mar 2010 19:43:26 +0300 Subject: [PATCH 15/16] Enable ndb and rpl_ndb test suites in daily builds. --- mysql-test/collections/default.daily | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily index 52af68328c4..a95e5f4657d 100644 --- a/mysql-test/collections/default.daily +++ b/mysql-test/collections/default.daily @@ -2,3 +2,4 @@ perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collection perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded --vardir=var-emebbed --embedded perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 +perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_ndb_row --vardir=var-rpl_ndb_row --mysqld=--binlog-format=row --suite=rpl_ndb,ndb From c161a4876bd8d94cc5b3f6d2636240a859e66b23 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 15 Mar 2010 20:00:20 +0300 Subject: [PATCH 16/16] A patch for Bug#52071 (rpl_ndb.rpl_ndb_ctype_ucs2_def fails). Use new command line options instead of deprecated and removed ones. --- mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt index 84d2a52b639..711ec42bd8a 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt @@ -1 +1 @@ ---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1 +--collation-server=ucs2_unicode_ci --character-set-server=ucs2,latin1