summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt3
-rw-r--r--client/mysqlbinlog.cc19
-rw-r--r--configure.in104
-rw-r--r--include/Makefile.am1
-rw-r--r--include/config-win.h14
-rw-r--r--include/my_net.h16
-rw-r--r--include/my_rdtsc.h129
-rw-r--r--include/violite.h24
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_id.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_reset_slave.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_blob.test12
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_func003.test36
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_sp003.test5
-rw-r--r--mysql-test/extra/rpl_tests/rpl_stm_000001.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_trig004.test5
-rw-r--r--mysql-test/include/check_ipv6.inc14
-rw-r--r--mysql-test/include/ipv6.inc22
-rw-r--r--mysql-test/include/ipv6_clients.inc7
-rw-r--r--mysql-test/include/master-slave-reset.inc47
-rw-r--r--mysql-test/include/master-slave.inc9
-rw-r--r--mysql-test/include/not_ndb_default.inc2
-rw-r--r--mysql-test/include/rpl_ip_mix.inc24
-rw-r--r--mysql-test/include/rpl_ip_mix2.inc24
-rw-r--r--mysql-test/include/rpl_ipv6.inc22
-rw-r--r--mysql-test/include/wait_for_ndb_to_binlog.inc41
-rw-r--r--mysql-test/include/wait_show_condition.inc74
-rwxr-xr-xmysql-test/lib/v1/mysql-test-run.pl29
-rwxr-xr-xmysql-test/mysql-test-run.pl2
-rw-r--r--mysql-test/r/archive.result10
-rw-r--r--mysql-test/r/deprecated_features.result26
-rw-r--r--mysql-test/r/flush2.result2
-rw-r--r--mysql-test/r/ipv4_as_ipv6.result179
-rw-r--r--mysql-test/r/ipv4_as_ipv6_win.result32
-rw-r--r--mysql-test/r/ipv6.result264
-rw-r--r--mysql-test/r/ipv6_win.result88
-rw-r--r--mysql-test/r/myisampack.result33
-rw-r--r--mysql-test/r/partition.result19
-rw-r--r--mysql-test/r/ps_1general.result2
-rw-r--r--mysql-test/r/show_check.result7
-rw-r--r--mysql-test/r/signal_code.result16
-rw-r--r--mysql-test/r/sp-code.result4
-rw-r--r--mysql-test/r/sp-error.result20
-rw-r--r--mysql-test/r/sp.result9
-rw-r--r--mysql-test/r/sp_trans.result4
-rw-r--r--mysql-test/r/type_blob.result16
-rw-r--r--mysql-test/r/type_timestamp.result26
-rw-r--r--mysql-test/r/warnings.result3
-rw-r--r--mysql-test/suite/binlog/r/binlog_max_extension.result8
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result16
-rw-r--r--mysql-test/suite/binlog/r/binlog_tmp_table.result1
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result55
-rw-r--r--mysql-test/suite/binlog/t/binlog_max_extension.test92
-rw-r--r--mysql-test/suite/binlog/t/binlog_tmp_table.test1
-rw-r--r--mysql-test/suite/binlog/t/binlog_unsafe.test68
-rw-r--r--mysql-test/suite/rpl/my.cnf9
-rw-r--r--mysql-test/suite/rpl/r/rpl000017.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_000015.result44
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug33931.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug41902.result34
-rw-r--r--mysql-test/suite/rpl/r/rpl_empty_master_crash.result11
-rw-r--r--mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_heartbeat.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_ip_mix.result164
-rw-r--r--mysql-test/suite/rpl/r/rpl_ip_mix2.result180
-rw-r--r--mysql-test/suite/rpl/r/rpl_ip_mix2_win.result84
-rw-r--r--mysql-test/suite/rpl/r/rpl_ip_mix_win.result84
-rw-r--r--mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6.result110
-rw-r--r--mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6_win.result35
-rw-r--r--mysql-test/suite/rpl/r/rpl_ipv6.result155
-rw-r--r--mysql-test/suite/rpl/r/rpl_ipv6_win.result80
-rw-r--r--mysql-test/suite/rpl/r/rpl_load_from_master.result133
-rw-r--r--mysql-test/suite/rpl/r/rpl_load_table_from_master.result51
-rw-r--r--mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_reset_slave.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_show_slave_hosts.result17
-rw-r--r--mysql-test/suite/rpl/r/rpl_sp.result11
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_reset_slave.result3
-rw-r--r--mysql-test/suite/rpl/t/disabled.def4
-rw-r--r--mysql-test/suite/rpl/t/rpl000010.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl000011.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl000013.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl000017-slave.opt1
-rw-r--r--[-rwxr-xr-x]mysql-test/suite/rpl/t/rpl000017-slave.sh0
-rw-r--r--mysql-test/suite/rpl/t/rpl000017.test15
-rw-r--r--mysql-test/suite/rpl/t/rpl_000015-slave.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_000015.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_alter.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment_11932.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_bit.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_bit_npk.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug33931.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug41902-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug41902.test61
-rw-r--r--mysql-test/suite/rpl/t/rpl_change_master.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_colSize.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_do_grant.test16
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop_view.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_dual_pos_advance.test16
-rw-r--r--mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_empty_master_crash.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_err_ignoredtable.test16
-rw-r--r--[-rwxr-xr-x]mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh0
-rw-r--r--[-rwxr-xr-x]mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh0
-rw-r--r--mysql-test/suite/rpl/t/rpl_flushlog_loop.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix.test93
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix2.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix2.test109
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix2_win.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix2_win.test78
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix_win.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ip_mix_win.test65
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.test90
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.test63
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv6.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv6.test93
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv6_win.cnf56
-rw-r--r--mysql-test/suite/rpl/t/rpl_ipv6_win.test65
-rw-r--r--mysql-test/suite/rpl/t/rpl_known_bugs_detection.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_load_from_master.test181
-rw-r--r--mysql-test/suite/rpl/t/rpl_load_table_from_master.test98
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_charset.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_fatal.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_m.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_s.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddatalocal.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_master_pos_wait.test4
-rw-r--r--[-rwxr-xr-x]mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh0
-rw-r--r--mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete2.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_optimize.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_packet.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_ps.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_relayspace.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_replicate_do.test8
-rw-r--r--[-rwxr-xr-x]mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh0
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_create_table.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test28
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp001.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp005.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp008.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp009.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp010.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig002.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig003.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_server_id2.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_session_var.test21
-rw-r--r--mysql-test/suite/rpl/t/rpl_set_charset.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf20
-rw-r--r--mysql-test/suite/rpl/t/rpl_show_slave_hosts.test47
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_skip.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp-master.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp-slave.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp004.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_sporadic_master.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_ssl1.test19
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_until.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_temp_table.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_temporary.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_trigger.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_user_variables.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_variables_stm.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_view.test12
-rw-r--r--mysql-test/suite/rpl_ndb/my.cnf10
-rw-r--r--mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.cnf5
-rw-r--r--mysql-test/t/archive.test12
-rwxr-xr-xmysql-test/t/backup-master.sh5
-rw-r--r--mysql-test/t/backup.test104
-rw-r--r--mysql-test/t/deprecated_features.test27
-rw-r--r--mysql-test/t/ipv4_as_ipv6-master.opt1
-rw-r--r--mysql-test/t/ipv4_as_ipv6.test65
-rw-r--r--mysql-test/t/ipv4_as_ipv6_win-master.opt1
-rw-r--r--mysql-test/t/ipv4_as_ipv6_win.test31
-rw-r--r--mysql-test/t/ipv6-master.opt1
-rw-r--r--mysql-test/t/ipv6.test79
-rw-r--r--mysql-test/t/ipv6_win-master.opt1
-rw-r--r--mysql-test/t/ipv6_win.test39
-rw-r--r--mysql-test/t/myisampack.test114
-rw-r--r--mysql-test/t/partition.test39
-rw-r--r--mysql-test/t/ps_1general.test3
-rw-r--r--mysql-test/t/show_check.test14
-rw-r--r--mysql-test/t/skip_name_resolve.test2
-rw-r--r--mysql-test/t/sp-error.test19
-rw-r--r--mysql-test/t/sp.test7
-rw-r--r--mysql-test/t/sp_trans.test2
-rw-r--r--mysql-test/t/system_mysql_db_fix40123.test6
-rw-r--r--mysql-test/t/system_mysql_db_fix50030.test8
-rw-r--r--mysql-test/t/system_mysql_db_fix50117.test6
-rw-r--r--mysql-test/t/type_blob.test14
-rw-r--r--mysql-test/t/type_timestamp.test13
-rw-r--r--mysql-test/t/warnings.test5
-rwxr-xr-xmysys/CMakeLists.txt5
-rw-r--r--mysys/Makefile.am10
-rw-r--r--mysys/my_delete.c41
-rw-r--r--mysys/my_rdtsc.c1004
-rw-r--r--mysys/my_timer_cycles.il38
-rw-r--r--scripts/mysql_system_tables.sql6
-rw-r--r--scripts/mysql_system_tables_data.sql1
-rw-r--r--scripts/mysql_system_tables_fix.sql2
-rw-r--r--sql-common/client.c198
-rw-r--r--sql/client_settings.h4
-rw-r--r--sql/handler.cc30
-rw-r--r--sql/handler.h12
-rw-r--r--sql/hostname.cc593
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_cmpfunc.h1
-rw-r--r--sql/lex.h2
-rw-r--r--sql/log.cc118
-rw-r--r--sql/log.h14
-rw-r--r--sql/mysql_priv.h51
-rw-r--r--sql/mysqld.cc230
-rw-r--r--sql/repl_failsafe.cc332
-rw-r--r--sql/rpl_mi.cc64
-rw-r--r--sql/rpl_mi.h3
-rw-r--r--sql/rpl_rli.h10
-rw-r--r--sql/set_var.cc50
-rw-r--r--sql/set_var.h25
-rw-r--r--sql/share/errmsg.txt8
-rw-r--r--sql/slave.cc303
-rw-r--r--sql/sp_head.cc3
-rw-r--r--sql/sql_acl.cc81
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_connect.cc43
-rw-r--r--sql/sql_lex.h6
-rw-r--r--sql/sql_load.cc1
-rw-r--r--sql/sql_parse.cc174
-rw-r--r--sql/sql_repl.cc33
-rw-r--r--sql/sql_show.cc29
-rw-r--r--sql/sql_table.cc139
-rw-r--r--sql/sql_yacc.yy112
-rw-r--r--storage/archive/ha_archive.cc4
-rw-r--r--storage/myisam/ha_myisam.cc191
-rw-r--r--storage/myisam/ha_myisam.h6
-rw-r--r--storage/myisam/myisampack.c48
-rw-r--r--tests/mysql_client_test.c22
-rw-r--r--unittest/mysys/CMakeLists.txt35
-rw-r--r--unittest/mysys/Makefile.am5
-rw-r--r--unittest/mysys/my_rdtsc-t.c229
-rw-r--r--vio/vio.c4
-rw-r--r--vio/vio_priv.h5
-rw-r--r--vio/viosocket.c254
251 files changed, 6916 insertions, 3228 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a5ee9223bc..6e8c7db3c2a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,9 @@ ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MY
ADD_DEFINITIONS(-DPACKAGE=mysql)
ADD_DEFINITIONS(-DSHAREDIR="share")
+# Enable IPv6 handling code
+ADD_DEFINITIONS(-DHAVE_IPV6)
+
# Set debug options
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index f87f5b92f10..874b5a3d77a 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -442,6 +442,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
{
error("Could not construct local filename %s%s.",
target_dir_name,bname);
+ my_free(fname, MYF(0));
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@@ -449,9 +450,15 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
rec.fname= fname;
rec.event= ce;
+ /*
+ fname is freed in process_event()
+ after Execute_load_query_log_event or Execute_load_log_event
+ will have been processed, otherwise in Load_log_processor::destroy()
+ */
if (set_dynamic(&file_names, (uchar*)&rec, file_id))
{
error("Out of memory.");
+ my_free(fname, MYF(0));
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@@ -831,7 +838,17 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
print_event_info->common_header_len=
glob_description_event->common_header_len;
ev->print(result_file, print_event_info);
- ev->temp_buf= 0; // as the event ref is zeroed
+ if (!remote_opt)
+ {
+ ev->free_temp_buf(); // free memory allocated in dump_local_log_entries
+ }
+ else
+ {
+ /*
+ disassociate but not free dump_remote_log_entries time memory
+ */
+ ev->temp_buf= 0;
+ }
/*
We don't want this event to be deleted now, so let's hide it (I
(Guilhem) should later see if this triggers a non-serious Valgrind
diff --git a/configure.in b/configure.in
index 361d117b2dc..c7fc07b3f88 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,21 @@
dnl -*- ksh -*-
dnl Process this file with autoconf to produce a configure script.
+# Copyright (C) 2008-2009 Sun Microsystems, Inc
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
AC_PREREQ(2.52)dnl Minimum Autoconf version required.
AC_INIT(sql/mysqld.cc)
@@ -864,6 +879,42 @@ AC_CHECK_DECLS(MHA_MAPSIZE_VA,
fi
#--------------------------------------------------------------------
+# Check for IPv6 support
+#--------------------------------------------------------------------
+
+AC_CHECK_HEADERS(netinet/in6.h)
+
+AC_CHECK_TYPES([struct sockaddr_in6, struct in6_addr],
+ [have_in6_types=yes],
+ [have_in6_types=no],
+ [[
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <sys/socket.h>
+ #endif
+
+ #ifdef HAVE_NETINET_IN6_H
+ #include <netinet/in6.h>
+ #endif
+ ]])
+
+AC_MSG_CHECKING([for IPv6 support])
+
+AC_ARG_ENABLE(ipv6,
+ AS_HELP_STRING([--disable-ipv6], [Disable support for IPv6 networking]),
+ [disable_ipv6=yes], [disable_ipv6=no])
+
+if test x"$disable_ipv6" = xyes -o x"$have_in6_types" = xno; then
+ AC_MSG_RESULT([no])
+else
+ AC_DEFINE([HAVE_IPV6], [1], [Define if IPv6 networking support is present])
+ AC_MSG_RESULT([yes])
+fi
+
+#--------------------------------------------------------------------
# Check for TCP wrapper support
#--------------------------------------------------------------------
@@ -961,12 +1012,6 @@ AC_CHECK_TYPES([int8, uint8, int16, uint16, int32, uint32, int64, uint64,
uchar, uint, ulong],[],[], [
#include <sys/types.h>
])
-AC_CHECK_TYPES([in_addr_t], [], [], [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-])
AC_CHECK_TYPES([fp_except], [], [], [
#include <sys/types.h>
#include <ieeefp.h>
@@ -2914,7 +2959,54 @@ case $SYSTEM_TYPE in
esac
AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
+#--------------------------------------------------------------------
+# Support for WL#2373 (Use cycle counter for timing)
+#--------------------------------------------------------------------
+
+AC_CHECK_HEADERS(time.h)
+AC_CHECK_HEADERS(sys/time.h)
+AC_CHECK_HEADERS(sys/times.h)
+AC_CHECK_HEADERS(asm/msr.h)
+#msr.h has rdtscll()
+
+AC_CHECK_HEADERS(ia64intrin.h)
+
+AC_CHECK_FUNCS(times)
+AC_CHECK_FUNCS(gettimeofday)
+AC_CHECK_FUNCS(read_real_time)
+# This should work on AIX.
+
+AC_CHECK_FUNCS(ftime)
+# This is still a normal call for milliseconds.
+
+AC_CHECK_FUNCS(time)
+# We can use time() on Macintosh if there is no ftime().
+
+AC_CHECK_FUNCS(rdtscll)
+# I doubt that we'll ever reach the check for this.
+
+# When compiling with Sun Studio C / C++ we need to include
+# my_timer_cycles.il, an "inline templates" separate file,
+# on the command line. It has assembly code, "rd %tick" for
+# SPARC or "rdtsc" for x86.
+RDTSC_SPARC_ASSEMBLY=""
+case $CC_VERSION in
+ *Sun*C*)
+ RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
+ ;;
+esac
+case $CXX_VERSION in
+ *Sun*C++*)
+ RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
+ ;;
+esac
+
+AC_SUBST([RDTSC_SPARC_ASSEMBLY])
+
+#--------------------------------------------------------------------
# Output results
+#--------------------------------------------------------------------
+
if test -d "$srcdir/pstack" ; then
AC_CONFIG_FILES(pstack/Makefile pstack/aout/Makefile)
fi
diff --git a/include/Makefile.am b/include/Makefile.am
index 83a22f1beec..fff162474a5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -38,6 +38,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
my_handler.h my_time.h service_versions.h \
+ my_rdtsc.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
diff --git a/include/config-win.h b/include/config-win.h
index 431bfcfa702..68248c09bef 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -20,6 +20,13 @@
#define BIG_TABLES
+/*
+ Minimal version of Windows we should be able to run on.
+ Currently Windows XP.
+*/
+#define _WIN32_WINNT 0x0501
+
+
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
@@ -27,6 +34,7 @@
#include <sys/locking.h>
#include <winsock2.h>
+#include <Ws2tcpip.h>
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
@@ -88,6 +96,12 @@
#define S_IROTH S_IREAD /* for my_lib */
+/* Winsock2 constant (Vista SDK and later)*/
+#define IPPROTO_IPV6 41
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
#ifdef __BORLANDC__
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
#define O_TEMPORARY 0
diff --git a/include/my_net.h b/include/my_net.h
index 3af79ea3db5..18fb3db8e88 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -43,7 +43,7 @@ C_MODE_START
#include <sys/ioctl.h>
#endif
-#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__NETWARE__)
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -73,11 +73,6 @@ C_MODE_START
#define in_addr_t uint32
#endif
-/* On some operating systems (e.g. Solaris) INADDR_NONE is not defined */
-#ifndef INADDR_NONE
-#define INADDR_NONE -1 /* Error value from inet_addr */
-#endif
-
/* Thread safe or portable version of some functions */
void my_inet_ntoa(struct in_addr in, char *buf);
@@ -86,9 +81,6 @@ void my_inet_ntoa(struct in_addr in, char *buf);
Handling of gethostbyname_r()
*/
-#if !defined(HPUX10)
-struct hostent;
-#endif /* HPUX */
#if !defined(HAVE_GETHOSTBYNAME_R)
struct hostent *my_gethostbyname_r(const char *name,
struct hostent *result, char *buffer,
@@ -118,11 +110,5 @@ struct hostent *my_gethostbyname_r(const char *name,
#define GETHOSTBYNAME_BUFF_SIZE 2048
#endif
-/* On SCO you get a link error when refering to h_errno */
-#ifdef SCO
-#undef h_errno
-#define h_errno errno
-#endif
-
C_MODE_END
#endif
diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h
new file mode 100644
index 00000000000..81bc1aafb58
--- /dev/null
+++ b/include/my_rdtsc.h
@@ -0,0 +1,129 @@
+/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ rdtsc3 -- multi-platform timer code
+ pgulutzan@mysql.com, 2005-08-29
+ modified 2008-11-02
+*/
+
+#ifndef MY_RDTSC_H
+#define MY_RDTSC_H
+
+/**
+ Characteristics of a timer.
+*/
+struct my_timer_unit_info
+{
+ /** Routine used for the timer. */
+ ulonglong routine;
+ /** Overhead of the timer. */
+ ulonglong overhead;
+ /** Frequency of the timer. */
+ ulonglong frequency;
+ /** Resolution of the timer. */
+ ulonglong resolution;
+};
+
+/**
+ Characteristics of all the supported timers.
+ @sa my_timer_init().
+*/
+struct my_timer_info
+{
+ /** Characteristics of the cycle timer. */
+ struct my_timer_unit_info cycles;
+ /** Characteristics of the nanosecond timer. */
+ struct my_timer_unit_info nanoseconds;
+ /** Characteristics of the microsecond timer. */
+ struct my_timer_unit_info microseconds;
+ /** Characteristics of the millisecond timer. */
+ struct my_timer_unit_info milliseconds;
+ /** Characteristics of the tick timer. */
+ struct my_timer_unit_info ticks;
+};
+
+typedef struct my_timer_info MY_TIMER_INFO;
+
+C_MODE_START
+
+/**
+ A cycle timer.
+ @return the current timer value, in cycles.
+*/
+ulonglong my_timer_cycles(void);
+
+/**
+ A namoseconds timer.
+ @return the current timer value, in nanoseconds.
+*/
+ulonglong my_timer_nanoseconds(void);
+
+/**
+ A microseconds timer.
+ @return the current timer value, in microseconds.
+*/
+ulonglong my_timer_microseconds(void);
+
+/**
+ A millisecond timer.
+ @return the current timer value, in milliseconds.
+*/
+ulonglong my_timer_milliseconds(void);
+
+/**
+ A ticks timer.
+ @return the current timer value, in ticks.
+*/
+ulonglong my_timer_ticks(void);
+
+/**
+ Timer initialization function.
+ @param [out] mti the timer characteristics.
+*/
+void my_timer_init(MY_TIMER_INFO *mti);
+
+C_MODE_END
+
+#define MY_TIMER_ROUTINE_ASM_X86 1
+#define MY_TIMER_ROUTINE_ASM_X86_64 2
+#define MY_TIMER_ROUTINE_RDTSCLL 3
+#define MY_TIMER_ROUTINE_ASM_X86_WIN 4
+#define MY_TIMER_ROUTINE_RDTSC 5
+#define MY_TIMER_ROUTINE_ASM_IA64 6
+#define MY_TIMER_ROUTINE_ASM_PPC 7
+#define MY_TIMER_ROUTINE_SGI_CYCLE 8
+#define MY_TIMER_ROUTINE_GETHRTIME 9
+#define MY_TIMER_ROUTINE_READ_REAL_TIME 10
+#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
+#define MY_TIMER_ROUTINE_NXGETTIME 12
+#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
+#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
+#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
+#define MY_TIMER_ROUTINE_TIME 16
+#define MY_TIMER_ROUTINE_TIMES 17
+#define MY_TIMER_ROUTINE_FTIME 18
+#define MY_TIMER_ROUTINE_ASM_PPC64 19
+#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20
+#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21
+#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
+#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
+#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
+#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
+#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
+#define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27
+
+#endif
+
diff --git a/include/violite.h b/include/violite.h
index 3e8e430392b..eed6c46271f 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -81,13 +81,19 @@ int vio_errno(Vio*vio);
/* Get socket number */
my_socket vio_fd(Vio*vio);
/* Remote peer's address and name in text form */
-my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
-/* Remotes in_addr */
-void vio_in_addr(Vio *vio, struct in_addr *in);
+my_bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
my_bool vio_poll_read(Vio *vio, uint timeout);
my_bool vio_is_connected(Vio *vio);
ssize_t vio_pending(Vio *vio);
+my_bool vio_get_normalized_ip_string(const struct sockaddr *addr, int addr_length,
+ char *ip_string, size_t ip_string_size);
+
+int vio_getnameinfo(const struct sockaddr *sa,
+ char *hostname, size_t hostname_size,
+ char *port, size_t port_size,
+ int flags);
+
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER < 0x0090700f
@@ -154,8 +160,7 @@ void vio_end(void);
#define vio_should_retry(vio) (vio)->should_retry(vio)
#define vio_was_interrupted(vio) (vio)->was_interrupted(vio)
#define vio_close(vio) ((vio)->vioclose)(vio)
-#define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt)
-#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
+#define vio_peer_addr(vio, buf, prt, buflen) (vio)->peer_addr(vio, buf, prt, buflen)
#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
#define vio_poll_read(vio, timeout) (vio)->poll_read(vio, timeout)
#define vio_is_connected(vio) (vio)->is_connected(vio)
@@ -180,8 +185,9 @@ struct st_vio
HANDLE hPipe;
my_bool localhost; /* Are we from localhost? */
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
- struct sockaddr_in local; /* Local internet address */
- struct sockaddr_in remote; /* Remote internet address */
+ struct sockaddr_storage local; /* Local internet address */
+ struct sockaddr_storage remote; /* Remote internet address */
+ int addrLen; /* Length of remote address */
enum enum_vio_type type; /* Type of connection */
char desc[30]; /* String description */
char *read_buffer; /* buffer for vio_read_buff */
@@ -197,8 +203,8 @@ struct st_vio
my_bool (*is_blocking)(Vio*);
int (*viokeepalive)(Vio*, my_bool);
int (*fastsend)(Vio*);
- my_bool (*peer_addr)(Vio*, char *, uint16*);
- void (*in_addr)(Vio*, struct in_addr*);
+ my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
+ void (*in_addr)(Vio*, struct sockaddr_storage*);
my_bool (*should_retry)(Vio*);
my_bool (*was_interrupted)(Vio*);
int (*vioclose)(Vio*);
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index 3bb66c0eb1a..062dddaaf40 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -81,4 +81,3 @@ parts.partition_syntax_ndb
parts.partition_alter1_1_2_ndb
parts.partition_basic_ndb
parts.partition_mgm_lc0_ndb
-
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test
index bd815d9de02..b076e73a215 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_id.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test
@@ -179,7 +179,9 @@ begin
end|
delimiter ;|
+--disable_warnings
insert into t1 (last_id) values (0);
+--enable_warnings
drop trigger t1_bi;
@@ -512,7 +514,9 @@ set sql_log_bin=0;
insert into t2 (id) values(5),(6),(7);
delete from t2 where id>=5;
set sql_log_bin=1;
+--disable_warnings
insert into t1 select insid();
+--enable_warnings
select * from t1 order by id;
select * from t2 order by id;
diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
index 1f88c792fce..428554ac598 100644
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
@@ -22,6 +22,7 @@ source include/show_slave_status2.inc;
reset slave;
source include/show_slave_status2.inc;
+change master to master_user='root';
start slave;
sync_with_master;
source include/show_slave_status2.inc;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_blob.test b/mysql-test/extra/rpl_tests/rpl_row_blob.test
index 080df7d75dd..762daa816c0 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_blob.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_blob.test
@@ -36,7 +36,7 @@ SELECT LENGTH(data) FROM test.t1 WHERE c1 = 3;
save_master_pos;
connection slave;
sync_with_master;
-sleep 5;
+--source include/wait_for_ndb_to_binlog.inc
--echo
--echo **** Data Insert Validation Slave Section test.t1 ****
--echo
@@ -56,12 +56,10 @@ UPDATE t1 set data=repeat('c',17*1024) where c1 = 2;
--echo
SELECT LENGTH(data) FROM test.t1 WHERE c1 = 1;
SELECT LENGTH(data) FROM test.t1 WHERE c1 = 2;
-# Sleep is needed for NDB to allow time for
-# Injector thread to populate the bin log.
save_master_pos;
connection slave;
sync_with_master;
-sleep 5;
+--source include/wait_for_ndb_to_binlog.inc
--echo
--echo **** Data Update Validation Slave Section test.t1 ****
--echo
@@ -132,7 +130,7 @@ FROM test.t2 WHERE c1=2;
save_master_pos;
connection slave;
sync_with_master;
-sleep 5;
+--source include/wait_for_ndb_to_binlog.inc
--echo
--echo **** Data Insert Validation Slave Section test.t2 ****
--echo
@@ -155,12 +153,10 @@ SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
FROM test.t2 WHERE c1=1;
SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
FROM test.t2 WHERE c1=2;
-# Sleep is needed for NDB to allow time for
-# Injector thread to populate the bin log.
save_master_pos;
connection slave;
sync_with_master;
-sleep 5;
+--source include/wait_for_ndb_to_binlog.inc
--echo
--echo **** Data Update Validation Slave Section test.t2 ****
--echo
diff --git a/mysql-test/extra/rpl_tests/rpl_row_func003.test b/mysql-test/extra/rpl_tests/rpl_row_func003.test
index 8ee2d863527..e72ab04aec3 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_func003.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_func003.test
@@ -3,10 +3,7 @@
# Original Date: Aug/15/2005 #
# Update: 08/29/2005 Comment out sleep. Only needed for debugging #
#############################################################################
-# Note: Many lines are commented out in this test case. These were used for #
-# creating the test case and debugging and are being left for #
-# debugging, but they can not be used for the regular testing as the #
-# Time changes and is not deteministic, so instead we dump both the #
+# Note: Time changes and is not deteministic, so instead we dump both the #
# master and slave and diff the dumps. If the dumps differ then the #
# test case will fail. To run during diff failuers, comment out the #
# diff. #
@@ -26,7 +23,6 @@ DROP TABLE IF EXISTS test.t1;
--enable_warnings
-
eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
delimiter |;
@@ -44,33 +40,24 @@ END|
delimiter ;|
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
-sleep 6;
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
-sleep 6;
-
-#Select in this test are used for debugging
-#select * from test.t1;
-#connection slave;
-#select * from test.t1;
-connection master;
SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO test.t1 VALUES (null,test.f1());
ROLLBACK;
SET AUTOCOMMIT=1;
-#select * from test.t1;
-#sleep 6;
-
-#connection slave;
-#select * from test.t1;
-
-#connection master;
-#used for debugging
-#show binlog events;
+# Sync master and slave for all engines except NDB
+if (`SELECT UPPER(LEFT('$engine_type', 3)) != 'NDB'`) {
+ sync_slave_with_master;
+ connection master;
+}
+# Sync master and slave for NDB engine
+let $wait_time= 6;
+--source include/wait_for_ndb_to_binlog.inc
-# time to dump the databases and so we can see if they match
+# Time to dump the databases and so we can see if they match
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
@@ -87,5 +74,8 @@ DROP TABLE test.t1;
diff_files $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
+# Clean up
+remove_file $MYSQLTEST_VARDIR/tmp/func003_master.sql;
+remove_file $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
# End of 5.0 test case
diff --git a/mysql-test/extra/rpl_tests/rpl_row_sp003.test b/mysql-test/extra/rpl_tests/rpl_row_sp003.test
index 7cf3d0fa19c..7bc326a3791 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_sp003.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_sp003.test
@@ -41,10 +41,7 @@ CALL test.p2();
SELECT release_lock("test");
SELECT * FROM test.t1;
#show binlog events;
-# Added sleep for use with NDB to ensure that
-# the injector thread will populate log before
-# we switch to the slave.
-sleep 5;
+--source include/wait_for_ndb_to_binlog.inc
sync_slave_with_master;
connection slave;
SELECT * FROM test.t1;
diff --git a/mysql-test/extra/rpl_tests/rpl_stm_000001.test b/mysql-test/extra/rpl_tests/rpl_stm_000001.test
index 869a9e3b07c..323d626c95f 100644
--- a/mysql-test/extra/rpl_tests/rpl_stm_000001.test
+++ b/mysql-test/extra/rpl_tests/rpl_stm_000001.test
@@ -68,8 +68,8 @@ enable_query_log;
connection slave;
lock tables t1 read;
start slave;
-#hope this is long enough for I/O thread to fetch over 16K relay log data
-sleep 3;
+connection master;
+--source include/sync_slave_io_with_master.inc
unlock tables;
#test handling of aborted connection in the middle of update
diff --git a/mysql-test/extra/rpl_tests/rpl_trig004.test b/mysql-test/extra/rpl_tests/rpl_trig004.test
index 45cb11f2787..1a738db27fc 100644
--- a/mysql-test/extra/rpl_tests/rpl_trig004.test
+++ b/mysql-test/extra/rpl_tests/rpl_trig004.test
@@ -35,9 +35,8 @@ INSERT INTO test.t2 VALUES (1, 0.0);
#show binlog events;
select * from test.t1;
select * from test.t2;
-# Have to sleep for a few seconds to allow
-# NDB injector thread to populate binlog
-sleep 10;
+let $wait_time= 10;
+--source include/wait_for_ndb_to_binlog.inc
sync_slave_with_master;
connection slave;
select * from test.t1;
diff --git a/mysql-test/include/check_ipv6.inc b/mysql-test/include/check_ipv6.inc
new file mode 100644
index 00000000000..14d04b11e83
--- /dev/null
+++ b/mysql-test/include/check_ipv6.inc
@@ -0,0 +1,14 @@
+# Check if ipv6 is available. If not, server is crashing (see BUG#48915).
+--disable_query_log
+--disable_abort_on_error
+connect (checkcon123456789,::1,root,,test);
+if($mysql_errno)
+{
+skip wrong IP;
+}
+connection default;
+disconnect checkcon123456789;
+--enable_abort_on_error
+--enable_query_log
+# end check
+
diff --git a/mysql-test/include/ipv6.inc b/mysql-test/include/ipv6.inc
new file mode 100644
index 00000000000..378733dd03a
--- /dev/null
+++ b/mysql-test/include/ipv6.inc
@@ -0,0 +1,22 @@
+eval CREATE USER testuser@'$IPv6' identified by '1234';
+eval GRANT ALL ON test.* TO testuser@'$IPv6';
+eval SHOW GRANTS FOR testuser@'$IPv6';
+# deliver NULL instead of a valid number, see bug#34037
+eval SET @nip= inet_aton('$IPv6');
+SELECT @nip;
+SELECT inet_ntoa(@nip);
+# delivers a wrong value, see bug#34037
+SELECT USER();
+SELECT current_user();
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+connect (con1, $IPv6, root, , test, $MASTER_MYPORT);
+connection default;
+disconnect con1;
+eval REVOKE ALL ON test.* FROM testuser@'$IPv6';
+eval RENAME USER testuser@'$IPv6' to testuser1@'$IPv6';
+eval SET PASSWORD FOR testuser1@'$IPv6' = PASSWORD ('9876');
+SELECT USER();
+eval DROP USER testuser1@'$IPv6';
+
diff --git a/mysql-test/include/ipv6_clients.inc b/mysql-test/include/ipv6_clients.inc
new file mode 100644
index 00000000000..3f2b35d811a
--- /dev/null
+++ b/mysql-test/include/ipv6_clients.inc
@@ -0,0 +1,7 @@
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -h $IPv6 -P $MASTER_MYPORT -u root ping
+--disable_result_log
+--exec $MYSQL_CHECK -h $IPv6 -P $MASTER_MYPORT -u root test
+--exec $MYSQL_DUMP -h $IPv6 -P $MASTER_MYPORT -u root test
+--exec $MYSQL_SHOW -h $IPv6 -P $MASTER_MYPORT -u root
+--exec $MYSQL --host=$IPv6 --port=$MASTER_MYPORT --user=root test -e "SELECT current_user();SELECT user();"
+--enable_result_log
diff --git a/mysql-test/include/master-slave-reset.inc b/mysql-test/include/master-slave-reset.inc
index 938eb2c074a..f54f5b83eb5 100644
--- a/mysql-test/include/master-slave-reset.inc
+++ b/mysql-test/include/master-slave-reset.inc
@@ -6,12 +6,29 @@
# Since we expect STOP SLAVE to produce a warning as the slave is
# stopped (the server was started with skip-slave-start), we disable
# warnings when doing STOP SLAVE.
+#
+# $no_change_master If true, no change master will be done nor any reset slave.
+# This is to avoid touching the relay-log.info file allowing
+# the test to create one itself.
+# $skip_slave_start If true, the slave will not be started
connection slave;
+
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
+--disable_query_log
+if (!$no_change_master) {
+ eval CHANGE MASTER TO MASTER_USER='root',
+ MASTER_CONNECT_RETRY=1,
+ MASTER_HOST='127.0.0.1',
+ MASTER_PORT=$MASTER_MYPORT;
+}
+--enable_query_log
source include/wait_for_slave_to_stop.inc;
--enable_warnings
+
connection master;
--disable_warnings
--disable_query_log
@@ -20,17 +37,39 @@ use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
reset master;
+
--disable_query_log
-reset slave;
+if (!$no_change_master) {
+ reset slave;
+}
--enable_query_log
connection slave;
-reset slave;
+
+--disable_warnings
+# the first RESET SLAVE may produce a warning about non-existent
+# 'ndb_apply_status' table, because this table is created
+# asynchronously at the server startup and may not exist yet
+# if RESET SLAVE comes too soon after the server startup
+if (!$no_change_master) {
+ reset slave;
+}
+--enable_warnings
+
# Clean up old test tables
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
+
--disable_query_log
+#eval CHANGE MASTER TO MASTER_USER='root',
+# MASTER_CONNECT_RETRY=1,
+# MASTER_HOST='127.0.0.1',
+# MASTER_PORT=$MASTER_MYPORT;
reset master;
--enable_query_log
-start slave;
-source include/wait_for_slave_to_start.inc;
+
+if (!$skip_slave_start) {
+ start slave;
+ source include/wait_for_slave_to_start.inc;
+}
+
diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc
index 25e0150dd0a..134bb61ddab 100644
--- a/mysql-test/include/master-slave.inc
+++ b/mysql-test/include/master-slave.inc
@@ -1,4 +1,6 @@
# Replication tests need binlog
+#
+# $skip_slave_start If true, the slave will not be started
source include/have_log_bin.inc;
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
@@ -8,7 +10,10 @@ connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
-- source include/master-slave-reset.inc
-connection master;
-sync_slave_with_master;
+if (!$skip_slave_start) {
+ connection master;
+ sync_slave_with_master;
+}
+
# Set the default connection to 'master'
connection master;
diff --git a/mysql-test/include/not_ndb_default.inc b/mysql-test/include/not_ndb_default.inc
index ca3c57a671a..682a2944171 100644
--- a/mysql-test/include/not_ndb_default.inc
+++ b/mysql-test/include/not_ndb_default.inc
@@ -1,4 +1,4 @@
--require r/not_ndb_default.require
disable_query_log;
-select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE";
+select convert(@@storage_engine using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE";
enable_query_log;
diff --git a/mysql-test/include/rpl_ip_mix.inc b/mysql-test/include/rpl_ip_mix.inc
new file mode 100644
index 00000000000..96766e7dbdd
--- /dev/null
+++ b/mysql-test/include/rpl_ip_mix.inc
@@ -0,0 +1,24 @@
+--echo connect (master,$IPv6,root,,test,MASTER_MYPORT);
+connect (master,$IPv6,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/include/rpl_ip_mix2.inc b/mysql-test/include/rpl_ip_mix2.inc
new file mode 100644
index 00000000000..390c788a461
--- /dev/null
+++ b/mysql-test/include/rpl_ip_mix2.inc
@@ -0,0 +1,24 @@
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT);
+connect (slave,$IPv6,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/include/rpl_ipv6.inc b/mysql-test/include/rpl_ipv6.inc
new file mode 100644
index 00000000000..d2d53a4841a
--- /dev/null
+++ b/mysql-test/include/rpl_ipv6.inc
@@ -0,0 +1,22 @@
+--echo connect (master,$IPv6,root,,test,MASTER_MYPORT);
+connect (master,$IPv6,root,,test,$MASTER_MYPORT);
+--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT);
+connect (slave,$IPv6,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/include/wait_for_ndb_to_binlog.inc b/mysql-test/include/wait_for_ndb_to_binlog.inc
new file mode 100644
index 00000000000..77da6d62154
--- /dev/null
+++ b/mysql-test/include/wait_for_ndb_to_binlog.inc
@@ -0,0 +1,41 @@
+# ==== Purpose ====
+#
+# Several test primitives from mysql-test/extra/rpl_tests
+# shared for test cases for MyISAM, InnoDB, NDB and other
+# engines. But for NDB all events will be added by NDB
+# injector and now there are no way to detect the state of
+# NDB injector therefore this primitive waits 5 sec
+# if engine type is NDB.
+# In future that should be fixed by waiting of proper
+# state of NDB injector.
+#
+# ==== Usage ====
+#
+# let $engine_type= NDB;
+# --source include/wait_for_ndb_to_binlog.inc
+#
+# ==== Parameters =====
+#
+# $engine_type
+# Type of engine. If type is NDB then it waits $wait_time sec
+#
+# $wait_time
+# Test will wait $wait_time seconds
+
+let $_wait_time= 5;
+
+if (!$wait_time) {
+ let $_wait_time= $wait_time;
+}
+
+if (`SELECT UPPER(LEFT('$engine_type',3)) = 'NDB'`) {
+ while (!$_wait_time) {
+ let $_wait_time_internal= 10;
+ while (!$_wait_time_internal) {
+ sleep 0.1;
+ dec $_wait_time_internal;
+ }
+ dec $_wait_time;
+ }
+}
+
diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc
index 253101d1e07..f683ca7b47b 100644
--- a/mysql-test/include/wait_show_condition.inc
+++ b/mysql-test/include/wait_show_condition.inc
@@ -2,13 +2,16 @@
#
# SUMMARY
#
-# Waits until the show statement ($show_statement) has at least within one of
-# the rows of the result set for the field ($field) a value which fulfils
+# Waits until the show statement ($show_statement) has one or all of the
+# rows of the result set for the field ($field) a value which fulfils
# a condition ($condition), or the operation times out.
#
#
# USAGE
#
+# All rows of the result must fulfil the condition if $all_rows_fulfil is 1
+# else at least one of the result must fulfil the condition.
+# let $wait_for_all= 1;
# let $show_statement= SHOW PROCESSLIST;
# let $field= State;
# let $condition= = 'Updating';
@@ -46,27 +49,56 @@ inc $max_run_time;
let $found= 0;
let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`;
-while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
+
+if (`SELECT '$wait_for_all' != '1'`)
{
- # Sleep a bit to avoid too heavy load.
- real_sleep 0.2;
- let $rowno= 1;
- let $process_result= 1;
- while (`SELECT $process_result = 1 AND $found = 0`)
- {
- let $field_value= query_get_value($show_statement, $field, $rowno);
- if (`SELECT '$field_value' $condition`)
- {
- let $found= 1;
- }
- if (`SELECT '$field_value' = 'No such row'`)
- {
- # We are behind the last row of the result set.
- let $process_result= 0;
- }
- inc $rowno;
- }
+ while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
+ {
+ # Sleep a bit to avoid too heavy load.
+ real_sleep 0.2;
+ let $rowno= 1;
+ let $process_result= 1;
+ while (`SELECT $process_result = 1 AND $found = 0`)
+ {
+ let $field_value= query_get_value($show_statement, $field, $rowno);
+ if (`SELECT '$field_value' $condition`)
+ {
+ let $found= 1;
+ }
+ if (`SELECT '$field_value' = 'No such row'`)
+ {
+ # We are behind the last row of the result set.
+ let $process_result= 0;
+ }
+ inc $rowno;
+ }
+ }
}
+
+if (`SELECT '$wait_for_all' = '1'`)
+{
+ while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
+ {
+ # Sleep a bit to avoid too heavy load.
+ real_sleep 0.2;
+ let $rowno= 1;
+ let $process_result= 1;
+ while (`SELECT $process_result = 1 AND $found = 0`)
+ {
+ let $field_value= query_get_value($show_statement, $field, $rowno);
+ if (`SELECT '$field_value' = 'No such row'`)
+ {
+ let $found= 1;
+ }
+ if (`SELECT $found = 0 AND NOT '$field_value' $condition`)
+ {
+ let process_result= 0;
+ }
+ inc $rowno;
+ }
+ }
+}
+
if (!$found)
{
echo # Timeout in include/wait_show_condition.inc for $wait_condition;
diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl
index 86ad5c485c1..9ae3208fc24 100755
--- a/mysql-test/lib/v1/mysql-test-run.pl
+++ b/mysql-test/lib/v1/mysql-test-run.pl
@@ -4024,15 +4024,26 @@ sub mysqld_arguments ($$$$) {
}
else
{
- if ($mysql_version_id < 50200)
- {
- mtr_add_arg($args, "%s--master-user=root", $prefix);
- mtr_add_arg($args, "%s--master-connect-retry=1", $prefix);
- mtr_add_arg($args, "%s--master-host=127.0.0.1", $prefix);
- mtr_add_arg($args, "%s--master-password=", $prefix);
- mtr_add_arg($args, "%s--master-port=%d", $prefix,
- $master->[0]->{'port'}); # First master
- }
+# NOTE: the backport (see BUG#48048) originally removed the
+# commented out lines below. However, given that they are
+# protected with a version check (< 50200) now, it should be
+# safe to keep them. The problem is that the backported patch
+# was into a 5.1 GA codebase - mysql-5.1-rep+2 tree - so
+# version is 501XX, consequently check becomes worthless. It
+# should be safe to uncomment them when merging up to 5.5.
+#
+# RQG semisync test runs on the 5.1 GA tree and needs MTR v1.
+# This was causing the test to fail (slave would not start
+# due to unrecognized option(s)).
+# if ($mysql_version_id < 50200)
+# {
+# mtr_add_arg($args, "%s--master-user=root", $prefix);
+# mtr_add_arg($args, "%s--master-connect-retry=1", $prefix);
+# mtr_add_arg($args, "%s--master-host=127.0.0.1", $prefix);
+# mtr_add_arg($args, "%s--master-password=", $prefix);
+# mtr_add_arg($args, "%s--master-port=%d", $prefix,
+# $master->[0]->{'port'}); # First master
+# }
my $slave_server_id= 2 + $idx;
my $slave_rpl_rank= $slave_server_id;
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index f76cb008c3c..a99989137e2 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -68,7 +68,7 @@ use My::File::Path; # Patched version of File::Path
use File::Basename;
use File::Copy;
use File::Find;
-use File::Temp qw / tempdir /;
+use File::Temp qw /tempdir/;
use File::Spec::Functions qw / splitdir /;
use My::Platform;
use My::SafeProcess;
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index e865d775c6a..a250821d12b 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -12717,3 +12717,13 @@ COUNT(t1.a)
729
DROP TABLE t1;
SET @@join_buffer_size= @save_join_buffer_size;
+End of 5.1 tests
+CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t1 VALUES(NULL,'a'),(NULL,'a');
+CREATE TABLE t2(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
+SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
+id id name name
+1 1 a b
+2 2 a b
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/deprecated_features.result b/mysql-test/r/deprecated_features.result
new file mode 100644
index 00000000000..ecfb830542d
--- /dev/null
+++ b/mysql-test/r/deprecated_features.result
@@ -0,0 +1,26 @@
+set global log_bin_trust_routine_creators=1;
+ERROR HY000: Unknown system variable 'log_bin_trust_routine_creators'
+set table_type='MyISAM';
+ERROR HY000: Unknown system variable 'table_type'
+select @@table_type='MyISAM';
+ERROR HY000: Unknown system variable 'table_type'
+backup table t1 to 'data.txt';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'backup table t1 to 'data.txt'' at line 1
+restore table t1 from 'data.txt';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'restore table t1 from 'data.txt'' at line 1
+show plugin;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'plugin' at line 1
+load table t1 from master;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table t1 from master' at line 1
+load data from master;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from master' at line 1
+SHOW INNODB STATUS;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNODB STATUS' at line 1
+create table t1 (t6 timestamp(6));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6))' at line 1
+create table t1 (t6 timestamp) type=myisam;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=myisam' at line 1
+show table types;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'types' at line 1
+show mutex status;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mutex status' at line 1
diff --git a/mysql-test/r/flush2.result b/mysql-test/r/flush2.result
index 5056955c7b7..13bcc371ef6 100644
--- a/mysql-test/r/flush2.result
+++ b/mysql-test/r/flush2.result
@@ -4,11 +4,9 @@ show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_trust_function_creators ON
-log_bin_trust_routine_creators ON
flush logs;
show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_trust_function_creators ON
-log_bin_trust_routine_creators ON
set global expire_logs_days = 0;
diff --git a/mysql-test/r/ipv4_as_ipv6.result b/mysql-test/r/ipv4_as_ipv6.result
new file mode 100644
index 00000000000..8523dc82f02
--- /dev/null
+++ b/mysql-test/r/ipv4_as_ipv6.result
@@ -0,0 +1,179 @@
+=============Test of '127.0.0.1' (IPv4) ===========================
+mysqld is alive
+CREATE USER testuser@'127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'127.0.0.1';
+SHOW GRANTS FOR testuser@'127.0.0.1';
+Grants for testuser@127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'127.0.0.1'
+SET @nip= inet_aton('127.0.0.1');
+SELECT @nip;
+@nip
+2130706433
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+127.0.0.1
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
+RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
+SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'127.0.0.1';
+=============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================
+mysqld is alive
+CREATE USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+Grants for testuser@0:0:0:0:0:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0:0:0:0:0:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0:0:0:0:FFFF:127.0.0.1'
+SET @nip= inet_aton('0:0:0:0:0:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+RENAME USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' to testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0:0:0:0:0:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
+=============Test of '0000:0000:0000:0000:0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Grants for testuser@0000:0000:0000:0000:0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0000:0000:0000:0000:0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0000:0000:0000:0000:0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' to testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+=============Test of '0:0000:0000:0:0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+Grants for testuser@0:0000:0000:0:0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0:0000:0000:0:0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0000:0000:0:0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0:0000:0000:0:0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1' to testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+=============Test of '0::0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0::0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0::0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0::0000:FFFF:127.0.0.1';
+Grants for testuser@0::0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0::0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0::0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0::0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0::0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0::0000:FFFF:127.0.0.1' to testuser1@'0::0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0::0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0::0000:FFFF:127.0.0.1';
+=============Test of '0:0:0:0:0:FFFF:127.0.0.1/96' ================
+=============Test of '::FFFF:127.0.0.1' ===========================
+mysqld is alive
+CREATE USER testuser@'::FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'::FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'::FFFF:127.0.0.1';
+Grants for testuser@::FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'::FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::FFFF:127.0.0.1'
+SET @nip= inet_aton('::FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'::FFFF:127.0.0.1';
+RENAME USER testuser@'::FFFF:127.0.0.1' to testuser1@'::FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'::FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'::FFFF:127.0.0.1';
+=============Test of '::FFFF:127.0.0.1/96' ========================
+=============Test of '::1' ========================
+connect (con1, ::1, root, , test, MASTER_MYPORT,);
+Got one of the listed errors
diff --git a/mysql-test/r/ipv4_as_ipv6_win.result b/mysql-test/r/ipv4_as_ipv6_win.result
new file mode 100644
index 00000000000..45e23d4d7e6
--- /dev/null
+++ b/mysql-test/r/ipv4_as_ipv6_win.result
@@ -0,0 +1,32 @@
+=============Test of '127.0.0.1' (IPv4) ===========================
+mysqld is alive
+CREATE USER testuser@'127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'127.0.0.1';
+SHOW GRANTS FOR testuser@'127.0.0.1';
+Grants for testuser@127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'127.0.0.1'
+SET @nip= inet_aton('127.0.0.1');
+SELECT @nip;
+@nip
+2130706433
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+127.0.0.1
+SELECT USER();
+USER()
+root@127.0.0.1
+SELECT current_user();
+current_user()
+root@127.0.0.1
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
+RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
+SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@127.0.0.1
+DROP USER testuser1@'127.0.0.1';
+=============Test of '::1' ========================
+connect (con1, ::1, root, , test, MASTER_MYPORT);
+Got one of the listed errors
diff --git a/mysql-test/r/ipv6.result b/mysql-test/r/ipv6.result
new file mode 100644
index 00000000000..566938296a9
--- /dev/null
+++ b/mysql-test/r/ipv6.result
@@ -0,0 +1,264 @@
+=============Test of '::1' ========================================
+mysqld is alive
+CREATE USER testuser@'::1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'::1';
+SHOW GRANTS FOR testuser@'::1';
+Grants for testuser@::1
+GRANT USAGE ON *.* TO 'testuser'@'::1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::1'
+SET @nip= inet_aton('::1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'::1';
+RENAME USER testuser@'::1' to testuser1@'::1';
+SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'::1';
+=============Test of '::1/128' ====================================
+=============Test of '0000:0000:0000:0000:0000:0000:0000:0001' ====
+mysqld is alive
+CREATE USER testuser@'0000:0000:0000:0000:0000:0000:0000:0001' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+SHOW GRANTS FOR testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+Grants for testuser@0000:0000:0000:0000:0000:0000:0000:0001
+GRANT USAGE ON *.* TO 'testuser'@'0000:0000:0000:0000:0000:0000:0000:0001' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0000:0000:0000:0000:0000:0000:0000:0001'
+SET @nip= inet_aton('0000:0000:0000:0000:0000:0000:0000:0001');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+RENAME USER testuser@'0000:0000:0000:0000:0000:0000:0000:0001' to testuser1@'0000:0000:0000:0000:0000:0000:0000:0001';
+SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:0000:0000:0001' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0000:0000:0000:0000:0000:0000:0000:0001';
+=============Test of '0:0:0:0:0:0:0:1' ============================
+mysqld is alive
+CREATE USER testuser@'0:0:0:0:0:0:0:1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0:0:0:0:0:0:1';
+SHOW GRANTS FOR testuser@'0:0:0:0:0:0:0:1';
+Grants for testuser@0:0:0:0:0:0:0:1
+GRANT USAGE ON *.* TO 'testuser'@'0:0:0:0:0:0:0:1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0:0:0:0:0:0:1'
+SET @nip= inet_aton('0:0:0:0:0:0:0:1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:0:0:1';
+RENAME USER testuser@'0:0:0:0:0:0:0:1' to testuser1@'0:0:0:0:0:0:0:1';
+SET PASSWORD FOR testuser1@'0:0:0:0:0:0:0:1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0:0:0:0:0:0:0:1';
+=============Test of '127.0.0.1' (IPv4) ===========================
+mysqld is alive
+CREATE USER testuser@'127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'127.0.0.1';
+SHOW GRANTS FOR testuser@'127.0.0.1';
+Grants for testuser@127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'127.0.0.1'
+SET @nip= inet_aton('127.0.0.1');
+SELECT @nip;
+@nip
+2130706433
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+127.0.0.1
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
+RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
+SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'127.0.0.1';
+=============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================
+mysqld is alive
+CREATE USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+Grants for testuser@0:0:0:0:0:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0:0:0:0:0:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0:0:0:0:FFFF:127.0.0.1'
+SET @nip= inet_aton('0:0:0:0:0:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:FFFF:127.0.0.1';
+RENAME USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' to testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0:0:0:0:0:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
+=============Test of '0000:0000:0000:0000:0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Grants for testuser@0000:0000:0000:0000:0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0000:0000:0000:0000:0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0000:0000:0000:0000:0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' to testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+=============Test of '0:0000:0000:0:0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+Grants for testuser@0:0000:0000:0:0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0:0000:0000:0:0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0000:0000:0:0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0:0000:0000:0:0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1' to testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1';
+=============Test of '0::0000:FFFF:127.0.0.1' ====
+mysqld is alive
+CREATE USER testuser@'0::0000:FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0::0000:FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'0::0000:FFFF:127.0.0.1';
+Grants for testuser@0::0000:FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'0::0000:FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0::0000:FFFF:127.0.0.1'
+SET @nip= inet_aton('0::0000:FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0::0000:FFFF:127.0.0.1';
+RENAME USER testuser@'0::0000:FFFF:127.0.0.1' to testuser1@'0::0000:FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'0::0000:FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'0::0000:FFFF:127.0.0.1';
+=============Test of '0:0:0:0:0:FFFF:127.0.0.1/96' ================
+=============Test of '::FFFF:127.0.0.1' ===========================
+mysqld is alive
+CREATE USER testuser@'::FFFF:127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'::FFFF:127.0.0.1';
+SHOW GRANTS FOR testuser@'::FFFF:127.0.0.1';
+Grants for testuser@::FFFF:127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'::FFFF:127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::FFFF:127.0.0.1'
+SET @nip= inet_aton('::FFFF:127.0.0.1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'::FFFF:127.0.0.1';
+RENAME USER testuser@'::FFFF:127.0.0.1' to testuser1@'::FFFF:127.0.0.1';
+SET PASSWORD FOR testuser1@'::FFFF:127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'::FFFF:127.0.0.1';
+=============Test of '::FFFF:127.0.0.1/96' ========================
diff --git a/mysql-test/r/ipv6_win.result b/mysql-test/r/ipv6_win.result
new file mode 100644
index 00000000000..8082e8aa25e
--- /dev/null
+++ b/mysql-test/r/ipv6_win.result
@@ -0,0 +1,88 @@
+=============Test of '::1' ========================================
+mysqld is alive
+CREATE USER testuser@'::1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'::1';
+SHOW GRANTS FOR testuser@'::1';
+Grants for testuser@::1
+GRANT USAGE ON *.* TO 'testuser'@'::1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::1'
+SET @nip= inet_aton('::1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@::1
+SELECT current_user();
+current_user()
+root@::1
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'::1';
+RENAME USER testuser@'::1' to testuser1@'::1';
+SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@::1
+DROP USER testuser1@'::1';
+=============Test of '::1/128' ====================================
+=============Test of '0000:0000:0000:0000:0000:0000:0000:0001' ====
+mysqld is alive
+CREATE USER testuser@'0000:0000:0000:0000:0000:0000:0000:0001' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+SHOW GRANTS FOR testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+Grants for testuser@0000:0000:0000:0000:0000:0000:0000:0001
+GRANT USAGE ON *.* TO 'testuser'@'0000:0000:0000:0000:0000:0000:0000:0001' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0000:0000:0000:0000:0000:0000:0000:0001'
+SET @nip= inet_aton('0000:0000:0000:0000:0000:0000:0000:0001');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@::1
+SELECT current_user();
+current_user()
+root@::1
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
+RENAME USER testuser@'0000:0000:0000:0000:0000:0000:0000:0001' to testuser1@'0000:0000:0000:0000:0000:0000:0000:0001';
+SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:0000:0000:0001' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@::1
+DROP USER testuser1@'0000:0000:0000:0000:0000:0000:0000:0001';
+=============Test of '0:0:0:0:0:0:0:1' ============================
+mysqld is alive
+CREATE USER testuser@'0:0:0:0:0:0:0:1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'0:0:0:0:0:0:0:1';
+SHOW GRANTS FOR testuser@'0:0:0:0:0:0:0:1';
+Grants for testuser@0:0:0:0:0:0:0:1
+GRANT USAGE ON *.* TO 'testuser'@'0:0:0:0:0:0:0:1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'0:0:0:0:0:0:0:1'
+SET @nip= inet_aton('0:0:0:0:0:0:0:1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@::1
+SELECT current_user();
+current_user()
+root@::1
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:0:0:1';
+RENAME USER testuser@'0:0:0:0:0:0:0:1' to testuser1@'0:0:0:0:0:0:0:1';
+SET PASSWORD FOR testuser1@'0:0:0:0:0:0:0:1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@::1
+DROP USER testuser1@'0:0:0:0:0:0:0:1';
diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result
index fbcd8aed17a..dd14c31f32e 100644
--- a/mysql-test/r/myisampack.result
+++ b/mysql-test/r/myisampack.result
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1(c1 DOUBLE, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 DOUBLE,
c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY);
INSERT INTO t1 VALUES
@@ -85,5 +86,37 @@ FLUSH TABLE mysql_db1.t1;
SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5;
COUNT(*)
128
+# ===== myisampack.1 =====
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(20);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES(40);
+FLUSH TABLE t1,t2;
+#If the myisampack --join operation is successful, we have table t3(.frm)
+#so we should be able to query about the table from server.
+SELECT COUNT(a) FROM t3;
+COUNT(a)
+1024
+# ===== myisampack.2 =====
+FLUSH TABLE t3;
+#Tests the myisampack join operation with an existing destination .frm file,
+#the command should return correct exit status(0) and
+#we should be able to query the table.
+SELECT COUNT(a) FROM t3;
+COUNT(a)
+1024
+# ===== myisampack.3 =====
+DROP TABLE t3;
+#Tests the myisampack join operation without frm file for the first and second table
+#No frm file is generated in this and we shouldn't be able to access the newly
+#created table
+SELECT COUNT(a) FROM t3;
+ERROR 42S02: Table 'test.t3' doesn't exist
+# ===== myisampack.4 =====
+#Tests the myisampack join operation with an existing destination .frm,.MYI,.MDI
+#the command should fail with exit status 2
+myisampack: Can't create/write to file (Errcode: 17)
+Aborted: file is not compressed
+DROP TABLE t1,t2,t3;
DROP TABLE mysql_db1.t1;
DROP DATABASE mysql_db1;
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 065e46dbf92..543a70f9a2a 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -2048,23 +2048,4 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
PARTITION BY HASH(id) PARTITIONS 2;
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
-#
-# BUG#45816 - assertion failure with index containing double
-# column on partitioned table
-#
-CREATE TABLE t1 (
-a INT DEFAULT NULL,
-b DOUBLE DEFAULT NULL,
-c INT DEFAULT NULL,
-KEY idx2(b,a)
-) PARTITION BY HASH(c) PARTITIONS 3;
-INSERT INTO t1 VALUES (6,8,9);
-INSERT INTO t1 VALUES (6,8,10);
-SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
-1
-1
-1
-1
-1
-DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 3ab65c24040..1603ecec127 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -412,8 +412,6 @@ prepare stmt1 from ' optimize table t1 ' ;
prepare stmt1 from ' analyze table t1 ' ;
prepare stmt1 from ' checksum table t1 ' ;
prepare stmt1 from ' repair table t1 ' ;
-prepare stmt1 from ' restore table t1 from ''<MYSQLTEST_VARDIR>/tmp/data.txt'' ' ;
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' handler t1 open ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' commit ' ;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 091d932a6fc..50384149a26 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -808,7 +808,6 @@ show plugins;
show columns in t1;
show slave hosts;
show keys in t1;
-show table types;
show storage engines;
show authors;
show contributors;
@@ -1291,11 +1290,6 @@ delete from mysql.db where user='mysqltest_4';
delete from mysql.tables_priv where user='mysqltest_4';
flush privileges;
drop database mysqltest;
-show full plugin;
-show warnings;
-Level Code Message
-Warning 1287 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW PLUGINS' instead
-show plugin;
show plugins;
create database `mysqlttest\1`;
create table `mysqlttest\1`.`a\b` (a int);
@@ -1447,7 +1441,6 @@ DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLE t1;
DROP EVENT ev1;
-SHOW TABLE TYPES;
CREATE USER test_u@localhost;
GRANT PROCESS ON *.* TO test_u@localhost;
SHOW ENGINE MYISAM MUTEX;
diff --git a/mysql-test/r/signal_code.result b/mysql-test/r/signal_code.result
index 8cda8877216..2ecba4701fa 100644
--- a/mysql-test/r/signal_code.result
+++ b/mysql-test/r/signal_code.result
@@ -20,16 +20,16 @@ return 0;
end $$
show procedure code signal_proc;
Pos Instruction
-0 stmt 135 "SIGNAL foo"
-1 stmt 135 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
-2 stmt 136 "RESIGNAL foo"
-3 stmt 136 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
+0 stmt 131 "SIGNAL foo"
+1 stmt 131 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
+2 stmt 132 "RESIGNAL foo"
+3 stmt 132 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
drop procedure signal_proc;
show function code signal_func;
Pos Instruction
-0 stmt 135 "SIGNAL foo"
-1 stmt 135 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
-2 stmt 136 "RESIGNAL foo"
-3 stmt 136 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
+0 stmt 131 "SIGNAL foo"
+1 stmt 131 "SIGNAL foo SET MESSAGE_TEXT = "This i..."
+2 stmt 132 "RESIGNAL foo"
+3 stmt 132 "RESIGNAL foo SET MESSAGE_TEXT = "This..."
4 freturn 3 0
drop function signal_func;
diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result
index 949976719ea..0a0f620b80a 100644
--- a/mysql-test/r/sp-code.result
+++ b/mysql-test/r/sp-code.result
@@ -155,11 +155,11 @@ Pos Instruction
0 stmt 9 "drop temporary table if exists sudoku..."
1 stmt 1 "create temporary table sudoku_work ( ..."
2 stmt 1 "create temporary table sudoku_schedul..."
-3 stmt 93 "call sudoku_init()"
+3 stmt 89 "call sudoku_init()"
4 jump_if_not 7(8) p_naive@0
5 stmt 4 "update sudoku_work set cnt = 0 where ..."
6 jump 8
-7 stmt 93 "call sudoku_count()"
+7 stmt 89 "call sudoku_count()"
8 stmt 6 "insert into sudoku_schedule (row,col)..."
9 set v_scounter@2 0
10 set v_i@3 1
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 7a3cb55858b..00ae7dd4eca 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -921,10 +921,6 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN DROP TRIGGER test1; EN
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
-CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN load table t1 from master; END |
-ERROR 0A000: LOAD TABLE is not allowed in stored procedures
-CREATE FUNCTION bug_13627_f() returns int BEGIN load table t1 from master; return 1; END |
-ERROR 0A000: LOAD TABLE is not allowed in stored procedures
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
CREATE FUNCTION bug_13627_f() returns int BEGIN create table t2 (a int); return 1; END |
@@ -1115,18 +1111,6 @@ REPAIR TABLE t1;
RETURN 1;
END|
ERROR 0A000: Not allowed to return a result set from a function
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-BACKUP TABLE t1 TO '/tmp';
-RETURN 1;
-END|
-ERROR 0A000: Not allowed to return a result set from a function
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-RESTORE TABLE t1 FROM '/tmp';
-RETURN 1;
-END|
-ERROR 0A000: Not allowed to return a result set from a function
create table t1 (a int)|
CREATE PROCEDURE bug13012_1() REPAIR TABLE t1|
CREATE FUNCTION bug13012_2() RETURNS INT
@@ -1639,11 +1623,9 @@ DROP TABLE t1|
drop procedure if exists p1;
create procedure p1()
begin
-create table t1 (a int) type=MyISAM;
+create table t1 (a int) engine=MyISAM;
drop table t1;
end|
-Warnings:
-Warning 1287 The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead
call p1();
call p1();
drop procedure p1;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 47d441ee182..bcc738d695c 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4303,19 +4303,10 @@ drop procedure if exists bug13012|
create procedure bug13012()
BEGIN
REPAIR TABLE t1;
-BACKUP TABLE t1 to '<MYSQLTEST_VARDIR>/tmp/';
-DROP TABLE t1;
-RESTORE TABLE t1 FROM '<MYSQLTEST_VARDIR>/tmp/';
END|
call bug13012()|
Table Op Msg_type Msg_text
test.t1 repair status OK
-Table Op Msg_type Msg_text
-test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
-test.t1 backup status OK
-Table Op Msg_type Msg_text
-test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
-test.t1 restore status OK
drop procedure bug13012|
create view v1 as select * from t1|
create procedure bug13012()
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index be45e5ff5d7..f55e535a293 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -533,9 +533,7 @@ set @@session.max_heap_table_size=default|
CREATE DATABASE db_bug7787|
use db_bug7787|
CREATE PROCEDURE p1()
-SHOW INNODB STATUS; |
-Warnings:
-Warning 1287 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW ENGINE INNODB STATUS' instead
+SHOW ENGINE INNODB STATUS; |
GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
DROP DATABASE db_bug7787|
drop user user_bug7787@localhost|
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index d11ab236c34..b7464ae8ad6 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -889,28 +889,12 @@ CREATE TABLE b15776 (a year(0));
DROP TABLE b15776;
CREATE TABLE b15776 (a year(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
-CREATE TABLE b15776 (a timestamp(4294967294));
-Warnings:
-Warning 1287 The syntax 'TIMESTAMP(4294967294)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-DROP TABLE b15776;
-CREATE TABLE b15776 (a timestamp(4294967295));
-Warnings:
-Warning 1287 The syntax 'TIMESTAMP(4294967295)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-DROP TABLE b15776;
-CREATE TABLE b15776 (a timestamp(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
-CREATE TABLE b15776 (a timestamp(-1));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
-CREATE TABLE b15776 (a timestamp(-2));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
-CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index 24cb725de9f..fd13f53d02b 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -97,30 +97,6 @@ date date_time time_stamp
2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
-t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
-t14 timestamp(14));
-Warnings:
-Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
Warnings:
@@ -436,7 +412,7 @@ max(t)
2004-02-01 00:00:00
drop table t1;
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp);
show create table t1;
Table Create Table
t1 CREATE TABLE "t1" (
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index e2bce537179..8e70ea8b53d 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -166,9 +166,6 @@ show variables like 'max_error_count';
Variable_name Value
max_error_count 10
drop table t1;
-set table_type=MYISAM;
-Warnings:
-Warning 1287 The syntax '@@table_type' is deprecated and will be removed in MySQL 6.0. Please use '@@storage_engine' instead
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
update t1 set a='abc';
diff --git a/mysql-test/suite/binlog/r/binlog_max_extension.result b/mysql-test/suite/binlog/r/binlog_max_extension.result
new file mode 100644
index 00000000000..af341db4536
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_max_extension.result
@@ -0,0 +1,8 @@
+call mtr.add_suppression("Next log extension: 2147483647. Remaining log filename extensions: 0.");
+call mtr.add_suppression("Log filename extension number exhausted:");
+call mtr.add_suppression("Can't generate a unique log-filename");
+RESET MASTER;
+FLUSH LOGS;
+Warnings:
+Warning 1098 Can't generate a unique log-filename master-bin.(1-999)
+
diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
index 06c57fba2e7..ea081183cd1 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
@@ -456,7 +456,11 @@ return n;
end|
reset master;
insert into t2 values (bug27417(1));
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
insert into t2 select bug27417(2);
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
reset master;
insert into t2 values (bug27417(2));
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
@@ -473,6 +477,8 @@ select count(*) from t2;
count(*)
2
delete from t2 where a=bug27417(3);
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
select count(*) from t2 /* nothing got deleted */;
count(*)
2
@@ -486,6 +492,8 @@ count(*)
5
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
affected rows: 0
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
select count(*) from t1 /* must be 7 */;
count(*)
7
@@ -700,7 +708,11 @@ return n;
end|
reset master;
insert into t2 values (bug27417(1));
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
insert into t2 select bug27417(2);
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
reset master;
insert into t2 values (bug27417(2));
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
@@ -716,6 +728,8 @@ select count(*) from t2;
count(*)
2
delete from t2 where a=bug27417(3);
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
select count(*) from t2 /* nothing got deleted */;
count(*)
2
@@ -728,6 +742,8 @@ count(*)
5
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
affected rows: 0
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
select count(*) from t1 /* must be 7 */;
count(*)
7
diff --git a/mysql-test/suite/binlog/r/binlog_tmp_table.result b/mysql-test/suite/binlog/r/binlog_tmp_table.result
index 14b1963ffd9..e4928432324 100644
--- a/mysql-test/suite/binlog/r/binlog_tmp_table.result
+++ b/mysql-test/suite/binlog/r/binlog_tmp_table.result
@@ -1,4 +1,3 @@
-RESET MASTER;
create table foo (a int);
flush logs;
create temporary table tmp1_foo like foo;
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 3047ff54cf0..58738a0d97c 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -300,4 +300,59 @@ Warnings:
Note 1592 Statement may not be safe to log in statement format.
DROP TABLE t1, t2;
SET @@SESSION.SQL_MODE = @save_sql_mode;
+CREATE TABLE t1 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+CREATE FUNCTION func_modify_t1 ()
+RETURNS INT
+BEGIN
+INSERT INTO t1 SET a = 1;
+RETURN 0;
+END|
+# The following statement causes auto-incrementation
+# of both t1 and t2. It is logged in statement format,
+# so it should produce unsafe warning.
+INSERT INTO t2 SET a = func_modify_t1();
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+SET SESSION binlog_format = MIXED;
+# Check if the statement is logged in row format.
+INSERT INTO t2 SET a = func_modify_t1();
+SHOW BINLOG EVENTS FROM 12283;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 12283 Query 1 12351 BEGIN
+master-bin.000001 12351 Table_map 1 12393 table_id: 44 (test.t2)
+master-bin.000001 12393 Table_map 1 12435 table_id: 45 (test.t1)
+master-bin.000001 12435 Write_rows 1 12473 table_id: 45
+master-bin.000001 12473 Write_rows 1 12511 table_id: 44 flags: STMT_END_F
+master-bin.000001 12511 Query 1 12580 COMMIT
+DROP TABLE t1,t2;
+DROP FUNCTION func_modify_t1;
+SET SESSION binlog_format = STATEMENT;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+CREATE TABLE t3 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+create trigger tri_modify_two_tables before insert on t1 for each row begin
+insert into t2(a) values(new.a);
+insert into t3(a) values(new.a);
+end |
+# The following statement causes auto-incrementation
+# of both t2 and t3. It is logged in statement format,
+# so it should produce unsafe warning
+INSERT INTO t1 SET a = 1;
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+SET SESSION binlog_format = MIXED;
+# Check if the statement is logged in row format.
+INSERT INTO t1 SET a = 2;
+SHOW BINLOG EVENTS FROM 13426;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 13426 Query 1 13494 BEGIN
+master-bin.000001 13494 Table_map 1 13535 table_id: 47 (test.t1)
+master-bin.000001 13535 Table_map 1 13577 table_id: 48 (test.t3)
+master-bin.000001 13577 Table_map 1 13619 table_id: 49 (test.t2)
+master-bin.000001 13619 Write_rows 1 13657 table_id: 49
+master-bin.000001 13657 Write_rows 1 13695 table_id: 48
+master-bin.000001 13695 Write_rows 1 13729 table_id: 47 flags: STMT_END_F
+master-bin.000001 13729 Query 1 13798 COMMIT
+DROP TABLE t1,t2,t3;
"End of tests"
diff --git a/mysql-test/suite/binlog/t/binlog_max_extension.test b/mysql-test/suite/binlog/t/binlog_max_extension.test
new file mode 100644
index 00000000000..9f52d195e21
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_max_extension.test
@@ -0,0 +1,92 @@
+# BUG#40611: MySQL cannot make a binary log after sequential number beyond
+# unsigned long.
+#
+# Problem statement
+# =================
+#
+# Extension for log file names might be created with negative
+# numbers (when counter used would wrap around), causing server
+# failure when incrementing -00001 (reaching number 000000
+# extension).
+#
+# Test
+# ====
+# This tests aims at testing the a patch that removes negatives
+# numbers from log name extensions and checks that the server
+# reports gracefully that the limit has been reached.
+#
+# It instruments index file to point to a log file close to
+# the new maximum and calls flush logs to get warning.
+#
+
+call mtr.add_suppression("Next log extension: 2147483647. Remaining log filename extensions: 0.");
+call mtr.add_suppression("Log filename extension number exhausted:");
+call mtr.add_suppression("Can't generate a unique log-filename");
+
+
+-- source include/have_log_bin.inc
+RESET MASTER;
+
+-- let $MYSQLD_DATADIR= `select @@datadir`
+
+###############################################
+# check hitting maximum file name extension:
+###############################################
+
+##########
+# Prepare
+##########
+
+# 1. Stop master server
+-- write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait
+EOF
+-- shutdown_server 10
+-- source include/wait_until_disconnected.inc
+
+# 2. Prepare log and index file
+-- copy_file $MYSQLD_DATADIR/master-bin.index $MYSQLD_DATADIR/master-bin.index.orig
+-- copy_file $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.2147483646
+-- append_file $MYSQLD_DATADIR/master-bin.index
+master-bin.2147483646
+EOF
+
+# 3. Restart the server
+-- append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+###########
+# Assertion
+###########
+
+# assertion: should throw warning
+FLUSH LOGS;
+
+##############
+# Clean up
+##############
+
+# 1. Stop the server
+-- write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait
+EOF
+-- shutdown_server 10
+-- source include/wait_until_disconnected.inc
+
+# 2. Undo changes to index and log files
+-- remove_file $MYSQLD_DATADIR/master-bin.index
+-- copy_file $MYSQLD_DATADIR/master-bin.index.orig $MYSQLD_DATADIR/master-bin.index
+-- remove_file $MYSQLD_DATADIR/master-bin.index.orig
+
+-- remove_file $MYSQLD_DATADIR/master-bin.2147483646
+-- remove_file $MYSQLD_DATADIR/master-bin.2147483647
+
+# 3. Restart the server
+-- append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
diff --git a/mysql-test/suite/binlog/t/binlog_tmp_table.test b/mysql-test/suite/binlog/t/binlog_tmp_table.test
index 54af8a8cb68..6947959a5e0 100644
--- a/mysql-test/suite/binlog/t/binlog_tmp_table.test
+++ b/mysql-test/suite/binlog/t/binlog_tmp_table.test
@@ -30,7 +30,6 @@ source include/have_binlog_format_mixed_or_statement.inc;
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
-RESET MASTER;
create table foo (a int);
diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test
index c4e1f31cbce..1cda75cdb6d 100644
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test
@@ -388,4 +388,72 @@ DELETE FROM t1 LIMIT 1;
DROP TABLE t1, t2;
SET @@SESSION.SQL_MODE = @save_sql_mode;
+
+#
+# BUG#45827
+# The test verifies if stmt that have more than one
+# different tables to update with autoinc columns
+# will produce unsafe warning
+#
+
+# Test case1: stmt that have more than one different tables
+# to update with autoinc columns should produce
+# unsafe warning when calling a function
+CREATE TABLE t1 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+
+# The purpose of this function is to insert into t1 so that the second
+# column is auto_increment'ed.
+DELIMITER |;
+CREATE FUNCTION func_modify_t1 ()
+RETURNS INT
+BEGIN
+ INSERT INTO t1 SET a = 1;
+ RETURN 0;
+END|
+DELIMITER ;|
+--echo # The following statement causes auto-incrementation
+--echo # of both t1 and t2. It is logged in statement format,
+--echo # so it should produce unsafe warning.
+INSERT INTO t2 SET a = func_modify_t1();
+
+SET SESSION binlog_format = MIXED;
+--echo # Check if the statement is logged in row format.
+let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+INSERT INTO t2 SET a = func_modify_t1();
+eval SHOW BINLOG EVENTS FROM $pos0_master;
+
+# clean up
+DROP TABLE t1,t2;
+DROP FUNCTION func_modify_t1;
+
+# Test case2: stmt that have more than one different tables
+# to update with autoinc columns should produce
+# unsafe warning when invoking a trigger
+SET SESSION binlog_format = STATEMENT;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+CREATE TABLE t3 (a INT, b INT PRIMARY KEY AUTO_INCREMENT);
+# The purpose of this function is to insert into t1 so that the second
+# column is auto_increment'ed.
+delimiter |;
+create trigger tri_modify_two_tables before insert on t1 for each row begin
+ insert into t2(a) values(new.a);
+ insert into t3(a) values(new.a);
+end |
+delimiter ;|
+--echo # The following statement causes auto-incrementation
+--echo # of both t2 and t3. It is logged in statement format,
+--echo # so it should produce unsafe warning
+INSERT INTO t1 SET a = 1;
+
+SET SESSION binlog_format = MIXED;
+--echo # Check if the statement is logged in row format.
+let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+INSERT INTO t1 SET a = 2;
+eval SHOW BINLOG EVENTS FROM $pos1_master;
+
+# clean up
+DROP TABLE t1,t2,t3;
+
--echo "End of tests"
diff --git a/mysql-test/suite/rpl/my.cnf b/mysql-test/suite/rpl/my.cnf
index 4d0e5e51664..74233b056c7 100644
--- a/mysql-test/suite/rpl/my.cnf
+++ b/mysql-test/suite/rpl/my.cnf
@@ -3,13 +3,6 @@
!include rpl_1slave_base.cnf
!include include/default_client.cnf
+
[mysqld.2]
-# Hardcode the host to 127.0.0.1 until running on more
-# than one host and it need to be masked
-# master-host= @mysqld.1.#host
-master-host= 127.0.0.1
-master-port= @mysqld.1.port
-master-password= @mysqld.1.#password
-master-user= @mysqld.1.#user
-master-connect-retry= 1
diff --git a/mysql-test/suite/rpl/r/rpl000017.result b/mysql-test/suite/rpl/r/rpl000017.result
index 1c611357e64..403f4d4d4fe 100644
--- a/mysql-test/suite/rpl/r/rpl000017.result
+++ b/mysql-test/suite/rpl/r/rpl000017.result
@@ -1,10 +1,7 @@
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;
-stop slave;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
start slave;
diff --git a/mysql-test/suite/rpl/r/rpl_000015.result b/mysql-test/suite/rpl/r/rpl_000015.result
index d6cb544df7c..1b1249bc979 100644
--- a/mysql-test/suite/rpl/r/rpl_000015.result
+++ b/mysql-test/suite/rpl/r/rpl_000015.result
@@ -4,50 +4,8 @@ File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
reset slave;
SHOW SLAVE STATUS;
-change master to master_host='127.0.0.1';
-SHOW SLAVE STATUS;
-Slave_IO_State #
-Master_Host 127.0.0.1
-Master_User test
-Master_Port 3306
-Connect_Retry 7
-Master_Log_File
-Read_Master_Log_Pos #
-Relay_Log_File #
-Relay_Log_Pos #
-Relay_Master_Log_File
-Slave_IO_Running No
-Slave_SQL_Running No
-Replicate_Do_DB
-Replicate_Ignore_DB
-Replicate_Do_Table
-Replicate_Ignore_Table #
-Replicate_Wild_Do_Table
-Replicate_Wild_Ignore_Table
-Last_Errno 0
-Last_Error
-Skip_Counter 0
-Exec_Master_Log_Pos #
-Relay_Log_Space #
-Until_Condition None
-Until_Log_File
-Until_Log_Pos 0
-Master_SSL_Allowed No
-Master_SSL_CA_File
-Master_SSL_CA_Path
-Master_SSL_Cert
-Master_SSL_Cipher
-Master_SSL_Key
-Seconds_Behind_Master #
-Master_SSL_Verify_Server_Cert No
-Last_IO_Errno #
-Last_IO_Error #
-Last_SQL_Errno 0
-Last_SQL_Error
-Replicate_Ignore_Server_Ids
-Master_Server_Id 0
change master to master_host='127.0.0.1',master_user='root',
-master_password='',master_port=MASTER_PORT;
+master_password='',master_port=MASTER_PORT, MASTER_CONNECT_RETRY=7;
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
diff --git a/mysql-test/suite/rpl/r/rpl_bug33931.result b/mysql-test/suite/rpl/r/rpl_bug33931.result
index ba3c3ebafe6..256238d35cd 100644
--- a/mysql-test/suite/rpl/r/rpl_bug33931.result
+++ b/mysql-test/suite/rpl/r/rpl_bug33931.result
@@ -1,7 +1,6 @@
reset master;
-call mtr.add_suppression("Failed during slave I/O thread initialization");
-stop slave;
reset slave;
+call mtr.add_suppression("Failed during slave I/O thread initialization");
SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
start slave;
show slave status;
diff --git a/mysql-test/suite/rpl/r/rpl_bug41902.result b/mysql-test/suite/rpl/r/rpl_bug41902.result
new file mode 100644
index 00000000000..c65773708cc
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_bug41902.result
@@ -0,0 +1,34 @@
+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;
+stop slave;
+SET @@debug="d,simulate_find_log_pos_error";
+reset slave;
+ERROR HY000: Target log not found in binlog index
+show warnings;
+Level Code Message
+Error 1373 Target log not found in binlog index
+Error 1371 Failed purging old relay logs: Failed during log reset
+SET @@debug="";
+reset slave;
+change master to master_host='dummy';
+SET @@debug="d,simulate_find_log_pos_error";
+change master to master_host='dummy';
+ERROR HY000: Target log not found in binlog index
+SET @@debug="";
+reset slave;
+change master to master_host='dummy';
+SET @@debug="d,simulate_find_log_pos_error";
+reset master;
+ERROR HY000: Target log not found in binlog index
+SET @@debug="";
+reset master;
+SET @@debug="d,simulate_find_log_pos_error";
+purge binary logs to 'master-bin.000001';
+ERROR HY000: Target log not found in binlog index
+SET @@debug="";
+purge binary logs to 'master-bin.000001';
+End of the tests
diff --git a/mysql-test/suite/rpl/r/rpl_empty_master_crash.result b/mysql-test/suite/rpl/r/rpl_empty_master_crash.result
deleted file mode 100644
index f0d84f85069..00000000000
--- a/mysql-test/suite/rpl/r/rpl_empty_master_crash.result
+++ /dev/null
@@ -1,11 +0,0 @@
-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;
-SHOW SLAVE STATUS;
-load table t1 from master;
-ERROR 08S01: Error connecting to master: Master is not configured
-load table t1 from master;
-ERROR HY000: Error from master: 'Table 'test.t1' doesn't exist'
diff --git a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
index 5f2a55b5e35..6b9166834e2 100644
--- a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
+++ b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
@@ -4,9 +4,10 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+call mtr.add_suppression("Slave I/O: .* failed with error: Lost connection to MySQL server at 'reading initial communication packet'");
+call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again");
call mtr.add_suppression("Get master clock failed with error: ");
call mtr.add_suppression("Get master SERVER_ID failed with error: ");
-call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again");
call mtr.add_suppression("Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; .*");
SELECT IS_FREE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP");
IS_FREE_LOCK("debug_lock.before_get_UNIX_TIMESTAMP")
diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat.result b/mysql-test/suite/rpl/r/rpl_heartbeat.result
index b79545b8336..92ba8549ee4 100644
--- a/mysql-test/suite/rpl/r/rpl_heartbeat.result
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat.result
@@ -1,8 +1,6 @@
reset master;
set @restore_slave_net_timeout= @@global.slave_net_timeout;
set @@global.slave_net_timeout= 10;
-Warnings:
-Warning 1624 The currect value for master_heartbeat_period exceeds the new value of `slave_net_timeout' sec. A sensible value for the period should be less than the timeout.
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
show status like 'Slave_heartbeat_period';;
Variable_name Slave_heartbeat_period
@@ -59,7 +57,7 @@ Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
-Connect_Retry 1
+Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos 280
Relay_Log_File #
@@ -100,7 +98,7 @@ Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
-Connect_Retry 1
+Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos 280
Relay_Log_File #
diff --git a/mysql-test/suite/rpl/r/rpl_ip_mix.result b/mysql-test/suite/rpl/r/rpl_ip_mix.result
new file mode 100644
index 00000000000..11aa5a46cfa
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ip_mix.result
@@ -0,0 +1,164 @@
+#################### IP: ::1 ###########################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: No such row
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::1
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,0:0:0:0:0:0:0:1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:0:0:1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:FFFF:127.0.0.1 ###########################
+connect (master,0:0:0:0:0:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:FFFF:127.0.0.1';
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:FFFF:127.0.0.1 ###########################
+connect (master,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+change master to master_host='0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0000:0000:0:0000:FFFF:127.0.0.1 ###########################
+connect (master,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+change master to master_host='0:0000:0000:0:0000:FFFF:127.0.0.1';
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0::0000:FFFF:127.0.0.1 ###########################
+connect (master,0::0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+change master to master_host='0::0000:FFFF:127.0.0.1';
+Master-Host: 0::0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::FFFF:127.0.0.1 ###########################
+connect (master,::FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0::0000:FFFF:127.0.0.1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ip_mix2.result b/mysql-test/suite/rpl/r/rpl_ip_mix2.result
new file mode 100644
index 00000000000..e5cc3e1621d
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ip_mix2.result
@@ -0,0 +1,180 @@
+#################### IP: ::1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: No such row
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::1
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::1
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:0:0:1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:0:0:1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:FFFF:127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:FFFF:127.0.0.1';
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:FFFF:127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+change master to master_host='0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0000:0000:0:0000:FFFF:127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+change master to master_host='0:0000:0000:0:0000:FFFF:127.0.0.1';
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0::0000:FFFF:127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0::0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+change master to master_host='0::0000:FFFF:127.0.0.1';
+Master-Host: 0::0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::FFFF:127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0::0000:FFFF:127.0.0.1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ip_mix2_win.result b/mysql-test/suite/rpl/r/rpl_ip_mix2_win.result
new file mode 100644
index 00000000000..c7cec70ed6c
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ip_mix2_win.result
@@ -0,0 +1,84 @@
+#################### IP: ::1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: No such row
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::1
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:0:0:1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:0:0:1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ip_mix_win.result b/mysql-test/suite/rpl/r/rpl_ip_mix_win.result
new file mode 100644
index 00000000000..a1d11e109e5
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ip_mix_win.result
@@ -0,0 +1,84 @@
+#################### IP: ::1 ###########################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: No such row
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::1
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,0:0:0:0:0:0:0:1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 0:0:0:0:0:0:0:1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6.result b/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6.result
new file mode 100644
index 00000000000..4168cff1e97
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6.result
@@ -0,0 +1,110 @@
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:FFFF:127.0.0.1 ###########################
+connect (master,0:0:0:0:0:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0:0:0:0:FFFF:127.0.0.1';
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:FFFF:127.0.0.1 ###########################
+connect (master,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0000:0000:0:0000:FFFF:127.0.0.1 ###########################
+connect (master,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0000:0000:0:0000:FFFF:127.0.0.1';
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0::0000:FFFF:127.0.0.1 ###########################
+connect (master,0::0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0::0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0::0000:FFFF:127.0.0.1';
+Master-Host: 0::0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::FFFF:127.0.0.1 ###########################
+connect (master,::FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6_win.result b/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6_win.result
new file mode 100644
index 00000000000..a1e48ea6610
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ipv4_as_ipv6_win.result
@@ -0,0 +1,35 @@
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ipv6.result b/mysql-test/suite/rpl/r/rpl_ipv6.result
new file mode 100644
index 00000000000..f46e60548a6
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ipv6.result
@@ -0,0 +1,155 @@
+#################### IP: ::1 ###########################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,0:0:0:0:0:0:0:1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:0:0:1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:FFFF:127.0.0.1 ###########################
+connect (master,0:0:0:0:0:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0:0:0:0:FFFF:127.0.0.1';
+Master-Host: 0:0:0:0:0:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:FFFF:127.0.0.1 ###########################
+connect (master,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0000:0000:0000:0000:0000:FFFF:127.0.0.1';
+Master-Host: 0000:0000:0000:0000:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0000:0000:0:0000:FFFF:127.0.0.1 ###########################
+connect (master,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0:0000:0000:0:0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0000:0000:0:0000:FFFF:127.0.0.1';
+Master-Host: 0:0000:0000:0:0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0::0000:FFFF:127.0.0.1 ###########################
+connect (master,0::0000:FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,0::0000:FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0::0000:FFFF:127.0.0.1';
+Master-Host: 0::0000:FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::FFFF:127.0.0.1 ###########################
+connect (master,::FFFF:127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,::FFFF:127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='::FFFF:127.0.0.1';
+Master-Host: ::FFFF:127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_ipv6_win.result b/mysql-test/suite/rpl/r/rpl_ipv6_win.result
new file mode 100644
index 00000000000..79dc8422161
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_ipv6_win.result
@@ -0,0 +1,80 @@
+#################### IP: ::1 ###########################
+connect (master,::1,root,,test,MASTER_MYPORT);
+connect (slave,::1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='::1';
+Master-Host: ::1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0000:0000:0000:0000:0000:0000:0000:0001 ###########################
+connect (master,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,MASTER_MYPORT);
+connect (slave,0000:0000:0000:0000:0000:0000:0000:0001,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0000:0000:0000:0000:0000:0000:0000:0001';
+Master-Host: 0000:0000:0000:0000:0000:0000:0000:0001
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 0:0:0:0:0:0:0:1 ###########################
+connect (master,0:0:0:0:0:0:0:1,root,,test,MASTER_MYPORT);
+connect (slave,0:0:0:0:0:0:0:1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: 127.0.0.1 ###########################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+disconnect slave;
+disconnect master;
+connection default;
+#################### IP: ::1 mix #######################
+connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connection master;
+reset master;
+show master status;
+File Position Binlog_Do_DB Binlog_Ignore_DB
+master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
+connection slave;
+reset slave;
+Master-Host: 127.0.0.1
+change master to master_host='::1';
+Master-Host: ::1
+change master to master_host='127.0.0.1';
+Master-Host: 127.0.0.1
+change master to master_host='0:0:0:0:0:0:0:1';
+Master-Host: 0:0:0:0:0:0:0:1
+disconnect slave;
+disconnect master;
+connection default;
diff --git a/mysql-test/suite/rpl/r/rpl_load_from_master.result b/mysql-test/suite/rpl/r/rpl_load_from_master.result
deleted file mode 100644
index e1c2ecb35be..00000000000
--- a/mysql-test/suite/rpl/r/rpl_load_from_master.result
+++ /dev/null
@@ -1,133 +0,0 @@
-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;
-drop database if exists mysqltest;
-drop database if exists mysqltest2;
-drop database if exists mysqltest3;
-drop database if exists mysqltest;
-drop database if exists mysqltest2;
-drop database if exists mysqltest3;
-create database mysqltest2;
-create database mysqltest;
-create database mysqltest2;
-create table mysqltest2.foo (n int)ENGINE=MyISAM;
-insert into mysqltest2.foo values(4);
-create table mysqltest2.foo (n int)ENGINE=MyISAM;
-insert into mysqltest2.foo values(5);
-create table mysqltest.bar (m int)ENGINE=MyISAM;
-insert into mysqltest.bar values(15);
-select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
-n m
-4 15
-drop database mysqltest;
-drop database if exists mysqltest2;
-drop database mysqltest;
-ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
-drop database mysqltest2;
-set sql_log_bin = 0;
-create database mysqltest2;
-create database mysqltest;
-show databases like 'mysql%';
-Database (mysql%)
-mysql
-mysqltest
-mysqltest2
-create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
-create table mysqltest2.t2(n int, s text)ENGINE=MyISAM;
-insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
-insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
-create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
-create table mysqltest.t2(n int, s text)ENGINE=MyISAM;
-insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
-insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
-(13, 'thirteen test');
-set sql_log_bin = 1;
-show databases like 'mysql%';
-Database (mysql%)
-mysql
-create database mysqltest2;
-create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest2.t1 values (1, 'original foo.t1');
-create table mysqltest2.t3(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest2.t3 values (1, 'original foo.t3');
-create database mysqltest3;
-create table mysqltest3.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest3.t1 values (1, 'original foo2.t1');
-create database mysqltest;
-create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest.t1 values (1, 'original bar.t1');
-create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest.t3 values (1, 'original bar.t3');
-load data from master;
-show databases like 'mysql%';
-Database (mysql%)
-mysql
-mysqltest
-mysqltest2
-mysqltest3
-use mysqltest2;
-show tables;
-Tables_in_mysqltest2
-t1
-t3
-select * from t1;
-n s
-1 original foo.t1
-use mysqltest3;
-show tables;
-Tables_in_mysqltest3
-t1
-select * from t1;
-n s
-1 original foo2.t1
-use mysqltest;
-show tables;
-Tables_in_mysqltest
-t1
-t2
-t3
-select * from mysqltest.t1;
-n s
-1 one test
-2 two test
-3 three test
-select * from mysqltest.t2;
-n s
-11 eleven test
-12 twelve test
-13 thirteen test
-select * from mysqltest.t3;
-n s
-1 original bar.t3
-insert into mysqltest.t1 values (4, 'four test');
-select * from mysqltest.t1;
-n s
-1 one test
-2 two test
-3 three test
-4 four test
-stop slave;
-reset slave;
-load data from master;
-start slave;
-insert into mysqltest.t1 values (5, 'five bar');
-select * from mysqltest.t1;
-n s
-1 one test
-2 two test
-3 three test
-4 four test
-5 five bar
-load table mysqltest.t1 from master;
-ERROR 42S01: Table 't1' already exists
-drop table mysqltest.t1;
-load table mysqltest.t1 from master;
-load table bar.t1 from master;
-ERROR HY000: Error from master: 'Table 'bar.t1' doesn't exist'
-drop database mysqltest;
-drop database mysqltest2;
-drop database mysqltest2;
-drop database mysqltest3;
diff --git a/mysql-test/suite/rpl/r/rpl_load_table_from_master.result b/mysql-test/suite/rpl/r/rpl_load_table_from_master.result
deleted file mode 100644
index 9d9a1d7d6cb..00000000000
--- a/mysql-test/suite/rpl/r/rpl_load_table_from_master.result
+++ /dev/null
@@ -1,51 +0,0 @@
-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;
-"******************** Test Requirment 1 *************"
-SET SQL_LOG_BIN=0,timestamp=200006;
-CREATE TABLE t1(t TIMESTAMP NOT NULL,a CHAR(1))ENGINE=MyISAM;
-INSERT INTO t1 ( a) VALUE ('F');
-select unix_timestamp(t) from t1;
-unix_timestamp(t)
-200006
-load table t1 from master;
-select unix_timestamp(t) from t1;
-unix_timestamp(t)
-200006
-set SQL_LOG_BIN=1,timestamp=default;
-drop table t1;
-set SQL_LOG_BIN=0;
-"******************** Test Requirment 2 *************"
-CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1;
-INSERT INTO t1 VALUES (1);
-load table t1 from master;
-check table t1;
-Table Op Msg_type Msg_text
-test.t1 check status OK
-drop table t1;
-drop table t1;
-set SQL_LOG_BIN=0;
-create table t1 (word char(20) not null, index(word))ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t1;
-create table t2 (word char(20) not null)ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t2;
-create table t3 (word char(20) not null primary key)ENGINE=MyISAM;
-load table t1 from master;
-load table t2 from master;
-load table t3 from master;
-check table t1;
-Table Op Msg_type Msg_text
-test.t1 check status OK
-select count(*) from t2;
-count(*)
-70
-select count(*) from t3;
-count(*)
-0
-set SQL_LOG_BIN=1;
-drop table if exists t1,t2,t3;
-create table t1(n int);
-drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
index 08d3241c48f..a353ee73d3f 100644
--- a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
@@ -13,8 +13,8 @@ n
2001
2002
show slave hosts;
-Server_id Host Port Rpl_recovery_rank Master_id
-2 127.0.0.1 9999 0 1
+Server_id Host Port Master_id
+2 127.0.0.1 9999 1
drop table t1;
stop slave;
create table t2(id int auto_increment primary key, created datetime);
diff --git a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
index 501749e12f9..028b73e6153 100644
--- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
@@ -92,7 +92,7 @@ reset slave;
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
-Master_User root
+Master_User test
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File
@@ -130,6 +130,7 @@ Last_SQL_Errno 0
Last_SQL_Error
Replicate_Ignore_Server_Ids
Master_Server_Id 1
+change master to master_user='root';
start slave;
SHOW SLAVE STATUS;
Slave_IO_State #
diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result
new file mode 100644
index 00000000000..9838d8b08a8
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.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;
+RESET SLAVE;
+CHANGE MASTER TO master_host='127.0.0.1',master_port=MASTER_PORT,master_user='root';
+START SLAVE IO_THREAD;
+SHOW SLAVE HOSTS;
+Server_id Host Port Master_id
+3 slave2 DEFAULT_PORT 1
+2 SLAVE_PORT 1
+STOP SLAVE IO_THREAD;
+SHOW SLAVE HOSTS;
+Server_id Host Port Master_id
+2 SLAVE_PORT 1
diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result
index e2946bb487a..58c0280aafe 100644
--- a/mysql-test/suite/rpl/r/rpl_sp.result
+++ b/mysql-test/suite/rpl/r/rpl_sp.result
@@ -191,14 +191,9 @@ begin
return unix_timestamp();
end|
ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
-set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators;
set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
-set global log_bin_trust_routine_creators=1;
-Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set global log_bin_trust_function_creators=0;
set global log_bin_trust_function_creators=1;
-set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators;
set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
set global log_bin_trust_function_creators=1;
create function fn2()
@@ -557,13 +552,7 @@ insert into t values (1);
return 0;
end
master-bin.000001 # Query # # use `mysqltest`; SELECT `mysqltest2`.`f1`()
-set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
-Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
-set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
-Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
drop database mysqltest;
drop database mysqltest2;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
index d18ca563b7b..94e8a31390d 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
@@ -92,7 +92,7 @@ reset slave;
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
-Master_User root
+Master_User test
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File
@@ -130,6 +130,7 @@ Last_SQL_Errno 0
Last_SQL_Error
Replicate_Ignore_Server_Ids
Master_Server_Id 1
+change master to master_user='root';
start slave;
SHOW SLAVE STATUS;
Slave_IO_State #
diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
index da962a7fb9d..485ba229257 100644
--- a/mysql-test/suite/rpl/t/disabled.def
+++ b/mysql-test/suite/rpl/t/disabled.def
@@ -10,9 +10,5 @@
#
##############################################################################
-rpl_get_master_version_and_clock: # Bug#46931 2009-10-17 joro rpl.rpl_get_master_version_and_clock fails
rpl_cross_version : BUG#43913 2009-10-22 luis rpl_cross_version fails with symptom in described in bug report
rpl_spec_variables : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
-rpl_empty_master_crash : BUG#48048
-rpl_load_from_master : BUG#48048
-rpl_load_table_from_master : BUG#48048
diff --git a/mysql-test/suite/rpl/t/rpl000010.test b/mysql-test/suite/rpl/t/rpl000010.test
index 261b9148774..a95cded6496 100644
--- a/mysql-test/suite/rpl/t/rpl000010.test
+++ b/mysql-test/suite/rpl/t/rpl000010.test
@@ -6,14 +6,10 @@ source include/master-slave.inc;
create table t1 (n int not null auto_increment primary key);
insert into t1 values(NULL);
insert into t1 values(2);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select n from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000011.test b/mysql-test/suite/rpl/t/rpl000011.test
index 32f6227f7c5..baff7c1a1b5 100644
--- a/mysql-test/suite/rpl/t/rpl000011.test
+++ b/mysql-test/suite/rpl/t/rpl000011.test
@@ -4,7 +4,9 @@ create table t1 (n int);
insert into t1 values(1);
sync_slave_with_master;
stop slave;
+--source include/wait_for_slave_to_stop.inc
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
insert into t1 values(2);
#let slave catch up
diff --git a/mysql-test/suite/rpl/t/rpl000013.test b/mysql-test/suite/rpl/t/rpl000013.test
index 69a102e84ce..c5a3285733a 100644
--- a/mysql-test/suite/rpl/t/rpl000013.test
+++ b/mysql-test/suite/rpl/t/rpl000013.test
@@ -9,9 +9,7 @@
--source include/have_binlog_format_mixed_or_statement.inc
source include/master-slave.inc;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection master;
create table t2(n int);
@@ -46,8 +44,6 @@ connection master2;
# exist in this connection.
drop table if exists t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000017-slave.opt b/mysql-test/suite/rpl/t/rpl000017-slave.opt
deleted file mode 100644
index 58a964c90d0..00000000000
--- a/mysql-test/suite/rpl/t/rpl000017-slave.opt
+++ /dev/null
@@ -1 +0,0 @@
---skip-slave-start
diff --git a/mysql-test/suite/rpl/t/rpl000017-slave.sh b/mysql-test/suite/rpl/t/rpl000017-slave.sh
index 1d95798260a..1d95798260a 100755..100644
--- a/mysql-test/suite/rpl/t/rpl000017-slave.sh
+++ b/mysql-test/suite/rpl/t/rpl000017-slave.sh
diff --git a/mysql-test/suite/rpl/t/rpl000017.test b/mysql-test/suite/rpl/t/rpl000017.test
index d6b3e46fa31..a65189657cc 100644
--- a/mysql-test/suite/rpl/t/rpl000017.test
+++ b/mysql-test/suite/rpl/t/rpl000017.test
@@ -1,12 +1,23 @@
+# The test manually replaces the relay-log.info file with connection
+# information which the slave then should pick up. However, to avoid
+# overwriting the file, no CHANGE MASTER TO nor RESET SLAVE statements
+# should be executed.
+#
+# Starting replication before granting a replication user privileges
+# to replicate will cause the start slave to fail, so we shouldn't do
+# that.
+
+let $no_change_master = 1;
+let $skip_slave_start = 1;
source include/master-slave.inc;
-connection slave;
-stop slave;
+
connection master;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
connection slave;
start slave;
source include/wait_for_slave_to_start.inc;
+
connection master;
--disable_warnings
drop table if exists t1;
diff --git a/mysql-test/suite/rpl/t/rpl_000015-slave.opt b/mysql-test/suite/rpl/t/rpl_000015-slave.opt
index 28bc753dd56..178e9d781f6 100644
--- a/mysql-test/suite/rpl/t/rpl_000015-slave.opt
+++ b/mysql-test/suite/rpl/t/rpl_000015-slave.opt
@@ -1 +1 @@
---server-id=22 --master-connect-retry=7
+--server-id=22
diff --git a/mysql-test/suite/rpl/t/rpl_000015.test b/mysql-test/suite/rpl/t/rpl_000015.test
index 45a43cd38d0..446c2f06ae5 100644
--- a/mysql-test/suite/rpl/t/rpl_000015.test
+++ b/mysql-test/suite/rpl/t/rpl_000015.test
@@ -15,14 +15,12 @@ connection slave;
reset slave;
source include/show_slave_status2.inc;
-change master to master_host='127.0.0.1';
-# The following needs to be cleaned up when change master is fixed
-source include/show_slave_status2.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
- master_password='',master_port=$MASTER_MYPORT;
+ master_password='',master_port=$MASTER_MYPORT, MASTER_CONNECT_RETRY=7;
source include/show_slave_status2.inc;
start slave;
+--source include/wait_for_slave_to_start.inc
sync_with_master;
source include/show_slave_status2.inc;
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_alter.test b/mysql-test/suite/rpl/t/rpl_alter.test
index 576376a0264..6a6da9c9f24 100644
--- a/mysql-test/suite/rpl/t/rpl_alter.test
+++ b/mysql-test/suite/rpl/t/rpl_alter.test
@@ -10,15 +10,11 @@ insert into mysqltest.t1 values (1,2);
create table mysqltest.t2 (n int);
insert into mysqltest.t2 values (45);
rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from mysqltest.t2;
select * from mysqltest.t3;
connection master;
drop database mysqltest;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
index d4b7872fb2b..8c95e158847 100644
--- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
@@ -51,9 +51,7 @@ CALL simpleproc3();
select * from t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
use test1;
select * from t1;
diff --git a/mysql-test/suite/rpl/t/rpl_bit.test b/mysql-test/suite/rpl/t/rpl_bit.test
index 07b0778296c..c648159ff3a 100644
--- a/mysql-test/suite/rpl/t/rpl_bit.test
+++ b/mysql-test/suite/rpl/t/rpl_bit.test
@@ -78,10 +78,8 @@ SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
SELECT hex(bit1) FROM test.t1 ORDER BY bit1;
SELECT hex(bit2) from test.t1 ORDER BY bit2;
SELECT hex(bit3) from test.t1 ORDER BY bit3;
-save_master_pos;
+sync_slave_with_master;
-connection slave;
-sync_with_master;
SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
SELECT hex(bit1) FROM test.t1 ORDER BY bit1;
SELECT hex(bit2) from test.t1 ORDER BY bit2;
diff --git a/mysql-test/suite/rpl/t/rpl_bit_npk.test b/mysql-test/suite/rpl/t/rpl_bit_npk.test
index 12b587919f9..1df7341eafc 100644
--- a/mysql-test/suite/rpl/t/rpl_bit_npk.test
+++ b/mysql-test/suite/rpl/t/rpl_bit_npk.test
@@ -76,10 +76,8 @@ SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034
SELECT hex(bit1) from test.t1 ORDER BY bit1;
SELECT hex(bit2) from test.t1 ORDER BY bit2;
SELECT hex(bit3) from test.t1 ORDER BY bit3;
-save_master_pos;
+sync_slave_with_master;
-connection slave;
-sync_with_master;
SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034
FROM test.t1
ORDER BY oSupp, sSuppD, GSuppDf, VNotSupp, x034;
@@ -100,10 +98,8 @@ UPDATE test.t3 SET a = 2 WHERE b = 0;
SELECT a, hex(b) FROM test.t2 ORDER BY a,b;
SELECT * FROM test.t3 ORDER BY a,b;
-save_master_pos;
+sync_slave_with_master;
-connection slave;
-sync_with_master;
SELECT a, hex(b) FROM test.t2 ORDER BY a,b;
SELECT * FROM test.t3 ORDER BY a,b;
diff --git a/mysql-test/suite/rpl/t/rpl_bug33931.test b/mysql-test/suite/rpl/t/rpl_bug33931.test
index 1316ddb7401..42d86a7fc1e 100644
--- a/mysql-test/suite/rpl/t/rpl_bug33931.test
+++ b/mysql-test/suite/rpl/t/rpl_bug33931.test
@@ -8,23 +8,25 @@ source include/have_log_bin.inc;
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
-
connection master;
reset master;
connection slave;
+reset slave;
# Add suppression for expected warnings in slaves error log
call mtr.add_suppression("Failed during slave I/O thread initialization");
---disable_warnings
-stop slave;
---enable_warnings
-reset slave;
-
# Set debug flags on slave to force errors to occur
SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
+--disable_query_log
+eval CHANGE MASTER TO MASTER_USER='root',
+ MASTER_CONNECT_RETRY=1,
+ MASTER_HOST='127.0.0.1',
+ MASTER_PORT=$MASTER_MYPORT;
+--enable_query_log
+
start slave;
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt b/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt
new file mode 100644
index 00000000000..37fc56036fb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt
@@ -0,0 +1 @@
+--loose-debug=-d,simulate_find_log_pos_error
diff --git a/mysql-test/suite/rpl/t/rpl_bug41902.test b/mysql-test/suite/rpl/t/rpl_bug41902.test
new file mode 100644
index 00000000000..05f13bbc848
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bug41902.test
@@ -0,0 +1,61 @@
+# Test for Bug #41902 MYSQL_BIN_LOG::reset_logs() doesn't call my_error()
+# in face of an error
+#
+
+source include/have_debug.inc;
+source include/master-slave.inc;
+
+#
+# test checks that
+# a. there is no crash when find_log_pos() returns with an error
+# that tests expect to receive;
+# b. in the case of multiple error messages the first error message is
+# reported to the user and others are available as warnings.
+#
+
+connection slave;
+stop slave;
+
+SET @@debug="d,simulate_find_log_pos_error";
+
+--error ER_UNKNOWN_TARGET_BINLOG
+reset slave;
+show warnings;
+
+SET @@debug="";
+reset slave;
+change master to master_host='dummy';
+
+SET @@debug="d,simulate_find_log_pos_error";
+
+--error ER_UNKNOWN_TARGET_BINLOG
+change master to master_host='dummy';
+
+SET @@debug="";
+reset slave;
+change master to master_host='dummy';
+
+connection master;
+SET @@debug="d,simulate_find_log_pos_error";
+--error ER_UNKNOWN_TARGET_BINLOG
+reset master;
+
+SET @@debug="";
+reset master;
+
+SET @@debug="d,simulate_find_log_pos_error";
+--error ER_UNKNOWN_TARGET_BINLOG
+purge binary logs to 'master-bin.000001';
+
+SET @@debug="";
+purge binary logs to 'master-bin.000001';
+
+--disable_query_log
+call mtr.add_suppression("Failed to locate old binlog or relay log files");
+call mtr.add_suppression("MYSQL_LOG::purge_logs was called with file ./master-bin.000001 not listed in the index");
+connection slave;
+call mtr.add_suppression("Failed to locate old binlog or relay log files");
+call mtr.add_suppression("MYSQL_LOG::purge_logs was called with file ./master-bin.000001 not listed in the index");
+--enable_query_log
+
+--echo End of the tests
diff --git a/mysql-test/suite/rpl/t/rpl_change_master.test b/mysql-test/suite/rpl/t/rpl_change_master.test
index c1ef417ea78..997cca42e82 100644
--- a/mysql-test/suite/rpl/t/rpl_change_master.test
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test
@@ -28,9 +28,7 @@ sync_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
index a49253f90c1..37420b13805 100644
--- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
@@ -7,6 +7,9 @@
#############################################################
--source include/have_innodb.inc
+# Use wait_for_slave_to_(start|stop) for current connections
+let $keep_connection= 1;
+
# Set up circular ring and new names for servers
--echo *** Set up circular ring by schema A->B->C->D->A ***
--source include/circular_rpl_for_4_hosts_init.inc
diff --git a/mysql-test/suite/rpl/t/rpl_colSize.test b/mysql-test/suite/rpl/t/rpl_colSize.test
index c20f2c3fd35..07fd8041b18 100644
--- a/mysql-test/suite/rpl/t/rpl_colSize.test
+++ b/mysql-test/suite/rpl/t/rpl_colSize.test
@@ -16,6 +16,7 @@ DROP TABLE IF EXISTS t1;
--echo *** Create "wider" table on slave ***
sync_slave_with_master;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
RESET SLAVE;
eval CREATE TABLE t1 (
@@ -69,6 +70,7 @@ RESET MASTER;
--echo *** Start replication ***
connection slave;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
--echo *** Insert data on master and display it. ***
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test
index a13adf28b95..1cd36d35931 100644
--- a/mysql-test/suite/rpl/t/rpl_do_grant.test
+++ b/mysql-test/suite/rpl/t/rpl_do_grant.test
@@ -8,9 +8,7 @@ connection master;
delete from mysql.user where user=_binary'rpl_do_grant';
delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# if these DELETE did nothing on the master, we need to do them manually on the
# slave.
delete from mysql.user where user=_binary'rpl_ignore_grant';
@@ -21,17 +19,13 @@ flush privileges;
connection master;
grant select on *.* to rpl_do_grant@localhost;
grant drop on test.* to rpl_do_grant@localhost;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
show grants for rpl_do_grant@localhost;
# test replication of SET PASSWORD
connection master;
set password for rpl_do_grant@localhost=password("does it work?");
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
#
@@ -44,9 +38,7 @@ select password<>'' from mysql.user where user='rpl_do_grant';
set sql_mode='ANSI_QUOTES';
set password for rpl_do_grant@localhost=password('does it work?');
set sql_mode='';
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select password<>'' from mysql.user where user='rpl_do_grant';
diff --git a/mysql-test/suite/rpl/t/rpl_drop.test b/mysql-test/suite/rpl/t/rpl_drop.test
index b38007a755f..6f586d90de3 100644
--- a/mysql-test/suite/rpl/t/rpl_drop.test
+++ b/mysql-test/suite/rpl/t/rpl_drop.test
@@ -7,10 +7,6 @@ drop table if exists t1, t2;
create table t1 (a int);
--error 1051
drop table t1, t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
-
-
diff --git a/mysql-test/suite/rpl/t/rpl_drop_view.test b/mysql-test/suite/rpl/t/rpl_drop_view.test
index 11633a0a7e8..05bf112b8b8 100644
--- a/mysql-test/suite/rpl/t/rpl_drop_view.test
+++ b/mysql-test/suite/rpl/t/rpl_drop_view.test
@@ -20,9 +20,7 @@ drop view v1, not_exist_view;
--error 1146
select * from v1;
drop view v2, v3;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--error 1146
select * from v1;
--error 1146
diff --git a/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test b/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
index 9efb3d16d2b..b2530e83b89 100644
--- a/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
+++ b/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
@@ -22,6 +22,7 @@ connection master;
eval change master to master_host="127.0.0.1",master_port=$SLAVE_MYPORT,master_user="root";
start slave;
+--source include/wait_for_slave_to_start.inc
# now we test it
@@ -38,12 +39,11 @@ sync_with_master;
# log-slave-updates and circul repl
#
stop slave;
+--source include/wait_for_slave_to_stop.inc
create table t2 (n int); # create one ignored event
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection slave;
@@ -85,6 +85,7 @@ start slave until master_log_file="slave-bin.000001",master_log_pos=663;
select * from t3;
start slave;
+--source include/wait_for_slave_to_start.inc
# BUG#13023 is that Exec_master_log_pos may stay too low "forever":
@@ -94,9 +95,7 @@ create table t4 (n int); # create 3 ignored events
create table t5 (n int);
create table t6 (n int);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection slave;
@@ -114,11 +113,10 @@ show tables;
# cleanup
stop slave;
+--source include/wait_for_slave_to_stop.inc
reset slave;
drop table t1,t2,t3,t4,t5,t6;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt b/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt
deleted file mode 100644
index cef79bc8585..00000000000
--- a/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---force-restart
diff --git a/mysql-test/suite/rpl/t/rpl_empty_master_crash.test b/mysql-test/suite/rpl/t/rpl_empty_master_crash.test
deleted file mode 100644
index f8e7870ae3c..00000000000
--- a/mysql-test/suite/rpl/t/rpl_empty_master_crash.test
+++ /dev/null
@@ -1,14 +0,0 @@
-source include/master-slave.inc;
-
-source include/show_slave_status.inc;
-
-#
-# Load table should not succeed on the master as this is not a slave
-#
---error 1218
-load table t1 from master;
-connection slave;
---error 1188
-load table t1 from master;
-
-# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
index e77cd308f39..a955de02c0f 100644
--- a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
+++ b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
@@ -14,19 +14,15 @@ create table t4 (a int primary key);
--error 1022, ER_DUP_ENTRY
insert into t1 values (1),(1);
insert into t4 values (1),(2);
-save_master_pos;
-connection slave;
# as the t1 table is ignored on the slave, the slave should be able to sync
-sync_with_master;
+sync_slave_with_master;
# check that the table has been ignored, because otherwise the test is nonsense
show tables like 't1';
show tables like 't4';
SELECT * FROM test.t4 ORDER BY a;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# Now test that even critical errors (connection killed)
# are ignored if rules allow it.
@@ -53,15 +49,11 @@ connection master;
--error 0,1317,2013
reap;
connection master1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t4 ORDER BY a;
connection master1;
DROP TABLE test.t4;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
# Adding comment for force manual merge 5.0 -> wl1012. delete me if needed
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh
index a321dd690cd..a321dd690cd 100755..100644
--- a/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh
index e46ea6d400b..e46ea6d400b 100755..100644
--- a/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test
index a8befe612c2..a873c1fa3a9 100644
--- a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test
@@ -1,6 +1,8 @@
# Testing if "flush logs" command bouncing resulting in logs created in a loop
# in case of bi-directional replication
-- source include/master-slave.inc
+# Use wait_for_slave_to_(start|stop) for current connections
+let $keep_connection= 1;
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR/
@@ -9,18 +11,20 @@ show variables like 'relay_log%';
connection slave;
--disable_warnings
stop slave;
+--source include/wait_for_slave_to_stop.inc
--enable_warnings
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
start slave;
-
+--source include/wait_for_slave_to_start.inc
#
# Start replication slave -> master
#
connection master;
--disable_warnings
stop slave;
+--source include/wait_for_slave_to_stop.inc
--enable_warnings
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval change master to master_host='127.0.0.1',master_user='root',
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix.cnf b/mysql-test/suite/rpl/t/rpl_ip_mix.cnf
new file mode 100644
index 00000000000..00e2637d822
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= ::
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= 0.0.0.0
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix.test b/mysql-test/suite/rpl/t/rpl_ip_mix.test
new file mode 100644
index 00000000000..68aa2fc87a9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix.test
@@ -0,0 +1,93 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, master: --bind-address=::, slave: --bind-address=0.0.0.0
+# (see corresponding cnf file)
+#
+--source include/check_ipv6.inc
+# Can't be tested with windows due to mixed format like 0::0000:FFFF:127.0.0.1
+--source include/not_windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+#let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix.inc
+
+let $IPv6= ::FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+#let $IPv6= ::FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,$IPv6,root,,test,MASTER_MYPORT);
+connect (master,$IPv6,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='::FFFF:127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix2.cnf b/mysql-test/suite/rpl/t/rpl_ip_mix2.cnf
new file mode 100644
index 00000000000..306df437bcc
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix2.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= 0.0.0.0
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= ::
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix2.test b/mysql-test/suite/rpl/t/rpl_ip_mix2.test
new file mode 100644
index 00000000000..d6435d710c1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix2.test
@@ -0,0 +1,109 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, master: --bind-address=0.0.0.0, slave: --bind-address=::
+# (see corresponding cnf file)
+#
+# Check if ipv6 is available. If not, server is crashing (see BUG#48915).
+--disable_query_log
+--disable_abort_on_error
+connect (checkcon123456789,::1,root,,test,$SLAVE_MYPORT);
+if($mysql_errno)
+{
+skip wrong IP for slave;
+}
+connection default;
+disconnect checkcon123456789;
+--enable_abort_on_error
+--enable_query_log
+# end check
+
+# Can't be tested with windows due to mixed format like 0::0000:FFFF:127.0.0.1
+--source include/not_windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+#let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix2.inc
+
+let $IPv6= ::FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+#let $IPv6= ::FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix2.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT);
+connect (slave,$IPv6,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='::FFFF:127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix2_win.cnf b/mysql-test/suite/rpl/t/rpl_ip_mix2_win.cnf
new file mode 100644
index 00000000000..306df437bcc
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix2_win.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= 0.0.0.0
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= ::
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix2_win.test b/mysql-test/suite/rpl/t/rpl_ip_mix2_win.test
new file mode 100644
index 00000000000..f9a2022ddd4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix2_win.test
@@ -0,0 +1,78 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, master: --bind-address=0.0.0.0, slave: --bind-address=::
+# (see corresponding cnf file)
+#
+# Check if ipv6 is available. If not, server is crashing (see BUG#48915).
+--disable_query_log
+--disable_abort_on_error
+connect (checkcon123456789,::1,root,,test,$SLAVE_MYPORT);
+if($mysql_errno)
+{
+skip wrong IP for slave;
+}
+connection default;
+disconnect checkcon123456789;
+--enable_abort_on_error
+--enable_query_log
+# end check
+
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix2.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT);
+connect (slave,$IPv6,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+--exit
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix_win.cnf b/mysql-test/suite/rpl/t/rpl_ip_mix_win.cnf
new file mode 100644
index 00000000000..00e2637d822
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix_win.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= ::
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= 0.0.0.0
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ip_mix_win.test b/mysql-test/suite/rpl/t/rpl_ip_mix_win.test
new file mode 100644
index 00000000000..7d78f71bd1b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ip_mix_win.test
@@ -0,0 +1,65 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, master: --bind-address=::, slave: --bind-address=0.0.0.0
+# (see corresponding cnf file)
+#
+--source include/check_ipv6.inc
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ip_mix.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ip_mix.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,$IPv6,root,,test,MASTER_MYPORT);
+connect (master,$IPv6,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+--exit
diff --git a/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.cnf b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.cnf
new file mode 100644
index 00000000000..b646a4088ff
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= 0.0.0.0
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= 0.0.0.0
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.test b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.test
new file mode 100644
index 00000000000..f4e5ad6af7b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6.test
@@ -0,0 +1,90 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv4 (127.0.0.1) in ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, --bind-address=0.0.0.0 (see corresponding cnf file)
+# for master and slave
+#
+# Check if ipv4 is available.
+--disable_query_log
+--disable_abort_on_error
+connect (checkcon123456789,127.0.0.1,root,,test);
+if($mysql_errno)
+{
+skip wrong IP;
+}
+connection default;
+disconnect checkcon123456789;
+--enable_abort_on_error
+--enable_query_log
+# end check
+
+# Can't be tested with windows due to mixed format like 0::0000:FFFF:127.0.0.1
+--source include/not_windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+#let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= ::FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+#let $IPv6= ::FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='::FFFF:127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.cnf b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.cnf
new file mode 100644
index 00000000000..b646a4088ff
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= 0.0.0.0
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= 0.0.0.0
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.test b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.test
new file mode 100644
index 00000000000..db786536c2d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv4_as_ipv6_win.test
@@ -0,0 +1,63 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv4 (127.0.0.1) in ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, --bind-address=0.0.0.0 (see corresponding cnf file)
+# for master and slave
+#
+# Check if ipv4 is available.
+--disable_query_log
+--disable_abort_on_error
+connect (checkcon123456789,127.0.0.1,root,,test);
+if($mysql_errno)
+{
+skip wrong IP;
+}
+connection default;
+disconnect checkcon123456789;
+--enable_abort_on_error
+--enable_query_log
+# end check
+
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+--exit
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv6.cnf b/mysql-test/suite/rpl/t/rpl_ipv6.cnf
new file mode 100644
index 00000000000..c657e7c5115
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv6.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= ::
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= ::
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv6.test b/mysql-test/suite/rpl/t/rpl_ipv6.test
new file mode 100644
index 00000000000..71fedcb4208
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv6.test
@@ -0,0 +1,93 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, --bind-address=:: (see corresponding cnf file)
+# for master and slave.
+#
+--source include/check_ipv6.inc
+# Can't be tested with windows due to mixed format like 0::0000:FFFF:127.0.0.1
+--source include/not_windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+#let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= ::FFFF:127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+#let $IPv6= ::FFFF:127.0.0.1/96;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='::FFFF:127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv6_win.cnf b/mysql-test/suite/rpl/t/rpl_ipv6_win.cnf
new file mode 100644
index 00000000000..c657e7c5115
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv6_win.cnf
@@ -0,0 +1,56 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+skip-name-resolve
+bind-address= ::
+
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+init-rpl-role= slave
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= localhost
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+skip-name-resolve
+bind-address= ::
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_ipv6_win.test b/mysql-test/suite/rpl/t/rpl_ipv6_win.test
new file mode 100644
index 00000000000..7c9d437541a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ipv6_win.test
@@ -0,0 +1,65 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format, especially "change master host=..."
+# Options: --skip-name-resolve, --bind-address=:: (see corresponding cnf file)
+# for master and slave.
+#
+--source include/check_ipv6.inc
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+--source include/have_log_bin.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= ::1/128;
+#--echo #################### IP: $IPv6 ###########################
+#--source include/rpl_ipv6.inc
+
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 0:0:0:0:0:0:0:1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= 127.0.0.1;
+--echo #################### IP: $IPv6 ###########################
+--source include/rpl_ipv6.inc
+
+let $IPv6= ::1;
+--echo #################### IP: $IPv6 mix #######################
+--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT);
+--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
+--echo connection master;
+connection master;
+reset master;
+source include/show_master_status.inc;
+save_master_pos;
+--echo connection slave;
+connection slave;
+reset slave;
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='$IPv6';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='127.0.0.1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+eval change master to master_host='0:0:0:0:0:0:0:1';
+let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1);
+--echo Master-Host: $master_host
+--echo disconnect slave;
+disconnect slave;
+--echo disconnect master;
+disconnect master;
+--echo connection default;
+connection default;
+--exit
diff --git a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
index b300603f454..60bccaad0d3 100644
--- a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
+++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
@@ -34,12 +34,14 @@ SELECT * FROM t1;
# restart replication for the next testcase
stop slave;
+--source include/wait_for_slave_to_stop.inc
reset slave;
connection master;
reset master;
drop table t1;
connection slave;
start slave;
+--source include/wait_for_slave_to_start.inc
# testcase with INSERT SELECT
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_load_from_master.test b/mysql-test/suite/rpl/t/rpl_load_from_master.test
deleted file mode 100644
index 0f085457817..00000000000
--- a/mysql-test/suite/rpl/t/rpl_load_from_master.test
+++ /dev/null
@@ -1,181 +0,0 @@
-# This one assumes we are ignoring updates on tables in database mysqltest2,
-# but doing the ones in database mysqltest
-#################################################################
-# Change Author: JBM
-# Change Date: 2006-02-02
-# Change: Added ENGINE=MyISAM
-# Reason: LOAD from master is only supported by MyISAM
-#################################################################
-
-source include/master-slave.inc;
---disable_warnings
-drop database if exists mysqltest;
-drop database if exists mysqltest2;
-drop database if exists mysqltest3;
-connection slave;
-drop database if exists mysqltest;
-drop database if exists mysqltest2;
-drop database if exists mysqltest3;
-connection master;
-create database mysqltest2;
-create database mysqltest;
---enable_warnings
-
-save_master_pos;
-connection slave;
-sync_with_master;
-create database mysqltest2;
-create table mysqltest2.foo (n int)ENGINE=MyISAM;
-insert into mysqltest2.foo values(4);
-connection master;
-create table mysqltest2.foo (n int)ENGINE=MyISAM;
-insert into mysqltest2.foo values(5);
-create table mysqltest.bar (m int)ENGINE=MyISAM;
-insert into mysqltest.bar values(15);
-save_master_pos;
-connection slave;
-sync_with_master;
-select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
-connection master;
-drop database mysqltest;
-drop database if exists mysqltest2;
-save_master_pos;
-connection slave;
-sync_with_master;
---error 1008
-drop database mysqltest;
-drop database mysqltest2;
-
-# Now let's test load data from master
-
-# First create some databases and tables on the master
-
-connection master;
-set sql_log_bin = 0;
-create database mysqltest2;
-create database mysqltest;
-show databases like 'mysql%';
-create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
-create table mysqltest2.t2(n int, s text)ENGINE=MyISAM;
-insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
-insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
-
-create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
-create table mysqltest.t2(n int, s text)ENGINE=MyISAM;
-insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
-insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
- (13, 'thirteen test');
-set sql_log_bin = 1;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# This should show that the slave is empty at this point
-show databases like 'mysql%';
-# Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM
-# MASTER will neither touch database mysqltest nor mysqltest3
-create database mysqltest2;
-create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest2.t1 values (1, 'original foo.t1');
-create table mysqltest2.t3(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest2.t3 values (1, 'original foo.t3');
-create database mysqltest3;
-create table mysqltest3.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest3.t1 values (1, 'original foo2.t1');
-
-# Create mysqltest, and mysqltest.t1, to check that it gets replaced,
-# and mysqltest.t3 to check that it is not touched (there is no
-# mysqltest.t3 on master)
-create database mysqltest;
-create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest.t1 values (1, 'original bar.t1');
-create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM;
-insert into mysqltest.t3 values (1, 'original bar.t3');
-
-load data from master;
-
-# Now let's check if we have the right tables and the right data in them
-show databases like 'mysql%';
-use mysqltest2;
-
-# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which
-# databases have to be copied. So it thinks "mysqltest" has to be
-# copied. Before 4.0.16 it would first drop "mysqltest", then create
-# "mysqltest". This "drop" is a bug; in that case t3 would disappear. So
-# here the effect of this bug (BUG#1248) would be to leave an empty
-# "mysqltest" on the slave.
-
-show tables; # should be t1 & t3
-select * from t1; # should be slave's original
-use mysqltest3;
-show tables; # should be t1
-select * from t1; # should be slave's original
-use mysqltest;
-show tables; # should contain master's copied t1&t2, slave's original t3
-select * from mysqltest.t1;
-select * from mysqltest.t2;
-select * from mysqltest.t3;
-
-# Now let's see if replication works
-connection master;
-insert into mysqltest.t1 values (4, 'four test');
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from mysqltest.t1;
-
-# Check that LOAD DATA FROM MASTER is able to create master.info
-# if needed (if RESET SLAVE was used before), before writing to it (BUG#2922).
-
-stop slave;
-reset slave;
-load data from master;
-start slave;
-# see if replication coordinates were restored fine
-connection master;
-insert into mysqltest.t1 values (5, 'five bar');
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from mysqltest.t1;
-
-# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
-# table to be overwritten.
-# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
-# insert into mysqltest.t1 values(10, 'should be there');
-# flush tables;
-let $MYSQLD_SLAVE_DATADIR= `select @@datadir`;
-# system chmod 500 $MYSQLD_SLAVE_DATADIR/mysqltest/;
-# --error 6
-# load data from master; # should fail (errno 13)
-# system chmod 700 $MYSQLD_SLAVE_DATADIR/mysqltest/;
-# select * from mysqltest.t1; # should contain the row (10, ...)
-
-
-# Check that LOAD TABLE FROM MASTER fails if the table exists on slave
---error 1050
-load table mysqltest.t1 from master;
-drop table mysqltest.t1;
-load table mysqltest.t1 from master;
-
-# Check what happens when requestion not existing table
-#
---error 1188
-load table bar.t1 from master;
-
-# as LOAD DATA FROM MASTER failed it did not restart slave threads
-# DISABLED FOR NOW
-# start slave;
-
-# Now time for cleanup
-connection master;
-drop database mysqltest;
-drop database mysqltest2;
-save_master_pos;
-connection slave;
-sync_with_master;
-# These have to be dropped on slave because they are not replicated
-drop database mysqltest2;
-drop database mysqltest3;
-
-# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_load_table_from_master.test b/mysql-test/suite/rpl/t/rpl_load_table_from_master.test
deleted file mode 100644
index aad113878d3..00000000000
--- a/mysql-test/suite/rpl/t/rpl_load_table_from_master.test
+++ /dev/null
@@ -1,98 +0,0 @@
-###########################################################
-# Change Author: JBM
-# Change Date: 2006-2-2
-# Change: Added ENGINE=$engine_type for first create table
-# Reason: Only MyISAM supports load from master no need to
-# run test case for other engines, in addition test will
-# fail if other engines are set as default engine
-###########################################################
-# Change Author: JBM
-# Change Date: 2006-2-3
-# Change: removed ENGINE=$engine_type for first create table
-# and renamed test file to rpl_load_table_from_master.test.
-# In addition added test requirements.
-# Reason: Request from review.
-############################################################
-# REQUIREMENT TEST 1:
-# LOAD TABLE FROM MASTER must work with a forced timestamp.
-############################################################
-#
-# Test forced timestamp
-#
--- source include/master-slave.inc
-
--- echo "******************** Test Requirment 1 *************"
-
-# Don't log table creating to the slave as we want to test LOAD TABLE
-SET SQL_LOG_BIN=0,timestamp=200006;
-eval CREATE TABLE t1(t TIMESTAMP NOT NULL,a CHAR(1))ENGINE=MyISAM;
-INSERT INTO t1 ( a) VALUE ('F');
-select unix_timestamp(t) from t1;
-connection slave;
-load table t1 from master;
-select unix_timestamp(t) from t1;
-
-# Delete the created table on master and slave
-connection master;
-set SQL_LOG_BIN=1,timestamp=default;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-connection master;
-
-#
-# Test copying table with checksum
-#
-
-# Don't log table creating to the slave as we want to test LOAD TABLE
-set SQL_LOG_BIN=0;
-
-#######################################################
-# REQUIREMENTi TEST 2:
-#LOAD TABLE FROM MASTER must work with table checksum
-#######################################################
--- echo "******************** Test Requirment 2 *************"
-
-eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1;
-INSERT INTO t1 VALUES (1);
-save_master_pos;
-connection slave;
-sync_with_master;
-load table t1 from master;
-check table t1;
-drop table t1;
-connection master;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-connection master;
-set SQL_LOG_BIN=0;
-create table t1 (word char(20) not null, index(word))ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t1;
-create table t2 (word char(20) not null)ENGINE=MyISAM;
-load data infile '../../std_data/words.dat' into table t2;
-create table t3 (word char(20) not null primary key)ENGINE=MyISAM;
-connection slave;
-load table t1 from master;
-load table t2 from master;
-load table t3 from master;
-check table t1;
-select count(*) from t2;
-select count(*) from t3;
-connection master;
-set SQL_LOG_BIN=1;
-drop table if exists t1,t2,t3;
-save_master_pos;
-connection slave;
-sync_with_master;
-create table t1(n int);
-drop table t1;
-
-
-
-
-
-# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_charset.test b/mysql-test/suite/rpl/t/rpl_loaddata_charset.test
index 031a0f6c351..3e1bc917a41 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_charset.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_charset.test
@@ -23,9 +23,7 @@ load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8
select hex(a) from t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select hex(a) from t1;
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
index b7d9995c834..979f09f64e6 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
@@ -16,7 +16,7 @@ connection master;
LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE t1;
connection slave;
-wait_for_slave_to_stop;
+--source include/wait_for_slave_sql_to_stop.inc
source include/show_slave_status.inc;
connection slave;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_m.test b/mysql-test/suite/rpl/t/rpl_loaddata_m.test
index 42c3ad99f33..48451c4aee1 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_m.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_m.test
@@ -28,9 +28,7 @@ LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
SELECT COUNT(*) FROM mysqltest.t1;
# Now lets check the slave to see what we have :-)
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SHOW DATABASES;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_s.test b/mysql-test/suite/rpl/t/rpl_loaddata_s.test
index 2dd2218eb5c..91ebcf058a6 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_s.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_s.test
@@ -16,9 +16,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
# Test logging on slave;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select count(*) from test.t1; # check that LOAD was replicated
source include/show_binlog_events.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
index a93a82d6d9f..ed556f3aedf 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
@@ -27,15 +27,11 @@ truncate table t1;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
--remove_file $MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select a,count(*) from t1 group by a;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_master_pos_wait.test b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test
index 2f7b18ae04b..ea107a28954 100644
--- a/mysql-test/suite/rpl/t/rpl_master_pos_wait.test
+++ b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test
@@ -1,9 +1,7 @@
# See if master_pos_wait(,,timeout)
# Terminates with "timeout expired" (-1)
source include/master-slave.inc;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# Ask for a master log that has certainly not been reached yet
# timeout= 2 seconds
select master_pos_wait('master-bin.999999',0,2);
diff --git a/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh b/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh
index 8ce79797822..8ce79797822 100755..100644
--- a/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh
+++ b/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh
diff --git a/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
index 6a1f81abed3..85335d47c3a 100644
--- a/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
+++ b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
@@ -18,6 +18,7 @@ show slave hosts;
drop table t1;
sync_slave_with_master;
stop slave;
+--source include/wait_for_slave_to_stop.inc
connection master;
# Test replication of timestamp
@@ -35,6 +36,7 @@ create table t5 select * from t4;
save_master_pos;
connection slave;
start slave;
+--source include/wait_for_slave_to_start.inc
sync_with_master;
select * from t2;
show create table t3;
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete.test b/mysql-test/suite/rpl/t/rpl_multi_delete.test
index a251cbf8833..568a8a578a9 100644
--- a/mysql-test/suite/rpl/t/rpl_multi_delete.test
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete.test
@@ -19,8 +19,6 @@ select * from t2;
connection master;
drop table t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete2.test b/mysql-test/suite/rpl/t/rpl_multi_delete2.test
index e91fad1872a..c3f939276e0 100644
--- a/mysql-test/suite/rpl/t/rpl_multi_delete2.test
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete2.test
@@ -27,11 +27,9 @@ SELECT * FROM a;
insert into a values(2),(3);
delete alias FROM a alias where alias.i=2;
select * from a;
-save_master_pos;
-connection slave;
+sync_slave_with_master;
use mysqltest_to;
-sync_with_master;
select * from a;
# BUG#3461
diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test
index f4582ba1167..3c677a95463 100644
--- a/mysql-test/suite/rpl/t/rpl_optimize.test
+++ b/mysql-test/suite/rpl/t/rpl_optimize.test
@@ -47,8 +47,7 @@ sync_with_master; # won't work if slave SQL thread stopped
connection master; # cleanup
drop table t1;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# If the machine is so fast that slave syncs before OPTIMIZE
# starts, this test wil demonstrate nothing but will pass.
diff --git a/mysql-test/suite/rpl/t/rpl_packet.test b/mysql-test/suite/rpl/t/rpl_packet.test
index bfc144c759b..61a1ad9d987 100644
--- a/mysql-test/suite/rpl/t/rpl_packet.test
+++ b/mysql-test/suite/rpl/t/rpl_packet.test
@@ -38,20 +38,15 @@ select @@net_buffer_length, @@max_allowed_packet;
create table `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1023');
-save_master_pos;
+sync_slave_with_master;
-connection slave;
-sync_with_master;
eval select count(*) from `$db`.`t1` /* must be 1 */;
SHOW STATUS LIKE 'Slave_running';
select * from information_schema.session_status where variable_name= 'SLAVE_RUNNING';
connection master;
eval drop database $db;
-save_master_pos;
-
-connection slave;
-sync_with_master;
+sync_slave_with_master;
#
# Bug #23755: Replicated event larger that max_allowed_packet infinitely re-transmits
diff --git a/mysql-test/suite/rpl/t/rpl_ps.test b/mysql-test/suite/rpl/t/rpl_ps.test
index b00dec6b80c..143f75e5477 100644
--- a/mysql-test/suite/rpl/t/rpl_ps.test
+++ b/mysql-test/suite/rpl/t/rpl_ps.test
@@ -6,9 +6,7 @@
###########################################################
source include/master-slave.inc;
-#save_master_pos;
-#connection slave;
-#sync_with_master;
+#sync_slave_with_master;
#reset master;
#connection master;
@@ -30,20 +28,16 @@ prepare stmt2 from @var2;
set @var1='from-master-3';
execute stmt2 using @var1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM t1 ORDER BY n;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
stop slave;
-
+source include/wait_for_slave_to_stop.inc;
# End of 4.1 tests
#
@@ -102,13 +96,12 @@ use mysqltest1;
EXECUTE stmt_d_1;
--echo
---save_master_pos
+--sync_slave_with_master
+
--echo
--echo # Connection: slave
--echo
---connection slave
---sync_with_master
--echo
SELECT * FROM t1;
@@ -125,13 +118,12 @@ DROP DATABASE mysqltest1;
use test;
DROP TABLE t1;
--echo
---save_master_pos
+--sync_slave_with_master
+
--echo
--echo # Connection: slave
--echo
---connection slave
---sync_with_master
--echo
STOP SLAVE;
diff --git a/mysql-test/suite/rpl/t/rpl_relayspace.test b/mysql-test/suite/rpl/t/rpl_relayspace.test
index 0fc564cdb46..45b46674c05 100644
--- a/mysql-test/suite/rpl/t/rpl_relayspace.test
+++ b/mysql-test/suite/rpl/t/rpl_relayspace.test
@@ -4,6 +4,7 @@
source include/master-slave.inc;
connection slave;
stop slave;
+--source include/wait_for_slave_to_stop.inc
connection master;
# This will generate a master's binlog > 10 bytes
create table t1 (a int);
diff --git a/mysql-test/suite/rpl/t/rpl_replicate_do.test b/mysql-test/suite/rpl/t/rpl_replicate_do.test
index fea168ee9f1..3e22984aef8 100644
--- a/mysql-test/suite/rpl/t/rpl_replicate_do.test
+++ b/mysql-test/suite/rpl/t/rpl_replicate_do.test
@@ -18,18 +18,14 @@ insert into t1 values(15),(16),(17);
update t1 set m=20 where m=16;
delete from t1 where m=17;
create table t11 select * from t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1 ORDER BY m;
select * from t2;
--error 1146
select * from t11;
connection master;
drop table if exists t1,t2,t11;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# show slave status, just to see of it prints replicate-do-table
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh b/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh
index 81490a54b4b..81490a54b4b 100755..100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
index e06099fd707..2490471018b 100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -56,6 +56,7 @@ connection master;
reset master;
connection slave;
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
#
@@ -100,6 +101,7 @@ connection slave;
#restart slave skipping one event
set global sql_slave_skip_counter=1;
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
@@ -161,9 +163,7 @@ select count(*) from t3 where n >= 4;
create table t4 select * from temp_table;
source include/show_binary_logs.inc;
source include/show_master_status.inc;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t4;
source include/show_slave_status2.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test
index 0d91d855a57..33457d759b8 100644
--- a/mysql-test/suite/rpl/t/rpl_row_create_table.test
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test
@@ -25,8 +25,10 @@ sync_slave_with_master;
--disable_query_log
set @storage_engine = @@global.storage_engine;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
SET GLOBAL storage_engine=memory;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
--enable_query_log
--source include/reset_master_and_slave.inc
@@ -129,8 +131,10 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
sync_slave_with_master;
# Here we reset the value of the default storage engine
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
SET GLOBAL storage_engine=@storage_engine;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
--enable_ps_protocol
# BUG#22864 (Rollback following CREATE ... SELECT discards 'CREATE
@@ -138,11 +142,13 @@ START SLAVE;
--echo ================ BUG#22864 ================
connection slave;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
RESET SLAVE;
connection master;
RESET MASTER;
connection slave;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
connection master;
SET AUTOCOMMIT=0;
CREATE TABLE t1 (a INT);
@@ -190,6 +196,7 @@ sync_slave_with_master;
# Some tests with temporary tables
connection slave;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
RESET SLAVE;
connection master;
@@ -197,6 +204,7 @@ RESET MASTER;
connection slave;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
connection master;
CREATE TABLE t1 (a INT);
diff --git a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
index a7967f6643a..9a645baead0 100644
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
@@ -116,16 +116,14 @@ sync_slave_with_master;
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
+--source include/wait_for_slave_to_stop.inc
--enable_warnings
---require r/slave-stopped.result
-show status like 'Slave_running';
connection master;
reset master;
connection slave;
reset slave;
start slave;
---require r/slave-running.result
-show status like 'Slave_running';
+--source include/wait_for_slave_to_start.inc
connection master;
# We should be clean at this point, now we will run in the file from above.
@@ -164,7 +162,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
# this test for position option
-# By setting this position to 417, we should only get the create of t3
+# By setting this position to 416, we should only get the create of t3
--disable_query_log
select "--- Test 2 position test --" as "";
--enable_query_log
@@ -181,9 +179,7 @@ select "--- Test 3 First Remote test --" as "";
# This is broken now
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=570 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
-
-# This part is disabled due to bug #17654
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=569 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- Test 4 Second Remote test --" as "";
@@ -206,16 +202,14 @@ sync_slave_with_master;
--disable_warnings
stop slave;
+--source include/wait_for_slave_to_stop.inc
--enable_warnings
---require r/slave-stopped.result
-show status like 'Slave_running';
connection master;
reset master;
connection slave;
reset slave;
start slave;
---require r/slave-running.result
-show status like 'Slave_running';
+--source include/wait_for_slave_to_start.inc
connection master;
# We should be clean at this point, now we will run in the file from above.
@@ -272,8 +266,8 @@ let $MYSQLD_DATADIR= `select @@datadir;`;
select "--- Test 7 reading stdin w/position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --position=417 --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001
-
+--exec $MYSQL_BINLOG --short-form --position=417 --stop-position=570 - < $MYSQLD_DATADIR/master-bin.000001
+
# Bug#16217 (mysql client did not know how not switch its internal charset)
--disable_query_log
select "--- Test 8 switch internal charset --" as "";
@@ -285,16 +279,14 @@ sync_slave_with_master;
--disable_warnings
stop slave;
+--source include/wait_for_slave_to_stop.inc
--enable_warnings
---require r/slave-stopped.result
-show status like 'Slave_running';
connection master;
reset master;
connection slave;
reset slave;
start slave;
---require r/slave-running.result
-show status like 'Slave_running';
+--source include/wait_for_slave_to_start.inc
connection master;
create table t4 (f text character set utf8);
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp001.test b/mysql-test/suite/rpl/t/rpl_row_sp001.test
index 1595c4a21d5..34d42d985f9 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp001.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp001.test
@@ -90,9 +90,7 @@ delimiter ;//
INSERT INTO test.t2 VALUES(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW');
SELECT * FROM t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM t2 ORDER BY a;
connection master;
@@ -105,17 +103,13 @@ SELECT * FROM t2 ORDER BY a;
connection master;
call test.p2(2);
SELECT * FROM t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM t2 ORDER BY a;
connection master;
call test.p2(3);
SELECT * FROM t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM t2 ORDER BY a;
##Used for debugging
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp005.test b/mysql-test/suite/rpl/t/rpl_row_sp005.test
index f5a74325b7c..abc7fb4f490 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp005.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp005.test
@@ -74,9 +74,7 @@ SELECT * FROM test.t2 ORDER BY id2;
let $message=< ---- Slave selects-- >;
--source include/show_msg.inc
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t1 ORDER BY id;
SELECT * FROM test.t2 ORDER BY id2;
@@ -92,8 +90,7 @@ SELECT * FROM test.t3 ORDER BY id3;
let $message=< ---- Slave selects-- >;
--source include/show_msg.inc
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t3 ORDER BY id3;
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp008.test b/mysql-test/suite/rpl/t/rpl_row_sp008.test
index b1295820c99..80603c28d27 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp008.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp008.test
@@ -41,9 +41,7 @@ SELECT * FROM test.t2;
let $message=< ---- Slave selects-- >;
--source include/show_msg.inc
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t2;
# Cleanup
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp009.test b/mysql-test/suite/rpl/t/rpl_row_sp009.test
index 92d47c6f50f..77860621961 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp009.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp009.test
@@ -71,9 +71,7 @@ delimiter ;|
CALL test.p1('a');
SELECT * FROM test.t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t2 ORDER BY a;
connection master;
truncate test.t2;
@@ -81,17 +79,13 @@ truncate test.t2;
# this next call fails, but should not
call test.p1('b');
select * from test.t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t2 ORDER BY a;
connection master;
truncate test.t2;
SELECT * FROM test.t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t2 ORDER BY a;
# Cleanup
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp010.test b/mysql-test/suite/rpl/t/rpl_row_sp010.test
index 28b82217517..7fa0077f117 100644
--- a/mysql-test/suite/rpl/t/rpl_row_sp010.test
+++ b/mysql-test/suite/rpl/t/rpl_row_sp010.test
@@ -39,9 +39,7 @@ delimiter ;|
CALL test.p2();
SELECT * FROM test.t1 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
show tables;
connection master;
@@ -61,9 +59,7 @@ delimiter ;|
CALL test.p4();
SELECT * FROM test.t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t2 ORDER BY a;
# Cleanup
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig002.test b/mysql-test/suite/rpl/t/rpl_row_trig002.test
index 7ca8a68f060..1ea245498d5 100644
--- a/mysql-test/suite/rpl/t/rpl_row_trig002.test
+++ b/mysql-test/suite/rpl/t/rpl_row_trig002.test
@@ -39,9 +39,7 @@ INSERT INTO test.t1 VALUES (1, 'example.com'),(2, 'mysql.com'),(3, 'earthmotherw
SELECT * FROM test.t1 ORDER BY id;
#show binlog events;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t1 ORDER BY id;
connection master;
@@ -51,9 +49,7 @@ INSERT INTO test.t2 VALUES ('Yes', 1, NULL, 'spamfilter','scan_incoming');
select * from test.t2;
select * from test.t3;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from test.t2;
select * from test.t3;
connection master;
@@ -63,9 +59,7 @@ DELETE FROM test.t1 WHERE id = 1;
SELECT * FROM test.t1 ORDER BY id;
connection master;
SELECT * FROM test.t1 ORDER BY id;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t1 ORDER BY id;
# Cleanup
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig003.test b/mysql-test/suite/rpl/t/rpl_row_trig003.test
index 5d667e29d69..781862161c1 100644
--- a/mysql-test/suite/rpl/t/rpl_row_trig003.test
+++ b/mysql-test/suite/rpl/t/rpl_row_trig003.test
@@ -120,9 +120,7 @@ DELETE FROM test.t1 WHERE id = 1;
DELETE FROM test.t2 WHERE id = 1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection master;
# time to dump the databases and so we can see if they match
diff --git a/mysql-test/suite/rpl/t/rpl_server_id2.test b/mysql-test/suite/rpl/t/rpl_server_id2.test
index 488a3aa6ab6..5c51a7fc08e 100644
--- a/mysql-test/suite/rpl/t/rpl_server_id2.test
+++ b/mysql-test/suite/rpl/t/rpl_server_id2.test
@@ -7,9 +7,11 @@ create table t1 (n int);
reset master;
# replicate ourselves
stop slave;
+--source include/wait_for_slave_to_stop.inc
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval change master to master_port=$SLAVE_MYPORT;
start slave;
+--source include/wait_for_slave_to_start.inc
insert into t1 values (1);
save_master_pos;
sync_with_master;
@@ -18,6 +20,7 @@ select * from t1; # check that indeed 2 were inserted
# 'drop table t1' executed twice, so an error in the slave.err
# (not critical).
stop slave;
+--source include/wait_for_slave_to_stop.inc
drop table t1;
diff --git a/mysql-test/suite/rpl/t/rpl_session_var.test b/mysql-test/suite/rpl/t/rpl_session_var.test
index 50efc8930a1..ee9f7e0585a 100644
--- a/mysql-test/suite/rpl/t/rpl_session_var.test
+++ b/mysql-test/suite/rpl/t/rpl_session_var.test
@@ -9,9 +9,7 @@ insert into t1 values('My'||'SQL', 1);
set @@session.sql_mode=default;
insert into t1 values('1'||'2', 2);
select * from t1 where b<3 order by a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1 where b<3 order by a;
connection master;
# if the slave does the next sync_with_master fine, then it means it accepts the
@@ -31,15 +29,11 @@ set @@session.sql_auto_is_null=0;
insert into t1 values(null);
insert into t2 select 2,a from t1 where a is null;
select * from t2 order by b;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t2 order by b;
connection master;
drop table t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
#
# Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
@@ -54,12 +48,9 @@ CREATE TABLE t1 (
--disable_warnings
INSERT INTO t1(data) VALUES(SESSION_USER());
--enable_warnings
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT length(data) < 100 FROM t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
+
diff --git a/mysql-test/suite/rpl/t/rpl_set_charset.test b/mysql-test/suite/rpl/t/rpl_set_charset.test
index c70eb2681f5..241c1c5738b 100644
--- a/mysql-test/suite/rpl/t/rpl_set_charset.test
+++ b/mysql-test/suite/rpl/t/rpl_set_charset.test
@@ -20,16 +20,12 @@ INSERT INTO t1 VALUES ('àáâãäåæçèéêëìíîï','E0');
INSERT INTO t1 VALUES ('ðñòóôõö÷øùúûüýþÿ','F0');
select "--- on master ---";
select hex(a),b from t1 order by b;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
use mysqltest1;
select "--- on slave ---";
select hex(a),b from t1 order by b;
connection master;
drop database mysqltest1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf
new file mode 100644
index 00000000000..288f0132fba
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.cnf
@@ -0,0 +1,20 @@
+!include ../my.cnf
+
+[mysqld.1]
+server_id=1
+
+[mysqld.2]
+server_id=2
+report-host=
+report-user=
+
+[mysqld.3]
+server_id=3
+report-host=slave2
+slave-net-timeout=5
+
+[ENV]
+SLAVE_MYPORT2= @mysqld.3.port
+SLAVE_MYSOCK2= @mysqld.3.socket
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test
new file mode 100644
index 00000000000..9f202487968
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test
@@ -0,0 +1,47 @@
+###############################################################################
+# Bug#13963 SHOW SLAVE HOSTS is unreliable
+#
+# Slaves only appear in the output of SHOW SLAVE HOSTS when report-host option
+# is set. If an expected slave does not appear in the list, nobody knows
+# whether the slave does not connect or has started without the "report-host"
+# option.
+#
+# Remove the "Rpl_recovery_rank" column from SHOW SLAVE HOSTS, It is not
+# implemented.
+#######################################################################
+source include/master-slave.inc;
+connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
+
+connection slave2;
+RESET SLAVE;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root'
+START SLAVE IO_THREAD;
+source include/wait_for_slave_io_to_start.inc;
+
+connection master;
+let $show_statement= SHOW SLAVE HOSTS;
+let $field= Server_id;
+# 3 is server_id of slave2.
+let $connection= ='3';
+source include/wait_show_condition.inc;
+--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
+SHOW SLAVE HOSTS;
+
+connection slave2;
+STOP SLAVE IO_THREAD;
+source include/wait_for_slave_io_to_stop.inc;
+
+connection master;
+let $show_statement= SHOW SLAVE HOSTS;
+let $field= Server_id;
+# 3 is server_id of slave2.
+let $condition= <> '3';
+# All rows of 'SHOW SLAVE HOSTS' are not equal to 3. It mean that master has
+# knew the leave of slave2 and has unregistered it.
+let $wait_for_all= 1;
+source include/wait_show_condition.inc;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+SHOW SLAVE HOSTS;
+
+source include/master-slave-end.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_slave_skip.test b/mysql-test/suite/rpl/t/rpl_slave_skip.test
index 6336e775af1..5ef58892ef6 100644
--- a/mysql-test/suite/rpl/t/rpl_slave_skip.test
+++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test
@@ -5,6 +5,7 @@ source include/have_innodb.inc;
connection slave;
source include/have_innodb.inc;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
--echo **** On Master ****
connection master;
@@ -27,7 +28,7 @@ connection slave;
# Stop when reaching the the first table map event.
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
--- source include/wait_for_slave_sql_to_stop.inc
+--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
query_vertical SHOW SLAVE STATUS;
@@ -37,6 +38,7 @@ query_vertical SHOW SLAVE STATUS;
# changed.
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
sync_with_master;
# These values should be what was inserted, not what was
@@ -47,6 +49,7 @@ SELECT * FROM t1;
SELECT * FROM t2;
STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
RESET SLAVE;
connection master;
RESET MASTER;
@@ -59,9 +62,10 @@ source include/show_binlog_events.inc;
connection slave;
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=106;
--- source include/wait_for_slave_sql_to_stop.inc
+--source include/wait_for_slave_sql_to_stop.inc
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
+--source include/wait_for_slave_to_start.inc
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
diff --git a/mysql-test/suite/rpl/t/rpl_sp-master.opt b/mysql-test/suite/rpl/t/rpl_sp-master.opt
index 709a224fd92..18c5c96955f 100644
--- a/mysql-test/suite/rpl/t/rpl_sp-master.opt
+++ b/mysql-test/suite/rpl/t/rpl_sp-master.opt
@@ -1 +1 @@
---log_bin_trust_routine_creators=0
+--log_bin_trust_function_creators=0
diff --git a/mysql-test/suite/rpl/t/rpl_sp-slave.opt b/mysql-test/suite/rpl/t/rpl_sp-slave.opt
index 709a224fd92..18c5c96955f 100644
--- a/mysql-test/suite/rpl/t/rpl_sp-slave.opt
+++ b/mysql-test/suite/rpl/t/rpl_sp-slave.opt
@@ -1 +1 @@
---log_bin_trust_routine_creators=0
+--log_bin_trust_function_creators=0
diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test
index 2811db8ef1e..96a41d9a9ad 100644
--- a/mysql-test/suite/rpl/t/rpl_sp.test
+++ b/mysql-test/suite/rpl/t/rpl_sp.test
@@ -3,11 +3,6 @@
# Test of replication of stored procedures (WL#2146 for MySQL 5.0)
# Modified by WL#2971.
-# Note that in the .opt files we still use the old variable name
-# log-bin-trust-routine-creators so that this test checks that it's
-# still accepted (this test also checks that the new name is
-# accepted). The old name could be removed in 5.1 or 6.0.
-
source include/have_binlog_format_mixed.inc;
source include/master-slave.inc;
@@ -241,16 +236,11 @@ begin
end|
delimiter ;|
connection master;
-set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators;
set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
-# test old variable name:
-set global log_bin_trust_routine_creators=1;
-# now use new name:
set global log_bin_trust_function_creators=0;
set global log_bin_trust_function_creators=1;
# slave needs it too otherwise will not execute what master allowed:
connection slave;
-set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators;
set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
set global log_bin_trust_function_creators=1;
@@ -466,9 +456,7 @@ DROP FUNCTION IF EXISTS f1;
--echo
--echo ---> Synchronizing slave with master...
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--echo
--echo ---> connection: master
@@ -492,9 +480,7 @@ SHOW CREATE FUNCTION f1;
--echo
--echo ---> Synchronizing slave with master...
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--echo ---> connection: master
@@ -516,9 +502,7 @@ SHOW CREATE FUNCTION f1;
DROP PROCEDURE p1;
DROP FUNCTION f1;
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--connection master
@@ -575,10 +559,8 @@ source include/show_binlog_events.inc;
# This is a cleanup for all parts above where we tested stored
# functions and triggers.
connection slave;
-set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
connection master;
-set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
# Clean up
diff --git a/mysql-test/suite/rpl/t/rpl_sp004.test b/mysql-test/suite/rpl/t/rpl_sp004.test
index 967e7007c15..2f9b329eb66 100644
--- a/mysql-test/suite/rpl/t/rpl_sp004.test
+++ b/mysql-test/suite/rpl/t/rpl_sp004.test
@@ -46,9 +46,7 @@ delimiter ;|
CALL test.p1();
SELECT * FROM test.t1 ORDER BY a;
SELECT * FROM test.t2 ORDER BY a;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t1 ORDER BY a;
SELECT * FROM test.t2 ORDER BY a;
@@ -57,9 +55,7 @@ CALL test.p2();
USE test;
SHOW TABLES;
#SELECT * FROM test.t3;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
USE test;
SHOW TABLES;
#SELECT * FROM test.t3;
@@ -69,9 +65,7 @@ CALL test.p1();
SELECT * FROM test.t1 ORDER BY a;
SELECT * FROM test.t2 ORDER BY a;
#SELECT * FROM test.t3;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
SELECT * FROM test.t1 ORDER BY a;
SELECT * FROM test.t2 ORDER BY a;
#SELECT * FROM test.t3;
diff --git a/mysql-test/suite/rpl/t/rpl_sporadic_master.test b/mysql-test/suite/rpl/t/rpl_sporadic_master.test
index 824f7abc9f5..6640544b0ed 100644
--- a/mysql-test/suite/rpl/t/rpl_sporadic_master.test
+++ b/mysql-test/suite/rpl/t/rpl_sporadic_master.test
@@ -14,7 +14,9 @@ truncate table t1;
insert into t1 values (4),(NULL);
sync_slave_with_master;
stop slave;
+--source include/wait_for_slave_to_stop.inc
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
insert into t1 values (NULL),(NULL);
flush logs;
diff --git a/mysql-test/suite/rpl/t/rpl_ssl1.test b/mysql-test/suite/rpl/t/rpl_ssl1.test
index b5355d737d5..85f073d9c09 100644
--- a/mysql-test/suite/rpl/t/rpl_ssl1.test
+++ b/mysql-test/suite/rpl/t/rpl_ssl1.test
@@ -9,14 +9,13 @@ source include/master-slave.inc;
connection master;
grant replication slave on *.* to replssl@localhost require ssl;
create table t1 (t int);
-save_master_pos;
#syncing with master
-connection slave;
-sync_with_master;
+sync_slave_with_master;
#trying to use this user without ssl
stop slave;
+--source include/wait_for_slave_to_stop.inc
change master to master_user='replssl',master_password='';
start slave;
@@ -31,15 +30,15 @@ select * from t1;
#showing that replication could work with ssl params
stop slave;
+--source include/wait_for_slave_to_stop.inc
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval change master to master_ssl=1 , master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem', master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem';
start slave;
+--source include/wait_for_slave_to_start.inc
#avoiding unneeded sleeps
connection master;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
#checking that replication is ok
select * from t1;
@@ -51,14 +50,14 @@ query_vertical show slave status;
#checking if replication works without ssl also performing clean up
stop slave;
+--source include/wait_for_slave_to_stop.inc
change master to master_user='root',master_password='', master_ssl=0;
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
drop user replssl@localhost;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
query_vertical show slave status;
@@ -68,6 +67,7 @@ query_vertical show slave status;
# Start replication with ssl_verify_server_cert turned on
connection slave;
stop slave;
+--source include/wait_for_slave_to_stop.inc
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval change master to
master_host="localhost",
@@ -77,6 +77,7 @@ eval change master to
master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem',
master_ssl_verify_server_cert=1;
start slave;
+--source include/wait_for_slave_to_start.inc
connection master;
create table t1 (t int);
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
index d9b87427321..d599e88c840 100644
--- a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
@@ -9,6 +9,7 @@ connection master;
create table t1(n int);
sync_slave_with_master;
stop slave;
+--source include/wait_for_slave_to_stop.inc
connection master;
let $1=5000;
disable_query_log;
@@ -31,10 +32,7 @@ sync_with_master;
connection master;
drop table t1;
-save_master_pos;
-
-connection slave;
-sync_with_master;
+sync_slave_with_master;
#
diff --git a/mysql-test/suite/rpl/t/rpl_stm_until.test b/mysql-test/suite/rpl/t/rpl_stm_until.test
index 07a3b27763d..6b731780163 100644
--- a/mysql-test/suite/rpl/t/rpl_stm_until.test
+++ b/mysql-test/suite/rpl/t/rpl_stm_until.test
@@ -22,6 +22,9 @@
# Test is dependent on binlog positions
+# prepare version for substitutions
+let $VERSION=`select version()`;
+
# Stop slave before it starts replication. Also sync with master
# to avoid nondeterministic behaviour.
--echo [on slave]
diff --git a/mysql-test/suite/rpl/t/rpl_temp_table.test b/mysql-test/suite/rpl/t/rpl_temp_table.test
index 9b73961aeea..dc24f2fc87b 100644
--- a/mysql-test/suite/rpl/t/rpl_temp_table.test
+++ b/mysql-test/suite/rpl/t/rpl_temp_table.test
@@ -54,6 +54,4 @@ show status like 'Slave_open_temp_tables';
connect (master2,localhost,root,,);
connection master2;
drop table if exists t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test
index a59e4f2fd21..3f9f5c19a25 100644
--- a/mysql-test/suite/rpl/t/rpl_temporary.test
+++ b/mysql-test/suite/rpl/t/rpl_temporary.test
@@ -1,6 +1,5 @@
# Test need anonymous user when connection are made as "zedjzlcsjhd"
source include/add_anonymous_users.inc;
-
-- source include/master-slave.inc
# Clean up old slave's binlogs.
diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test
index a3929458026..a7547a14433 100644
--- a/mysql-test/suite/rpl/t/rpl_trigger.test
+++ b/mysql-test/suite/rpl/t/rpl_trigger.test
@@ -38,10 +38,12 @@ insert into t3 values(100,"log",0,0,0);
SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
# Emulate that we have rows 2-9 deleted on the slave
+--disable_warnings
insert into t1 values(1,1,rand()),(NULL,2,rand());
insert into t2 (b) values(last_insert_id());
insert into t2 values(3,0),(NULL,0);
insert into t2 values(NULL,0),(500,0);
+--enable_warnings
select a,b, truncate(rand_value,4) from t1;
select * from t2;
diff --git a/mysql-test/suite/rpl/t/rpl_user_variables.test b/mysql-test/suite/rpl/t/rpl_user_variables.test
index 8d570f28f64..0eae78fcb9f 100644
--- a/mysql-test/suite/rpl/t/rpl_user_variables.test
+++ b/mysql-test/suite/rpl/t/rpl_user_variables.test
@@ -20,9 +20,7 @@
# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
# We wait for the slave to have written all he wants to the binlog
# (otherwise RESET MASTER may come too early).
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
reset master;
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_variables_stm.test b/mysql-test/suite/rpl/t/rpl_variables_stm.test
index 85152ae878a..67f2e50e041 100644
--- a/mysql-test/suite/rpl/t/rpl_variables_stm.test
+++ b/mysql-test/suite/rpl/t/rpl_variables_stm.test
@@ -471,7 +471,9 @@ BEGIN
END|
DELIMITER ;|
+--disable_warnings
INSERT INTO trigger_table VALUES ('bye.');
+--enable_warnings
--echo ==== Insert variables from a prepared statement ====
diff --git a/mysql-test/suite/rpl/t/rpl_view.test b/mysql-test/suite/rpl/t/rpl_view.test
index 1053514bfec..01b4dc5ef55 100644
--- a/mysql-test/suite/rpl/t/rpl_view.test
+++ b/mysql-test/suite/rpl/t/rpl_view.test
@@ -74,9 +74,7 @@ DROP VIEW IF EXISTS v1;
--echo
--echo ---> Synchronizing slave with master...
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--echo
--echo ---> connection: master
@@ -104,9 +102,7 @@ SELECT * FROM t1;
--echo
--echo ---> Synchronizing slave with master...
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--echo ---> connection: master
@@ -127,9 +123,7 @@ SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
---save_master_pos
---connection slave
---sync_with_master
+--sync_slave_with_master
--connection master
#
diff --git a/mysql-test/suite/rpl_ndb/my.cnf b/mysql-test/suite/rpl_ndb/my.cnf
index a0ec3659c18..191683fc9df 100644
--- a/mysql-test/suite/rpl_ndb/my.cnf
+++ b/mysql-test/suite/rpl_ndb/my.cnf
@@ -30,16 +30,6 @@ log-bin= master-bin
# starting the mysqld
#!use-slave-opt
-# Connect mysqld in the second cluster as save to first mysqld
-# Hardcode the host to 127.0.0.1 until running on more
-# than one host and it probably need to be masked anyway
-# master-host= @mysqld.1.#host
-master-host= 127.0.0.1
-master-port= @mysqld.1.1.port
-master-password= @mysqld.1.1.#password
-master-user= @mysqld.1.1.#user
-master-connect-retry= 1
-
log-bin= slave-bin
relay-log= slave-relay-bin
diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.cnf b/mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.cnf
index b1b010ef0f3..58f8555afd1 100644
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.cnf
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.cnf
@@ -15,11 +15,6 @@ skip-slave-start
[mysqld.2.slave]
server-id= 2
-master-host= 127.0.0.1
-master-port= @mysqld.2.1.port
-master-password= @mysqld.2.1.#password
-master-user= @mysqld.2.1.#user
-master-connect-retry= 1
init-rpl-role= slave
log-bin
skip-slave-start
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index aad3d19455d..a27efcf9583 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1623,3 +1623,15 @@ INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e;
DROP TABLE t1;
SET @@join_buffer_size= @save_join_buffer_size;
+
+--echo End of 5.1 tests
+
+#
+# BUG#40677 - Archive tables joined on primary return no result
+#
+CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t1 VALUES(NULL,'a'),(NULL,'a');
+CREATE TABLE t2(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
+SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/backup-master.sh b/mysql-test/t/backup-master.sh
deleted file mode 100755
index c099064f6b7..00000000000
--- a/mysql-test/t/backup-master.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if [ "$MYSQL_TEST_DIR" ]
-then
- rm -f $MYSQLTEST_VARDIR/tmp/*.frm $MYSQLTEST_VARDIR/tmp/*.MY?
-fi
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
deleted file mode 100644
index c761f48cbcb..00000000000
--- a/mysql-test/t/backup.test
+++ /dev/null
@@ -1,104 +0,0 @@
-
-# The server need to be started in $MYSQLTEST_VARDIR since it
-# uses ../../std_data/
---source include/uses_vardir.inc
-
-# Save the initial number of concurrent sessions
---source include/count_sessions.inc
-
-#
-# This test is a bit tricky as we can't use backup table to overwrite an old
-# table
-#
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-connection con1;
-set SQL_LOG_BIN=0;
---disable_warnings
-drop table if exists t1, t2, t3, t4;
---enable_warnings
-create table t4(n int);
---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-backup table t4 to '../../bogus';
-backup table t4 to '../../tmp';
---replace_result ": 7" ": X" ": 17" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-backup table t4 to '../../tmp';
-drop table t4;
-restore table t4 from '../../tmp';
-select count(*) from t4;
-
-create table t1(n int);
-insert into t1 values (23),(45),(67);
-backup table t1 to '../../tmp';
-drop table t1;
---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-restore table t1 from '../../bogus';
-restore table t1 from '../../tmp';
-select n from t1;
-create table t2(m int not null primary key);
-create table t3(k int not null primary key);
-insert into t2 values (123),(145),(167);
-insert into t3 values (223),(245),(267);
-backup table t2,t3 to '../../tmp';
-drop table t1,t2,t3;
-restore table t1,t2,t3 from '../../tmp';
-select n from t1;
-select m from t2;
-select k from t3;
-drop table t1,t2,t3,t4;
-restore table t1 from '../../tmp';
-connection con2;
-rename table t1 to t5;
---send
-lock tables t5 write;
-connection con1;
---send
-backup table t5 to '../../tmp';
-connection con2;
-reap;
-unlock tables;
-connection con1;
-reap;
-drop table t5;
-connection default;
-disconnect con1;
-disconnect con2;
-remove_file $MYSQLTEST_VARDIR/tmp/t1.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t2.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t3.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t4.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t5.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t1.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t2.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t3.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t4.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t5.frm;
-
-
-# End of 4.1 tests
-# End of 5.0 tests
-
-#
-# Bug#18775 - Temporary table from alter table visible to other threads
-#
-# Backup did not encode table names.
---disable_warnings
-DROP TABLE IF EXISTS `t+1`;
---enable_warnings
-CREATE TABLE `t+1` (c1 INT);
-INSERT INTO `t+1` VALUES (1), (2), (3);
-BACKUP TABLE `t+1` TO '../../tmp';
-DROP TABLE `t+1`;
-#
-# Same for restore.
-RESTORE TABLE `t+1` FROM '../../tmp';
-SELECT * FROM `t+1`;
-DROP TABLE `t+1`;
-#
-remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.MYD;
-
-
-# Wait till all disconnects are completed
---source include/wait_until_count_sessions.inc
-
diff --git a/mysql-test/t/deprecated_features.test b/mysql-test/t/deprecated_features.test
new file mode 100644
index 00000000000..002f4ad1122
--- /dev/null
+++ b/mysql-test/t/deprecated_features.test
@@ -0,0 +1,27 @@
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+set global log_bin_trust_routine_creators=1;
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+set table_type='MyISAM';
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+select @@table_type='MyISAM';
+--error ER_PARSE_ERROR
+backup table t1 to 'data.txt';
+--error ER_PARSE_ERROR
+restore table t1 from 'data.txt';
+--error ER_PARSE_ERROR
+show plugin;
+--error ER_PARSE_ERROR
+load table t1 from master;
+--error ER_PARSE_ERROR
+load data from master;
+--error ER_PARSE_ERROR
+SHOW INNODB STATUS;
+--error ER_PARSE_ERROR
+create table t1 (t6 timestamp(6));
+--error ER_PARSE_ERROR
+create table t1 (t6 timestamp) type=myisam;
+--error ER_PARSE_ERROR
+show table types;
+--error ER_PARSE_ERROR
+show mutex status;
+
diff --git a/mysql-test/t/ipv4_as_ipv6-master.opt b/mysql-test/t/ipv4_as_ipv6-master.opt
new file mode 100644
index 00000000000..f55a8e9209d
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=0.0.0.0
diff --git a/mysql-test/t/ipv4_as_ipv6.test b/mysql-test/t/ipv4_as_ipv6.test
new file mode 100644
index 00000000000..4f4e68e8bfc
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6.test
@@ -0,0 +1,65 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv4 (127.0.0.1) in ipv6 format
+# Options: --skip-name-resolve, --bind-address=0.0.0.0 (see corresponding opt file).
+#
+# Can't be tested with windows due to mixed format like 0::0000:FFFF:127.0.0.1
+--source include/not_windows.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '127.0.0.1' (IPv4) ===========================;
+let $IPv6= 127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0000:0000:0:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0::0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1/96' ================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1' ===========================;
+let $IPv6= ::FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1/96' ========================;
+let $IPv6= ::FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '::1' ========================;
+let $IPv6= ::1;
+--echo connect (con1, $IPv6, root, , test, MASTER_MYPORT,);
+--disable_query_log
+--error 2003,2006
+connect (con1, $IPv6, root, , test, $MASTER_MYPORT,);
+--enable_query_log
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/ipv4_as_ipv6_win-master.opt b/mysql-test/t/ipv4_as_ipv6_win-master.opt
new file mode 100644
index 00000000000..f55a8e9209d
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6_win-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=0.0.0.0
diff --git a/mysql-test/t/ipv4_as_ipv6_win.test b/mysql-test/t/ipv4_as_ipv6_win.test
new file mode 100644
index 00000000000..04f908a119d
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6_win.test
@@ -0,0 +1,31 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv4 (127.0.0.1) in ipv6 format
+# Options: --skip-name-resolve, --bind-address=0.0.0.0 (see corresponding opt file).
+#
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '127.0.0.1' (IPv4) ===========================;
+let $IPv6= 127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::1' ========================;
+let $IPv6= ::1;
+--echo connect (con1, $IPv6, root, , test, MASTER_MYPORT);
+--disable_query_log
+--error 2003,2006
+connect (con1, $IPv6, root, , test, $MASTER_MYPORT);
+--enable_query_log
+connection default;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/ipv6-master.opt b/mysql-test/t/ipv6-master.opt
new file mode 100644
index 00000000000..d705811808c
--- /dev/null
+++ b/mysql-test/t/ipv6-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=::
diff --git a/mysql-test/t/ipv6.test b/mysql-test/t/ipv6.test
new file mode 100644
index 00000000000..a1515e9d533
--- /dev/null
+++ b/mysql-test/t/ipv6.test
@@ -0,0 +1,79 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format
+# Options: --skip-name-resolve, --bind-address=:: (see corresponding opt file).
+#
+--source include/check_ipv6.inc
+
+# Can't be tested with windows due to the mixed format like 0:0:0:0:0:FFFF:127.0.0.1
+--source include/not_windows.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '::1' ========================================;
+let $IPv6= ::1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::1/128' ====================================;
+let $IPv6= ::1/128;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:0000:0000:0001' ====;
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:0:0:1' ============================;
+let $IPv6= 0:0:0:0:0:0:0:1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '127.0.0.1' (IPv4) ===========================;
+let $IPv6= 127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0000:0000:0:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0::0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1/96' ================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1' ===========================;
+let $IPv6= ::FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1/96' ========================;
+let $IPv6= ::FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/ipv6_win-master.opt b/mysql-test/t/ipv6_win-master.opt
new file mode 100644
index 00000000000..d705811808c
--- /dev/null
+++ b/mysql-test/t/ipv6_win-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=::
diff --git a/mysql-test/t/ipv6_win.test b/mysql-test/t/ipv6_win.test
new file mode 100644
index 00000000000..86d867cc448
--- /dev/null
+++ b/mysql-test/t/ipv6_win.test
@@ -0,0 +1,39 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format
+# Options: --skip-name-resolve, --bind-address=:: (see corresponding opt file).
+#
+--source include/check_ipv6.inc
+
+# For windows due to missing the mixed format like 0::0000:FFFF:127.0.0.1
+--source include/windows.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '::1' ========================================;
+let $IPv6= ::1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::1/128' ====================================;
+let $IPv6= ::1/128;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:0000:0000:0001' ====;
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:0:0:1' ============================;
+let $IPv6= 0:0:0:0:0:0:0:1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test
index 9d27ed53254..463aa559de2 100644
--- a/mysql-test/t/myisampack.test
+++ b/mysql-test/t/myisampack.test
@@ -1,3 +1,6 @@
+-- disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+-- enable_warnings
#
# BUG#31277 - myisamchk --unpack corrupts a table
#
@@ -105,5 +108,116 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYISAMCHK -srq $MYSQLD_DATADIR/mysql_db1/t1
SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5;
#
+# Bug#36573 myisampack --join does not create destination table .frm file
+#
+#############################################################################
+# Testcase myisampack.1: Positive test for myisampack --join
+# To test myisampack --join operation creates .frm file
+# If it creates .frm file, we will be able to access from mysql
+# server
+#############################################################################
+--echo # ===== myisampack.1 =====
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(20);
+
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t1 SELECT a from t1;
+ dec $i;
+}
+--enable_query_log
+
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES(40);
+
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t2 SELECT a from t2;
+ dec $i;
+}
+--enable_query_log
+
+FLUSH TABLE t1,t2;
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+
+--echo #If the myisampack --join operation is successful, we have table t3(.frm)
+--echo #so we should be able to query about the table from server.
+SELECT COUNT(a) FROM t3;
+
+#############################################################################
+# Testcase myisampack.2: 2nd Positive test for myisampack --join
+# Test myisampack join operation with an existing destination frm file.
+# It should finish the join operation successfully
+#############################################################################
+--echo # ===== myisampack.2 =====
+FLUSH TABLE t3;
+--remove_file $MYSQLD_DATADIR/test/t3.MYI
+--remove_file $MYSQLD_DATADIR/test/t3.MYD
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+--echo #Tests the myisampack join operation with an existing destination .frm file,
+--echo #the command should return correct exit status(0) and
+--echo #we should be able to query the table.
+
+SELECT COUNT(a) FROM t3;
+
+#############################################################################
+# Testcase myisampack.3: 3rd Positive test for myisampack --join
+# Test myisampack join operation without frm file for first table and second
+# table. It should finish the join operation successfully
+#############################################################################
+--echo # ===== myisampack.3 =====
+--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm
+--copy_file $MYSQLD_DATADIR/test/t2.frm $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--remove_file $MYSQLD_DATADIR/test/t2.frm
+
+DROP TABLE t3;
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+--echo #Tests the myisampack join operation without frm file for the first and second table
+--echo #No frm file is generated in this and we shouldn't be able to access the newly
+--echo #created table
+
+--error ER_NO_SUCH_TABLE
+SELECT COUNT(a) FROM t3;
+
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm $MYSQLD_DATADIR/test/t2.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm $MYSQLD_DATADIR/test/t3.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm
+
+#############################################################################
+# Testcase myisampack.4: Negative test for myisampack --join
+# Test myisampack join operation with an existing .MYI,.MDI,.frm files
+# the test should fail
+#############################################################################
+--echo # ===== myisampack.4 =====
+--echo #Tests the myisampack join operation with an existing destination .frm,.MYI,.MDI
+--echo #the command should fail with exit status 2
+#
+# Note: Use of regular expressions in this file is for output printed in result file
+# The main purpose of this regular expression is to supress the filenames for
+# error messages produced so that we can create a generic result file
+#
+#1. /.*myisampack(\.exe)?: Can't create\/write to file .*\(/myisampack: Can't create\/write to file (/
+# Replace everything before "myisampack" or "myisampack.exe" and followed by
+# ": Can't create\/write to file " until the first open paranthesis , with
+# "myisampack: Can't create\/write to file ("
+#
+#2. /Aborted: .*is/Aborted: file is/
+# Replace everything after starting with "Aborted: " until ending with "is" with
+# "Aborted: file is/
+#
+--replace_regex /.*myisampack(\.exe)?: Can't create\/write to file .*\(/myisampack: Can't create\/write to file (/ /Aborted: .*is/Aborted: file is/
+--error 2
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+
+DROP TABLE t1,t2,t3;
+
DROP TABLE mysql_db1.t1;
DROP DATABASE mysql_db1;
+
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 459acc9f1f5..8ab91f23522 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -2039,23 +2039,24 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
-
---echo #
---echo # BUG#45816 - assertion failure with index containing double
---echo # column on partitioned table
---echo #
-
-CREATE TABLE t1 (
- a INT DEFAULT NULL,
- b DOUBLE DEFAULT NULL,
- c INT DEFAULT NULL,
- KEY idx2(b,a)
-) PARTITION BY HASH(c) PARTITIONS 3;
-
-INSERT INTO t1 VALUES (6,8,9);
-INSERT INTO t1 VALUES (6,8,10);
-
-SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
-
-DROP TABLE t1;
+# This testcase is commented due to the Bug #46853
+# Should be uncommented after fixing Bug #46853
+#--echo #
+#--echo # BUG#45816 - assertion failure with index containing double
+#--echo # column on partitioned table
+#--echo #
+#
+#CREATE TABLE t1 (
+# a INT DEFAULT NULL,
+# b DOUBLE DEFAULT NULL,
+# c INT DEFAULT NULL,
+# KEY idx2(b,a)
+#) PARTITION BY HASH(c) PARTITIONS 3;
+#
+#INSERT INTO t1 VALUES (6,8,9);
+#INSERT INTO t1 VALUES (6,8,10);
+#
+#SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
+#
+#DROP TABLE t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 387b3ebdd05..b9e84d8d7df 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -458,9 +458,6 @@ prepare stmt1 from ' analyze table t1 ' ;
prepare stmt1 from ' checksum table t1 ' ;
prepare stmt1 from ' repair table t1 ' ;
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_UNSUPPORTED_PS
-eval prepare stmt1 from ' restore table t1 from ''$datafile'' ' ;
--remove_file $datafile
## handler
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 0e4af16dd1f..6e07f717db6 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -629,7 +629,6 @@ show plugins;
show columns in t1;
show slave hosts;
show keys in t1;
-show table types;
show storage engines;
show authors;
show contributors;
@@ -1008,11 +1007,6 @@ disconnect con4;
#
--disable_result_log
-show full plugin;
---enable_result_log
-show warnings;
---disable_result_log
-show plugin;
show plugins;
--enable_result_log
@@ -1180,14 +1174,6 @@ DROP TABLE t1;
DROP EVENT ev1;
#
-# Bug#30036 SHOW TABLE TYPES causes the debug client to crash
-#
---disable_result_log
-SHOW TABLE TYPES;
---enable_result_log
-
-
-#
# Bug#32710 SHOW INNODB STATUS requires SUPER
#
diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test
index df010d15fa0..cd7ffe1690d 100644
--- a/mysql-test/t/skip_name_resolve.test
+++ b/mysql-test/t/skip_name_resolve.test
@@ -15,7 +15,7 @@ DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
# Bug#13407 Remote connecting crashes server
# Server crashed when one used USER() function in connection for which
# was impossible to obtain peer hostname.
-connect (con1, 127.0.0.1, root, , test, $MASTER_MYPORT, );
+connect (con1, localhost, root, , test, $MASTER_MYPORT, );
--replace_column 1 #
SELECT USER();
# We are only interested in the fact that statement below doesn't
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index a9bb80647bc..e33adf56284 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1325,11 +1325,6 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN DROP TRIGGER test1; EN
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
--- error ER_SP_BADSTATEMENT
-CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN load table t1 from master; END |
--- error ER_SP_BADSTATEMENT
-CREATE FUNCTION bug_13627_f() returns int BEGIN load table t1 from master; return 1; END |
-
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
@@ -1580,18 +1575,6 @@ BEGIN
REPAIR TABLE t1;
RETURN 1;
END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
- BACKUP TABLE t1 TO '/tmp';
- RETURN 1;
-END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
- RESTORE TABLE t1 FROM '/tmp';
- RETURN 1;
-END|
create table t1 (a int)|
CREATE PROCEDURE bug13012_1() REPAIR TABLE t1|
CREATE FUNCTION bug13012_2() RETURNS INT
@@ -2386,7 +2369,7 @@ drop procedure if exists p1;
delimiter |;
create procedure p1()
begin
- create table t1 (a int) type=MyISAM;
+ create table t1 (a int) engine=MyISAM;
drop table t1;
end|
delimiter ;|
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index b477b5a3e24..7cf2fcf9bb7 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5216,20 +5216,15 @@ drop procedure bug5967|
--disable_warnings
drop procedure if exists bug13012|
+--enable_warnings
# Disable warnings also for BACKUP/RESTORE: they are deprecated.
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval create procedure bug13012()
BEGIN
REPAIR TABLE t1;
- BACKUP TABLE t1 to '$backupdir';
- DROP TABLE t1;
- RESTORE TABLE t1 FROM '$backupdir';
END|
call bug13012()|
--enable_warnings
---remove_file $backupdir/t1.frm
---remove_file $backupdir/t1.MYD
drop procedure bug13012|
diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test
index ce18b2b578e..bd465a1a09b 100644
--- a/mysql-test/t/sp_trans.test
+++ b/mysql-test/t/sp_trans.test
@@ -565,7 +565,7 @@ use db_bug7787|
# Test.
CREATE PROCEDURE p1()
- SHOW INNODB STATUS; |
+ SHOW ENGINE INNODB STATUS; |
GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test
index 440fcc8aa8a..818993e5f27 100644
--- a/mysql-test/t/system_mysql_db_fix40123.test
+++ b/mysql-test/t/system_mysql_db_fix40123.test
@@ -26,7 +26,7 @@ use test;
# create system tables as in mysql-4.1.23
# created by executing "./mysql_create_system_tables real ."
-set table_type=myisam;
+set storage_engine=myisam;
CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
@@ -41,8 +41,8 @@ INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url varchar(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name varchar(64) not null, parent_category_id smallint unsigned null, url varchar(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test
index 4924c625d57..45084177570 100644
--- a/mysql-test/t/system_mysql_db_fix50030.test
+++ b/mysql-test/t/system_mysql_db_fix50030.test
@@ -26,7 +26,7 @@ use test;
# create system tables as in mysql-5.0.30
# created by executing "./mysql_create_system_tables real ."
-set table_type=myisam;
+set storage_engine=myisam;
CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
@@ -39,9 +39,9 @@ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
@@ -60,7 +60,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL,
CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test
index d88c4edba93..bed00239081 100644
--- a/mysql-test/t/system_mysql_db_fix50117.test
+++ b/mysql-test/t/system_mysql_db_fix50117.test
@@ -44,9 +44,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
-CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 460da1c1614..17ffade5f63 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -534,18 +534,6 @@ DROP TABLE b15776;
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a year(-2));
-## For timestamp, we silently rewrite widths to 14 or 19.
-CREATE TABLE b15776 (a timestamp(4294967294));
-DROP TABLE b15776;
-CREATE TABLE b15776 (a timestamp(4294967295));
-DROP TABLE b15776;
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a timestamp(4294967296));
---error ER_PARSE_ERROR
-CREATE TABLE b15776 (a timestamp(-1));
---error ER_PARSE_ERROR
-CREATE TABLE b15776 (a timestamp(-2));
-
# We've already tested the case, but this should visually show that
# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
@@ -555,8 +543,6 @@ CREATE TABLE b15776 (a int(99999999999999999999999999999999999999999999999999999
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
## Do not select, too much memory needed.
CREATE TABLE b15776 select cast(null as char(4294967295));
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index e8374e0ebfc..2a49e0def1a 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
- t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
- t14 timestamp(14));
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-select * from t1;
-drop table t1;
-
#
# Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers)
@@ -298,7 +287,7 @@ drop table t1;
# mode regardless of whether a display width is given.
#
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp);
show create table t1;
# restore default mode
set sql_mode='';
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 176f320e390..98e1db62d84 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -112,11 +112,6 @@ show variables like 'max_error_count';
drop table t1;
#
-# Test for deprecated table_type variable
-#
-set table_type=MYISAM;
-
-#
# Tests for show warnings limit a, b
#
create table t1 (a int);
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 757e37aa0a9..ae9406450ed 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc
#
# 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
@@ -41,7 +41,8 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
- my_atomic.c my_getncpus.c)
+ my_atomic.c my_getncpus.c
+ my_rdtsc.c)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 3b53fc1dd59..476b63d3ad5 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -16,7 +16,8 @@
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
-INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
+INCLUDES = @ZLIB_INCLUDES@ @RDTSC_SPARC_ASSEMBLY@ \
+ -I$(top_builddir)/include \
-I$(top_srcdir)/include -I$(srcdir)
pkglib_LIBRARIES = libmysys.a
LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
@@ -53,7 +54,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \
- my_windac.c my_access.c base64.c my_libwrap.c
+ my_windac.c my_access.c base64.c my_libwrap.c \
+ my_rdtsc.c
if NEED_THREAD
# mf_keycache is used only in the server, so it is safe to leave the file
@@ -65,7 +67,9 @@ endif
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \
CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c my_winerr.c my_winfile.c
+ my_conio.c my_wincond.c my_winthread.c my_winerr.c \
+ my_winfile.c \
+ my_timer_cycles.il
libmysys_a_LIBADD = @THREAD_LOBJECTS@
# test_dir_DEPENDENCIES= $(LIBRARIES)
# testhash_DEPENDENCIES= $(LIBRARIES)
diff --git a/mysys/my_delete.c b/mysys/my_delete.c
index 3ab6ba399f9..edee1c4e875 100644
--- a/mysys/my_delete.c
+++ b/mysys/my_delete.c
@@ -37,7 +37,7 @@ int my_delete(const char *name, myf MyFlags)
} /* my_delete */
#if defined(__WIN__)
-/*
+/**
Delete file which is possibly not closed.
This function is intended to be used exclusively as a temporal solution
@@ -53,6 +53,20 @@ int my_delete(const char *name, myf MyFlags)
renamed to <name>.<num>.deleted where <name> - the initial name of the
file, <num> - a hexadecimal number chosen to make the temporal name to
be unique.
+
+ @param the name of the being deleted file
+ @param the flags instructing how to react on an error internally in
+ the function
+
+ @note The per-thread @c my_errno holds additional info for a caller to
+ decide how critical the error can be.
+
+ @retval
+ 0 ok
+ @retval
+ 1 error
+
+
*/
int nt_share_delete(const char *name, myf MyFlags)
{
@@ -63,6 +77,7 @@ int nt_share_delete(const char *name, myf MyFlags)
for (cnt= GetTickCount(); cnt; cnt--)
{
+ errno= 0;
sprintf(buf, "%s.%08X.deleted", name, cnt);
if (MoveFile(name, buf))
break;
@@ -78,15 +93,23 @@ int nt_share_delete(const char *name, myf MyFlags)
name, buf, errno));
break;
}
-
- if (DeleteFile(buf))
- DBUG_RETURN(0);
-
- my_errno= GetLastError();
+
+ if (errno == ERROR_FILE_NOT_FOUND)
+ {
+ my_errno= ENOENT; // marking, that `name' doesn't exist
+ }
+ else if (errno == 0)
+ {
+ if (DeleteFile(buf))
+ DBUG_RETURN(0);
+ else if ((my_errno= GetLastError()) == 0)
+ my_errno= ENOENT; // marking, that `buf' doesn't exist
+ } else
+ my_errno= errno;
+
if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
- name, my_errno);
-
+ my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
+ name, my_errno);
DBUG_RETURN(-1);
}
#endif
diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c
new file mode 100644
index 00000000000..4227498b92c
--- /dev/null
+++ b/mysys/my_rdtsc.c
@@ -0,0 +1,1004 @@
+/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ rdtsc3 -- multi-platform timer code
+ pgulutzan@mysql.com, 2005-08-29
+ modified 2008-11-02
+
+ Functions:
+
+ my_timer_cycles ulonglong cycles
+ my_timer_nanoseconds ulonglong nanoseconds
+ my_timer_microseconds ulonglong "microseconds"
+ my_timer_milliseconds ulonglong milliseconds
+ my_timer_ticks ulonglong ticks
+ my_timer_init initialization / test
+
+ We'll call the first 5 functions (the ones that return
+ a ulonglong) "my_timer_xxx" functions.
+ Each my_timer_xxx function returns a 64-bit timing value
+ since an arbitrary 'epoch' start. Since the only purpose
+ is to determine elapsed times, wall-clock time-of-day
+ is not known and not relevant.
+
+ The my_timer_init function is necessary for initializing.
+ It returns information (underlying routine name,
+ frequency, resolution, overhead) about all my_timer_xxx
+ functions. A program should call my_timer_init once,
+ use the information to decide what my_timer_xxx function
+ to use, and subsequently call that function by function
+ pointer.
+
+ A typical use would be:
+ my_timer_init() ... once, at program start
+ ...
+ time1= my_timer_xxx() ... time before start
+ [code that's timed]
+ time2= my_timer_xxx() ... time after end
+ elapsed_time= (time2 - time1) - overhead
+*/
+
+#include "my_global.h"
+#include "my_rdtsc.h"
+
+#if defined(_WIN32)
+#include <stdio.h>
+#include "windows.h"
+#else
+#include <stdio.h>
+#endif
+
+#if !defined(_WIN32)
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h> /* for clock_gettime */
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#elif defined(HAVE_TIME_H)
+#include <time.h>
+#endif
+#endif
+#endif
+
+#if defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
+#include <asm/msr.h> /* for rdtscll */
+#endif
+
+#if defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME)
+#include <sys/timeb.h> /* for ftime */
+#endif
+
+#if defined(HAVE_SYS_TIMES_H) && defined(HAVE_TIMES)
+#include <sys/times.h> /* for times */
+#endif
+
+#if defined(__NETWARE__)
+#include <nks/time.h> /* for NXGetTime */
+#endif
+
+#if defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
+#include <ia64intrin.h> /* for __GetReg */
+#endif
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include <mach/mach_time.h>
+#endif
+
+#if defined(__SUNPRO_CC) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
+extern "C" ulonglong my_timer_cycles_il_sparc64();
+#elif defined(__SUNPRO_CC) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+extern "C" ulonglong my_timer_cycles_il_sparc32();
+#elif defined(__SUNPRO_CC) && defined(__i386) && defined(_ILP32)
+extern "C" ulonglong my_timer_cycles_il_i386();
+#elif defined(__SUNPRO_CC) && defined(__x86_64) && defined(_LP64)
+extern "C" ulonglong my_timer_cycles_il_x86_64();
+#elif defined(__SUNPRO_C) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
+ulonglong my_timer_cycles_il_sparc64();
+#elif defined(__SUNPRO_C) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+ulonglong my_timer_cycles_il_sparc32();
+#elif defined(__SUNPRO_C) && defined(__i386) && defined(_ILP32)
+ulonglong my_timer_cycles_il_i386();
+#elif defined(__SUNPRO_C) && defined(__x86_64) && defined(_LP64)
+ulonglong my_timer_cycles_il_x86_64();
+#endif
+
+#if defined(__INTEL_COMPILER)
+/*
+ icc warning #1011 is:
+ missing return statement at end of non-void function
+*/
+#pragma warning (disable:1011)
+#endif
+
+/*
+ For cycles, we depend on RDTSC for x86 platforms,
+ or on time buffer (which is not really a cycle count
+ but a separate counter with less than nanosecond
+ resolution) for most PowerPC platforms, or on
+ gethrtime which is okay for hpux and solaris, or on
+ clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms,
+ or on read_real_time for aix platforms. There is
+ nothing for Alpha platforms, they would be tricky.
+*/
+
+ulonglong my_timer_cycles(void)
+{
+#if defined(__GNUC__) && defined(__i386__)
+ /* This works much better if compiled with "gcc -O3". */
+ ulonglong result;
+ __asm__ __volatile__ ("rdtsc" : "=A" (result));
+ return result;
+#elif defined(__SUNPRO_C) && defined(__i386)
+ __asm("rdtsc");
+#elif defined(__GNUC__) && defined(__x86_64__)
+ ulonglong result;
+ __asm__ __volatile__ ("rdtsc\n\t" \
+ "shlq $32,%%rdx\n\t" \
+ "orq %%rdx,%%rax"
+ : "=a" (result) :: "%edx");
+ return result;
+#elif defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
+ {
+ ulonglong result;
+ rdtscll(result);
+ return result;
+ }
+#elif defined(_WIN32) && defined(_M_IX86)
+ __asm {rdtsc};
+#elif defined(_WIN64) && defined(_M_X64)
+ /* For 64-bit Windows: unsigned __int64 __rdtsc(); */
+ return __rdtsc();
+#elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
+ return (ulonglong) __getReg(_IA64_REG_AR_ITC); /* (3116) */
+#elif defined(__GNUC__) && defined(__ia64__)
+ {
+ ulonglong result;
+ __asm __volatile__ ("mov %0=ar.itc" : "=r" (result));
+ return result;
+ }
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (defined(__64BIT__) || defined(_ARCH_PPC64))
+ {
+ ulonglong result;
+ __asm __volatile__ ("mftb %0" : "=r" (result));
+ return result;
+ }
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (!defined(__64BIT__) && !defined(_ARCH_PPC64))
+ {
+ /*
+ mftbu means "move from time-buffer-upper to result".
+ The loop is saying: x1=upper, x2=lower, x3=upper,
+ if x1!=x3 there was an overflow so repeat.
+ */
+ unsigned int x1, x2, x3;
+ ulonglong result;
+ for (;;)
+ {
+ __asm __volatile__ ( "mftbu %0" : "=r"(x1) );
+ __asm __volatile__ ( "mftb %0" : "=r"(x2) );
+ __asm __volatile__ ( "mftbu %0" : "=r"(x3) );
+ if (x1 == x3) break;
+ }
+ result = x1;
+ return ( result << 32 ) | x2;
+ }
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
+ return (my_timer_cycles_il_sparc64());
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+ return (my_timer_cycles_il_sparc32());
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
+ /* This is probably redundant for __SUNPRO_C. */
+ return (my_timer_cycles_il_i386());
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__x86_64) && defined(_LP64)
+ return (my_timer_cycles_il_x86_64());
+#elif defined(__GNUC__) && defined(__sparcv9) && defined(_LP64) && (__GNUC__>2)
+ {
+ ulonglong result;
+ __asm __volatile__ ("rd %%tick,%0" : "=r" (result));
+ return result;
+ }
+#elif defined(__GNUC__) && defined(__sparc__) && !defined(_LP64) && (__GNUC__>2)
+ {
+ union {
+ ulonglong wholeresult;
+ struct {
+ ulong high;
+ ulong low;
+ } splitresult;
+ } result;
+ __asm __volatile__ ("rd %%tick,%1; srlx %1,32,%0" : "=r" (result.splitresult.high), "=r" (result.splitresult.low));
+ return result.wholeresult;
+ }
+#elif defined(__sgi) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE)
+ {
+ struct timespec tp;
+ clock_gettime(CLOCK_SGI_CYCLE, &tp);
+ return (ulonglong) tp.tv_sec * 1000000000 + (ulonglong) tp.tv_nsec;
+ }
+#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ /* gethrtime may appear as either cycle or nanosecond counter */
+ return (ulonglong) gethrtime();
+#else
+ return 0;
+#endif
+}
+
+#if defined(__INTEL_COMPILER)
+/* re-enable warning#1011 which was only for my_timer_cycles() */
+/* There may be an icc bug which means we must leave disabled. */
+#pragma warning (default:1011)
+#endif
+
+/*
+ For nanoseconds, most platforms have nothing available that
+ (a) doesn't require bringing in a 40-kb librt.so library
+ (b) really has nanosecond resolution.
+*/
+
+ulonglong my_timer_nanoseconds(void)
+{
+#if defined(HAVE_READ_REAL_TIME)
+ {
+ timebasestruct_t tr;
+ read_real_time(&tr, TIMEBASE_SZ);
+ return (ulonglong) tr.tb_high * 1000000000 + (ulonglong) tr.tb_low;
+ }
+#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+ {
+ struct timespec tp;
+ clock_gettime(CLOCK_REALTIME, &tp);
+ return (ulonglong) tp.tv_sec * 1000000000 + (ulonglong) tp.tv_nsec;
+ }
+#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ /* SunOS 5.10+, Solaris, HP-UX: hrtime_t gethrtime(void) */
+ return (ulonglong) gethrtime();
+#elif defined(__NETWARE__)
+ {
+ NXTime_t tm;
+ NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm);
+ return (ulonglong) tm;
+ }
+#elif defined(__APPLE__) && defined(__MACH__)
+ {
+ ulonglong tm;
+ static mach_timebase_info_data_t timebase_info= {0,0};
+ if (timebase_info.denom == 0)
+ (void) mach_timebase_info(&timebase_info);
+ tm= mach_absolute_time();
+ return (tm * timebase_info.numer) / timebase_info.denom;
+ }
+#else
+ return 0;
+#endif
+}
+
+/*
+ For microseconds, gettimeofday() is available on
+ almost all platforms. On Windows we use
+ QueryPerformanceCounter which will usually tick over
+ 3.5 million times per second, and we don't throw
+ away the extra precision. (On Windows Server 2003
+ the frequency is same as the cycle frequency.)
+*/
+
+ulonglong my_timer_microseconds(void)
+{
+#if defined(HAVE_GETTIMEOFDAY)
+ {
+ static ulonglong last_value= 0;
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) == 0)
+ last_value= (ulonglong) tv.tv_sec * 1000000 + (ulonglong) tv.tv_usec;
+ else
+ {
+ /*
+ There are reports that gettimeofday(2) can have intermittent failures
+ on some platform, see for example Bug#36819.
+ We are not trying again or looping, just returning the best value possible
+ under the circumstances ...
+ */
+ last_value++;
+ }
+ return last_value;
+ }
+#elif defined(_WIN32)
+ {
+ /* QueryPerformanceCounter usually works with about 1/3 microsecond. */
+ LARGE_INTEGER t_cnt;
+
+ QueryPerformanceCounter(&t_cnt);
+ return (ulonglong) t_cnt.QuadPart;
+ }
+#elif defined(__NETWARE__)
+ {
+ NXTime_t tm;
+ NXGetTime(NX_SINCE_1970, NX_USECONDS, &tm);
+ return (ulonglong) tm;
+ }
+#else
+ return 0;
+#endif
+}
+
+/*
+ For milliseconds, we use ftime() if it's supported
+ or time()*1000 if it's not. With modern versions of
+ Windows and with HP Itanium, resolution is 10-15
+ milliseconds.
+*/
+
+ulonglong my_timer_milliseconds(void)
+{
+#if defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME)
+ /* ftime() is obsolete but maybe the platform is old */
+ struct timeb ft;
+ ftime(&ft);
+ return (ulonglong)ft.time * 1000 + (ulonglong)ft.millitm;
+#elif defined(HAVE_TIME)
+ return (ulonglong) time(NULL) * 1000;
+#elif defined(_WIN32)
+ FILETIME ft;
+ GetSystemTimeAsFileTime( &ft );
+ return ((ulonglong)ft.dwLowDateTime +
+ (((ulonglong)ft.dwHighDateTime) << 32))/10000;
+#elif defined(__NETWARE__)
+ {
+ NXTime_t tm;
+ NXGetTime(NX_SINCE_1970, NX_MSECONDS, &tm);
+ return (ulonglong)tm;
+ }
+#else
+ return 0;
+#endif
+}
+
+/*
+ For ticks, which we handle with times(), the frequency
+ is usually 100/second and the overhead is surprisingly
+ bad, sometimes even worse than gettimeofday's overhead.
+*/
+
+ulonglong my_timer_ticks(void)
+{
+#if defined(HAVE_SYS_TIMES_H) && defined(HAVE_TIMES)
+ {
+ struct tms times_buf;
+ return (ulonglong) times(&times_buf);
+ }
+#elif defined(__NETWARE__)
+ {
+ NXTime_t tm;
+ NXGetTime(NX_SINCE_BOOT, NX_TICKS, &tm);
+ return (ulonglong) tm;
+ }
+#elif defined(_WIN32)
+ return (ulonglong) GetTickCount();
+#else
+ return 0;
+#endif
+}
+
+/*
+ The my_timer_init() function and its sub-functions
+ have several loops which call timers. If there's
+ something wrong with a timer -- which has never
+ happened in tests -- we want the loop to end after
+ an arbitrary number of iterations, and my_timer_info
+ will show a discouraging result. The arbitrary
+ number is 1,000,000.
+*/
+#define MY_TIMER_ITERATIONS 1000000
+
+/*
+ Calculate overhead. Called from my_timer_init().
+ Usually best_timer_overhead = cycles.overhead or
+ nanoseconds.overhead, so returned amount is in
+ cycles or nanoseconds. We repeat the calculation
+ ten times, so that we can disregard effects of
+ caching or interrupts. Result is quite consistent
+ for cycles, at least. But remember it's a minimum.
+*/
+
+static void my_timer_init_overhead(ulonglong *overhead,
+ ulonglong (*cycle_timer)(void),
+ ulonglong (*this_timer)(void),
+ ulonglong best_timer_overhead)
+{
+ ulonglong time1, time2;
+ int i;
+
+ /* *overhead, least of 20 calculations - cycles.overhead */
+ for (i= 0, *overhead= 1000000000; i < 20; ++i)
+ {
+ time1= cycle_timer();
+ this_timer(); /* rather than 'time_tmp= timer();' */
+ time2= cycle_timer() - time1;
+ if (*overhead > time2)
+ *overhead= time2;
+ }
+ *overhead-= best_timer_overhead;
+}
+
+/*
+ Calculate Resolution. Called from my_timer_init().
+ If a timer goes up by jumps, e.g. 1050, 1075, 1100, ...
+ then the best resolution is the minimum jump, e.g. 25.
+ If it's always divisible by 1000 then it's just a
+ result of multiplication of a lower-precision timer
+ result, e.g. nanoseconds are often microseconds * 1000.
+ If the minimum jump is less than an arbitrary passed
+ figure (a guess based on maximum overhead * 2), ignore.
+ Usually we end up with nanoseconds = 1 because it's too
+ hard to detect anything <= 100 nanoseconds.
+ Often GetTickCount() has resolution = 15.
+ We don't check with ticks because they take too long.
+*/
+static ulonglong my_timer_init_resolution(ulonglong (*this_timer)(void),
+ ulonglong overhead_times_2)
+{
+ ulonglong time1, time2;
+ ulonglong best_jump;
+ int i, jumps, divisible_by_1000, divisible_by_1000000;
+
+ divisible_by_1000= divisible_by_1000000= 0;
+ best_jump= 1000000;
+ for (i= jumps= 0; jumps < 3 && i < MY_TIMER_ITERATIONS * 10; ++i)
+ {
+ time1= this_timer();
+ time2= this_timer();
+ time2-= time1;
+ if (time2)
+ {
+ ++jumps;
+ if (!(time2 % 1000))
+ {
+ ++divisible_by_1000;
+ if (!(time2 % 1000000))
+ ++divisible_by_1000000;
+ }
+ if (best_jump > time2)
+ best_jump= time2;
+ /* For milliseconds, one jump is enough. */
+ if (overhead_times_2 == 0)
+ break;
+ }
+ }
+ if (jumps == 3)
+ {
+ if (jumps == divisible_by_1000000)
+ return 1000000;
+ if (jumps == divisible_by_1000)
+ return 1000;
+ }
+ if (best_jump > overhead_times_2)
+ return best_jump;
+ return 1;
+}
+
+/*
+ Calculate cycle frequency by seeing how many cycles pass
+ in a 200-microsecond period. I tried with 10-microsecond
+ periods originally, and the result was often very wrong.
+*/
+
+static ulonglong my_timer_init_frequency(MY_TIMER_INFO *mti)
+{
+ int i;
+ ulonglong time1, time2, time3, time4;
+ time1= my_timer_cycles();
+ time2= my_timer_microseconds();
+ time3= time2; /* Avoids a Microsoft/IBM compiler warning */
+ for (i= 0; i < MY_TIMER_ITERATIONS; ++i)
+ {
+ time3= my_timer_microseconds();
+ if (time3 - time2 > 200) break;
+ }
+ time4= my_timer_cycles() - mti->cycles.overhead;
+ time4-= mti->microseconds.overhead;
+ return (mti->microseconds.frequency * (time4 - time1)) / (time3 - time2);
+}
+
+/*
+ Call my_timer_init before the first call to my_timer_xxx().
+ If something must be initialized, it happens here.
+ Set: what routine is being used e.g. "asm_x86"
+ Set: function, overhead, actual frequency, resolution.
+*/
+
+void my_timer_init(MY_TIMER_INFO *mti)
+{
+ ulonglong (*best_timer)(void);
+ ulonglong best_timer_overhead;
+ ulonglong time1, time2;
+ int i;
+
+ /* cycles */
+ mti->cycles.frequency= 1000000000;
+#if defined(__GNUC__) && defined(__i386__)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86;
+#elif defined(__SUNPRO_C) && defined(__i386)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86;
+#elif defined(__GNUC__) && defined(__x86_64__)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86_64;
+#elif defined(HAVE_ASM_MSR_H) && defined(HAVE_RDTSCLL)
+ mti->cycles.routine= MY_TIMER_ROUTINE_RDTSCLL;
+#elif defined(_WIN32) && defined(_M_IX86)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_X86_WIN;
+#elif defined(_WIN64) && defined(_M_X64)
+ mti->cycles.routine= MY_TIMER_ROUTINE_RDTSC;
+#elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_IA64;
+#elif defined(__GNUC__) && defined(__ia64__)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_IA64;
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (defined(__64BIT__) || defined(_ARCH_PPC64))
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_PPC64;
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__) || (defined(_POWER) && defined(_AIX52))) && (!defined(__64BIT__) && !defined(_ARCH_PPC64))
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_PPC;
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64;
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32;
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_I386;
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__x86_64) && defined(_LP64)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64;
+#elif defined(__GNUC__) && defined(__sparcv9) && defined(_LP64) && (__GNUC__>2)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_GCC_SPARC64;
+#elif defined(__GNUC__) && defined(__sparc__) && !defined(_LP64) && (__GNUC__>2)
+ mti->cycles.routine= MY_TIMER_ROUTINE_ASM_GCC_SPARC32;
+#elif defined(__sgi) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE)
+ mti->cycles.routine= MY_TIMER_ROUTINE_SGI_CYCLE;
+#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ mti->cycles.routine= MY_TIMER_ROUTINE_GETHRTIME;
+#else
+ mti->cycles.routine= 0;
+#endif
+
+ if (!mti->cycles.routine || !my_timer_cycles())
+ {
+ mti->cycles.routine= 0;
+ mti->cycles.resolution= 0;
+ mti->cycles.frequency= 0;
+ mti->cycles.overhead= 0;
+ }
+
+ /* nanoseconds */
+ mti->nanoseconds.frequency= 1000000000; /* initial assumption */
+#if defined(HAVE_READ_REAL_TIME)
+ mti->nanoseconds.routine= MY_TIMER_ROUTINE_READ_REAL_TIME;
+#elif defined(HAVE_CLOCK_GETTIME)
+ mti->nanoseconds.routine= MY_TIMER_ROUTINE_CLOCK_GETTIME;
+#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ mti->nanoseconds.routine= MY_TIMER_ROUTINE_GETHRTIME;
+#elif defined(__NETWARE__)
+ mti->nanoseconds.routine= MY_TIMER_ROUTINE_NXGETTIME;
+#elif defined(__APPLE__) && defined(__MACH__)
+ mti->nanoseconds.routine= MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME;
+#else
+ mti->nanoseconds.routine= 0;
+#endif
+ if (!mti->nanoseconds.routine || !my_timer_nanoseconds())
+ {
+ mti->nanoseconds.routine= 0;
+ mti->nanoseconds.resolution= 0;
+ mti->nanoseconds.frequency= 0;
+ mti->nanoseconds.overhead= 0;
+ }
+
+ /* microseconds */
+ mti->microseconds.frequency= 1000000; /* initial assumption */
+#if defined(HAVE_GETTIMEOFDAY)
+ mti->microseconds.routine= MY_TIMER_ROUTINE_GETTIMEOFDAY;
+#elif defined(_WIN32)
+ {
+ LARGE_INTEGER li;
+ /* Windows: typical frequency = 3579545, actually 1/3 microsecond. */
+ if (!QueryPerformanceFrequency(&li))
+ mti->microseconds.routine= 0;
+ else
+ {
+ mti->microseconds.frequency= li.QuadPart;
+ mti->microseconds.routine= MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER;
+ }
+ }
+#elif defined(__NETWARE__)
+ mti->microseconds.routine= MY_TIMER_ROUTINE_NXGETTIME;
+#else
+ mti->microseconds.routine= 0;
+#endif
+ if (!mti->microseconds.routine || !my_timer_microseconds())
+ {
+ mti->microseconds.routine= 0;
+ mti->microseconds.resolution= 0;
+ mti->microseconds.frequency= 0;
+ mti->microseconds.overhead= 0;
+ }
+
+ /* milliseconds */
+ mti->milliseconds.frequency= 1000; /* initial assumption */
+#if defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME)
+ mti->milliseconds.routine= MY_TIMER_ROUTINE_FTIME;
+#elif defined(_WIN32)
+ mti->milliseconds.routine= MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME;
+#elif defined(__NETWARE__)
+ mti->milliseconds.routine= MY_TIMER_ROUTINE_NXGETTIME;
+#elif defined(HAVE_TIME)
+ mti->milliseconds.routine= MY_TIMER_ROUTINE_TIME;
+#else
+ mti->milliseconds.routine= 0;
+#endif
+ if (!mti->milliseconds.routine || !my_timer_milliseconds())
+ {
+ mti->milliseconds.routine= 0;
+ mti->milliseconds.resolution= 0;
+ mti->milliseconds.frequency= 0;
+ mti->milliseconds.overhead= 0;
+ }
+
+ /* ticks */
+ mti->ticks.frequency= 100; /* permanent assumption */
+#if defined(HAVE_SYS_TIMES_H) && defined(HAVE_TIMES)
+ mti->ticks.routine= MY_TIMER_ROUTINE_TIMES;
+#elif defined(__NETWARE__)
+ mti->ticks.routine= MY_TIMER_ROUTINE_NXGETTIME;
+#elif defined(_WIN32)
+ mti->ticks.routine= MY_TIMER_ROUTINE_GETTICKCOUNT;
+#else
+ mti->ticks.routine= 0;
+#endif
+ if (!mti->ticks.routine || !my_timer_ticks())
+ {
+ mti->ticks.routine= 0;
+ mti->ticks.resolution= 0;
+ mti->ticks.frequency= 0;
+ mti->ticks.overhead= 0;
+ }
+
+ /*
+ Calculate overhead in terms of the timer that
+ gives the best resolution: cycles or nanoseconds.
+ I doubt it ever will be as bad as microseconds.
+ */
+ if (mti->cycles.routine)
+ best_timer= &my_timer_cycles;
+ else
+ {
+ if (mti->nanoseconds.routine)
+ {
+ best_timer= &my_timer_nanoseconds;
+ }
+ else
+ best_timer= &my_timer_microseconds;
+ }
+
+ /* best_timer_overhead = least of 20 calculations */
+ for (i= 0, best_timer_overhead= 1000000000; i < 20; ++i)
+ {
+ time1= best_timer();
+ time2= best_timer() - time1;
+ if (best_timer_overhead > time2)
+ best_timer_overhead= time2;
+ }
+ if (mti->cycles.routine)
+ my_timer_init_overhead(&mti->cycles.overhead,
+ best_timer,
+ &my_timer_cycles,
+ best_timer_overhead);
+ if (mti->nanoseconds.routine)
+ my_timer_init_overhead(&mti->nanoseconds.overhead,
+ best_timer,
+ &my_timer_nanoseconds,
+ best_timer_overhead);
+ if (mti->microseconds.routine)
+ my_timer_init_overhead(&mti->microseconds.overhead,
+ best_timer,
+ &my_timer_microseconds,
+ best_timer_overhead);
+ if (mti->milliseconds.routine)
+ my_timer_init_overhead(&mti->milliseconds.overhead,
+ best_timer,
+ &my_timer_milliseconds,
+ best_timer_overhead);
+ if (mti->ticks.routine)
+ my_timer_init_overhead(&mti->ticks.overhead,
+ best_timer,
+ &my_timer_ticks,
+ best_timer_overhead);
+
+/*
+ Calculate resolution for nanoseconds or microseconds
+ or milliseconds, by seeing if it's always divisible
+ by 1000, and by noticing how much jumping occurs.
+ For ticks, just assume the resolution is 1.
+*/
+ if (mti->cycles.routine)
+ mti->cycles.resolution= 1;
+ if (mti->nanoseconds.routine)
+ mti->nanoseconds.resolution=
+ my_timer_init_resolution(&my_timer_nanoseconds, 20000);
+ if (mti->microseconds.routine)
+ mti->microseconds.resolution=
+ my_timer_init_resolution(&my_timer_microseconds, 20);
+ if (mti->milliseconds.routine)
+ {
+ if (mti->milliseconds.routine == MY_TIMER_ROUTINE_TIME)
+ mti->milliseconds.resolution= 1000;
+ else
+ mti->milliseconds.resolution=
+ my_timer_init_resolution(&my_timer_milliseconds, 0);
+ }
+ if (mti->ticks.routine)
+ mti->ticks.resolution= 1;
+
+/*
+ Calculate cycles frequency,
+ if we have both a cycles routine and a microseconds routine.
+ In tests, this usually results in a figure within 2% of
+ what "cat /proc/cpuinfo" says.
+ If the microseconds routine is QueryPerformanceCounter
+ (i.e. it's Windows), and the microseconds frequency is >
+ 500,000,000 (i.e. it's Windows Server so it uses RDTSC)
+ and the microseconds resolution is > 100 (i.e. dreadful),
+ then calculate cycles frequency = microseconds frequency.
+*/
+ if (mti->cycles.routine
+ && mti->microseconds.routine)
+ {
+ if (mti->microseconds.routine ==
+ MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER
+ && mti->microseconds.frequency > 500000000
+ && mti->microseconds.resolution > 100)
+ mti->cycles.frequency= mti->microseconds.frequency;
+ else
+ {
+ ulonglong time1, time2;
+ time1= my_timer_init_frequency(mti);
+ /* Repeat once in case there was an interruption. */
+ time2= my_timer_init_frequency(mti);
+ if (time1 < time2) mti->cycles.frequency= time1;
+ else mti->cycles.frequency= time2;
+ }
+ }
+
+/*
+ Calculate milliseconds frequency =
+ (cycles-frequency/#-of-cycles) * #-of-milliseconds,
+ if we have both a milliseconds routine and a cycles
+ routine.
+ This will be inaccurate if milliseconds resolution > 1.
+ This is probably only useful when testing new platforms.
+*/
+ if (mti->milliseconds.routine
+ && mti->milliseconds.resolution < 1000
+ && mti->microseconds.routine
+ && mti->cycles.routine)
+ {
+ int i;
+ ulonglong time1, time2, time3, time4;
+ time1= my_timer_cycles();
+ time2= my_timer_milliseconds();
+ time3= time2; /* Avoids a Microsoft/IBM compiler warning */
+ for (i= 0; i < MY_TIMER_ITERATIONS * 1000; ++i)
+ {
+ time3= my_timer_milliseconds();
+ if (time3 - time2 > 10) break;
+ }
+ time4= my_timer_cycles();
+ mti->milliseconds.frequency=
+ (mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
+ }
+
+/*
+ Calculate ticks.frequency =
+ (cycles-frequency/#-of-cycles * #-of-ticks,
+ if we have both a ticks routine and a cycles
+ routine,
+ This is probably only useful when testing new platforms.
+*/
+ if (mti->ticks.routine
+ && mti->microseconds.routine
+ && mti->cycles.routine)
+ {
+ int i;
+ ulonglong time1, time2, time3, time4;
+ time1= my_timer_cycles();
+ time2= my_timer_ticks();
+ time3= time2; /* Avoids a Microsoft/IBM compiler warning */
+ for (i= 0; i < MY_TIMER_ITERATIONS * 1000; ++i)
+ {
+ time3= my_timer_ticks();
+ if (time3 - time2 > 10) break;
+ }
+ time4= my_timer_cycles();
+ mti->ticks.frequency=
+ (mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
+ }
+}
+
+/*
+ Additional Comments
+ -------------------
+
+ This is for timing, i.e. finding out how long a piece of code
+ takes. If you want time of day matching a wall clock, the
+ my_timer_xxx functions won't help you.
+
+ The best timer is the one with highest frequency, lowest
+ overhead, and resolution=1. The my_timer_info() routine will tell
+ you at runtime which timer that is. Usually it will be
+ my_timer_cycles() but be aware that, although it's best,
+ it has possible flaws and dangers. Depending on platform:
+ - The frequency might change. We don't test for this. It
+ happens on laptops for power saving, and on blade servers
+ for avoiding overheating.
+ - The overhead that my_timer_init() returns is the minimum.
+ In fact it could be slightly greater because of caching or
+ because you call the routine by address, as recommended.
+ It could be hugely greater if there's an interrupt.
+ - The x86 cycle counter, RDTSC doesn't "serialize". That is,
+ if there is out-of-order execution, rdtsc might be processed
+ after an instruction that logically follows it.
+ (We could force serialization, but that would be slower.)
+ - It is possible to set a flag which renders RDTSC
+ inoperative. Somebody responsible for the kernel
+ of the operating system would have to make this
+ decision. For the platforms we've tested with, there's
+ no such problem.
+ - With a multi-processor arrangement, it's possible
+ to get the cycle count from one processor in
+ thread X, and the cycle count from another processor
+ in thread Y. They may not always be in synch.
+ - You can't depend on a cycle counter being available for
+ all platforms. On Alphas, the
+ cycle counter is only 32-bit, so it would overflow quickly,
+ so we don't bother with it. On platforms that we haven't
+ tested, there might be some if/endif combination that we
+ didn't expect, or some assembler routine that we didn't
+ supply.
+
+ The recommended way to use the timer routines is:
+ 1. Somewhere near the beginning of the program, call
+ my_timer_init(). This should only be necessary once,
+ although you can call it again if you think that the
+ frequency has changed.
+ 2. Determine the best timer based on frequency, resolution,
+ overhead -- all things that my_timer_init() returns.
+ Preserve the address of the timer and the my_timer_into
+ results in an easily-accessible place.
+ 3. Instrument the code section that you're monitoring, thus:
+ time1= my_timer_xxx();
+ Instrumented code;
+ time2= my_timer_xxx();
+ elapsed_time= (time2 - time1) - overhead;
+ If the timer is always on, then overhead is always there,
+ so don't subtract it.
+ 4. Save the elapsed time, or add it to a totaller.
+ 5. When all timing processes are complete, transfer the
+ saved / totalled elapsed time to permanent storage.
+ Optionally you can convert cycles to microseconds at
+ this point. (Don't do so every time you calculate
+ elapsed_time! That would waste time and lose precision!)
+ For converting cycles to microseconds, use the frequency
+ that my_timer_init() returns. You'll also need to convert
+ if the my_timer_microseconds() function is the Windows
+ function QueryPerformanceCounter(), since that's sometimes
+ a counter with precision slightly better than microseconds.
+
+ Since we recommend calls by function pointer, we supply
+ no inline functions.
+
+ Some comments on the many candidate routines for timing ...
+
+ clock() -- We don't use because it would overflow frequently.
+
+ clock_gettime() -- Often we don't use this even when it exists.
+ In configure.in, we use AC_CHECK_FUNCS(clock_gettime). Not
+ AC_CHECK_LIB(rc,clock_gettime)
+ AC_CHECK_FUNCS(clock_gettime)
+ If we had the above lines in configure.in, we'd have to use
+ /usr/lib/librt.so or /usr/lib64/librt.so when linking, and
+ the size of librt.so is 40KB. In tests, clock_gettime often
+ had resolution = 1000.
+
+ ftime() -- A "man ftime" says: "This function is obsolete.
+ Don't use it." On every platform that we tested, if ftime()
+ was available, then so was gettimeofday(), and gettimeofday()
+ overhead was always at least as good as ftime() overhead.
+
+ gettimeofday() -- available on most platforms, though not
+ on Windows. There is a hardware timer (sometimes a Programmable
+ Interrupt Timer or "PIT") (sometimes a "HPET") used for
+ interrupt generation. When it interrupts (a "tick" or "jiffy",
+ typically 1 centisecond) it sets xtime. For gettimeofday, a
+ Linux kernel routine usually gets xtime and then gets rdtsc
+ to get elapsed nanoseconds since the last tick. On Red Hat
+ Enterprise Linux 3, there was once a bug which caused the
+ resolution to be 1000, i.e. one centisecond. We never check
+ for time-zone change.
+
+ getnstimeofday() -- something to watch for in future Linux
+
+ do_gettimeofday() -- exists on Linux but not for "userland"
+
+ get_cycles() -- a multi-platform function, worth watching
+ in future Linux versions. But we found platform-specific
+ functions which were better documented in operating-system
+ manuals. And get_cycles() can fail or return a useless
+ 32-bit number. It might be available on some platforms,
+ such as arm, which we didn't test. Using
+ "include <linux/timex.h>" or "include <asm/timex.h>"
+ can lead to autoconf or compile errors, depending on system.
+
+ rdtsc, __rdtsc, rdtscll: available for x86 with Linux BSD,
+ Solaris, Windows. See "possible flaws and dangers" comments.
+
+ times(): what we use for ticks. Should just read the last
+ (xtime) tick count, therefore should be fast, but usually
+ isn't.
+
+ GetTickCount(): we use this for my_timer_ticks() on
+ Windows. Actually it really is a tick counter, so resolution
+ >= 10 milliseconds unless you have a very old Windows version.
+ With Windows 95 or 98 or ME, timeGetTime() has better resolution than
+ GetTickCount (1ms rather than 55ms). But with Windows NT or XP or 2000,
+ they're both getting from a variable in the Process Environment Block
+ (PEB), and the variable is set by the programmable interrupt timer, so
+ the resolution is the same (usually 10-15 milliseconds). Also timeGetTime
+ is slower on old machines:
+ http://www.doumo.jp/aon-java/jsp/postgretips/tips.jsp?tips=74.
+ Also timeGetTime requires linking winmm.lib,
+ Therefore we use GetTickCount.
+ It will overflow every 49 days because the return is 32-bit.
+ There is also a GetTickCount64 but it requires Vista or Windows Server 2008.
+ (As for GetSystemTimeAsFileTime, its precision is spurious, it
+ just reads the tick variable like the other functions do.
+ However, we don't expect it to overflow every 49 days, so we
+ will prefer it for my_timer_milliseconds().)
+
+ QueryPerformanceCounter() we use this for my_timer_microseconds()
+ on Windows. 1-PIT-tick (often 1/3-microsecond). Usually reads
+ the PIT so it's slow. On some Windows variants, uses RDTSC.
+
+ GetLocalTime() this is available on Windows but we don't use it.
+
+ getclock(): documented for Alpha, but not found during tests.
+
+ mach_absolute_time() and UpTime() are recommended for Apple.
+ Inititally they weren't tried, because asm_ppc seems to do the job.
+ But now we use mach_absolute_time for nanoseconds.
+
+ Any clock-based timer can be affected by NPT (ntpd program),
+ which means:
+ - full-second correction can occur for leap second
+ - tiny corrections can occcur approimately every 11 minutes
+ (but I think they only affect the RTC which isn't the PIT).
+
+ We define "precision" as "frequency" and "high precision" is
+ "frequency better than 1 microsecond". We define "resolution"
+ as a synonym for "granularity". We define "accuracy" as
+ "closeness to the truth" as established by some authoritative
+ clock, but we can't measure accuracy.
+
+ Do not expect any of our timers to be monotonic; we
+ won't guarantee that they return constantly-increasing
+ unique numbers.
+
+ We tested with AIX, Solaris (x86 + Sparc), Linux (x86 +
+ Itanium), Windows, 64-bit Windows, QNX, FreeBSD, HPUX,
+ Irix, Mac. We didn't test with NetWare or SCO.
+
+*/
+
diff --git a/mysys/my_timer_cycles.il b/mysys/my_timer_cycles.il
new file mode 100644
index 00000000000..2f3f776530b
--- /dev/null
+++ b/mysys/my_timer_cycles.il
@@ -0,0 +1,38 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Sun Studio SPARC inline templates for cycle timer */
+/* Sun Studio i386 and x86_64 inline templates for cycle timer */
+/* I didn't say ".volatile" or ".nonvolatile". */
+
+.inline my_timer_cycles_il_sparc64,0
+rd %tick,%o0
+.end
+
+.inline my_timer_cycles_il_sparc32,0
+rd %tick,%o2
+srlx %o2,32,%o0
+sra %o2,0,%o1
+.end
+
+.inline my_timer_cycles_il_i386,0
+rdtsc
+.end
+
+.inline my_timer_cycles_il_x86_64,0
+rdtsc
+shlq $32,%rdx
+orq %rdx,%rax
+.end
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index 48bca8ee2a9..e3ddf7ffc30 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -28,9 +28,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl var
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
-CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
-- Create general_log if CSV is enabled.
diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql
index 03136fe9361..a7988b5198e 100644
--- a/scripts/mysql_system_tables_data.sql
+++ b/scripts/mysql_system_tables_data.sql
@@ -24,6 +24,7 @@ set @current_hostname= @@hostname;
INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0 FROM dual WHERE LOWER( @current_hostname) != 'localhost';
REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+REPLACE INTO tmp_user VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO tmp_user (host,user) VALUES ('localhost','');
INSERT INTO tmp_user (host,user) SELECT @current_hostname,'' FROM dual WHERE LOWER(@current_hostname ) != 'localhost';
INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 8dc1ae94de0..b7bcaeb62c9 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -351,7 +351,7 @@ ALTER TABLE procs_priv
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
ALTER TABLE procs_priv
- MODIFY Timestamp timestamp(14) AFTER Proc_priv;
+ MODIFY Timestamp timestamp AFTER Proc_priv;
#
# proc
diff --git a/sql-common/client.c b/sql-common/client.c
index 5114b645818..1f9c00f93be 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -38,6 +38,10 @@
#include "mysql.h"
+#ifndef __WIN__
+#include <netdb.h>
+#endif
+
/* Remove client convenience wrappers */
#undef max_allowed_packet
#undef net_buffer_length
@@ -2227,9 +2231,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
{
char buff[NAME_LEN+USERNAME_LENGTH+100];
char *end,*host_info= NULL;
- my_socket sock;
- in_addr_t ip_addr;
- struct sockaddr_in sock_addr;
ulong pkt_length;
NET *net= &mysql->net;
#ifdef MYSQL_SERVER
@@ -2335,7 +2336,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
else
{
mysql->options.protocol=MYSQL_PROTOCOL_MEMORY;
- sock=0;
unix_socket = 0;
host=mysql->options.shared_memory_base_name;
my_snprintf(host_info=buff, sizeof(buff)-1,
@@ -2350,12 +2350,9 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(unix_socket || mysql_unix_port) &&
(!host || !strcmp(host,LOCAL_HOST)))
{
- host=LOCAL_HOST;
- if (!unix_socket)
- unix_socket=mysql_unix_port;
- host_info=(char*) ER(CR_LOCALHOST_CONNECTION);
- DBUG_PRINT("info",("Using UNIX sock '%s'",unix_socket));
- if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR)
+ DBUG_PRINT("info", ("Using socket"));
+ my_socket sock= socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sock == SOCKET_ERROR)
{
set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR,
unknown_sqlstate,
@@ -2363,12 +2360,28 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
socket_errno);
goto error;
}
+
net->vio= vio_new(sock, VIO_TYPE_SOCKET,
VIO_LOCALHOST | VIO_BUFFERED_READ);
- bzero((char*) &UNIXaddr,sizeof(UNIXaddr));
- UNIXaddr.sun_family = AF_UNIX;
+ if (!net->vio)
+ {
+ DBUG_PRINT("error",("Unknow protocol %d ", mysql->options.protocol));
+ set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
+ closesocket(sock);
+ goto error;
+ }
+
+ host= LOCAL_HOST;
+ if (!unix_socket)
+ unix_socket= mysql_unix_port;
+ host_info= (char*) ER(CR_LOCALHOST_CONNECTION);
+ DBUG_PRINT("info", ("Using UNIX sock '%s'", unix_socket));
+
+ bzero((char*) &UNIXaddr, sizeof(UNIXaddr));
+ UNIXaddr.sun_family= AF_UNIX;
strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path)-1);
- if (my_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
+
+ if (my_connect(sock, (struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
mysql->options.connect_timeout))
{
DBUG_PRINT("error",("Got error %d on connect to local server",
@@ -2377,6 +2390,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
unknown_sqlstate,
ER(CR_CONNECTION_ERROR),
unix_socket, socket_errno);
+ vio_delete(net->vio);
+ net->vio= 0;
goto error;
}
mysql->options.protocol=MYSQL_PROTOCOL_SOCKET;
@@ -2387,7 +2402,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
(! have_tcpip && (unix_socket || !host && is_NT()))))
{
- sock=0;
if ((hPipe= create_named_pipe(mysql, mysql->options.connect_timeout,
(char**) &host, (char**) &unix_socket)) ==
INVALID_HANDLE_VALUE)
@@ -2417,94 +2431,124 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(!mysql->options.protocol ||
mysql->options.protocol == MYSQL_PROTOCOL_TCP))
{
- int status= -1;
+ struct addrinfo *res_lst, hints, *t_res;
+ int gai_errno;
+ char port_buf[NI_MAXSERV];
+ my_socket sock= SOCKET_ERROR;
+ int UNINIT_VAR(saved_error), status= -1;
+
unix_socket=0; /* This is not used */
+
if (!port)
- port=mysql_port;
+ port= mysql_port;
+
if (!host)
- host=LOCAL_HOST;
- my_snprintf(host_info=buff,sizeof(buff)-1,ER(CR_TCP_CONNECTION),host);
- DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port));
+ host= LOCAL_HOST;
+
+ my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_TCP_CONNECTION), host);
+ DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host, port));
#ifdef MYSQL_SERVER
thr_alarm_init(&alarmed);
thr_alarm(&alarmed, mysql->options.connect_timeout, &alarm_buff);
#endif
- /* _WIN64 ; Assume that the (int) range is enough for socket() */
- sock = (my_socket) socket(AF_INET,SOCK_STREAM,0);
+
+ DBUG_PRINT("info",("IP '%s'", "client"));
+
#ifdef MYSQL_SERVER
thr_end_alarm(&alarmed);
#endif
- if (sock == SOCKET_ERROR)
- {
- set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate,
- ER(CR_IPSOCK_ERROR), socket_errno);
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_protocol= IPPROTO_TCP;
+ hints.ai_family= AF_UNSPEC;
+
+ DBUG_PRINT("info",("IPV6 getaddrinfo %s", host));
+ my_snprintf(port_buf, NI_MAXSERV, "%d", port);
+ gai_errno= getaddrinfo(host, port_buf, &hints, &res_lst);
+
+ if (gai_errno != 0)
+ {
+ /*
+ For DBUG we are keeping the right message but for client we default to
+ historical error message.
+ */
+ DBUG_PRINT("info",("IPV6 getaddrinfo error %d", gai_errno));
+ set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
+ ER(CR_UNKNOWN_HOST), host, errno);
+
goto error;
}
- net->vio= vio_new(sock, VIO_TYPE_TCPIP, VIO_BUFFERED_READ);
- bzero((char*) &sock_addr,sizeof(sock_addr));
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_port = (ushort) htons((ushort) port);
/*
- The server name may be a host name or IP address
+ A hostname might map to multiple IP addresses (IPv4/IPv6). Go over the
+ list of IP addresses until a successful connection can be established.
*/
-
- if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE)
- {
- memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
- sizeof(sock_addr), mysql->options.connect_timeout);
- }
- else
+ DBUG_PRINT("info", ("Try connect on all addresses for host."));
+ for (t_res= res_lst; t_res; t_res= t_res->ai_next)
{
- int i, tmp_errno;
- struct hostent tmp_hostent,*hp;
- char buff2[GETHOSTBYNAME_BUFF_SIZE];
- hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2),
- &tmp_errno);
+ DBUG_PRINT("info", ("Create socket, family: %d type: %d proto: %d",
+ t_res->ai_family, t_res->ai_socktype,
+ t_res->ai_protocol));
+ sock= socket(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol);
+ if (sock == SOCKET_ERROR)
+ {
+ saved_error= socket_errno;
+ continue;
+ }
+ DBUG_PRINT("info", ("Connect socket"));
+ status= my_connect(sock, t_res->ai_addr, t_res->ai_addrlen,
+ mysql->options.connect_timeout);
/*
- Don't attempt to connect to non IPv4 addresses as the client could
- end up sending information to a unknown server. For example, a IPv6
- address might be returned from gethostbyname depending on options
- set via the RES_OPTIONS environment variable.
+ Here we rely on my_connect() to return success only if the
+ connect attempt was really successful. Otherwise we would stop
+ trying another address, believing we were successful.
*/
- if (!hp || (hp->h_addrtype != AF_INET))
- {
- my_gethostbyname_r_free();
- set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
- ER(CR_UNKNOWN_HOST), host, tmp_errno);
- goto error;
- }
+ if (!status)
+ break;
- for (i= 0; status && hp->h_addr_list[i]; i++)
- {
- char ipaddr[18] __attribute__((unused));
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- /*
- Here we rely on my_connect() to return success only if the
- connect attempt was really successful. Otherwise we would stop
- trying another address, believing we were successful.
- */
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
- sizeof(sock_addr), mysql->options.connect_timeout);
- }
+ /*
+ Save value as socket errno might be overwritten due to
+ calling a socket function below.
+ */
+ saved_error= socket_errno;
- my_gethostbyname_r_free();
+ DBUG_PRINT("info", ("No success, close socket, try next address."));
+ closesocket(sock);
+ }
+ DBUG_PRINT("info",
+ ("End of connect attempts, sock: %d status: %d error: %d",
+ sock, status, saved_error));
+
+ freeaddrinfo(res_lst);
+
+ if (sock == SOCKET_ERROR)
+ {
+ set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate,
+ ER(CR_IPSOCK_ERROR), saved_error);
+ goto error;
}
if (status)
{
- DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,
- host));
+ DBUG_PRINT("error",("Got error %d on connect to '%s'", saved_error, host));
set_mysql_extended_error(mysql, CR_CONN_HOST_ERROR, unknown_sqlstate,
- ER(CR_CONN_HOST_ERROR), host, socket_errno);
+ ER(CR_CONN_HOST_ERROR), host, saved_error);
+ goto error;
+ }
+
+ net->vio= vio_new(sock, VIO_TYPE_TCPIP, VIO_BUFFERED_READ);
+ if (! net->vio )
+ {
+ DBUG_PRINT("error",("Unknow protocol %d ", mysql->options.protocol));
+ set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
+ closesocket(sock);
goto error;
}
}
+
+ DBUG_PRINT("info", ("net->vio: %p", net->vio));
if (!net->vio)
{
DBUG_PRINT("error",("Unknow protocol %d ",mysql->options.protocol));
@@ -2640,14 +2684,14 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
if (client_flag & CLIENT_MULTI_STATEMENTS)
client_flag|= CLIENT_MULTI_RESULTS;
-#ifdef HAVE_OPENSSL
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if (mysql->options.ssl_key || mysql->options.ssl_cert ||
mysql->options.ssl_ca || mysql->options.ssl_capath ||
mysql->options.ssl_cipher)
mysql->options.use_ssl= 1;
if (mysql->options.use_ssl)
client_flag|=CLIENT_SSL;
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY*/
if (db)
client_flag|=CLIENT_CONNECT_WITH_DB;
@@ -2676,7 +2720,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
}
mysql->client_flag=client_flag;
-#ifdef HAVE_OPENSSL
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if (client_flag & CLIENT_SSL)
{
/* Do the SSL layering. */
@@ -2727,7 +2771,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
}
}
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
DBUG_PRINT("info",("Server version = '%s' capabilites: %lu status: %u client_flag: %lu",
mysql->server_version,mysql->server_capabilities,
diff --git a/sql/client_settings.h b/sql/client_settings.h
index fd50bfdbb88..7d103d5904d 100644
--- a/sql/client_settings.h
+++ b/sql/client_settings.h
@@ -30,10 +30,6 @@
#define set_sigpipe(mysql)
#define reset_sigpipe(mysql)
#define read_user_name(A) {}
-#define mysql_rpl_query_type(A,B) MYSQL_RPL_ADMIN
-#define mysql_master_send_query(A, B, C) 1
-#define mysql_slave_send_query(A, B, C) 1
-#define mysql_rpl_probe(mysql) 0
#undef HAVE_SMEM
#undef _CUSTOMCONFIG_
diff --git a/sql/handler.cc b/sql/handler.cc
index 9366d91b290..2ccb87591dc 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3240,36 +3240,6 @@ handler::ha_reset_auto_increment(ulonglong value)
/**
- Backup table: public interface.
-
- @sa handler::backup()
-*/
-
-int
-handler::ha_backup(THD* thd, HA_CHECK_OPT* check_opt)
-{
- mark_trx_read_write();
-
- return backup(thd, check_opt);
-}
-
-
-/**
- Restore table: public interface.
-
- @sa handler::restore()
-*/
-
-int
-handler::ha_restore(THD* thd, HA_CHECK_OPT* check_opt)
-{
- mark_trx_read_write();
-
- return restore(thd, check_opt);
-}
-
-
-/**
Optimize table: public interface.
@sa handler::optimize()
diff --git a/sql/handler.h b/sql/handler.h
index 5f028796cf3..7e64a08700f 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1252,8 +1252,6 @@ public:
uint *dup_key_found);
int ha_delete_all_rows();
int ha_reset_auto_increment(ulonglong value);
- int ha_backup(THD* thd, HA_CHECK_OPT* check_opt);
- int ha_restore(THD* thd, HA_CHECK_OPT* check_opt);
int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
bool ha_check_and_repair(THD *thd);
@@ -1539,9 +1537,7 @@ public:
{ return HA_ADMIN_NOT_IMPLEMENTED; }
/* end of the list of admin commands */
- virtual int dump(THD* thd, int fd = -1) { return HA_ERR_WRONG_COMMAND; }
virtual int indexes_are_disabled(void) {return 0;}
- virtual int net_read_dump(NET* net) { return HA_ERR_WRONG_COMMAND; }
virtual char *update_table_comment(const char * comment)
{ return (char*) comment;}
virtual void append_create_info(String *packet) {}
@@ -1909,14 +1905,6 @@ private:
*/
virtual int reset_auto_increment(ulonglong value)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int backup(THD* thd, HA_CHECK_OPT* check_opt)
- { return HA_ADMIN_NOT_IMPLEMENTED; }
- /**
- Restore assumes .frm file must exist, and that generate_table() has been
- called; It will just copy the data file and run repair.
- */
- virtual int restore(THD* thd, HA_CHECK_OPT* check_opt)
- { return HA_ADMIN_NOT_IMPLEMENTED; }
virtual int optimize(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt)
diff --git a/sql/hostname.cc b/sql/hostname.cc
index b498c548e61..cf35e60061f 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -18,10 +18,10 @@
@file
@brief
- Get hostname for an IP.
+ Get hostname for an IP address.
- Hostnames are checked with reverse name lookup and
- checked that they doesn't resemble an ip.
+ Hostnames are checked with reverse name lookup and checked that they
+ doesn't resemble an IP address.
*/
#include "mysql_priv.h"
@@ -34,24 +34,54 @@ extern "C" { // Because of SCO 3.2V4.2
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
-#include <netdb.h>
#include <sys/utsname.h>
#endif // __WIN__
#ifdef __cplusplus
}
#endif
+/*
+ HOST_ENTRY_KEY_SIZE -- size of IP address string in the hash cache.
+*/
+
+#define HOST_ENTRY_KEY_SIZE INET6_ADDRSTRLEN
+
+/**
+ An entry in the hostname hash table cache.
+
+ Host name cache does two things:
+ - caches host names to save DNS look ups;
+ - counts connect errors from IP.
-class host_entry :public hash_filo_element
+ Host name can be NULL (that means DNS look up failed), but connect errors
+ still are counted.
+*/
+
+class Host_entry :public hash_filo_element
{
public:
- char ip[sizeof(((struct in_addr *) 0)->s_addr)];
- uint errors;
- char *hostname;
+ /**
+ Client IP address. This is the key used with the hash table.
+
+ The client IP address is always expressed in IPv6, even when the
+ network IPv6 stack is not present.
+
+ This IP address is never used to connect to a socket.
+ */
+ char ip_key[HOST_ENTRY_KEY_SIZE];
+
+ /**
+ Number of errors during handshake phase from the IP address.
+ */
+ uint connect_errors;
+
+ /**
+ One of the host names for the IP address. May be NULL.
+ */
+ const char *hostname;
};
static hash_filo *hostname_cache;
-static pthread_mutex_t LOCK_hostname;
void hostname_cache_refresh()
{
@@ -60,219 +90,468 @@ void hostname_cache_refresh()
bool hostname_cache_init()
{
- host_entry tmp;
- uint offset= (uint) ((char*) (&tmp.ip) - (char*) &tmp);
- if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset,
- sizeof(struct in_addr),NULL,
- (my_hash_free_key) free,
- &my_charset_bin)))
+ Host_entry tmp;
+ uint key_offset= (uint) ((char*) (&tmp.ip_key) - (char*) &tmp);
+
+ if (!(hostname_cache= new hash_filo(HOST_CACHE_SIZE,
+ key_offset, HOST_ENTRY_KEY_SIZE,
+ NULL, (my_hash_free_key) free,
+ &my_charset_bin)))
return 1;
+
hostname_cache->clear();
- (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
+
return 0;
}
void hostname_cache_free()
{
- if (hostname_cache)
- {
- (void) pthread_mutex_destroy(&LOCK_hostname);
- delete hostname_cache;
- hostname_cache= 0;
- }
+ delete hostname_cache;
+ hostname_cache= NULL;
}
+static void prepare_hostname_cache_key(const char *ip_string,
+ char *ip_key)
+{
+ int ip_string_length= strlen(ip_string);
+ DBUG_ASSERT(ip_string_length < HOST_ENTRY_KEY_SIZE);
-static void add_hostname(struct in_addr *in,const char *name)
+ memset(ip_key, 0, HOST_ENTRY_KEY_SIZE);
+ memcpy_fixed(ip_key, ip_string, ip_string_length);
+}
+
+static inline Host_entry *hostname_cache_search(const char *ip_key)
{
- if (!(specialflag & SPECIAL_NO_HOST_CACHE))
+ return (Host_entry *) hostname_cache->search((uchar *) ip_key, 0);
+}
+
+static bool add_hostname_impl(const char *ip_key, const char *hostname)
+{
+ if (hostname_cache_search(ip_key))
+ return FALSE;
+
+ size_t hostname_size= hostname ? strlen(hostname) + 1 : 0;
+
+ Host_entry *entry= (Host_entry *) malloc(sizeof (Host_entry) + hostname_size);
+
+ if (!entry)
+ return TRUE;
+
+ char *hostname_copy;
+
+ memcpy_fixed(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE);
+
+ if (hostname_size)
{
- pthread_mutex_lock(&hostname_cache->lock);
- host_entry *entry;
- if (!(entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
- {
- uint length=name ? (uint) strlen(name) : 0;
+ hostname_copy= (char *) (entry + 1);
+ memcpy(hostname_copy, hostname, hostname_size);
- if ((entry=(host_entry*) malloc(sizeof(host_entry)+length+1)))
- {
- char *new_name;
- memcpy_fixed(&entry->ip, &in->s_addr, sizeof(in->s_addr));
- if (length)
- memcpy(new_name= (char *) (entry+1), name, length+1);
- else
- new_name=0;
- entry->hostname=new_name;
- entry->errors=0;
- (void) hostname_cache->add(entry);
- }
- }
- pthread_mutex_unlock(&hostname_cache->lock);
+ DBUG_PRINT("info", ("Adding '%s' -> '%s' to the hostname cache...'",
+ (const char *) ip_key,
+ (const char *) hostname_copy));
}
-}
+ else
+ {
+ hostname_copy= NULL;
+
+ DBUG_PRINT("info", ("Adding '%s' -> NULL to the hostname cache...'",
+ (const char *) ip_key));
+ }
+
+ entry->hostname= hostname_copy;
+ entry->connect_errors= 0;
+ return hostname_cache->add(entry);
+}
-inline void add_wrong_ip(struct in_addr *in)
+static bool add_hostname(const char *ip_key, const char *hostname)
{
- add_hostname(in,NullS);
+ if (specialflag & SPECIAL_NO_HOST_CACHE)
+ return FALSE;
+
+ pthread_mutex_lock(&hostname_cache->lock);
+
+ bool err_status= add_hostname_impl(ip_key, hostname);
+
+ pthread_mutex_unlock(&hostname_cache->lock);
+
+ return err_status;
}
-void inc_host_errors(struct in_addr *in)
+void inc_host_errors(const char *ip_string)
{
+ if (!ip_string)
+ return;
+
+ char ip_key[HOST_ENTRY_KEY_SIZE];
+ prepare_hostname_cache_key(ip_string, ip_key);
+
pthread_mutex_lock(&hostname_cache->lock);
- host_entry *entry;
- if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
- entry->errors++;
+
+ Host_entry *entry= hostname_cache_search(ip_key);
+
+ if (entry)
+ entry->connect_errors++;
+
pthread_mutex_unlock(&hostname_cache->lock);
}
-void reset_host_errors(struct in_addr *in)
+
+void reset_host_errors(const char *ip_string)
{
+ if (!ip_string)
+ return;
+
+ char ip_key[HOST_ENTRY_KEY_SIZE];
+ prepare_hostname_cache_key(ip_string, ip_key);
+
pthread_mutex_lock(&hostname_cache->lock);
- host_entry *entry;
- if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
- entry->errors=0;
+
+ Host_entry *entry= hostname_cache_search(ip_key);
+
+ if (entry)
+ entry->connect_errors= 0;
+
pthread_mutex_unlock(&hostname_cache->lock);
}
-/* Deal with systems that don't defined INADDR_LOOPBACK */
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK 0x7f000001UL
-#endif
-char * ip_to_hostname(struct in_addr *in, uint *errors)
+static inline bool is_ip_loopback(const struct sockaddr *ip)
+{
+ switch (ip->sa_family) {
+ case AF_INET:
+ {
+ /* Check for IPv4 127.0.0.1. */
+ struct in_addr *ip4= &((struct sockaddr_in *) ip)->sin_addr;
+ return ntohl(ip4->s_addr) == INADDR_LOOPBACK;
+ }
+
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ {
+ /* Check for IPv6 ::1. */
+ struct in6_addr *ip6= &((struct sockaddr_in6 *) ip)->sin6_addr;
+ return IN6_IS_ADDR_LOOPBACK(ip6);
+ }
+#endif /* HAVE_IPV6 */
+
+ default:
+ return FALSE;
+ }
+}
+
+static inline bool is_hostname_valid(const char *hostname)
{
- uint i;
- host_entry *entry;
+ /*
+ A hostname is invalid if it starts with a number followed by a dot
+ (IPv4 address).
+ */
+
+ if (!my_isdigit(&my_charset_latin1, hostname[0]))
+ return TRUE;
+
+ const char *p= hostname + 1;
+
+ while (my_isdigit(&my_charset_latin1, *p))
+ ++p;
+
+ return *p != '.';
+}
+
+/**
+ Resolve IP-address to host name.
+
+ This function does the following things:
+ - resolves IP-address;
+ - employs Forward Confirmed Reverse DNS technique to validate IP-address;
+ - returns host name if IP-address is validated;
+ - set value to out-variable connect_errors -- this variable represents the
+ number of connection errors from the specified IP-address.
+
+ NOTE: connect_errors are counted (are supported) only for the clients
+ where IP-address can be resolved and FCrDNS check is passed.
+
+ @param [in] ip_storage IP address (sockaddr). Must be set.
+ @param [in] ip_string IP address (string). Must be set.
+ @param [out] hostname
+ @param [out] connect_errors
+
+ @return Error status
+ @retval FALSE Success
+ @retval TRUE Error
+
+ The function does not set/report MySQL server error in case of failure.
+ It's caller's responsibility to handle failures of this function
+ properly.
+*/
+
+bool ip_to_hostname(struct sockaddr_storage *ip_storage,
+ const char *ip_string,
+ char **hostname, uint *connect_errors)
+{
+ const struct sockaddr *ip= (const sockaddr *) ip_storage;
+ int err_code;
+ bool err_status;
+
DBUG_ENTER("ip_to_hostname");
- *errors=0;
+ DBUG_PRINT("info", ("IP address: '%s'; family: %d.",
+ (const char *) ip_string,
+ (int) ip->sa_family));
- /* We always treat the loopback address as "localhost". */
- if (in->s_addr == htonl(INADDR_LOOPBACK)) // is expanded inline by gcc
- DBUG_RETURN((char *)my_localhost);
+ /* Check if we have loopback address (127.0.0.1 or ::1). */
+
+ if (is_ip_loopback(ip))
+ {
+ DBUG_PRINT("info", ("Loopback address detected."));
+
+ *connect_errors= 0; /* Do not count connect errors from localhost. */
+ *hostname= (char *) my_localhost;
+
+ DBUG_RETURN(FALSE);
+ }
+
+ /* Prepare host name cache key. */
+
+ char ip_key[HOST_ENTRY_KEY_SIZE];
+ prepare_hostname_cache_key(ip_string, ip_key);
+
+ /* Check first if we have host name in the cache. */
- /* Check first if we have name in cache */
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
{
pthread_mutex_lock(&hostname_cache->lock);
- if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
+
+ Host_entry *entry= hostname_cache_search(ip_key);
+
+ if (entry)
{
- char *name;
- if (!entry->hostname)
- name=0; // Don't allow connection
- else
- name=my_strdup(entry->hostname,MYF(0));
- *errors= entry->errors;
+ *connect_errors= entry->connect_errors;
+ *hostname= NULL;
+
+ if (entry->hostname)
+ *hostname= my_strdup(entry->hostname, MYF(0));
+
+ DBUG_PRINT("info",("IP (%s) has been found in the cache. "
+ "Hostname: '%s'; connect_errors: %d",
+ (const char *) ip_key,
+ (const char *) (*hostname? *hostname : "null"),
+ (int) *connect_errors));
+
pthread_mutex_unlock(&hostname_cache->lock);
- DBUG_RETURN(name);
+
+ DBUG_RETURN(FALSE);
}
+
pthread_mutex_unlock(&hostname_cache->lock);
}
- struct hostent *hp, *check;
- char *name;
- LINT_INIT(check);
-#if defined(HAVE_GETHOSTBYADDR_R) && defined(HAVE_SOLARIS_STYLE_GETHOST)
- char buff[GETHOSTBYADDR_BUFF_SIZE],buff2[GETHOSTBYNAME_BUFF_SIZE];
- int tmp_errno;
- struct hostent tmp_hostent, tmp_hostent2;
-#ifdef HAVE_purify
- bzero(buff,sizeof(buff)); // Bug in purify
-#endif
- if (!(hp=gethostbyaddr_r((char*) in,sizeof(*in),
- AF_INET,
- &tmp_hostent,buff,sizeof(buff),&tmp_errno)))
- {
- DBUG_PRINT("error",("gethostbyaddr_r returned %d",tmp_errno));
- return 0;
- }
- if (!(check=my_gethostbyname_r(hp->h_name,&tmp_hostent2,buff2,sizeof(buff2),
- &tmp_errno)))
+ /*
+ Resolve host name. Return an error if a host name can not be resolved
+ (instead of returning the numeric form of the host name).
+ */
+
+ char hostname_buffer[NI_MAXHOST];
+
+ DBUG_PRINT("info", ("Resolving '%s'...", (const char *) ip_key));
+
+ err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
+ NI_NAMEREQD);
+
+ if (err_code == EAI_NONAME)
{
- DBUG_PRINT("error",("gethostbyname_r returned %d",tmp_errno));
/*
- Don't cache responses when the DSN server is down, as otherwise
- transient DNS failure may leave any number of clients (those
- that attempted to connect during the outage) unable to connect
- indefinitely.
+ There is no reverse address mapping for the IP address. A host name
+ can not be resolved.
*/
- if (tmp_errno == HOST_NOT_FOUND || tmp_errno == NO_DATA)
- add_wrong_ip(in);
- my_gethostbyname_r_free();
- DBUG_RETURN(0);
- }
- if (!hp->h_name[0])
- {
- DBUG_PRINT("error",("Got an empty hostname"));
- add_wrong_ip(in);
- my_gethostbyname_r_free();
- DBUG_RETURN(0); // Don't allow empty hostnames
- }
- if (!(name=my_strdup(hp->h_name,MYF(0))))
- {
- my_gethostbyname_r_free();
- DBUG_RETURN(0); // out of memory
+
+ DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
+ "no reverse address mapping.",
+ (const char *) ip_key));
+
+ sql_print_warning("IP address '%s' could not be resolved: "
+ "no reverse address mapping.",
+ (const char *) ip_key);
+
+ err_status= add_hostname(ip_key, NULL);
+
+ *hostname= NULL;
+ *connect_errors= 0; /* New IP added to the cache. */
+
+ DBUG_RETURN(err_status);
}
- my_gethostbyname_r_free();
-#else
- pthread_mutex_lock(&LOCK_hostname);
- if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET)))
+ else if (err_code)
{
- pthread_mutex_unlock(&LOCK_hostname);
- DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
+ DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
+ "getnameinfo() returned %d.",
+ (const char *) ip_key,
+ (int) err_code));
+
+ sql_print_warning("IP address '%s' could not be resolved: "
+ "getnameinfo() returned error (code: %d).",
+ (const char *) ip_key,
+ (int) err_code);
- if (errno == HOST_NOT_FOUND || errno == NO_DATA)
- goto add_wrong_ip_and_return;
- /* Failure, don't cache responce */
- DBUG_RETURN(0);
+ DBUG_RETURN(TRUE);
}
- if (!hp->h_name[0]) // Don't allow empty hostnames
+
+ DBUG_PRINT("info", ("IP '%s' resolved to '%s'.",
+ (const char *) ip_key,
+ (const char *) hostname_buffer));
+
+ /*
+ Validate hostname: the server does not accept host names, which
+ resemble IP addresses.
+
+ The thing is that theoretically, a host name can be in a form of IPv4
+ address (123.example.org, or 1.2 or even 1.2.3.4). We have to deny such
+ host names because ACL-systems is not designed to work with them.
+
+ For example, it is possible to specify a host name mask (like
+ 192.168.1.%) for an ACL rule. Then, if IPv4-like hostnames are allowed,
+ there is a security hole: instead of allowing access for
+ 192.168.1.0/255 network (which was assumed by the user), the access
+ will be allowed for host names like 192.168.1.example.org.
+ */
+
+ if (!is_hostname_valid(hostname_buffer))
{
- pthread_mutex_unlock(&LOCK_hostname);
- DBUG_PRINT("error",("Got an empty hostname"));
- goto add_wrong_ip_and_return;
+ DBUG_PRINT("error", ("IP address '%s' has been resolved "
+ "to the host name '%s', which resembles "
+ "IPv4-address itself.",
+ (const char *) ip_key,
+ (const char *) hostname_buffer));
+
+ sql_print_warning("IP address '%s' has been resolved "
+ "to the host name '%s', which resembles "
+ "IPv4-address itself.",
+ (const char *) ip_key,
+ (const char *) hostname_buffer);
+
+ err_status= add_hostname(ip_key, NULL);
+
+ *hostname= NULL;
+ *connect_errors= 0; /* New IP added to the cache. */
+
+ DBUG_RETURN(err_status);
}
- if (!(name=my_strdup(hp->h_name,MYF(0))))
+
+ /* Get IP-addresses for the resolved host name (FCrDNS technique). */
+
+ struct addrinfo hints;
+ struct addrinfo *addr_info_list;
+
+ memset(&hints, 0, sizeof (struct addrinfo));
+ hints.ai_flags= AI_PASSIVE;
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_family= AF_UNSPEC;
+
+ DBUG_PRINT("info", ("Getting IP addresses for hostname '%s'...",
+ (const char *) hostname_buffer));
+
+ err_code= getaddrinfo(hostname_buffer, NULL, &hints, &addr_info_list);
+
+ if (err_code == EAI_NONAME)
{
- pthread_mutex_unlock(&LOCK_hostname);
- DBUG_RETURN(0); // out of memory
+ /*
+ Don't cache responses when the DNS server is down, as otherwise
+ transient DNS failure may leave any number of clients (those
+ that attempted to connect during the outage) unable to connect
+ indefinitely.
+ */
+
+ err_status= add_hostname(ip_key, NULL);
+
+ *hostname= NULL;
+ *connect_errors= 0; /* New IP added to the cache. */
+
+ DBUG_RETURN(err_status);
}
- check=gethostbyname(name);
- pthread_mutex_unlock(&LOCK_hostname);
- if (!check)
+ else if (err_code)
{
- DBUG_PRINT("error",("gethostbyname returned %d",errno));
- my_free(name,MYF(0));
- DBUG_RETURN(0);
+ DBUG_PRINT("error", ("getaddrinfo() failed with error code %d.", err_code));
+ DBUG_RETURN(TRUE);
}
-#endif
- /* Don't accept hostnames that starts with digits because they may be
- false ip:s */
- if (my_isdigit(&my_charset_latin1,name[0]))
+ /* Check that getaddrinfo() returned the used IP (FCrDNS technique). */
+
+ DBUG_PRINT("info", ("The following IP addresses found for '%s':",
+ (const char *) hostname_buffer));
+
+ for (struct addrinfo *addr_info= addr_info_list;
+ addr_info; addr_info= addr_info->ai_next)
{
- char *pos;
- for (pos= name+1 ; my_isdigit(&my_charset_latin1,*pos); pos++) ;
- if (*pos == '.')
+ char ip_buffer[HOST_ENTRY_KEY_SIZE];
+
+ {
+ err_status=
+ vio_get_normalized_ip_string(addr_info->ai_addr, addr_info->ai_addrlen,
+ ip_buffer, sizeof (ip_buffer));
+ DBUG_ASSERT(!err_status);
+ }
+
+ DBUG_PRINT("info", (" - '%s'", (const char *) ip_buffer));
+
+ if (strcmp(ip_key, ip_buffer) == 0)
{
- DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'"));
- my_free(name,MYF(0));
- goto add_wrong_ip_and_return;
+ /* Copy host name string to be stored in the cache. */
+
+ *hostname= my_strdup(hostname_buffer, MYF(0));
+
+ if (!*hostname)
+ {
+ DBUG_PRINT("error", ("Out of memory."));
+
+ freeaddrinfo(addr_info_list);
+ DBUG_RETURN(TRUE);
+ }
+
+ break;
}
}
- /* Check that 'gethostbyname' returned the used ip */
- for (i=0; check->h_addr_list[i]; i++)
+ /* Log resolved IP-addresses if no match was found. */
+
+ if (!*hostname)
{
- if (*(uint32*)(check->h_addr_list)[i] == in->s_addr)
+ sql_print_information("Hostname '%s' does not resolve to '%s'.",
+ (const char *) hostname_buffer,
+ (const char *) ip_key);
+ sql_print_information("Hostname '%s' has the following IP addresses:",
+ (const char *) hostname_buffer);
+
+ for (struct addrinfo *addr_info= addr_info_list;
+ addr_info; addr_info= addr_info->ai_next)
{
- add_hostname(in,name);
- DBUG_RETURN(name);
+ char ip_buffer[HOST_ENTRY_KEY_SIZE];
+
+ err_status=
+ vio_get_normalized_ip_string(addr_info->ai_addr, addr_info->ai_addrlen,
+ ip_buffer, sizeof (ip_buffer));
+ DBUG_ASSERT(!err_status);
+
+ sql_print_information(" - %s\n", (const char *) ip_buffer);
}
}
- DBUG_PRINT("error",("Couldn't verify hostname with gethostbyname"));
- my_free(name,MYF(0));
-add_wrong_ip_and_return:
- add_wrong_ip(in);
- DBUG_RETURN(0);
+ /* Free the result of getaddrinfo(). */
+
+ freeaddrinfo(addr_info_list);
+
+ /* Add an entry for the IP to the cache. */
+
+ if (*hostname)
+ {
+ err_status= add_hostname(ip_key, *hostname);
+ *connect_errors= 0;
+ }
+ else
+ {
+ DBUG_PRINT("error",("Couldn't verify hostname with getaddrinfo()."));
+
+ err_status= add_hostname(ip_key, NULL);
+ *hostname= NULL;
+ *connect_errors= 0;
+ }
+
+ DBUG_RETURN(err_status);
}
diff --git a/sql/item.h b/sql/item.h
index 72e4e37342a..342b482c471 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -3154,5 +3154,4 @@ extern Cached_item *new_Cached_item(THD *thd, Item *item);
extern Item_result item_cmp_type(Item_result a,Item_result b);
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
extern int stored_field_cmp_to_item(THD *thd, Field *field, Item *item);
-
#endif /* ITEM_INCLUDED */
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 8354f6a5d30..c7ee0ee9b91 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1727,5 +1727,4 @@ Item *and_expressions(Item *a, Item *b, Item **org_item);
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
const char *warn_name, MYSQL_TIME *l_time);
-
#endif /* ITEM_CMPFUNC_INCLUDED */
diff --git a/sql/lex.h b/sql/lex.h
index cd0c042159f..a12cf0c4b3e 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -259,8 +259,6 @@ static SYMBOL symbols[] = {
{ "INFILE", SYM(INFILE)},
{ "INITIAL_SIZE", SYM(INITIAL_SIZE_SYM)},
{ "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
{ "INOUT", SYM(INOUT_SYM)},
{ "INSENSITIVE", SYM(INSENSITIVE_SYM)},
{ "INSERT", SYM(INSERT)},
diff --git a/sql/log.cc b/sql/log.cc
index dd82134ae56..ea06f71b569 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -53,7 +53,7 @@ LOGGER logger;
MYSQL_BIN_LOG mysql_bin_log(&sync_binlog_period);
static bool test_if_number(const char *str,
- long *res, bool allow_wildcards);
+ ulong *res, bool allow_wildcards);
static int binlog_init(void *p);
static int binlog_close_connection(handlerton *hton, THD *thd);
static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv);
@@ -63,6 +63,35 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all);
static int binlog_prepare(handlerton *hton, THD *thd, bool all);
/**
+ purge logs, master and slave sides both, related error code
+ convertor.
+ Called from @c purge_error_message(), @c MYSQL_BIN_LOG::reset_logs()
+
+ @param res an internal to purging routines error code
+
+ @return the user level error code ER_*
+*/
+uint purge_log_get_error_code(int res)
+{
+ uint errcode= 0;
+
+ switch (res) {
+ case 0: break;
+ case LOG_INFO_EOF: errcode= ER_UNKNOWN_TARGET_BINLOG; break;
+ case LOG_INFO_IO: errcode= ER_IO_ERR_LOG_INDEX_READ; break;
+ case LOG_INFO_INVALID:errcode= ER_BINLOG_PURGE_PROHIBITED; break;
+ case LOG_INFO_SEEK: errcode= ER_FSEEK_FAIL; break;
+ case LOG_INFO_MEM: errcode= ER_OUT_OF_RESOURCES; break;
+ case LOG_INFO_FATAL: errcode= ER_BINLOG_PURGE_FATAL_ERR; break;
+ case LOG_INFO_IN_USE: errcode= ER_LOG_IN_USE; break;
+ case LOG_INFO_EMFILE: errcode= ER_BINLOG_PURGE_EMFILE; break;
+ default: errcode= ER_LOG_PURGE_UNKNOWN_ERR; break;
+ }
+
+ return errcode;
+}
+
+/**
Silence all errors and warnings reported when performing a write
to a log table.
Errors and warnings are not reported to the client or SQL exception
@@ -1852,22 +1881,27 @@ static void setup_windows_event_source()
/**
Find a unique filename for 'filename.#'.
- Set '#' to a number as low as possible.
+ Set '#' to the number next to the maximum found in the most
+ recent log file extension.
+
+ This function will return nonzero if: (i) the generated name
+ exceeds FN_REFLEN; (ii) if the number of extensions is exhausted;
+ or (iii) some other error happened while examining the filesystem.
@return
- nonzero if not possible to get unique filename
+ nonzero if not possible to get unique filename.
*/
static int find_uniq_filename(char *name)
{
- long number;
uint i;
- char buff[FN_REFLEN];
+ char buff[FN_REFLEN], ext_buf[FN_REFLEN];
struct st_my_dir *dir_info;
reg1 struct fileinfo *file_info;
- ulong max_found=0;
+ ulong max_found= 0, next= 0, number= 0;
size_t buf_length, length;
char *start, *end;
+ int error= 0;
DBUG_ENTER("find_uniq_filename");
length= dirname_part(buff, name, &buf_length);
@@ -1875,15 +1909,15 @@ static int find_uniq_filename(char *name)
end= strend(start);
*end='.';
- length= (size_t) (end-start+1);
+ length= (size_t) (end - start + 1);
- if (!(dir_info = my_dir(buff,MYF(MY_DONT_SORT))))
+ if (!(dir_info= my_dir(buff,MYF(MY_DONT_SORT))))
{ // This shouldn't happen
strmov(end,".1"); // use name+1
- DBUG_RETURN(0);
+ DBUG_RETURN(1);
}
file_info= dir_info->dir_entry;
- for (i=dir_info->number_off_files ; i-- ; file_info++)
+ for (i= dir_info->number_off_files ; i-- ; file_info++)
{
if (bcmp((uchar*) file_info->name, (uchar*) start, length) == 0 &&
test_if_number(file_info->name+length, &number,0))
@@ -1893,9 +1927,44 @@ static int find_uniq_filename(char *name)
}
my_dirend(dir_info);
+ /* check if reached the maximum possible extension number */
+ if ((max_found == MAX_LOG_UNIQUE_FN_EXT))
+ {
+ sql_print_error("Log filename extension number exhausted: %06lu. \
+Please fix this by archiving old logs and \
+updating the index files.", max_found);
+ error= 1;
+ goto end;
+ }
+
+ next= max_found + 1;
+ sprintf(ext_buf, "%06lu", next);
*end++='.';
- sprintf(end,"%06ld",max_found+1);
- DBUG_RETURN(0);
+
+ /*
+ Check if the generated extension size + the file name exceeds the
+ buffer size used. If one did not check this, then the filename might be
+ truncated, resulting in error.
+ */
+ if (((strlen(ext_buf) + (end - name)) >= FN_REFLEN))
+ {
+ sql_print_error("Log filename too large: %s%s (%lu). \
+Please fix this by archiving old logs and updating the \
+index files.", name, ext_buf, (strlen(ext_buf) + (end - name)));
+ error= 1;
+ goto end;
+ }
+
+ sprintf(end, "%06lu", next);
+
+ /* print warning if reaching the end of available extensions. */
+ if ((next > (MAX_LOG_UNIQUE_FN_EXT - LOG_WARN_UNIQUE_FN_EXT_LEFT)))
+ sql_print_warning("Next log extension: %lu. \
+Remaining log filename extensions: %lu. \
+Please consider archiving some logs.", next, (MAX_LOG_UNIQUE_FN_EXT - next));
+
+end:
+ DBUG_RETURN(error);
}
@@ -2094,6 +2163,13 @@ int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name)
{
if (find_uniq_filename(new_name))
{
+ /*
+ This should be treated as error once propagation of error further
+ up in the stack gets proper handling.
+ */
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_NO_UNIQUE_LOGFILE, ER(ER_NO_UNIQUE_LOGFILE),
+ log_name);
sql_print_error(ER(ER_NO_UNIQUE_LOGFILE), log_name);
return 1;
}
@@ -2789,8 +2865,10 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO *linfo, const char *log_name,
{
uint length;
my_off_t offset= my_b_tell(&index_file);
- /* If we get 0 or 1 characters, this is the end of the file */
+ DBUG_EXECUTE_IF("simulate_find_log_pos_error",
+ error= LOG_INFO_EOF; break;);
+ /* If we get 0 or 1 characters, this is the end of the file */
if ((length= my_b_gets(&index_file, fname, FN_REFLEN)) <= 1)
{
/* Did not find the given entry; Return not found or error */
@@ -2892,6 +2970,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
{
LOG_INFO linfo;
bool error=0;
+ int err;
const char* save_name;
DBUG_ENTER("reset_logs");
@@ -2918,9 +2997,12 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
/* First delete all old log files */
- if (find_log_pos(&linfo, NullS, 0))
+ if ((err= find_log_pos(&linfo, NullS, 0)) != 0)
{
- error=1;
+ uint errcode= purge_log_get_error_code(err);
+ sql_print_error("Failed to locate old binlog or relay log files");
+ my_message(errcode, ER(errcode), MYF(0));
+ error= 1;
goto err;
}
@@ -2989,6 +3071,8 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
my_free((uchar*) save_name, MYF(0));
err:
+ if (error == 1)
+ name= const_cast<char*>(save_name);
pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_unlock(&LOCK_index);
pthread_mutex_unlock(&LOCK_log);
@@ -4812,11 +4896,11 @@ void MYSQL_BIN_LOG::set_max_size(ulong max_size_arg)
@retval
1 String is a number
@retval
- 0 Error
+ 0 String is not a number
*/
static bool test_if_number(register const char *str,
- long *res, bool allow_wildcards)
+ ulong *res, bool allow_wildcards)
{
reg2 int flag;
const char *start;
diff --git a/sql/log.h b/sql/log.h
index a31be6dcce6..9be86b797a7 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -121,6 +121,19 @@ extern TC_LOG_DUMMY tc_log_dummy;
#define LOG_CLOSE_TO_BE_OPENED 2
#define LOG_CLOSE_STOP_EVENT 4
+/*
+ Maximum unique log filename extension.
+ Note: setting to 0x7FFFFFFF due to atol windows
+ overflow/truncate.
+ */
+#define MAX_LOG_UNIQUE_FN_EXT 0x7FFFFFFF
+
+/*
+ Number of warnings that will be printed to error log
+ before extension number is exhausted.
+*/
+#define LOG_WARN_UNIQUE_FN_EXT_LEFT 1000
+
class Relay_log_info;
typedef struct st_log_info
@@ -611,5 +624,6 @@ enum enum_binlog_format {
extern TYPELIB binlog_format_typelib;
int query_error_code(THD *thd, bool not_killed);
+uint purge_log_get_error_code(int res);
#endif /* LOG_H */
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index dc3f59dfec0..38a55e9ec4c 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -53,6 +53,9 @@
#include "sql_array.h"
#include "sql_plugin.h"
#include "scheduler.h"
+#ifndef __WIN__
+#include <netdb.h>
+#endif
class Parser_state;
@@ -121,16 +124,35 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
#define all_bits_set(A,B) ((A) & (B) != (B))
-#define WARN_DEPRECATED(Thd,Ver,Old,New) \
- do { \
- DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \
- if (((uchar*)Thd) != NULL) \
- push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
- ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \
- (Old), (Ver), (New)); \
- else \
- sql_print_warning("The syntax '%s' is deprecated and will be removed " \
- "in MySQL %s. Please use %s instead.", (Old), (Ver), (New)); \
+/*
+ Generates a warning that a feature is deprecated. After a specified
+ version asserts that the feature is removed.
+
+ Using it as
+
+ WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
+
+ Will result in a warning
+
+ "The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
+ use 'GOOD' instead"
+
+ Note that in macro arguments BAD is not quoted, while 'GOOD' is.
+ Note that the version is TWO numbers, separated with a comma
+ (two macro arguments, that is)
+*/
+#define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New) \
+ do { \
+ compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100); \
+ if (((THD *) Thd) != NULL) \
+ push_warning_printf(((THD *) Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
+ ER_WARN_DEPRECATED_SYNTAX, \
+ ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \
+ (Old), #VerHi "." #VerLo, (New)); \
+ else \
+ sql_print_warning("The syntax '%s' is deprecated and will be removed " \
+ "in MySQL %s. Please use %s instead.", \
+ (Old), #VerHi "." #VerLo, (New)); \
} while(0)
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
@@ -2228,10 +2250,11 @@ uint build_table_shadow_filename(char *buff, size_t bufflen,
#define FRM_ONLY (1 << 3)
/* from hostname.cc */
-struct in_addr;
-char * ip_to_hostname(struct in_addr *in,uint *errors);
-void inc_host_errors(struct in_addr *in);
-void reset_host_errors(struct in_addr *in);
+bool ip_to_hostname(struct sockaddr_storage *ip_storage,
+ const char *ip_string,
+ char **hostname, uint *connect_errors);
+void inc_host_errors(const char *ip_string);
+void reset_host_errors(const char *ip_string);
bool hostname_cache_init();
void hostname_cache_free();
void hostname_cache_refresh(void);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 90924b5b662..ee341314cd6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -106,7 +106,6 @@ extern "C" { // Because of SCO 3.2V4.2
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
-#include <netdb.h>
#ifdef HAVE_SELECT_H
# include <select.h>
#endif
@@ -176,7 +175,7 @@ static void registerwithneb();
static void getvolumename();
static void getvolumeID(BYTE *volumeName);
#endif /* __NETWARE__ */
-
+
#ifdef _AIX41
int initgroups(const char *,unsigned int);
@@ -390,7 +389,6 @@ static my_bool opt_short_log_format= 0;
static uint kill_cached_threads, wake_thread;
static ulong killed_threads, thread_created;
static ulong max_used_connections;
-static ulong my_bind_addr; /**< the address we bind to */
static volatile ulong cached_thread_count= 0;
static const char *sql_mode_str= "OFF";
/* Text representation for OPTIMIZER_SWITCH_DEFAULT */
@@ -458,7 +456,6 @@ my_bool opt_local_infile, opt_slave_compressed_protocol;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0;
-bool slave_warning_issued = false;
/*
Legacy global handlerton. These will be removed (please do not add more).
@@ -682,15 +679,11 @@ int mysqld_server_started= 0;
File_parser_dummy_hook file_parser_dummy_hook;
/* replication parameters, if master_host is not NULL, we are a slave */
-uint master_port= MYSQL_PORT, master_connect_retry = 60;
uint report_port= MYSQL_PORT;
ulong master_retry_count=0;
-char *master_user, *master_password, *master_host, *master_info_file;
+char *master_info_file;
char *relay_log_info_file, *report_user, *report_password, *report_host;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
-my_bool master_ssl;
-char *master_ssl_key, *master_ssl_cert;
-char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
char *opt_logname, *opt_slow_logname;
/* Static variables */
@@ -1635,17 +1628,18 @@ static void set_root(const char *path)
#endif
}
+
static void network_init(void)
{
- struct sockaddr_in IPaddr;
#ifdef HAVE_SYS_UN_H
struct sockaddr_un UNIXaddr;
#endif
- int arg=1;
+ int arg;
int ret;
uint waited;
uint this_wait;
uint retry;
+ char port_buf[NI_MAXSERV];
DBUG_ENTER("network_init");
LINT_INIT(ret);
@@ -1656,26 +1650,65 @@ static void network_init(void)
if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
{
+ struct addrinfo *ai, *a;
+ struct addrinfo hints;
+ int error;
DBUG_PRINT("general",("IP Socket is %d",mysqld_port));
- ip_sock = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&hints, sizeof (hints));
+ hints.ai_flags= AI_PASSIVE;
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_family= AF_UNSPEC;
+
+ my_snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
+ error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
+ if (error != 0)
+ {
+ DBUG_PRINT("error",("Got error: %d from getaddrinfo()", error));
+ sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
+ unireg_abort(1); /* purecov: tested */
+ }
+
+ for (a= ai; a != NULL; a= a->ai_next)
+ {
+ ip_sock= socket(a->ai_family, a->ai_socktype, a->ai_protocol);
+ if (ip_sock != INVALID_SOCKET)
+ break;
+ }
+
if (ip_sock == INVALID_SOCKET)
{
DBUG_PRINT("error",("Got error: %d from socket()",socket_errno));
- sql_perror(ER(ER_IPSOCK_ERROR)); /* purecov: tested */
+ sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
unireg_abort(1); /* purecov: tested */
}
- bzero((char*) &IPaddr, sizeof(IPaddr));
- IPaddr.sin_family = AF_INET;
- IPaddr.sin_addr.s_addr = my_bind_addr;
- IPaddr.sin_port = (unsigned short) htons((unsigned short) mysqld_port);
#ifndef __WIN__
/*
We should not use SO_REUSEADDR on windows as this would enable a
user to open two mysqld servers with the same TCP/IP port.
*/
+ arg= 1;
(void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg));
#endif /* __WIN__ */
+
+#ifdef IPV6_V6ONLY
+ /*
+ For interoperability with older clients, IPv6 socket should
+ listen on both IPv6 and IPv4 wildcard addresses.
+ Turn off IPV6_V6ONLY option.
+
+ NOTE: this will work starting from Windows Vista only.
+ On Windows XP dual stack is not available, so it will not
+ listen on the corresponding IPv4-address.
+ */
+ if (a->ai_family == AF_INET6)
+ {
+ arg= 0;
+ (void) setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
+ sizeof(arg));
+ }
+#endif
/*
Sometimes the port is not released fast enough when stopping and
restarting the server. This happens quite often with the test suite
@@ -1686,8 +1719,7 @@ static void network_init(void)
*/
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
{
- if (((ret= bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr),
- sizeof(IPaddr))) >= 0) ||
+ if (((ret= bind(ip_sock, a->ai_addr, a->ai_addrlen)) >= 0 ) ||
(socket_errno != SOCKET_EADDRINUSE) ||
(waited >= mysqld_port_timeout))
break;
@@ -1695,6 +1727,7 @@ static void network_init(void)
this_wait= retry * retry / 3 + 1;
sleep(this_wait);
}
+ freeaddrinfo(ai);
if (ret < 0)
{
DBUG_PRINT("error",("Got error: %d from bind",socket_errno));
@@ -1716,7 +1749,6 @@ static void network_init(void)
if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap &&
opt_enable_named_pipe)
{
-
strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\",
mysqld_unix_port, NullS);
bzero((char*) &saPipeSecurity, sizeof(saPipeSecurity));
@@ -1782,6 +1814,7 @@ static void network_init(void)
UNIXaddr.sun_family = AF_UNIX;
strmov(UNIXaddr.sun_path, mysqld_unix_port);
(void) unlink(mysqld_unix_port);
+ arg= 1;
(void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,
sizeof(arg));
umask(0);
@@ -2995,7 +3028,6 @@ SHOW_VAR com_status_vars[]= {
{"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
{"alter_tablespace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLESPACE]), SHOW_LONG_STATUS},
{"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
- {"backup_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BACKUP_TABLE]), SHOW_LONG_STATUS},
{"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
{"binlog", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS},
{"call_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CALL]), SHOW_LONG_STATUS},
@@ -3042,8 +3074,6 @@ SHOW_VAR com_status_vars[]= {
{"install_plugin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_INSTALL_PLUGIN]), SHOW_LONG_STATUS},
{"kill", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_KILL]), SHOW_LONG_STATUS},
{"load", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD]), SHOW_LONG_STATUS},
- {"load_master_data", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD_MASTER_DATA]), SHOW_LONG_STATUS},
- {"load_master_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOAD_MASTER_TABLE]), SHOW_LONG_STATUS},
{"lock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS},
{"optimize", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS},
{"preload_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PRELOAD_KEYS]), SHOW_LONG_STATUS},
@@ -3058,7 +3088,6 @@ SHOW_VAR com_status_vars[]= {
{"replace_select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
{"reset", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESET]), SHOW_LONG_STATUS},
{"resignal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESIGNAL]), SHOW_LONG_STATUS},
- {"restore_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RESTORE_TABLE]), SHOW_LONG_STATUS},
{"revoke", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE]), SHOW_LONG_STATUS},
{"revoke_all", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_REVOKE_ALL]), SHOW_LONG_STATUS},
{"rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
@@ -4402,21 +4431,12 @@ int main(int argc, char **argv)
if (opt_bin_log && !server_id)
{
- server_id= !master_host ? 1 : 2;
+ server_id= 1;
#ifdef EXTRA_DEBUG
- switch (server_id) {
- case 1:
- sql_print_warning("\
-You have enabled the binary log, but you haven't set server-id to \
-a non-zero value: we force server id to 1; updates will be logged to the \
-binary log, but connections from slaves will not be accepted.");
- break;
- case 2:
- sql_print_warning("\
-You should set server-id to a non-0 value if master_host is set; \
-we force server id to 2, but this MySQL server will not act as a slave.");
- break;
- }
+ sql_print_warning("You have enabled the binary log, but you haven't set "
+ "server-id to a non-zero value: we force server id to 1; "
+ "updates will be logged to the binary log, but "
+ "connections from slaves will not be accepted.");
#endif
}
@@ -4851,7 +4871,7 @@ static bool read_init_file(char *file_name)
When we enter this function, LOCK_thread_count is hold!
*/
-
+
void handle_connection_in_main_thread(THD *thd)
{
safe_mutex_assert_owner(&LOCK_thread_count);
@@ -4934,7 +4954,6 @@ void create_thread_to_handle_connection(THD *thd)
static void create_new_thread(THD *thd)
{
- NET *net=&thd->net;
DBUG_ENTER("create_new_thread");
/*
@@ -5004,6 +5023,7 @@ inline void kill_broken_server()
/* Handle new connections and spawn new process to handle them */
#ifndef EMBEDDED_LIBRARY
+
void handle_connections_sockets()
{
my_socket sock,new_sock;
@@ -5011,7 +5031,7 @@ void handle_connections_sockets()
uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
fd_set readFDs,clientFDs;
THD *thd;
- struct sockaddr_in cAddr;
+ struct sockaddr_storage cAddr;
int ip_flags=0,socket_flags=0,flags;
st_vio *vio_tmp;
DBUG_ENTER("handle_connections_sockets");
@@ -5085,9 +5105,9 @@ void handle_connections_sockets()
#endif /* NO_FCNTL_NONBLOCK */
for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
{
- size_socket length=sizeof(struct sockaddr_in);
- new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr),
- &length);
+ size_socket length= sizeof(struct sockaddr_storage);
+ new_sock= accept(sock, (struct sockaddr *)(&cAddr),
+ &length);
#ifdef __NETWARE__
// TODO: temporary fix, waiting for TCP/IP fix - DEFECT000303149
if ((new_sock == INVALID_SOCKET) && (socket_errno == EINVAL))
@@ -5158,9 +5178,10 @@ void handle_connections_sockets()
{
size_socket dummyLen;
- struct sockaddr dummy;
- dummyLen = sizeof(struct sockaddr);
- if (getsockname(new_sock,&dummy, &dummyLen) < 0)
+ struct sockaddr_storage dummy;
+ dummyLen = sizeof(dummy);
+ if ( getsockname(new_sock,(struct sockaddr *)&dummy,
+ (SOCKET_SIZE_TYPE *)&dummyLen) < 0 )
{
sql_perror("Error on new connection socket");
(void) shutdown(new_sock, SHUT_RDWR);
@@ -5506,7 +5527,7 @@ errorconn:
NullS);
sql_perror(buff);
}
- if (handle_client_file_map)
+ if (handle_client_file_map)
CloseHandle(handle_client_file_map);
if (handle_client_map)
UnmapViewOfFile(handle_client_map);
@@ -5570,13 +5591,8 @@ enum options_mysqld
OPT_STORAGE_ENGINE, OPT_INIT_FILE,
OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG,
OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR,
- OPT_MASTER_HOST, OPT_MASTER_USER,
- OPT_MASTER_PASSWORD, OPT_MASTER_PORT,
- OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY,
+ OPT_MASTER_INFO_FILE,
OPT_MASTER_RETRY_COUNT, OPT_LOG_TC, OPT_LOG_TC_SIZE,
- OPT_MASTER_SSL, OPT_MASTER_SSL_KEY,
- OPT_MASTER_SSL_CERT, OPT_MASTER_SSL_CAPATH,
- OPT_MASTER_SSL_CIPHER, OPT_MASTER_SSL_CA,
OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB,
OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES,
OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB,
@@ -6084,60 +6100,15 @@ log and this option justs turns on --log-bin instead.",
(uchar**) &global_system_variables.low_priority_updates,
(uchar**) &max_system_variables.low_priority_updates,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"master-connect-retry", OPT_MASTER_CONNECT_RETRY,
- "The number of seconds the slave thread will sleep before retrying to connect to the master in case the master goes down or the connection is lost.",
- (uchar**) &master_connect_retry, (uchar**) &master_connect_retry, 0, GET_UINT,
- REQUIRED_ARG, 60, 0, 0, 0, 0, 0},
- {"master-host", OPT_MASTER_HOST,
- "Master hostname or IP address for replication. If not set, the slave thread will not be started. Note that the setting of master-host will be ignored if there exists a valid master.info file.",
- (uchar**) &master_host, (uchar**) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
- 0, 0, 0, 0},
{"master-info-file", OPT_MASTER_INFO_FILE,
"The location and name of the file that remembers the master and where the I/O replication \
thread is in the master's binlogs.",
(uchar**) &master_info_file, (uchar**) &master_info_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"master-password", OPT_MASTER_PASSWORD,
- "The password the slave thread will authenticate with when connecting to the master. If not set, an empty password is assumed.The value in master.info will take precedence if it can be read.",
- (uchar**)&master_password, (uchar**)&master_password, 0,
- GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"master-port", OPT_MASTER_PORT,
- "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT is assumed. If you have not tinkered with configure options, this should be 3306. The value in master.info will take precedence if it can be read.",
- (uchar**) &master_port, (uchar**) &master_port, 0, GET_UINT, REQUIRED_ARG,
- MYSQL_PORT, 0, 0, 0, 0, 0},
{"master-retry-count", OPT_MASTER_RETRY_COUNT,
"The number of tries the slave will make to connect to the master before giving up.",
(uchar**) &master_retry_count, (uchar**) &master_retry_count, 0, GET_ULONG,
REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
- {"master-ssl", OPT_MASTER_SSL,
- "Enable the slave to connect to the master using SSL.",
- (uchar**) &master_ssl, (uchar**) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
- 0, 0},
- {"master-ssl-ca", OPT_MASTER_SSL_CA,
- "Master SSL CA file. Only applies if you have enabled master-ssl.",
- (uchar**) &master_ssl_ca, (uchar**) &master_ssl_ca, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"master-ssl-capath", OPT_MASTER_SSL_CAPATH,
- "Master SSL CA path. Only applies if you have enabled master-ssl.",
- (uchar**) &master_ssl_capath, (uchar**) &master_ssl_capath, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"master-ssl-cert", OPT_MASTER_SSL_CERT,
- "Master SSL certificate file name. Only applies if you have enabled \
-master-ssl",
- (uchar**) &master_ssl_cert, (uchar**) &master_ssl_cert, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER,
- "Master SSL cipher. Only applies if you have enabled master-ssl.",
- (uchar**) &master_ssl_cipher, (uchar**) &master_ssl_capath, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"master-ssl-key", OPT_MASTER_SSL_KEY,
- "Master SSL keyfile name. Only applies if you have enabled master-ssl.",
- (uchar**) &master_ssl_key, (uchar**) &master_ssl_key, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"master-user", OPT_MASTER_USER,
- "The username the slave thread will use for authentication when connecting to the master. The user must have FILE privilege. If the master user is not set, user test is assumed. The value in master.info will take precedence if it can be read.",
- (uchar**) &master_user, (uchar**) &master_user, 0, GET_STR, REQUIRED_ARG, 0, 0,
- 0, 0, 0, 0},
#ifdef HAVE_REPLICATION
{"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS,
"Option used by mysql-test for debugging and testing of replication.",
@@ -7787,7 +7758,6 @@ static int mysql_init_variables(void)
strmov(server_version, MYSQL_SERVER_VERSION);
myisam_recover_options_str= sql_mode_str= "OFF";
myisam_stats_method_str= "nulls_unequal";
- my_bind_addr = htonl(INADDR_ANY);
threads.empty();
thread_cache.empty();
key_caches.empty();
@@ -7808,12 +7778,8 @@ static int mysql_init_variables(void)
mysql_data_home_len= 2;
/* Replication parameters */
- master_user= (char*) "test";
- master_password= master_host= 0;
master_info_file= (char*) "master.info",
relay_log_info_file= (char*) "relay-log.info";
- master_ssl_key= master_ssl_cert= master_ssl_ca=
- master_ssl_capath= master_ssl_cipher= 0;
report_user= report_password = report_host= 0; /* TO BE DELETED */
opt_relay_logname= opt_relaylog_index_name= 0;
@@ -7967,7 +7933,7 @@ mysqld_get_one_option(int optid,
default_collation_name= 0;
break;
case 'l':
- WARN_DEPRECATED(NULL, "7.0", "--log", "'--general-log'/'--general-log-file'");
+ WARN_DEPRECATED(NULL, 7, 0, "--log", "'--general-log'/'--general-log-file'");
opt_log=1;
break;
case 'h':
@@ -8141,8 +8107,7 @@ mysqld_get_one_option(int optid,
}
#endif /* HAVE_REPLICATION */
case (int) OPT_SLOW_QUERY_LOG:
- WARN_DEPRECATED(NULL, "7.0", "--log-slow-queries",
- "'--slow-query-log'/'--slow-query-log-file'");
+ WARN_DEPRECATED(NULL, 7, 0, "--log-slow-queries", "'--slow-query-log'/'--slow-query-log-file'");
opt_slow_log= 1;
break;
#ifdef WITH_CSV_STORAGE_ENGINE
@@ -8227,27 +8192,25 @@ mysqld_get_one_option(int optid,
my_use_symdir=0;
break;
case (int) OPT_BIND_ADDRESS:
- if ((my_bind_addr= (ulong) inet_addr(argument)) == INADDR_NONE)
{
- struct hostent *ent;
- if (argument[0])
- ent=gethostbyname(argument);
- else
+ struct addrinfo *res_lst, hints;
+
+ bzero(&hints, sizeof(struct addrinfo));
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_protocol= IPPROTO_TCP;
+
+ if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
{
- char myhostname[255];
- if (gethostname(myhostname,sizeof(myhostname)) < 0)
- {
- sql_perror("Can't start server: cannot get my own hostname!");
- return 1;
- }
- ent=gethostbyname(myhostname);
+ sql_print_error("Can't start server: cannot resolve hostname!");
+ return 1;
}
- if (!ent)
+
+ if (res_lst->ai_next)
{
- sql_perror("Can't start server: cannot resolve hostname!");
+ sql_print_error("Can't start server: bind-address refers to multiple interfaces!");
return 1;
}
- my_bind_addr = (ulong) ((in_addr*)ent->h_addr_list[0])->s_addr;
+ freeaddrinfo(res_lst);
}
break;
case (int) OPT_PID_FILE:
@@ -8257,29 +8220,6 @@ mysqld_get_one_option(int optid,
case (int) OPT_STANDALONE: /* Dummy option for NT */
break;
#endif
- /*
- The following change issues a deprecation warning if the slave
- configuration is specified either in the my.cnf file or on
- the command-line. See BUG#21490.
- */
- case OPT_MASTER_HOST:
- case OPT_MASTER_USER:
- case OPT_MASTER_PASSWORD:
- case OPT_MASTER_PORT:
- case OPT_MASTER_CONNECT_RETRY:
- case OPT_MASTER_SSL:
- case OPT_MASTER_SSL_KEY:
- case OPT_MASTER_SSL_CERT:
- case OPT_MASTER_SSL_CAPATH:
- case OPT_MASTER_SSL_CIPHER:
- case OPT_MASTER_SSL_CA:
- if (!slave_warning_issued) //only show the warning once
- {
- slave_warning_issued = true;
- WARN_DEPRECATED(NULL, "6.0", "for replication startup options",
- "'CHANGE MASTER'");
- }
- break;
case OPT_CONSOLE:
if (opt_console)
opt_error_log= 0; // Force logs to stdout
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index c6c7f185080..e3893ce2500 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -183,12 +183,11 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
get_object(p,si->host, "Failed to register slave: too long 'report-host'");
get_object(p,si->user, "Failed to register slave: too long 'report-user'");
get_object(p,si->password, "Failed to register slave; too long 'report-password'");
- if (p+10 > p_end)
+ /*6 is the total length of port and master_id*/
+ if (p+6 != p_end)
goto err;
si->port= uint2korr(p);
p += 2;
- si->rpl_recovery_rank= uint4korr(p);
- p += 4;
if (!(si->master_id= uint4korr(p)))
si->master_id= server_id;
si->thd= thd;
@@ -672,8 +671,6 @@ bool show_slave_hosts(THD* thd)
field_list.push_back(new Item_empty_string("Password",20));
}
field_list.push_back(new Item_return_int("Port", 7, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("Rpl_recovery_rank", 7,
- MYSQL_TYPE_LONG));
field_list.push_back(new Item_return_int("Master_id", 10,
MYSQL_TYPE_LONG));
@@ -695,7 +692,6 @@ bool show_slave_hosts(THD* thd)
protocol->store(si->password, &my_charset_bin);
}
protocol->store((uint32) si->port);
- protocol->store((uint32) si->rpl_recovery_rank);
protocol->store((uint32) si->master_id);
if (protocol->write())
{
@@ -708,329 +704,5 @@ bool show_slave_hosts(THD* thd)
DBUG_RETURN(FALSE);
}
-
-int connect_to_master(THD *thd, MYSQL* mysql, Master_info* mi)
-{
- DBUG_ENTER("connect_to_master");
-
- if (!mi->host || !*mi->host) /* empty host */
- {
- strmov(mysql->net.last_error, "Master is not configured");
- DBUG_RETURN(1);
- }
- mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
- mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
-
-#ifdef HAVE_OPENSSL
- if (mi->ssl)
- {
- mysql_ssl_set(mysql,
- mi->ssl_key[0]?mi->ssl_key:0,
- mi->ssl_cert[0]?mi->ssl_cert:0,
- mi->ssl_ca[0]?mi->ssl_ca:0,
- mi->ssl_capath[0]?mi->ssl_capath:0,
- mi->ssl_cipher[0]?mi->ssl_cipher:0);
- mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
- &mi->ssl_verify_server_cert);
- }
-#endif
-
- mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
- mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
- if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
- mi->port, 0, 0))
- DBUG_RETURN(1);
- mysql->reconnect= 1;
- DBUG_RETURN(0);
-}
-
-
-static inline void cleanup_mysql_results(MYSQL_RES* db_res,
- MYSQL_RES** cur, MYSQL_RES** start)
-{
- for (; cur >= start; --cur)
- {
- if (*cur)
- mysql_free_result(*cur);
- }
- mysql_free_result(db_res);
-}
-
-
-static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
- MYSQL_RES *table_res, Master_info *mi)
-{
- MYSQL_ROW row;
- for (row = mysql_fetch_row(table_res); row;
- row = mysql_fetch_row(table_res))
- {
- TABLE_LIST table;
- const char* table_name= row[0];
- int error;
- if (rpl_filter->is_on())
- {
- bzero((char*) &table, sizeof(table)); //just for safe
- table.db= (char*) db;
- table.table_name= (char*) table_name;
- table.updating= 1;
-
- if (!rpl_filter->tables_ok(thd->db, &table))
- continue;
- }
- /* download master's table and overwrite slave's table */
- if ((error= fetch_master_table(thd, db, table_name, mi, mysql, 1)))
- return error;
- }
- return 0;
-}
-
-/**
- Load all MyISAM tables from master to this slave.
-
- REQUIREMENTS
- - No active transaction (flush_relay_log_info would not work in this case).
-
- @todo
- - add special option, not enabled
- by default, to allow inclusion of mysql database into load
- data from master
-*/
-
-bool load_master_data(THD* thd)
-{
- MYSQL mysql;
- MYSQL_RES* master_status_res = 0;
- int error = 0;
- const char* errmsg=0;
- int restart_thread_mask;
- HA_CREATE_INFO create_info;
-
- mysql_init(&mysql);
-
- /*
- We do not want anyone messing with the slave at all for the entire
- duration of the data load.
- */
- pthread_mutex_lock(&LOCK_active_mi);
- lock_slave_threads(active_mi);
- init_thread_mask(&restart_thread_mask,active_mi,0 /*not inverse*/);
- if (restart_thread_mask &&
- (error=terminate_slave_threads(active_mi,restart_thread_mask,
- 1 /*skip lock*/)))
- {
- my_message(error, ER(error), MYF(0));
- unlock_slave_threads(active_mi);
- pthread_mutex_unlock(&LOCK_active_mi);
- return TRUE;
- }
-
- if (connect_to_master(thd, &mysql, active_mi))
- {
- my_error(error= ER_CONNECT_TO_MASTER, MYF(0), mysql_error(&mysql));
- goto err;
- }
-
- // now that we are connected, get all database and tables in each
- {
- MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res;
- uint num_dbs;
-
- if (mysql_real_query(&mysql, STRING_WITH_LEN("SHOW DATABASES")) ||
- !(db_res = mysql_store_result(&mysql)))
- {
- my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
- goto err;
- }
-
- if (!(num_dbs = (uint) mysql_num_rows(db_res)))
- goto err;
- /*
- In theory, the master could have no databases at all
- and run with skip-grant
- */
-
- if (!(table_res = (MYSQL_RES**)thd->alloc(num_dbs * sizeof(MYSQL_RES*))))
- {
- my_message(error = ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0));
- goto err;
- }
-
- /*
- This is a temporary solution until we have online backup
- capabilities - to be replaced once online backup is working
- we wait to issue FLUSH TABLES WITH READ LOCK for as long as we
- can to minimize the lock time.
- */
- if (mysql_real_query(&mysql,
- STRING_WITH_LEN("FLUSH TABLES WITH READ LOCK")) ||
- mysql_real_query(&mysql, STRING_WITH_LEN("SHOW MASTER STATUS")) ||
- !(master_status_res = mysql_store_result(&mysql)))
- {
- my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
- goto err;
- }
-
- /*
- Go through every table in every database, and if the replication
- rules allow replicating it, get it
- */
-
- table_res_end = table_res + num_dbs;
-
- for (cur_table_res = table_res; cur_table_res < table_res_end;
- cur_table_res++)
- {
- // since we know how many rows we have, this can never be NULL
- MYSQL_ROW row = mysql_fetch_row(db_res);
- char* db = row[0];
-
- /*
- Do not replicate databases excluded by rules. We also test
- replicate_wild_*_table rules (replicate_wild_ignore_table='db1.%' will
- be considered as "ignore the 'db1' database as a whole, as it already
- works for CREATE DATABASE and DROP DATABASE).
- Also skip 'mysql' database - in most cases the user will
- mess up and not exclude mysql database with the rules when
- he actually means to - in this case, he is up for a surprise if
- his priv tables get dropped and downloaded from master
- TODO - add special option, not enabled
- by default, to allow inclusion of mysql database into load
- data from master
- */
-
- if (!rpl_filter->db_ok(db) ||
- !rpl_filter->db_ok_with_wild_table(db) ||
- !strcmp(db,"mysql") ||
- is_schema_db(db))
- {
- *cur_table_res = 0;
- continue;
- }
-
- bzero((char*) &create_info, sizeof(create_info));
- create_info.options= HA_LEX_CREATE_IF_NOT_EXISTS;
-
- if (mysql_create_db(thd, db, &create_info, 1))
- {
- cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
- goto err;
- }
- /* Clear the result of mysql_create_db(). */
- thd->stmt_da->reset_diagnostics_area();
-
- if (mysql_select_db(&mysql, db) ||
- mysql_real_query(&mysql, STRING_WITH_LEN("SHOW TABLES")) ||
- !(*cur_table_res = mysql_store_result(&mysql)))
- {
- my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
- cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
- goto err;
- }
-
- if ((error = fetch_db_tables(thd,&mysql,db,*cur_table_res,active_mi)))
- {
- // we do not report the error - fetch_db_tables handles it
- cleanup_mysql_results(db_res, cur_table_res, table_res);
- goto err;
- }
- }
-
- cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
-
- // adjust replication coordinates from the master
- if (master_status_res)
- {
- MYSQL_ROW row = mysql_fetch_row(master_status_res);
-
- /*
- We need this check because the master may not be running with
- log-bin, but it will still allow us to do all the steps
- of LOAD DATA FROM MASTER - no reason to forbid it, really,
- although it does not make much sense for the user to do it
- */
- if (row && row[0] && row[1])
- {
- /*
- If the slave's master info is not inited, we init it, then we write
- the new coordinates to it. Must call init_master_info() *before*
- setting active_mi, because init_master_info() sets active_mi with
- defaults.
- */
- int error_2;
-
- if (init_master_info(active_mi, master_info_file, relay_log_info_file,
- 0, (SLAVE_IO | SLAVE_SQL)))
- my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
- strmake(active_mi->master_log_name, row[0],
- sizeof(active_mi->master_log_name) -1);
- active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error_2);
- /* at least in recent versions, the condition below should be false */
- if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE)
- active_mi->master_log_pos = BIN_LOG_HEADER_SIZE;
- /*
- Relay log's IO_CACHE may not be inited (even if we are sure that some
- host was specified; there could have been a problem when replication
- started, which led to relay log's IO_CACHE to not be inited.
- */
- if (flush_master_info(active_mi, 0))
- sql_print_error("Failed to flush master info file");
- }
- mysql_free_result(master_status_res);
- }
-
- if (mysql_real_query(&mysql, STRING_WITH_LEN("UNLOCK TABLES")))
- {
- my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
- goto err;
- }
- }
- thd_proc_info(thd, "purging old relay logs");
- if (purge_relay_logs(&active_mi->rli,thd,
- 0 /* not only reset, but also reinit */,
- &errmsg))
- {
- my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg);
- unlock_slave_threads(active_mi);
- pthread_mutex_unlock(&LOCK_active_mi);
- return TRUE;
- }
- pthread_mutex_lock(&active_mi->rli.data_lock);
- active_mi->rli.group_master_log_pos = active_mi->master_log_pos;
- strmake(active_mi->rli.group_master_log_name,active_mi->master_log_name,
- sizeof(active_mi->rli.group_master_log_name)-1);
- /*
- Cancel the previous START SLAVE UNTIL, as the fact to download
- a new copy logically makes UNTIL irrelevant.
- */
- active_mi->rli.clear_until_condition();
-
- /*
- No need to update rli.event* coordinates, they will be when the slave
- threads start ; only rli.group* coordinates are necessary here.
- */
- flush_relay_log_info(&active_mi->rli);
- pthread_cond_broadcast(&active_mi->rli.data_cond);
- pthread_mutex_unlock(&active_mi->rli.data_lock);
- thd_proc_info(thd, "starting slave");
- if (restart_thread_mask)
- {
- error=start_slave_threads(0 /* mutex not needed */,
- 1 /* wait for start */,
- active_mi,master_info_file,relay_log_info_file,
- restart_thread_mask);
- }
-
-err:
- unlock_slave_threads(active_mi);
- pthread_mutex_unlock(&LOCK_active_mi);
- thd_proc_info(thd, 0);
-
- mysql_close(&mysql); // safe to call since we always do mysql_init()
- if (!error)
- my_ok(thd);
-
- return error;
-}
-
#endif /* HAVE_REPLICATION */
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index e83e0ad0ba9..4f8c3f50ded 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -21,6 +21,7 @@
#ifdef HAVE_REPLICATION
+#define DEFAULT_CONNECT_RETRY 60
// Defined in slave.cc
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
@@ -31,9 +32,10 @@ int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f);
Master_info::Master_info(bool is_slave_recovery)
:Slave_reporting_capability("I/O"),
- ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),
- rli(is_slave_recovery), abort_slave(0), slave_running(0),
- slave_run_id(0), sync_counter(0),
+ ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0),
+ port(MYSQL_PORT), connect_retry(DEFAULT_CONNECT_RETRY), inited(0),
+ rli(is_slave_recovery), abort_slave(0),
+ slave_running(0), slave_run_id(0), sync_counter(0),
heartbeat_period(0), received_heartbeats(0), master_id(0)
{
host[0] = 0; user[0] = 0; password[0] = 0;
@@ -97,33 +99,13 @@ bool Master_info::shall_ignore_server_id(ulong s_id)
!= NULL;
}
-void init_master_info_with_options(Master_info* mi)
+void init_master_log_pos(Master_info* mi)
{
- DBUG_ENTER("init_master_info_with_options");
+ DBUG_ENTER("init_master_log_pos");
mi->master_log_name[0] = 0;
mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number
- if (master_host)
- strmake(mi->host, master_host, sizeof(mi->host) - 1);
- if (master_user)
- strmake(mi->user, master_user, sizeof(mi->user) - 1);
- if (master_password)
- strmake(mi->password, master_password, MAX_PASSWORD_LENGTH);
- mi->port = master_port;
- mi->connect_retry = master_connect_retry;
-
- mi->ssl= master_ssl;
- if (master_ssl_ca)
- strmake(mi->ssl_ca, master_ssl_ca, sizeof(mi->ssl_ca)-1);
- if (master_ssl_capath)
- strmake(mi->ssl_capath, master_ssl_capath, sizeof(mi->ssl_capath)-1);
- if (master_ssl_cert)
- strmake(mi->ssl_cert, master_ssl_cert, sizeof(mi->ssl_cert)-1);
- if (master_ssl_cipher)
- strmake(mi->ssl_cipher, master_ssl_cipher, sizeof(mi->ssl_cipher)-1);
- if (master_ssl_key)
- strmake(mi->ssl_key, master_ssl_key, sizeof(mi->ssl_key)-1);
/* Intentionally init ssl_verify_server_cert to 0, no option available */
mi->ssl_verify_server_cert= 0;
/*
@@ -226,7 +208,7 @@ file '%s')", fname);
}
mi->fd = fd;
- init_master_info_with_options(mi);
+ init_master_log_pos(mi);
}
else // file exists
@@ -299,36 +281,34 @@ file '%s')", fname);
lines= 7;
if (init_intvar_from_file(&master_log_pos, &mi->file, 4) ||
- init_strvar_from_file(mi->host, sizeof(mi->host), &mi->file,
- master_host) ||
- init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file,
- master_user) ||
+ init_strvar_from_file(mi->host, sizeof(mi->host), &mi->file, 0) ||
+ init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file, "test") ||
init_strvar_from_file(mi->password, SCRAMBLED_PASSWORD_CHAR_LENGTH+1,
- &mi->file, master_password) ||
- init_intvar_from_file(&port, &mi->file, master_port) ||
+ &mi->file, 0) ||
+ init_intvar_from_file(&port, &mi->file, MYSQL_PORT) ||
init_intvar_from_file(&connect_retry, &mi->file,
- master_connect_retry))
+ DEFAULT_CONNECT_RETRY))
goto errwithmsg;
/*
If file has ssl part use it even if we have server without
- SSL support. But these option will be ignored later when
+ SSL support. But these options will be ignored later when
slave will try connect to master, so in this case warning
is printed.
*/
if (lines >= LINES_IN_MASTER_INFO_WITH_SSL)
{
- if (init_intvar_from_file(&ssl, &mi->file, master_ssl) ||
+ if (init_intvar_from_file(&ssl, &mi->file, 0) ||
init_strvar_from_file(mi->ssl_ca, sizeof(mi->ssl_ca),
- &mi->file, master_ssl_ca) ||
+ &mi->file, 0) ||
init_strvar_from_file(mi->ssl_capath, sizeof(mi->ssl_capath),
- &mi->file, master_ssl_capath) ||
+ &mi->file, 0) ||
init_strvar_from_file(mi->ssl_cert, sizeof(mi->ssl_cert),
- &mi->file, master_ssl_cert) ||
+ &mi->file, 0) ||
init_strvar_from_file(mi->ssl_cipher, sizeof(mi->ssl_cipher),
- &mi->file, master_ssl_cipher) ||
+ &mi->file, 0) ||
init_strvar_from_file(mi->ssl_key, sizeof(mi->ssl_key),
- &mi->file, master_ssl_key))
+ &mi->file, 0))
goto errwithmsg;
/*
@@ -360,8 +340,8 @@ file '%s')", fname);
#ifndef HAVE_OPENSSL
if (ssl)
sql_print_warning("SSL information in the master info file "
- "('%s') are ignored because this MySQL slave was compiled "
- "without SSL support.", fname);
+ "('%s') are ignored because this MySQL slave was "
+ "compiled without SSL support.", fname);
#endif /* HAVE_OPENSSL */
/*
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index f822a6bc1b1..6e4e2f9cdc7 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -113,8 +113,7 @@ class Master_info : public Slave_reporting_capability
DYNAMIC_ARRAY ignore_server_ids;
ulong master_id;
};
-
-void init_master_info_with_options(Master_info* mi);
+void init_master_log_pos(Master_info* mi);
int init_master_info(Master_info* mi, const char* master_info_fname,
const char* slave_info_fname,
bool abort_if_no_master_info_file,
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index 332bc4e53d0..949fa932127 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -221,8 +221,14 @@ public:
int events_till_abort;
#endif
- /* if not set, the value of other members of the structure are undefined */
- bool inited;
+ /*
+ inited changes its value within LOCK_active_mi-guarded critical
+ sections at times of start_slave_threads() (0->1) and end_slave() (1->0).
+ Readers may not acquire the mutex while they realize potential concurrency
+ issue.
+ If not set, the value of other members of the structure are undefined.
+ */
+ volatile bool inited;
volatile bool abort_slave;
volatile uint slave_running;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index cff85df6e7c..82ecb6b71cf 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -326,9 +326,6 @@ static sys_var_const sys_locked_in_memory(&vars, "locked_in_memory",
static sys_var_const sys_log_bin(&vars, "log_bin",
OPT_GLOBAL, SHOW_BOOL,
(uchar*) &opt_bin_log);
-static sys_var_trust_routine_creators
-sys_trust_routine_creators(&vars, "log_bin_trust_routine_creators",
- &trust_function_creators);
static sys_var_bool_ptr
sys_trust_function_creators(&vars, "log_bin_trust_function_creators",
&trust_function_creators);
@@ -617,8 +614,6 @@ sys_updatable_views_with_limit(&vars, "updatable_views_with_limit",
&SV::updatable_views_with_limit,
&updatable_views_with_limit_typelib);
-static sys_var_thd_table_type sys_table_type(&vars, "table_type",
- &SV::table_plugin);
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
&SV::table_plugin);
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
@@ -2504,9 +2499,9 @@ bool sys_var_log_state::update(THD *thd, set_var *var)
bool res;
if (this == &sys_var_log)
- WARN_DEPRECATED(thd, "7.0", "@@log", "'@@general_log'");
+ WARN_DEPRECATED(thd, 7, 0, "@@log", "'@@general_log'");
else if (this == &sys_var_log_slow)
- WARN_DEPRECATED(thd, "7.0", "@@log_slow_queries", "'@@slow_query_log'");
+ WARN_DEPRECATED(thd, 7, 0, "@@log_slow_queries", "'@@slow_query_log'");
pthread_mutex_lock(&LOCK_global_system_variables);
if (!var->save_result.ulong_value)
@@ -2523,9 +2518,9 @@ bool sys_var_log_state::update(THD *thd, set_var *var)
void sys_var_log_state::set_default(THD *thd, enum_var_type type)
{
if (this == &sys_var_log)
- WARN_DEPRECATED(thd, "7.0", "@@log", "'@@general_log'");
+ WARN_DEPRECATED(thd, 7, 0, "@@log", "'@@general_log'");
else if (this == &sys_var_log_slow)
- WARN_DEPRECATED(thd, "7.0", "@@log_slow_queries", "'@@slow_query_log'");
+ WARN_DEPRECATED(thd, 7, 0, "@@log_slow_queries", "'@@slow_query_log'");
pthread_mutex_lock(&LOCK_global_system_variables);
logger.deactivate_log_handler(thd, log_type);
@@ -3912,24 +3907,6 @@ bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
return 0;
}
-void sys_var_thd_table_type::warn_deprecated(THD *thd)
-{
- WARN_DEPRECATED(thd, "6.0", "@@table_type", "'@@storage_engine'");
-}
-
-void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type)
-{
- warn_deprecated(thd);
- sys_var_thd_storage_engine::set_default(thd, type);
-}
-
-bool sys_var_thd_table_type::update(THD *thd, set_var *var)
-{
- warn_deprecated(thd);
- return sys_var_thd_storage_engine::update(thd, var);
-}
-
-
/****************************************************************************
Functions to handle sql_mode
****************************************************************************/
@@ -4266,25 +4243,6 @@ bool process_key_caches(process_key_cache_t func)
return 0;
}
-
-void sys_var_trust_routine_creators::warn_deprecated(THD *thd)
-{
- WARN_DEPRECATED(thd, "6.0", "@@log_bin_trust_routine_creators",
- "'@@log_bin_trust_function_creators'");
-}
-
-void sys_var_trust_routine_creators::set_default(THD *thd, enum_var_type type)
-{
- warn_deprecated(thd);
- sys_var_bool_ptr::set_default(thd, type);
-}
-
-bool sys_var_trust_routine_creators::update(THD *thd, set_var *var)
-{
- warn_deprecated(thd);
- return sys_var_bool_ptr::update(thd, var);
-}
-
bool sys_var_opt_readonly::update(THD *thd, set_var *var)
{
bool result;
diff --git a/sql/set_var.h b/sql/set_var.h
index c08097521d2..120388415f5 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -617,18 +617,6 @@ public:
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
-class sys_var_thd_table_type :public sys_var_thd_storage_engine
-{
-public:
- sys_var_thd_table_type(sys_var_chain *chain, const char *name_arg,
- plugin_ref SV::*offset_arg)
- :sys_var_thd_storage_engine(chain, name_arg, offset_arg)
- {}
- void warn_deprecated(THD *thd);
- void set_default(THD *thd, enum_var_type type);
- bool update(THD *thd, set_var *var);
-};
-
class sys_var_thd_bit :public sys_var_thd
{
sys_check_func check_func;
@@ -1218,19 +1206,6 @@ public:
};
-class sys_var_trust_routine_creators :public sys_var_bool_ptr
-{
- /* We need a derived class only to have a warn_deprecated() */
-public:
- sys_var_trust_routine_creators(sys_var_chain *chain,
- const char *name_arg, my_bool *value_arg) :
- sys_var_bool_ptr(chain, name_arg, value_arg) {};
- void warn_deprecated(THD *thd);
- void set_default(THD *thd, enum_var_type type);
- bool update(THD *thd, set_var *var);
-};
-
-
/**
Handler for setting the system variable --read-only.
*/
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index b0ea4774a29..93385292c24 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -4299,16 +4299,16 @@ ER_SLAVE_NOT_RUNNING
ER_BAD_SLAVE
dan "Denne server er ikke konfigureret som slave. Ret in config-filen eller brug kommandoen CHANGE MASTER TO"
nla "De server is niet geconfigureerd als slave, fix in configuratie bestand of met CHANGE MASTER TO"
- eng "The server is not configured as slave; fix in config file or with CHANGE MASTER TO"
+ eng "The server is not configured as slave; fix with CHANGE MASTER TO"
fre "Le server n'est pas configuré comme un esclave, changez le fichier de configuration ou utilisez CHANGE MASTER TO"
- ger "Der Server ist nicht als Slave konfiguriert. Bitte in der Konfigurationsdatei oder mittels CHANGE MASTER TO beheben"
+ ger "Der Server ist nicht als Slave konfiguriert. Bitte mittels CHANGE MASTER TO beheben"
ita "Il server non e' configurato come 'slave', correggere il file di configurazione cambiando CHANGE MASTER TO"
por "O servidor não está configurado como 'slave'. Acerte o arquivo de configuração ou use CHANGE MASTER TO"
- rus "üÔÏÔ ÓÅÒ×ÅÒ ÎÅ ÎÁÓÔÒÏÅÎ ËÁË ÐÏÄÞÉÎÅÎÎÙÊ. ÷ÎÅÓÉÔÅ ÉÓÐÒÁ×ÌÅÎÉÑ × ËÏÎÆÉÇÕÒÁÃÉÏÎÎÏÍ ÆÁÊÌÅ ÉÌÉ Ó ÐÏÍÏÝØÀ CHANGE MASTER TO"
+ rus "üÔÏÔ ÓÅÒ×ÅÒ ÎÅ ÎÁÓÔÒÏÅÎ ËÁË ÐÏÄÞÉÎÅÎÎÙÊ. éÓÐÒÁ×ØÔÅ Ó ÐÏÍÏÝØÀ CHANGE MASTER TO"
serbian "Server nije konfigurisan kao podreðeni server, ispravite konfiguracioni file ili na njemu izvršite komandu 'CHANGE MASTER TO'"
spa "El servidor no está configurado como esclavo, edite el archivo config file o con CHANGE MASTER TO"
swe "Servern är inte konfigurerade som en replikationsslav. Ändra konfigurationsfilen eller gör CHANGE MASTER TO"
- ukr "óÅÒ×ÅÒ ÎÅ ÚËÏÎƦÇÕÒÏ×ÁÎÏ ÑË Ð¦ÄÌÅÇÌÉÊ, ×ÉÐÒÁ×ÔÅ ÃÅ Õ ÆÁÊ̦ ËÏÎƦÇÕÒÁæ§ ÁÂÏ Ú CHANGE MASTER TO"
+ ukr "óÅÒ×ÅÒ ÎÅ ÚËÏÎƦÇÕÒÏ×ÁÎÏ ÑË Ð¦ÄÌÅÇÌÉÊ, ×ÉÐÒÁ×ÔÅ ÃÅ ÚÁ ÄÏÐÏÍÏÇÏÀ CHANGE MASTER TO"
ER_MASTER_INFO
eng "Could not initialize master info structure; more error messages can be found in the MySQL error log"
fre "Impossible d'initialiser les structures d'information de maître, vous trouverez des messages d'erreur supplémentaires dans le journal des erreurs de MySQL"
diff --git a/sql/slave.cc b/sql/slave.cc
index 96aa9890c89..99a7fc8d3eb 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -144,9 +144,6 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
bool reconnect, bool suppress_warnings);
static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
void* thread_killed_arg);
-static int request_table_dump(MYSQL* mysql, const char* db, const char* table);
-static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
- const char* table_name, bool overwrite);
static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi);
static Log_event* next_event(Relay_log_info* rli);
static int queue_event(Master_info* mi,const char* buf,ulong event_len);
@@ -266,19 +263,16 @@ int init_slave()
}
if (init_master_info(active_mi,master_info_file,relay_log_info_file,
- !master_host, (SLAVE_IO | SLAVE_SQL)))
+ 1, (SLAVE_IO | SLAVE_SQL)))
{
sql_print_error("Failed to initialize the master info structure");
error= 1;
goto err;
}
- if (server_id && !master_host && active_mi->host[0])
- master_host= active_mi->host;
-
/* If server id is not set, start_slave_thread() will say it */
- if (master_host && !opt_skip_slave_start)
+ if (active_mi->host[0] && !opt_skip_slave_start)
{
if (start_slave_threads(1 /* need mutex */,
0 /* no wait for start*/,
@@ -656,11 +650,15 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
DBUG_PRINT("sleep",("Waiting for slave thread to start"));
const char* old_msg = thd->enter_cond(start_cond,cond_lock,
"Waiting for slave thread to start");
- pthread_cond_wait(start_cond,cond_lock);
+ pthread_cond_wait(start_cond, cond_lock);
thd->exit_cond(old_msg);
pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
if (thd->killed)
+ {
+ if (start_lock)
+ pthread_mutex_unlock(start_lock);
DBUG_RETURN(thd->killed_errno());
+ }
}
}
if (start_lock)
@@ -1079,17 +1077,6 @@ err:
}
-static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info)
-{
- if (io_slave_killed(thd, mi))
- {
- if (info && global_system_variables.log_warnings)
- sql_print_information("%s", info);
- return TRUE;
- }
- return FALSE;
-}
-
/*
Check if the error is caused by network.
@param[in] errorno Number of the error.
@@ -1468,199 +1455,6 @@ network_err:
DBUG_RETURN(2);
}
-/*
- Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
- DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
- from the dump. Honours replication inclusion/exclusion rules.
- db must be non-zero (guarded by assertion).
-
- RETURN VALUES
- 0 success
- 1 error
-*/
-
-static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
- const char* table_name, bool overwrite)
-{
- ulong packet_len;
- char *query, *save_db;
- uint32 save_db_length;
- Vio* save_vio;
- HA_CHECK_OPT check_opt;
- TABLE_LIST tables;
- int error= 1;
- handler *file;
- ulonglong save_options;
- NET *net= &mysql->net;
- const char *found_semicolon= NULL;
- DBUG_ENTER("create_table_from_dump");
-
- packet_len= my_net_read(net); // read create table statement
- if (packet_len == packet_error)
- {
- my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
- DBUG_RETURN(1);
- }
- if (net->read_pos[0] == 255) // error from master
- {
- char *err_msg;
- err_msg= (char*) net->read_pos + ((mysql->server_capabilities &
- CLIENT_PROTOCOL_41) ?
- 3+SQLSTATE_LENGTH+1 : 3);
- my_error(ER_MASTER, MYF(0), err_msg);
- DBUG_RETURN(1);
- }
- thd->command = COM_TABLE_DUMP;
- if (!(query = thd->strmake((char*) net->read_pos, packet_len)))
- {
- sql_print_error("create_table_from_dump: out of memory");
- my_message(ER_GET_ERRNO, "Out of memory", MYF(0));
- DBUG_RETURN(1);
- }
- thd->set_query(query, packet_len);
- thd->is_slave_error = 0;
-
- bzero((char*) &tables,sizeof(tables));
- tables.db = (char*)db;
- tables.alias= tables.table_name= (char*)table_name;
-
- /* Drop the table if 'overwrite' is true */
- if (overwrite)
- {
- if (mysql_rm_table(thd,&tables,1,0)) /* drop if exists */
- {
- sql_print_error("create_table_from_dump: failed to drop the table");
- goto err;
- }
- else
- {
- /* Clear the OK result of mysql_rm_table(). */
- thd->stmt_da->reset_diagnostics_area();
- }
- }
-
- /* Create the table. We do not want to log the "create table" statement */
- save_options = thd->options;
- thd->options &= ~ (OPTION_BIN_LOG);
- thd_proc_info(thd, "Creating table from master dump");
- // save old db in case we are creating in a different database
- save_db = thd->db;
- save_db_length= thd->db_length;
- thd->db = (char*)db;
- DBUG_ASSERT(thd->db != 0);
- thd->db_length= strlen(thd->db);
- /* run create table */
- mysql_parse(thd, thd->query(), packet_len, &found_semicolon);
- thd->db = save_db; // leave things the way the were before
- thd->db_length= save_db_length;
- thd->options = save_options;
-
- if (thd->is_slave_error)
- goto err; // mysql_parse took care of the error send
-
- thd_proc_info(thd, "Opening master dump table");
- thd->stmt_da->reset_diagnostics_area(); /* cleanup from CREATE_TABLE */
- /*
- Note: If this function starts to fail for MERGE tables,
- change the next two lines to these:
- tables.table= NULL; // was set by mysql_rm_table()
- if (!open_n_lock_single_table(thd, &tables, TL_WRITE))
- */
- tables.lock_type = TL_WRITE;
- if (!open_ltable(thd, &tables, TL_WRITE, 0))
- {
- sql_print_error("create_table_from_dump: could not open created table");
- goto err;
- }
-
- file = tables.table->file;
- thd_proc_info(thd, "Reading master dump table data");
- /* Copy the data file */
- if (file->net_read_dump(net))
- {
- my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
- sql_print_error("create_table_from_dump: failed in\
- handler::net_read_dump()");
- goto err;
- }
-
- check_opt.init();
- check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
- thd_proc_info(thd, "Rebuilding the index on master dump table");
- /*
- We do not want repair() to spam us with messages
- just send them to the error log, and report the failure in case of
- problems.
- */
- save_vio = thd->net.vio;
- thd->net.vio = 0;
- /* Rebuild the index file from the copied data file (with REPAIR) */
- error=file->ha_repair(thd,&check_opt) != 0;
- thd->net.vio = save_vio;
- if (error)
- my_error(ER_INDEX_REBUILD, MYF(0), tables.table->s->table_name.str);
-
-err:
- close_thread_tables(thd);
- DBUG_RETURN(error);
-}
-
-
-int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
- Master_info *mi, MYSQL *mysql, bool overwrite)
-{
- int error= 1;
- const char *errmsg=0;
- bool called_connected= (mysql != NULL);
- DBUG_ENTER("fetch_master_table");
- DBUG_PRINT("enter", ("db_name: '%s' table_name: '%s'",
- db_name,table_name));
-
- if (!called_connected)
- {
- if (!(mysql = mysql_init(NULL)))
- {
- DBUG_RETURN(1);
- }
- if (connect_to_master(thd, mysql, mi))
- {
- my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
- /*
- We need to clear the active VIO since, theoretically, somebody
- might issue an awake() on this thread. If we are then in the
- middle of closing and destroying the VIO inside the
- mysql_close(), we will have a problem.
- */
-#ifdef SIGNAL_WITH_VIO_CLOSE
- thd->clear_active_vio();
-#endif
- mysql_close(mysql);
- DBUG_RETURN(1);
- }
- if (thd->killed)
- goto err;
- }
-
- if (request_table_dump(mysql, db_name, table_name))
- {
- error= ER_UNKNOWN_ERROR;
- errmsg= "Failed on table dump request";
- goto err;
- }
- if (create_table_from_dump(thd, mysql, db_name,
- table_name, overwrite))
- goto err; // create_table_from_dump have sent the error already
- error = 0;
-
- err:
- if (!called_connected)
- mysql_close(mysql);
- if (errmsg && thd->vio_ok())
- my_message(error, errmsg, MYF(0));
- DBUG_RETURN(test(error)); // Return 1 on error
-}
-
-
static bool wait_for_relay_log_space(Relay_log_info* rli)
{
bool slave_killed=0;
@@ -1743,28 +1537,48 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi,
bool *suppress_warnings)
{
uchar buf[1024], *pos= buf;
- uint report_host_len, report_user_len=0, report_password_len=0;
+ uint report_host_len=0, report_user_len=0, report_password_len=0;
DBUG_ENTER("register_slave_on_master");
*suppress_warnings= FALSE;
- if (!report_host)
+ if (report_host)
+ report_host_len= strlen(report_host);
+ if (report_host_len > HOSTNAME_LENGTH)
+ {
+ sql_print_warning("The length of report_host is %d. "
+ "It is larger than the max length(%d), so this "
+ "slave cannot be registered to the master.",
+ report_host_len, HOSTNAME_LENGTH);
DBUG_RETURN(0);
- report_host_len= strlen(report_host);
+ }
+
if (report_user)
report_user_len= strlen(report_user);
+ if (report_user_len > USERNAME_LENGTH)
+ {
+ sql_print_warning("The length of report_user is %d. "
+ "It is larger than the max length(%d), so this "
+ "slave cannot be registered to the master.",
+ report_user_len, USERNAME_LENGTH);
+ DBUG_RETURN(0);
+ }
+
if (report_password)
report_password_len= strlen(report_password);
- /* 30 is a good safety margin */
- if (report_host_len + report_user_len + report_password_len + 30 >
- sizeof(buf))
- DBUG_RETURN(0); // safety
+ if (report_password_len > MAX_PASSWORD_LENGTH)
+ {
+ sql_print_warning("The length of report_password is %d. "
+ "It is larger than the max length(%d), so this "
+ "slave cannot be registered to the master.",
+ report_password_len, MAX_PASSWORD_LENGTH);
+ DBUG_RETURN(0);
+ }
int4store(pos, server_id); pos+= 4;
pos= net_store_data(pos, (uchar*) report_host, report_host_len);
pos= net_store_data(pos, (uchar*) report_user, report_user_len);
pos= net_store_data(pos, (uchar*) report_password, report_password_len);
int2store(pos, (uint16) report_port); pos+= 2;
- int4store(pos, rpl_recovery_rank); pos+= 4;
/* The master will fill in master_id */
int4store(pos, 0); pos+= 4;
@@ -2195,37 +2009,7 @@ static int request_dump(THD *thd, MYSQL* mysql, Master_info* mi,
else
sql_print_error("Error on COM_BINLOG_DUMP: %d %s, will retry in %d secs",
mysql_errno(mysql), mysql_error(mysql),
- master_connect_retry);
- DBUG_RETURN(1);
- }
-
- DBUG_RETURN(0);
-}
-
-
-static int request_table_dump(MYSQL* mysql, const char* db, const char* table)
-{
- uchar buf[1024], *p = buf;
- DBUG_ENTER("request_table_dump");
-
- uint table_len = (uint) strlen(table);
- uint db_len = (uint) strlen(db);
- if (table_len + db_len > sizeof(buf) - 2)
- {
- sql_print_error("request_table_dump: Buffer overrun");
- DBUG_RETURN(1);
- }
-
- *p++ = db_len;
- memcpy(p, db, db_len);
- p += db_len;
- *p++ = table_len;
- memcpy(p, table, table_len);
-
- if (simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
- {
- sql_print_error("request_table_dump: Error sending the table dump \
-command");
+ mi->connect_retry);
DBUG_RETURN(1);
}
@@ -2696,6 +2480,17 @@ on this slave.\
}
+static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info)
+{
+ if (io_slave_killed(thd, mi))
+ {
+ if (info && global_system_variables.log_warnings)
+ sql_print_information("%s", info);
+ return TRUE;
+ }
+ return FALSE;
+}
+
/**
@brief Try to reconnect slave IO thread.
@@ -4860,9 +4655,6 @@ void rotate_relay_log(Master_info* mi)
DBUG_EXECUTE_IF("crash_before_rotate_relaylog", abort(););
- /* We don't lock rli->run_lock. This would lead to deadlocks. */
- pthread_mutex_lock(&mi->run_lock);
-
/*
We need to test inited because otherwise, new_file() will attempt to lock
LOCK_log, which may not be inited (if we're not a slave).
@@ -4891,7 +4683,6 @@ void rotate_relay_log(Master_info* mi)
*/
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end:
- pthread_mutex_unlock(&mi->run_lock);
DBUG_VOID_RETURN;
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 1d953e773b3..9f672653266 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -166,7 +166,6 @@ sp_get_flags_for_command(LEX *lex)
}
/* fallthrough */
case SQLCOM_ANALYZE:
- case SQLCOM_BACKUP_TABLE:
case SQLCOM_OPTIMIZE:
case SQLCOM_PRELOAD_KEYS:
case SQLCOM_ASSIGN_TO_KEYCACHE:
@@ -213,7 +212,6 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_WARNS:
case SQLCOM_REPAIR:
- case SQLCOM_RESTORE_TABLE:
flags= sp_head::MULTI_RESULTS;
break;
/*
@@ -268,7 +266,6 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_COMMIT:
case SQLCOM_ROLLBACK:
case SQLCOM_LOAD:
- case SQLCOM_LOAD_MASTER_DATA:
case SQLCOM_LOCK_TABLES:
case SQLCOM_CREATE_PROCEDURE:
case SQLCOM_CREATE_SPFUNCTION:
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index aa2c697f221..817a5e982ee 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1783,24 +1783,83 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
(ip && !wild_compare(ip, host->hostname, 0)));
}
+/**
+ Check if the given host name needs to be resolved or not.
+ Host name has to be resolved if it actually contains *name*.
+
+ For example:
+ 192.168.1.1 --> FALSE
+ 192.168.1.0/255.255.255.0 --> FALSE
+ % --> FALSE
+ 192.168.1.% --> FALSE
+ AB% --> FALSE
+
+ AAAAFFFF --> TRUE (Hostname)
+ AAAA:FFFF:1234:5678 --> FALSE
+ ::1 --> FALSE
+
+ This function does not check if the given string is a valid host name or
+ not. It assumes that the argument is a valid host name.
+
+ @param hostname the string to check.
+
+ @return a flag telling if the argument needs to be resolved or not.
+ @retval TRUE the argument is a host name and needs to be resolved.
+ @retval FALSE the argument is either an IP address, or a patter and
+ should not be resolved.
+*/
+
bool hostname_requires_resolving(const char *hostname)
{
- char cur;
if (!hostname)
return FALSE;
- size_t namelen= strlen(hostname);
- size_t lhlen= strlen(my_localhost);
- if ((namelen == lhlen) &&
- !my_strnncoll(system_charset_info, (const uchar *)hostname, namelen,
- (const uchar *)my_localhost, strlen(my_localhost)))
+
+ /* Check if hostname is the localhost. */
+
+ size_t hostname_len= strlen(hostname);
+ size_t localhost_len= strlen(my_localhost);
+
+ if (hostname == my_localhost ||
+ (hostname_len == localhost_len &&
+ !my_strnncoll(system_charset_info,
+ (const uchar *) hostname, hostname_len,
+ (const uchar *) my_localhost, strlen(my_localhost))))
+ {
return FALSE;
- for (; (cur=*hostname); hostname++)
+ }
+
+ /*
+ If the string contains any of {':', '%', '_', '/'}, it is definitely
+ not a host name:
+ - ':' means that the string is an IPv6 address;
+ - '%' or '_' means that the string is a pattern;
+ - '/' means that the string is an IPv4 network address;
+ */
+
+ for (const char *p= hostname; *p; ++p)
{
- if ((cur != '%') && (cur != '_') && (cur != '.') && (cur != '/') &&
- ((cur < '0') || (cur > '9')))
- return TRUE;
+ switch (*p) {
+ case ':':
+ case '%':
+ case '_':
+ case '/':
+ return FALSE;
+ }
}
- return FALSE;
+
+ /*
+ Now we have to tell a host name (ab.cd, 12.ab) from an IPv4 address
+ (12.34.56.78). The assumption is that if the string contains only
+ digits and dots, it is an IPv4 address. Otherwise -- a host name.
+ */
+
+ for (const char *p= hostname; *p; ++p)
+ {
+ if (*p != '.' && !my_isdigit(&my_charset_latin1, *p))
+ return TRUE; /* a "letter" has been found. */
+ }
+
+ return FALSE; /* all characters are either dots or digits. */
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 6751dc763be..a84891c0ab7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4513,9 +4513,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count,
We can solve these problems in mixed mode by switching to binlogging
if at least one updated table is used by sub-statement
*/
- /* The BINLOG_FORMAT_MIXED judgement is saved for suppressing
- warnings, but it will be removed by fixing bug#45827 */
- if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED && tables &&
+ if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables &&
has_write_table_with_auto_increment(thd->lex->first_not_own_table()))
{
thd->lex->set_stmt_unsafe();
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a5236201724..3a6da64ca4a 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1309,7 +1309,6 @@ public:
HASH user_vars; // hash for user variables
String packet; // dynamic buffer for network I/O
String convert_buffer; // buffer for charset conversions
- struct sockaddr_in remote; // client socket address
struct rand_struct rand; // used for authentication
struct system_variables variables; // Changeable local variables
struct system_status_var status_var; // Per thread statistic vars
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index f5f962a02a3..8ecafce6f93 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -377,7 +377,8 @@ check_user(THD *thd, enum enum_server_command command,
if (send_old_password_request(thd) ||
my_net_read(net) != SCRAMBLE_LENGTH_323 + 1)
{
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
DBUG_RETURN(1);
}
@@ -498,9 +499,9 @@ check_user(THD *thd, enum enum_server_command command,
thd->main_security_ctx.host_or_ip,
passwd_len ? ER(ER_YES) : ER(ER_NO));
/*
- log access denied messages to the error log when log-warnings = 2
+ Log access denied messages to the error log when log-warnings = 2
so that the overhead of the general query log is not required to track
- failed connections
+ failed connections.
*/
if (global_system_variables.log_warnings > 1)
{
@@ -666,9 +667,9 @@ static int check_connection(THD *thd)
if (!thd->main_security_ctx.host) // If TCP/IP connection
{
- char ip[30];
+ char ip[NI_MAXHOST];
- if (vio_peer_addr(net->vio, ip, &thd->peer_port))
+ if (vio_peer_addr(net->vio, ip, &thd->peer_port, NI_MAXHOST))
{
my_error(ER_BAD_HOST_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
@@ -676,12 +677,15 @@ static int check_connection(THD *thd)
if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME))))
return 1; /* The error is set by my_strdup(). */
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
- vio_in_addr(net->vio,&thd->remote.sin_addr);
if (!(specialflag & SPECIAL_NO_RESOLVE))
{
- vio_in_addr(net->vio,&thd->remote.sin_addr);
- thd->main_security_ctx.host=
- ip_to_hostname(&thd->remote.sin_addr, &connect_errors);
+ if (ip_to_hostname(&net->vio->remote, thd->main_security_ctx.ip,
+ &thd->main_security_ctx.host, &connect_errors))
+ {
+ my_error(ER_BAD_HOST_ERROR, MYF(0), ip);
+ return 1;
+ }
+
/* Cut very long hostnames to avoid possible overflows */
if (thd->main_security_ctx.host)
{
@@ -714,7 +718,7 @@ static int check_connection(THD *thd)
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
thd->main_security_ctx.ip= 0;
/* Reset sin_addr */
- bzero((char*) &thd->remote, sizeof(thd->remote));
+ bzero((char*) &net->vio->remote, sizeof(net->vio->remote));
}
vio_keepalive(net->vio, TRUE);
@@ -769,7 +773,8 @@ static int check_connection(THD *thd)
(pkt_len= my_net_read(net)) == packet_error ||
pkt_len < MIN_HANDSHAKE_SIZE)
{
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0),
thd->main_security_ctx.host_or_ip);
return 1;
@@ -779,7 +784,7 @@ static int check_connection(THD *thd)
#include "_cust_sql_parse.h"
#endif
if (connect_errors)
- reset_host_errors(&thd->remote.sin_addr);
+ reset_host_errors(thd->main_security_ctx.ip);
if (thd->packet.alloc(thd->variables.net_buffer_length))
return 1; /* The error is set by alloc(). */
@@ -813,7 +818,7 @@ static int check_connection(THD *thd)
/* Do the SSL layering. */
if (!ssl_acceptor_fd)
{
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
}
@@ -821,7 +826,8 @@ static int check_connection(THD *thd)
if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout))
{
DBUG_PRINT("error", ("Failed to accept new SSL connection"));
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
}
@@ -831,7 +837,8 @@ static int check_connection(THD *thd)
{
DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
pkt_len));
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
}
@@ -840,7 +847,8 @@ static int check_connection(THD *thd)
if (end >= (char*) net->read_pos+ pkt_len +2)
{
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
}
@@ -878,7 +886,8 @@ static int check_connection(THD *thd)
if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
{
- inc_host_errors(&thd->remote.sin_addr);
+ inc_host_errors(thd->main_security_ctx.ip);
+
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 4bf8cd41aee..6b0c9699032 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -89,10 +89,10 @@ enum enum_sql_command {
SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
- SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
- SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
+ SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
+ SQLCOM_RENAME_TABLE,
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
- SQLCOM_SHOW_OPEN_TABLES, SQLCOM_LOAD_MASTER_DATA,
+ SQLCOM_SHOW_OPEN_TABLES,
SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index ef4382c9b4d..8f4fe4e8885 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -338,6 +338,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
(void) fn_format(name, ex->file_name, mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
+
#if !defined(__WIN__) && ! defined(__NETWARE__)
MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(MY_WME)))
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 9de07e90560..55ff9b5c835 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -249,8 +249,6 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_CREATE_DB]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA;
- sql_command_flags[SQLCOM_BACKUP_TABLE]= CF_CHANGES_DATA;
- sql_command_flags[SQLCOM_RESTORE_TABLE]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE;
sql_command_flags[SQLCOM_DROP_VIEW]= CF_CHANGES_DATA;
@@ -611,72 +609,6 @@ void cleanup_items(Item *item)
}
/**
- Handle COM_TABLE_DUMP command.
-
- @param thd thread handle
- @param db database name or an empty string. If empty,
- the current database of the connection is used
- @param tbl_name name of the table to dump
-
- @note
- This function is written to handle one specific command only.
-
- @retval
- 0 success
- @retval
- 1 error, the error message is set in THD
-*/
-
-static
-int mysql_table_dump(THD *thd, LEX_STRING *db, char *tbl_name)
-{
- TABLE* table;
- TABLE_LIST* table_list;
- int error = 0;
- DBUG_ENTER("mysql_table_dump");
- if (db->length == 0)
- {
- db->str= thd->db; /* purecov: inspected */
- db->length= thd->db_length; /* purecov: inspected */
- }
- if (!(table_list = (TABLE_LIST*) thd->calloc(sizeof(TABLE_LIST))))
- DBUG_RETURN(1); // out of memory
- table_list->db= db->str;
- table_list->table_name= table_list->alias= tbl_name;
- table_list->lock_type= TL_READ_NO_INSERT;
- table_list->prev_global= &table_list; // can be removed after merge with 4.1
-
- if (check_db_name(db))
- {
- /* purecov: begin inspected */
- my_error(ER_WRONG_DB_NAME ,MYF(0), db->str ? db->str : "NULL");
- goto err;
- /* purecov: end */
- }
- if (lower_case_table_names)
- my_casedn_str(files_charset_info, tbl_name);
-
- if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT, 0)))
- DBUG_RETURN(1);
-
- if (check_one_table_access(thd, SELECT_ACL, table_list))
- goto err;
- thd->free_list = 0;
- thd->set_query(tbl_name, (uint) strlen(tbl_name));
- if ((error = mysqld_dump_create_info(thd, table_list, -1)))
- {
- my_error(ER_GET_ERRNO, MYF(0), my_errno);
- goto err;
- }
- net_flush(&thd->net);
- if ((error= table->file->dump(thd,-1)))
- my_error(ER_GET_ERRNO, MYF(0), error);
-
-err:
- DBUG_RETURN(error);
-}
-
-/**
Ends the current transaction and (maybe) begin the next.
@param thd Current thread
@@ -1020,40 +952,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
#endif
- case COM_TABLE_DUMP:
- {
- char *tbl_name;
- LEX_STRING db;
- /* Safe because there is always a trailing \0 at the end of the packet */
- uint db_len= *(uchar*) packet;
- if (db_len + 1 > packet_length || db_len > NAME_LEN)
- {
- my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
- break;
- }
- /* Safe because there is always a trailing \0 at the end of the packet */
- uint tbl_len= *(uchar*) (packet + db_len + 1);
- if (db_len + tbl_len + 2 > packet_length || tbl_len > NAME_LEN)
- {
- my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
- break;
- }
-
- status_var_increment(thd->status_var.com_other);
- thd->enable_slow_log= opt_log_slow_admin_statements;
- db.str= (char*) thd->alloc(db_len + tbl_len + 2);
- if (!db.str)
- {
- my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
- break;
- }
- db.length= db_len;
- tbl_name= strmake(db.str, packet + 1, db_len)+1;
- strmake(tbl_name, packet + db_len + 2, tbl_len);
- if (mysql_table_dump(thd, &db, tbl_name) == 0)
- thd->stmt_da->disable_status();
- break;
- }
case COM_CHANGE_USER:
{
status_var_increment(thd->status_var.com_other);
@@ -2342,30 +2240,6 @@ case SQLCOM_PREPARE:
}
#endif
- case SQLCOM_BACKUP_TABLE:
- {
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
- || check_global_access(thd, FILE_ACL))
- goto error; /* purecov: inspected */
- thd->enable_slow_log= opt_log_slow_admin_statements;
- res = mysql_backup_table(thd, first_table);
- select_lex->table_list.first= (uchar*) first_table;
- lex->query_tables=all_tables;
- break;
- }
- case SQLCOM_RESTORE_TABLE:
- {
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- if (check_table_access(thd, INSERT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
- || check_global_access(thd, FILE_ACL))
- goto error; /* purecov: inspected */
- thd->enable_slow_log= opt_log_slow_admin_statements;
- res = mysql_restore_table(thd, first_table);
- select_lex->table_list.first= (uchar*) first_table;
- lex->query_tables=all_tables;
- break;
- }
case SQLCOM_ASSIGN_TO_KEYCACHE:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -2424,13 +2298,6 @@ case SQLCOM_PREPARE:
break;
}
- case SQLCOM_LOAD_MASTER_DATA: // sync with master
- if (check_global_access(thd, SUPER_ACL))
- goto error;
- if (end_active_trans(thd))
- goto error;
- res = load_master_data(thd);
- break;
#endif /* HAVE_REPLICATION */
case SQLCOM_SHOW_ENGINE_STATUS:
{
@@ -2446,35 +2313,6 @@ case SQLCOM_PREPARE:
res = ha_show_status(thd, lex->create_info.db_type, HA_ENGINE_MUTEX);
break;
}
-#ifdef HAVE_REPLICATION
- case SQLCOM_LOAD_MASTER_TABLE:
- {
- DBUG_ASSERT(first_table == all_tables && first_table != 0);
- DBUG_ASSERT(first_table->db); /* Must be set in the parser */
-
- if (check_access(thd, CREATE_ACL, first_table->db,
- &first_table->grant.privilege, 0, 0,
- test(first_table->schema_table)))
- goto error; /* purecov: inspected */
- /* Check that the first table has CREATE privilege */
- if (check_grant(thd, CREATE_ACL, all_tables, FALSE, 1, FALSE))
- goto error;
-
- pthread_mutex_lock(&LOCK_active_mi);
- /*
- fetch_master_table will send the error to the client on failure.
- Give error if the table already exists.
- */
- if (!fetch_master_table(thd, first_table->db, first_table->table_name,
- active_mi, 0, 0))
- {
- my_ok(thd);
- }
- pthread_mutex_unlock(&LOCK_active_mi);
- break;
- }
-#endif /* HAVE_REPLICATION */
-
case SQLCOM_CREATE_TABLE:
{
/* If CREATE TABLE of non-temporary table, do implicit commit */
@@ -3006,6 +2844,7 @@ end_with_restore_list:
if (check_table_access(thd, SELECT_ACL, all_tables,
FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
+
res = mysql_checksum_table(thd, first_table, &lex->check_opt);
break;
}
@@ -6298,17 +6137,6 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
DBUG_RETURN(1);
}
- if (type == MYSQL_TYPE_TIMESTAMP && length)
- {
- /* Display widths are no longer supported for TIMSTAMP as of MySQL 4.1.
- In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4),
- and so on, the display width is ignored.
- */
- char buf[32];
- my_snprintf(buf, sizeof(buf), "TIMESTAMP(%s)", length);
- WARN_DEPRECATED(thd, "6.0", buf, "'TIMESTAMP'");
- }
-
if (!(new_field= new Create_field()) ||
new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
default_value, on_update_value, comment, change,
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 4e5ce08ab5d..4f31b26fa6f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -259,24 +259,11 @@ bool log_in_use(const char* log_name)
bool purge_error_message(THD* thd, int res)
{
- uint errmsg= 0;
-
- switch (res) {
- case 0: break;
- case LOG_INFO_EOF: errmsg= ER_UNKNOWN_TARGET_BINLOG; break;
- case LOG_INFO_IO: errmsg= ER_IO_ERR_LOG_INDEX_READ; break;
- case LOG_INFO_INVALID:errmsg= ER_BINLOG_PURGE_PROHIBITED; break;
- case LOG_INFO_SEEK: errmsg= ER_FSEEK_FAIL; break;
- case LOG_INFO_MEM: errmsg= ER_OUT_OF_RESOURCES; break;
- case LOG_INFO_FATAL: errmsg= ER_BINLOG_PURGE_FATAL_ERR; break;
- case LOG_INFO_IN_USE: errmsg= ER_LOG_IN_USE; break;
- case LOG_INFO_EMFILE: errmsg= ER_BINLOG_PURGE_EMFILE; break;
- default: errmsg= ER_LOG_PURGE_UNKNOWN_ERR; break;
- }
+ uint errcode;
- if (errmsg)
+ if ((errcode= purge_log_get_error_code(res)) != 0)
{
- my_message(errmsg, ER(errmsg), MYF(0));
+ my_message(errcode, ER(errcode), MYF(0));
return TRUE;
}
my_ok(thd);
@@ -861,9 +848,7 @@ impossible position";
}
else
{
- DBUG_ASSERT(ret == 0 && signal_cnt != mysql_bin_log.signal_cnt ||
- thd->killed);
- DBUG_PRINT("wait",("binary log received update"));
+ DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
}
} while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed);
pthread_mutex_unlock(log_lock);
@@ -1243,14 +1228,8 @@ int reset_slave(THD *thd, Master_info* mi)
goto err;
}
- /*
- Clear master's log coordinates and reset host/user/etc to the values
- specified in mysqld's options (only for good display of SHOW SLAVE STATUS;
- next init_master_info() (in start_slave() for example) would have set them
- the same way; but here this is for the case where the user does SHOW SLAVE
- STATUS; before doing START SLAVE;
- */
- init_master_info_with_options(mi);
+ /* Clear master's log coordinates */
+ init_master_log_pos(mi);
/*
Reset errors (the idea is that we forget about the
old master).
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index a77ba6264a3..d9da11b79fd 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -842,35 +842,6 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
DBUG_VOID_RETURN;
}
-
-int
-mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd)
-{
- Protocol *protocol= thd->protocol;
- String *packet= protocol->storage_packet();
- DBUG_ENTER("mysqld_dump_create_info");
- DBUG_PRINT("enter",("table: %s",table_list->table->s->table_name.str));
-
- protocol->prepare_for_resend();
- if (store_create_info(thd, table_list, packet, NULL,
- FALSE /* show_database */))
- DBUG_RETURN(-1);
-
- if (fd < 0)
- {
- if (protocol->write())
- DBUG_RETURN(-1);
- protocol->flush();
- }
- else
- {
- if (my_write(fd, (const uchar*) packet->ptr(), packet->length(),
- MYF(MY_WME)))
- DBUG_RETURN(-1);
- }
- DBUG_RETURN(0);
-}
-
/*
Go through all character combinations and ensure that sql_lex.cc can
parse it as an identifier.
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 289cc77fb27..18605916789 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3994,15 +3994,43 @@ bool mysql_create_table_no_lock(THD *thd,
create_info->table_existed= 0; // Mark that table is created
#ifdef HAVE_READLINK
- if (test_if_data_home_dir(create_info->data_file_name))
{
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY");
- goto unlock_and_end;
- }
- if (test_if_data_home_dir(create_info->index_file_name))
- {
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY");
- goto unlock_and_end;
+ size_t dirlen;
+ char dirpath[FN_REFLEN];
+
+ /*
+ data_file_name and index_file_name include the table name without
+ extension. Mostly this does not refer to an existing file. When
+ comparing data_file_name or index_file_name against the data
+ directory, we try to resolve all symbolic links. On some systems,
+ we use realpath(3) for the resolution. This returns ENOENT if the
+ resolved path does not refer to an existing file. my_realpath()
+ does then copy the requested path verbatim, without symlink
+ resolution. Thereafter the comparison can fail even if the
+ requested path is within the data directory. E.g. if symlinks to
+ another file system are used. To make realpath(3) return the
+ resolved path, we strip the table name and compare the directory
+ path only. If the directory doesn't exist either, table creation
+ will fail anyway.
+ */
+ if (create_info->data_file_name)
+ {
+ dirname_part(dirpath, create_info->data_file_name, &dirlen);
+ if (test_if_data_home_dir(dirpath))
+ {
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY");
+ goto unlock_and_end;
+ }
+ }
+ if (create_info->index_file_name)
+ {
+ dirname_part(dirpath, create_info->index_file_name, &dirlen);
+ if (test_if_data_home_dir(dirpath))
+ {
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY");
+ goto unlock_and_end;
+ }
+ }
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -4330,78 +4358,6 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
}
-static int prepare_for_restore(THD* thd, TABLE_LIST* table,
- HA_CHECK_OPT *check_opt)
-{
- MDL_LOCK_DATA *mdl_lock_data= 0;
- enum enum_open_table_action ot_action_unused;
- DBUG_ENTER("prepare_for_restore");
-
- if (table->table) // do not overwrite existing tables on restore
- {
- DBUG_RETURN(send_check_errmsg(thd, table, "restore",
- "table exists, will not overwrite on restore"
- ));
- }
- else
- {
- char* backup_dir= thd->lex->backup_dir;
- char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1], uname[FN_REFLEN];
- char* table_name= table->table_name;
- char* db= table->db;
-
- tablename_to_filename(table->table_name, uname, sizeof(uname) - 1);
-
- if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext))
- DBUG_RETURN(-1); // protect buffer overflow
-
- build_table_filename(dst_path, sizeof(dst_path) - 1,
- db, table_name, reg_ext, 0);
-
- mdl_lock_data= mdl_alloc_lock(0, table->db, table->table_name,
- thd->mem_root);
- mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
- mdl_add_lock(&thd->mdl_context, mdl_lock_data);
- if (mdl_acquire_exclusive_locks(&thd->mdl_context))
- DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_open);
- tdc_remove_table(0, TDC_RT_REMOVE_UNUSED, table->db, table->table_name);
- pthread_mutex_unlock(&LOCK_open);
-
- if (my_copy(src_path, dst_path, MYF(MY_WME)))
- {
- mdl_release_lock(&thd->mdl_context, mdl_lock_data);
- DBUG_RETURN(send_check_errmsg(thd, table, "restore",
- "Failed copying .frm file"));
- }
- if (mysql_truncate(thd, table, 1))
- {
- mdl_release_lock(&thd->mdl_context, mdl_lock_data);
- DBUG_RETURN(send_check_errmsg(thd, table, "restore",
- "Failed generating table from .frm file"));
- }
- table->mdl_lock_data= mdl_lock_data;
- }
-
- /*
- Now we should be able to open the partially restored table
- to finish the restore in the handler later on
- */
- if (open_table(thd, table, thd->mem_root,
- &ot_action_unused, MYSQL_OPEN_REOPEN))
- {
- if (mdl_lock_data)
- mdl_release_lock(&thd->mdl_context, mdl_lock_data);
- DBUG_RETURN(send_check_errmsg(thd, table, "restore",
- "Failed to open partially restored table"));
- }
- /* A MERGE table must not come here. */
- DBUG_ASSERT(!table->table ||
- table->table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
- DBUG_RETURN(0);
-}
-
-
static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
HA_CHECK_OPT *check_opt)
{
@@ -5089,29 +5045,6 @@ err:
}
-bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
-{
- DBUG_ENTER("mysql_backup_table");
- WARN_DEPRECATED(thd, "6.0", "BACKUP TABLE",
- "MySQL Administrator (mysqldump, mysql)");
- DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
- "backup", TL_READ, 0, 0, 0, 0,
- &handler::ha_backup, 0));
-}
-
-
-bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
-{
- DBUG_ENTER("mysql_restore_table");
- WARN_DEPRECATED(thd, "6.0", "RESTORE TABLE",
- "MySQL Administrator (mysqldump, mysql)");
- DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
- "restore", TL_WRITE, 1, 1, 0,
- &prepare_for_restore,
- &handler::ha_restore, 0));
-}
-
-
bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{
DBUG_ENTER("mysql_repair_table");
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b1e750f09d5..24800f805d0 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -522,7 +522,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
Currently there are 169 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 169
+%expect 168
/*
Comments for TOKENS.
@@ -758,7 +758,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token INFILE
%token INITIAL_SIZE_SYM
%token INNER_SYM /* SQL-2003-R */
-%token INNOBASE_SYM
%token INOUT_SYM /* SQL-2003-R */
%token INSENSITIVE_SYM /* SQL-2003-R */
%token INSERT /* SQL-2003-R */
@@ -1279,7 +1278,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
show describe load alter optimize keycache preload flush
reset purge begin commit rollback savepoint release
slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
+ repair analyze check start checksum
field_list field_list_item field_spec kill column_def key_def
keycache_list keycache_list_or_parts assign_to_keycache
assign_to_keycache_parts
@@ -1433,7 +1432,6 @@ verb_clause:
statement:
alter
| analyze
- | backup
| binlog_base64_event
| call
| change
@@ -1468,7 +1466,6 @@ statement:
| replace
| reset
| resignal_stmt
- | restore
| revoke
| rollback
| savepoint
@@ -4734,13 +4731,6 @@ create_table_option:
Lex->create_info.db_type= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
}
- | TYPE_SYM opt_equal storage_engines
- {
- Lex->create_info.db_type= $3;
- WARN_DEPRECATED(yythd, "6.0", "TYPE=storage_engine",
- "'ENGINE=storage_engine'");
- Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
- }
| MAX_ROWS opt_equal ulonglong_num
{
Lex->create_info.max_rows= $3;
@@ -5154,7 +5144,7 @@ type:
{ $$=MYSQL_TYPE_DATE; }
| TIME_SYM
{ $$=MYSQL_TYPE_TIME; }
- | TIMESTAMP opt_field_length
+ | TIMESTAMP
{
if (YYTHD->variables.sql_mode & MODE_MAXDB)
$$=MYSQL_TYPE_DATETIME;
@@ -6430,28 +6420,6 @@ slave_until_opts:
| slave_until_opts ',' master_file_def
;
-restore:
- RESTORE_SYM table_or_tables
- {
- Lex->sql_command = SQLCOM_RESTORE_TABLE;
- }
- table_list FROM TEXT_STRING_sys
- {
- Lex->backup_dir = $6.str;
- }
- ;
-
-backup:
- BACKUP_SYM table_or_tables
- {
- Lex->sql_command = SQLCOM_BACKUP_TABLE;
- }
- table_list TO_SYM TEXT_STRING_sys
- {
- Lex->backup_dir = $6.str;
- }
- ;
-
checksum:
CHECKSUM_SYM table_or_tables
{
@@ -9093,7 +9061,7 @@ interval_time_stamp:
implementation without changing its
resolution.
*/
- WARN_DEPRECATED(yythd, "6.2", "FRAC_SECOND", "MICROSECOND");
+ WARN_DEPRECATED(yythd, 6, 2, "FRAC_SECOND", "MICROSECOND");
}
;
@@ -10265,14 +10233,6 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
MYSQL_YYABORT;
}
- | opt_full PLUGIN_SYM
- {
- LEX *lex= Lex;
- WARN_DEPRECATED(yythd, "6.0", "SHOW PLUGIN", "'SHOW PLUGINS'");
- lex->sql_command= SQLCOM_SHOW_PLUGINS;
- if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
- MYSQL_YYABORT;
- }
| PLUGINS_SYM
{
LEX *lex= Lex;
@@ -10333,14 +10293,6 @@ show_param:
if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
MYSQL_YYABORT;
}
- | TABLE_SYM TYPES_SYM
- {
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED(yythd, "6.0", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
- if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES))
- MYSQL_YYABORT;
- }
| opt_storage ENGINES_SYM
{
LEX *lex=Lex;
@@ -10388,30 +10340,6 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
MYSQL_YYABORT;
}
- | INNOBASE_SYM STATUS_SYM
- {
- LEX *lex= Lex;
- lex->sql_command = SQLCOM_SHOW_ENGINE_STATUS;
- if (!(lex->create_info.db_type=
- ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
- {
- my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
- MYSQL_YYABORT;
- }
- WARN_DEPRECATED(yythd, "6.0", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
- }
- | MUTEX_SYM STATUS_SYM
- {
- LEX *lex= Lex;
- lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
- if (!(lex->create_info.db_type=
- ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
- {
- my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
- MYSQL_YYABORT;
- }
- WARN_DEPRECATED(yythd, "6.0", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
- }
| opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| opt_var_type VARIABLES wild_and_where
@@ -10816,36 +10744,7 @@ load:
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec
{}
- | LOAD TABLE_SYM table_ident FROM MASTER_SYM
- {
- LEX *lex=Lex;
- WARN_DEPRECATED(yythd, "6.0", "LOAD TABLE FROM MASTER",
- "MySQL Administrator (mysqldump, mysql)");
- if (lex->sphead)
- {
- my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
- MYSQL_YYABORT;
- }
- lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
- if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
- MYSQL_YYABORT;
- }
- | LOAD DATA_SYM FROM MASTER_SYM
- {
- THD *thd= YYTHD;
- LEX *lex= thd->lex;
-
- if (lex->sphead)
- {
- my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD DATA");
- MYSQL_YYABORT;
- }
- Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
- WARN_DEPRECATED(yythd, "6.0", "LOAD DATA FROM MASTER",
- "mysqldump or future "
- "BACKUP/RESTORE DATABASE facility");
- }
- ;
+ ;
data_or_xml:
DATA_SYM { $$= FILETYPE_CSV; }
@@ -11882,7 +11781,6 @@ keyword_sp:
| IPC_SYM {}
| ISOLATION {}
| ISSUER_SYM {}
- | INNOBASE_SYM {}
| INSERT_METHOD {}
| KEY_BLOCK_SIZE {}
| LAST_SYM {}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index a341843662f..f69b19369b2 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -953,7 +953,11 @@ int ha_archive::index_read_idx(uchar *buf, uint index, const uchar *key,
}
if (found)
+ {
+ /* notify handler that a record has been found */
+ table->status= 0;
DBUG_RETURN(0);
+ }
error:
DBUG_RETURN(rc ? rc : HA_ERR_END_OF_FILE);
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 28d11e3d5f8..440a82b0da2 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -585,90 +585,6 @@ const char *ha_myisam::index_type(uint key_number)
"BTREE");
}
-#ifdef HAVE_REPLICATION
-int ha_myisam::net_read_dump(NET* net)
-{
- int data_fd = file->dfile;
- int error = 0;
-
- my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
- for (;;)
- {
- ulong packet_len = my_net_read(net);
- if (!packet_len)
- break ; // end of file
- if (packet_len == packet_error)
- {
- sql_print_error("ha_myisam::net_read_dump - read error ");
- error= -1;
- goto err;
- }
- if (my_write(data_fd, (uchar*)net->read_pos, (uint) packet_len,
- MYF(MY_WME|MY_FNABP)))
- {
- error = errno;
- goto err;
- }
- }
-err:
- return error;
-}
-
-
-int ha_myisam::dump(THD* thd, int fd)
-{
- MYISAM_SHARE* share = file->s;
- NET* net = &thd->net;
- uint blocksize = share->blocksize;
- my_off_t bytes_to_read = share->state.state.data_file_length;
- int data_fd = file->dfile;
- uchar *buf = (uchar*) my_malloc(blocksize, MYF(MY_WME));
- if (!buf)
- return ENOMEM;
-
- int error = 0;
- my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
- for (; bytes_to_read > 0;)
- {
- size_t bytes = my_read(data_fd, buf, blocksize, MYF(MY_WME));
- if (bytes == MY_FILE_ERROR)
- {
- error = errno;
- goto err;
- }
-
- if (fd >= 0)
- {
- if (my_write(fd, buf, bytes, MYF(MY_WME | MY_FNABP)))
- {
- error = errno ? errno : EPIPE;
- goto err;
- }
- }
- else
- {
- if (my_net_write(net, buf, bytes))
- {
- error = errno ? errno : EPIPE;
- goto err;
- }
- }
- bytes_to_read -= bytes;
- }
-
- if (fd < 0)
- {
- if (my_net_write(net, (uchar*) "", 0))
- error = errno ? errno : EPIPE;
- net_flush(net);
- }
-
-err:
- my_free((uchar*) buf, MYF(0));
- return error;
-}
-#endif /* HAVE_REPLICATION */
-
/* Name is here without an extension */
int ha_myisam::open(const char *name, int mode, uint test_if_locked)
@@ -906,113 +822,6 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
}
-int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
-{
- HA_CHECK_OPT tmp_check_opt;
- char *backup_dir= thd->lex->backup_dir;
- char src_path[FN_REFLEN], dst_path[FN_REFLEN];
- char table_name[FN_REFLEN];
- int error;
- const char* errmsg;
- DBUG_ENTER("restore");
-
- (void) tablename_to_filename(table->s->table_name.str, table_name,
- sizeof(table_name));
-
- if (fn_format_relative_to_data_home(src_path, table_name, backup_dir,
- MI_NAME_DEXT))
- DBUG_RETURN(HA_ADMIN_INVALID);
-
- strxmov(dst_path, table->s->normalized_path.str, MI_NAME_DEXT, NullS);
- if (my_copy(src_path, dst_path, MYF(MY_WME)))
- {
- error= HA_ADMIN_FAILED;
- errmsg= "Failed in my_copy (Error %d)";
- goto err;
- }
-
- tmp_check_opt.init();
- tmp_check_opt.flags |= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
- DBUG_RETURN(repair(thd, &tmp_check_opt));
-
- err:
- {
- MI_CHECK param;
- myisamchk_init(&param);
- param.thd= thd;
- param.op_name= "restore";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag= 0;
- mi_check_print_error(&param, errmsg, my_errno);
- DBUG_RETURN(error);
- }
-}
-
-
-int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
-{
- char *backup_dir= thd->lex->backup_dir;
- char src_path[FN_REFLEN], dst_path[FN_REFLEN];
- char table_name[FN_REFLEN];
- int error;
- const char *errmsg;
- DBUG_ENTER("ha_myisam::backup");
-
- (void) tablename_to_filename(table->s->table_name.str, table_name,
- sizeof(table_name));
-
- if (fn_format_relative_to_data_home(dst_path, table_name, backup_dir,
- reg_ext))
- {
- errmsg= "Failed in fn_format() for .frm file (errno: %d)";
- error= HA_ADMIN_INVALID;
- goto err;
- }
-
- strxmov(src_path, table->s->normalized_path.str, reg_ext, NullS);
- if (my_copy(src_path, dst_path,
- MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
- {
- error = HA_ADMIN_FAILED;
- errmsg = "Failed copying .frm file (errno: %d)";
- goto err;
- }
-
- /* Change extension */
- if (fn_format_relative_to_data_home(dst_path, table_name, backup_dir,
- MI_NAME_DEXT))
- {
- errmsg = "Failed in fn_format() for .MYD file (errno: %d)";
- error = HA_ADMIN_INVALID;
- goto err;
- }
-
- strxmov(src_path, table->s->normalized_path.str, MI_NAME_DEXT, NullS);
- if (my_copy(src_path, dst_path,
- MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
- {
- errmsg = "Failed copying .MYD file (errno: %d)";
- error= HA_ADMIN_FAILED;
- goto err;
- }
- DBUG_RETURN(HA_ADMIN_OK);
-
- err:
- {
- MI_CHECK param;
- myisamchk_init(&param);
- param.thd= thd;
- param.op_name= "backup";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag = 0;
- mi_check_print_error(&param,errmsg, my_errno);
- DBUG_RETURN(error);
- }
-}
-
-
int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
{
int error;
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 55a5eac92de..5bb46b03650 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -125,15 +125,9 @@ class ha_myisam: public handler
bool is_crashed() const;
bool auto_repair() const { return myisam_recover_options != 0; }
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
- int restore(THD* thd, HA_CHECK_OPT* check_opt);
- int backup(THD* thd, HA_CHECK_OPT* check_opt);
int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt);
int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
-#ifdef HAVE_REPLICATION
- int dump(THD* thd, int fd);
- int net_read_dump(NET* net);
-#endif
#ifdef HAVE_QUERY_CACHE
my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length,
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index 8adfcfd6fb2..fec6d32133e 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -44,6 +44,7 @@
#define DATA_TMP_EXT ".TMD"
#define OLD_EXT ".OLD"
+#define FRM_EXT ".frm"
#define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE
struct st_file_buffer {
@@ -125,6 +126,7 @@ static void get_options(int *argc,char ***argv);
static MI_INFO *open_isam_file(char *name,int mode);
static my_bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count);
static int compress(PACK_MRG_INFO *file,char *join_name);
+static int create_dest_frm(char *source_table, char *dest_table);
static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records);
static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees,
uint trees,
@@ -214,9 +216,13 @@ int main(int argc, char **argv)
error=ok=isamchk_neaded=0;
if (join_table)
- { /* Join files into one */
+ {
+ /*
+ Join files into one and create FRM file for the compressed table only if
+ the compression succeeds
+ */
if (open_isam_files(&merge,argv,(uint) argc) ||
- compress(&merge,join_table))
+ compress(&merge, join_table) || create_dest_frm(argv[0], join_table))
error=1;
}
else while (argc--)
@@ -757,6 +763,44 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
DBUG_RETURN(-1);
}
+
+/**
+ Create FRM for the destination table for --join operation
+ Copy the first table FRM as the destination table FRM file. Doing so
+ will help the mysql server to recognize the newly created table.
+ See Bug#36573.
+
+ @param source_table Name of the source table
+ @param dest_table Name of the destination table
+ @retval 0 Successful copy operation
+
+ @note We always return 0 because we don't want myisampack to report error
+ even if the copy operation fails.
+*/
+
+static int create_dest_frm(char *source_table, char *dest_table)
+{
+ char source_name[FN_REFLEN], dest_name[FN_REFLEN];
+
+ DBUG_ENTER("create_dest_frm");
+
+ (void) fn_format(source_name, source_table,
+ "", FRM_EXT, MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS);
+ (void) fn_format(dest_name, dest_table,
+ "", FRM_EXT, MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS);
+ /*
+ Error messages produced by my_copy() are suppressed as this
+ is not vital for --join operation. User shouldn't see any error messages
+ like "source file frm not found" and "unable to create destination frm
+ file. So we don't pass the flag MY_WME -Write Message on Error to
+ my_copy()
+ */
+ (void) my_copy(source_name, dest_name, MYF(MY_DONT_OVERWRITE_FILE));
+
+ return 0;
+}
+
+
/* Init a huff_count-struct for each field and init it */
static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 86906660d4c..02241dd92f6 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -2117,7 +2117,7 @@ static void test_prepare_field_result()
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_field_result(int_c int, "
- "var_c varchar(50), ts_c timestamp(14), "
+ "var_c varchar(50), ts_c timestamp, "
"char_c char(4), date_c date, extra tinyint)");
myquery(rc);
@@ -4878,11 +4878,11 @@ static void test_fetch_date()
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 date, c2 time, \
- c3 timestamp(14), \
+ c3 timestamp, \
c4 year, \
c5 datetime, \
- c6 timestamp(4), \
- c7 timestamp(6))");
+ c6 timestamp, \
+ c7 timestamp)");
myquery(rc);
rc= mysql_query(mysql, "SET SQL_MODE=''");
@@ -5196,7 +5196,7 @@ static void test_prepare_ext()
" c12 numeric(8, 4),"
" c13 date,"
" c14 datetime,"
- " c15 timestamp(14),"
+ " c15 timestamp,"
" c16 time,"
" c17 year,"
" c18 bit,"
@@ -6230,7 +6230,7 @@ static void test_manual_sample()
}
if (mysql_query(mysql, "CREATE TABLE test_table(col1 int, col2 varchar(50), \
col3 smallint, \
- col4 timestamp(14))"))
+ col4 timestamp)"))
{
fprintf(stderr, "\n create table failed");
fprintf(stderr, "\n %s", mysql_error(mysql));
@@ -7140,7 +7140,7 @@ static void test_date()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
myquery(rc);
- rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(14), \
+ rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
c2 TIME, \
c3 DATETIME, \
c4 DATE)");
@@ -7206,10 +7206,10 @@ static void test_date_ts()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
myquery(rc);
- rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(10), \
- c2 TIMESTAMP(14), \
+ rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
+ c2 TIMESTAMP, \
c3 TIMESTAMP, \
- c4 TIMESTAMP(6))");
+ c4 TIMESTAMP)");
myquery(rc);
@@ -8897,7 +8897,7 @@ static void test_fetch_seek()
myquery(rc);
- rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))");
+ rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp)");
myquery(rc);
rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql'), ('open'), ('source')");
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt
new file mode 100644
index 00000000000..a4c79afbf8b
--- /dev/null
+++ b/unittest/mysys/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright (C) 2007 MySQL AB, 2008-2009 Sun Microsystems, Inc
+#
+# 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
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include
+ ${CMAKE_SOURCE_DIR}/unittest/mytap)
+ADD_EXECUTABLE(bitmap-t bitmap-t.c)
+TARGET_LINK_LIBRARIES(bitmap-t mytap mysys dbug strings)
+
+ADD_EXECUTABLE(base64-t base64-t.c)
+TARGET_LINK_LIBRARIES(base64-t mytap mysys dbug strings)
+
+ADD_EXECUTABLE(my_atomic-t my_atomic-t.c)
+TARGET_LINK_LIBRARIES(my_atomic-t mytap mysys dbug strings)
+
+ADD_EXECUTABLE(lf-t lf-t.c)
+TARGET_LINK_LIBRARIES(lf-t mytap mysys dbug strings)
+
+ADD_EXECUTABLE(my_rdtsc-t my_rdtsc-t.c)
+TARGET_LINK_LIBRARIES(my_rdtsc-t mytap mysys dbug strings)
+
diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am
index d83b2909048..25b30e331b0 100644
--- a/unittest/mysys/Makefile.am
+++ b/unittest/mysys/Makefile.am
@@ -23,7 +23,7 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/strings/libmystrings.a
-noinst_PROGRAMS = bitmap-t base64-t lf-t my_vsnprintf-t
+noinst_PROGRAMS = bitmap-t base64-t lf-t my_rdtsc-t my_vsnprintf-t
if NEED_THREAD
# my_atomic-t is used to check thread functions, so it is safe to
@@ -32,5 +32,4 @@ if NEED_THREAD
noinst_PROGRAMS += my_atomic-t
endif
-# Don't update the files from bitkeeper
-%::SCCS/s.%
+EXTRA_DIST = CMakeLists.txt
diff --git a/unittest/mysys/my_rdtsc-t.c b/unittest/mysys/my_rdtsc-t.c
new file mode 100644
index 00000000000..286ff29fbfc
--- /dev/null
+++ b/unittest/mysys/my_rdtsc-t.c
@@ -0,0 +1,229 @@
+/* Copyright (C) 2008-2009 Sun Microsystems, Inc
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ rdtsc3 -- multi-platform timer code
+ pgulutzan@mysql.com, 2005-08-29
+ modified 2008-11-02
+
+ When you run rdtsc3, it will print the contents of
+ "my_timer_info". The display indicates
+ what timer routine is best for a given platform.
+
+ For example, this is the display on production.mysql.com,
+ a 2.8GHz Xeon with Linux 2.6.17, gcc 3.3.3:
+
+ cycles nanoseconds microseconds milliseconds ticks
+------------- ------------- ------------- ------------- -------------
+ 1 11 13 18 17
+ 2815019607 1000000000 1000000 1049 102
+ 1 1000 1 1 1
+ 88 4116 3888 4092 2044
+
+ The first line shows routines, e.g. 1 = MY_TIMER_ROUTINE_ASM_X86.
+ The second line shows frequencies, e.g. 2815019607 is nearly 2.8GHz.
+ The third line shows resolutions, e.g. 1000 = very poor resolution.
+ The fourth line shows overheads, e.g. ticks takes 2044 cycles.
+*/
+
+#include "my_global.h"
+#include "my_rdtsc.h"
+#include "tap.h"
+
+#define LOOP_COUNT 100
+
+MY_TIMER_INFO myt;
+
+void test_init()
+{
+ my_timer_init(&myt);
+
+ diag("----- Routine ---------------");
+ diag("myt.cycles.routine : %13llu", myt.cycles.routine);
+ diag("myt.nanoseconds.routine : %13llu", myt.nanoseconds.routine);
+ diag("myt.microseconds.routine : %13llu", myt.microseconds.routine);
+ diag("myt.milliseconds.routine : %13llu", myt.milliseconds.routine);
+ diag("myt.ticks.routine : %13llu", myt.ticks.routine);
+
+ diag("----- Frequency -------------");
+ diag("myt.cycles.frequency : %13llu", myt.cycles.frequency);
+ diag("myt.nanoseconds.frequency : %13llu", myt.nanoseconds.frequency);
+ diag("myt.microseconds.frequency : %13llu", myt.microseconds.frequency);
+ diag("myt.milliseconds.frequency : %13llu", myt.milliseconds.frequency);
+ diag("myt.ticks.frequency : %13llu", myt.ticks.frequency);
+
+ diag("----- Resolution ------------");
+ diag("myt.cycles.resolution : %13llu", myt.cycles.resolution);
+ diag("myt.nanoseconds.resolution : %13llu", myt.nanoseconds.resolution);
+ diag("myt.microseconds.resolution : %13llu", myt.microseconds.resolution);
+ diag("myt.milliseconds.resolution : %13llu", myt.milliseconds.resolution);
+ diag("myt.ticks.resolution : %13llu", myt.ticks.resolution);
+
+ diag("----- Overhead --------------");
+ diag("myt.cycles.overhead : %13llu", myt.cycles.overhead);
+ diag("myt.nanoseconds.overhead : %13llu", myt.nanoseconds.overhead);
+ diag("myt.microseconds.overhead : %13llu", myt.microseconds.overhead);
+ diag("myt.milliseconds.overhead : %13llu", myt.milliseconds.overhead);
+ diag("myt.ticks.overhead : %13llu", myt.ticks.overhead);
+
+ ok(1, "my_timer_init() did not crash");
+}
+
+void test_cycle()
+{
+ ulonglong t1= my_timer_cycles();
+ ulonglong t2;
+ int i;
+ int backward= 0;
+ int nonzero= 0;
+
+ for (i=0 ; i < LOOP_COUNT ; i++)
+ {
+ t2= my_timer_cycles();
+ if (t1 >= t2)
+ backward++;
+ if (t2 != 0)
+ nonzero++;
+ t1= t2;
+ }
+
+ /* Expect at most 1 backward, the cycle value can overflow */
+ ok((backward <= 1), "The cycle timer is strictly increasing");
+
+ if (myt.cycles.routine != 0)
+ ok((nonzero != 0), "The cycle timer is implemented");
+ else
+ ok((nonzero == 0), "The cycle timer is not implemented and returns 0");
+}
+
+void test_nanosecond()
+{
+ ulonglong t1= my_timer_nanoseconds();
+ ulonglong t2;
+ int i;
+ int backward= 0;
+ int nonzero= 0;
+
+ for (i=0 ; i < LOOP_COUNT ; i++)
+ {
+ t2= my_timer_nanoseconds();
+ if (t1 > t2)
+ backward++;
+ if (t2 != 0)
+ nonzero++;
+ t1= t2;
+ }
+
+ ok((backward == 0), "The nanosecond timer is increasing");
+
+ if (myt.nanoseconds.routine != 0)
+ ok((nonzero != 0), "The nanosecond timer is implemented");
+ else
+ ok((nonzero == 0), "The nanosecond timer is not implemented and returns 0");
+}
+
+void test_microsecond()
+{
+ ulonglong t1= my_timer_microseconds();
+ ulonglong t2;
+ int i;
+ int backward= 0;
+ int nonzero= 0;
+
+ for (i=0 ; i < LOOP_COUNT ; i++)
+ {
+ t2= my_timer_microseconds();
+ if (t1 > t2)
+ backward++;
+ if (t2 != 0)
+ nonzero++;
+ t1= t2;
+ }
+
+ ok((backward == 0), "The microsecond timer is increasing");
+
+ if (myt.microseconds.routine != 0)
+ ok((nonzero != 0), "The microsecond timer is implemented");
+ else
+ ok((nonzero == 0), "The microsecond timer is not implemented and returns 0");
+}
+
+void test_millisecond()
+{
+ ulonglong t1= my_timer_milliseconds();
+ ulonglong t2;
+ int i;
+ int backward= 0;
+ int nonzero= 0;
+
+ for (i=0 ; i < LOOP_COUNT ; i++)
+ {
+ t2= my_timer_milliseconds();
+ if (t1 > t2)
+ backward++;
+ if (t2 != 0)
+ nonzero++;
+ t1= t2;
+ }
+
+ ok((backward == 0), "The millisecond timer is increasing");
+
+ if (myt.milliseconds.routine != 0)
+ ok((nonzero != 0), "The millisecond timer is implemented");
+ else
+ ok((nonzero == 0), "The millisecond timer is not implemented and returns 0");
+}
+
+void test_tick()
+{
+ ulonglong t1= my_timer_ticks();
+ ulonglong t2;
+ int i;
+ int backward= 0;
+ int nonzero= 0;
+
+ for (i=0 ; i < LOOP_COUNT ; i++)
+ {
+ t2= my_timer_ticks();
+ if (t1 > t2)
+ backward++;
+ if (t2 != 0)
+ nonzero++;
+ t1= t2;
+ }
+
+ ok((backward == 0), "The tick timer is increasing");
+
+ if (myt.ticks.routine != 0)
+ ok((nonzero != 0), "The tick timer is implemented");
+ else
+ ok((nonzero == 0), "The tick timer is not implemented and returns 0");
+}
+
+int main(int argc __attribute__((unused)),
+ char ** argv __attribute__((unused)))
+{
+ plan(11);
+
+ test_init();
+ test_cycle();
+ test_nanosecond();
+ test_microsecond();
+ test_millisecond();
+ test_tick();
+
+ return 0;
+}
+
diff --git a/vio/vio.c b/vio/vio.c
index 34e02adae3d..b7bac69fc3c 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -78,7 +78,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio->was_interrupted=vio_was_interrupted;
vio->vioclose =vio_close_pipe;
vio->peer_addr =vio_peer_addr;
- vio->in_addr =vio_in_addr;
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
@@ -108,7 +107,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio->was_interrupted=vio_was_interrupted;
vio->vioclose =vio_close_shared_memory;
vio->peer_addr =vio_peer_addr;
- vio->in_addr =vio_in_addr;
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
@@ -136,7 +134,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio->was_interrupted=vio_was_interrupted;
vio->vioclose =vio_ssl_close;
vio->peer_addr =vio_peer_addr;
- vio->in_addr =vio_in_addr;
vio->vioblocking =vio_ssl_blocking;
vio->is_blocking =vio_is_blocking;
vio->timeout =vio_timeout;
@@ -156,7 +153,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio->was_interrupted=vio_was_interrupted;
vio->vioclose =vio_close;
vio->peer_addr =vio_peer_addr;
- vio->in_addr =vio_in_addr;
vio->vioblocking =vio_blocking;
vio->is_blocking =vio_is_blocking;
vio->timeout =vio_timeout;
diff --git a/vio/vio_priv.h b/vio/vio_priv.h
index c1ac2ab8365..69eb26083d6 100644
--- a/vio/vio_priv.h
+++ b/vio/vio_priv.h
@@ -25,6 +25,11 @@
#include <m_string.h>
#include <violite.h>
+#ifndef __WIN__
+#include <sys/socket.h>
+#include <netdb.h>
+#endif
+
#ifdef _WIN32
void vio_win32_timeout(Vio *vio, uint which, uint timeout);
#endif
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 51345d072b2..8dcf978f2fa 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -300,53 +300,209 @@ my_socket vio_fd(Vio* vio)
return vio->sd;
}
+/**
+ Convert a sock-address (AF_INET or AF_INET6) into the "normalized" form,
+ which is the IPv4 form for IPv4-mapped or IPv4-compatible IPv6 addresses.
+
+ @note Background: when IPv4 and IPv6 are used simultaneously, IPv4
+ addresses may be written in a form of IPv4-mapped or IPv4-compatible IPv6
+ addresses. That means, one address (a.b.c.d) can be written in three forms:
+ - IPv4: a.b.c.d;
+ - IPv4-compatible IPv6: ::a.b.c.d;
+ - IPv4-mapped IPv4: ::ffff:a.b.c.d;
+
+ Having three forms of one address makes it a little difficult to compare
+ addresses with each other (the IPv4-compatible IPv6-address of foo.bar
+ will be different from the IPv4-mapped IPv6-address of foo.bar).
+
+ @note This function can be made public when it's needed.
+
+ @param src [in] source IP address (AF_INET or AF_INET6).
+ @param src_length [in] length of the src.
+ @param dst [out] a buffer to store normalized IP address
+ (sockaddr_storage).
+ @param dst_length [out] actual length of the normalized IP address.
+*/
+static void vio_get_normalized_ip(const struct sockaddr *src,
+ int src_length,
+ struct sockaddr *dst,
+ int *dst_length)
+{
+ switch (src->sa_family) {
+ case AF_INET:
+ memcpy(dst, src, src_length);
+ *dst_length= src_length;
+ break;
+
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ {
+ const struct sockaddr_in6 *src_addr6= (const struct sockaddr_in6 *) src;
+ const struct in6_addr *src_ip6= &(src_addr6->sin6_addr);
+ const uint32 *src_ip6_int32= (uint32 *) src_ip6->s6_addr;
+
+ if (IN6_IS_ADDR_V4MAPPED(src_ip6) || IN6_IS_ADDR_V4COMPAT(src_ip6))
+ {
+ struct sockaddr_in *dst_ip4= (struct sockaddr_in *) dst;
+
+ /*
+ This is an IPv4-mapped or IPv4-compatible IPv6 address. It should
+ be converted to the IPv4 form.
+ */
+
+ *dst_length= sizeof (struct sockaddr_in);
-my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port)
+ memset(dst_ip4, 0, *dst_length);
+ dst_ip4->sin_family= AF_INET;
+ dst_ip4->sin_port= src_addr6->sin6_port;
+
+ /*
+ In an IPv4 mapped or compatible address, the last 32 bits represent
+ the IPv4 address. The byte orders for IPv6 and IPv4 addresses are
+ the same, so a simple copy is possible.
+ */
+ dst_ip4->sin_addr.s_addr= src_ip6_int32[3];
+ }
+ else
+ {
+ /* This is a "native" IPv6 address. */
+
+ memcpy(dst, src, src_length);
+ *dst_length= src_length;
+ }
+
+ break;
+ }
+#endif /* HAVE_IPV6 */
+ }
+}
+
+
+/**
+ Return the normalized IP address string for a sock-address.
+
+ The idea is to return an IPv4-address for an IPv4-mapped and
+ IPv4-compatible IPv6 address.
+
+ The function writes the normalized IP address to the given buffer.
+ The buffer should have enough space, otherwise error flag is returned.
+ The system constant INET6_ADDRSTRLEN can be used to reserve buffers of
+ the right size.
+
+ @param addr [in] sockaddr object (AF_INET or AF_INET6).
+ @param addr_length [in] length of the addr.
+ @param ip_string [out] buffer to write normalized IP address.
+ @param ip_string_size [in] size of the ip_string.
+
+ @return Error status.
+ @retval TRUE in case of error (the ip_string buffer is not enough).
+ @retval FALSE on success.
+*/
+
+my_bool vio_get_normalized_ip_string(const struct sockaddr *addr,
+ int addr_length,
+ char *ip_string,
+ size_t ip_string_size)
+{
+ struct sockaddr_storage norm_addr_storage;
+ struct sockaddr *norm_addr= (struct sockaddr *) &norm_addr_storage;
+ int norm_addr_length;
+ int err_code;
+
+ vio_get_normalized_ip(addr, addr_length, norm_addr, &norm_addr_length);
+
+ err_code= vio_getnameinfo(norm_addr, ip_string, ip_string_size, NULL, 0,
+ NI_NUMERICHOST);
+
+ if (!err_code)
+ return FALSE;
+
+ DBUG_PRINT("error", ("getnameinfo() failed with %d (%s).",
+ (int) err_code,
+ (const char *) gai_strerror(err_code)));
+ return TRUE;
+}
+
+
+/**
+ Return IP address and port of a VIO client socket.
+
+ The function returns an IPv4 address if IPv6 support is disabled.
+
+ The function returns an IPv4 address if the client socket is associated
+ with an IPv4-compatible or IPv4-mapped IPv6 address. Otherwise, the native
+ IPv6 address is returned.
+*/
+
+my_bool vio_peer_addr(Vio *vio, char *ip_buffer, uint16 *port,
+ size_t ip_buffer_size)
{
DBUG_ENTER("vio_peer_addr");
- DBUG_PRINT("enter", ("sd: %d", vio->sd));
+ DBUG_PRINT("enter", ("Client socked fd: %d", (int) vio->sd));
+
if (vio->localhost)
{
- strmov(buf,"127.0.0.1");
+ /*
+ Initialize vio->remote and vio->addLen. Set vio->remote to IPv4 loopback
+ address.
+ */
+ struct in_addr *ip4= &((struct sockaddr_in *) &(vio->remote))->sin_addr;
+
+ vio->remote.ss_family= AF_INET;
+ vio->addrLen= sizeof (struct sockaddr_in);
+
+ ip4->s_addr= htonl(INADDR_LOOPBACK);
+
+ /* Initialize ip_buffer and port. */
+
+ strmov(ip_buffer, "127.0.0.1");
*port= 0;
}
else
{
- size_socket addrLen = sizeof(vio->remote);
- if (getpeername(vio->sd, (struct sockaddr *) (&vio->remote),
- &addrLen) != 0)
+ int err_code;
+ char port_buffer[NI_MAXSERV];
+
+ struct sockaddr_storage addr_storage;
+ struct sockaddr *addr= (struct sockaddr *) &addr_storage;
+ size_socket addr_length= sizeof (addr_storage);
+
+ /* Get sockaddr by socked fd. */
+
+ err_code= getpeername(vio->sd, addr, &addr_length);
+
+ if (err_code)
{
- DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno));
- DBUG_RETURN(1);
+ DBUG_PRINT("exit", ("getpeername() gave error: %d", socket_errno));
+ DBUG_RETURN(TRUE);
}
- my_inet_ntoa(vio->remote.sin_addr,buf);
- *port= ntohs(vio->remote.sin_port);
- }
- DBUG_PRINT("exit", ("addr: %s", buf));
- DBUG_RETURN(0);
-}
+ /* Normalize IP address. */
-/*
- Get in_addr for a TCP/IP connection
+ vio_get_normalized_ip(addr, addr_length,
+ (struct sockaddr *) &vio->remote, &vio->addrLen);
- SYNOPSIS
- vio_in_addr()
- vio vio handle
- in put in_addr here
+ /* Get IP address & port number. */
- NOTES
- one must call vio_peer_addr() before calling this one
-*/
+ err_code= vio_getnameinfo((struct sockaddr *) &vio->remote,
+ ip_buffer, ip_buffer_size,
+ port_buffer, NI_MAXSERV,
+ NI_NUMERICHOST | NI_NUMERICSERV);
-void vio_in_addr(Vio *vio, struct in_addr *in)
-{
- DBUG_ENTER("vio_in_addr");
- if (vio->localhost)
- bzero((char*) in, sizeof(*in));
- else
- *in=vio->remote.sin_addr;
- DBUG_VOID_RETURN;
+ if (err_code)
+ {
+ DBUG_PRINT("exit", ("getnameinfo() gave error: %s",
+ gai_strerror(err_code)));
+ DBUG_RETURN(TRUE);
+ }
+
+ *port= (uint16) strtol(port_buffer, NULL, 10);
+ }
+
+ DBUG_PRINT("exit", ("Client IP address: %s; port: %d",
+ (const char *) ip_buffer,
+ (int) *port));
+ DBUG_RETURN(FALSE);
}
@@ -377,7 +533,8 @@ static my_bool socket_poll_read(my_socket sd, uint timeout)
FD_ZERO(&errorfds);
FD_SET(fd, &readfds);
FD_SET(fd, &errorfds);
- if ((res= select(fd, &readfds, NULL, &errorfds, &tm) <= 0))
+ /* The first argument is ignored on Windows, so a conversion to int is OK */
+ if ((res= select((int) fd, &readfds, NULL, &errorfds, &tm) <= 0))
{
DBUG_RETURN(res < 0 ? 0 : 1);
}
@@ -879,3 +1036,36 @@ ssize_t vio_pending(Vio *vio)
return 0;
}
+
+
+/**
+ This is a wrapper for the system getnameinfo(), because different OS
+ differ in the getnameinfo() implementation. For instance, Solaris 10
+ requires that the 2nd argument (salen) must match the actual size of the
+ struct sockaddr_storage passed to it.
+*/
+
+int vio_getnameinfo(const struct sockaddr *sa,
+ char *hostname, size_t hostname_size,
+ char *port, size_t port_size,
+ int flags)
+{
+ int sa_length= 0;
+
+ switch (sa->sa_family) {
+ case AF_INET:
+ sa_length= sizeof (struct sockaddr_in);
+ break;
+
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ sa_length= sizeof (struct sockaddr_in6);
+ break;
+#endif /* HAVE_IPV6 */
+ }
+
+ return getnameinfo(sa, sa_length,
+ hostname, hostname_size,
+ port, port_size,
+ flags);
+}