summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rwxr-xr-xBUILD/build_mccge.sh293
-rw-r--r--CMakeLists.txt34
-rw-r--r--client/mysql.cc8
-rw-r--r--client/mysqladmin.cc14
-rw-r--r--client/mysqldump.c15
-rw-r--r--client/mysqltest.cc11
-rw-r--r--cmake/build_configurations/mysql_release.cmake29
-rw-r--r--cmake/do_abi_check.cmake30
-rw-r--r--cmake/dtrace.cmake12
-rw-r--r--cmake/maintainer.cmake54
-rw-r--r--cmake/mysql_version.cmake18
-rw-r--r--cmake/plugin.cmake2
-rw-r--r--cmd-line-utils/libedit/CMakeLists.txt15
-rw-r--r--dbug/dbug.c19
-rw-r--r--include/atomic/x86-gcc.h14
-rw-r--r--include/m_ctype.h57
-rw-r--r--include/my_dbug.h3
-rw-r--r--include/my_global.h2
-rw-r--r--include/my_stacktrace.h2
-rw-r--r--include/my_sys.h3
-rw-r--r--include/mysql/plugin_audit.h40
-rw-r--r--include/mysql/plugin_audit.h.pp21
-rw-r--r--include/mysys_err.h3
-rw-r--r--libmysqld/CMakeLists.txt3
-rw-r--r--mysql-test/collections/default.weekly4
-rw-r--r--mysql-test/collections/test-bt20
-rw-r--r--mysql-test/collections/test-bt-debug2
-rw-r--r--mysql-test/collections/test-bt-fast4
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test53
-rw-r--r--mysql-test/extra/binlog_tests/binlog_cache_stat.test251
-rw-r--r--mysql-test/extra/binlog_tests/binlog_insert_delayed.test4
-rw-r--r--mysql-test/extra/binlog_tests/innodb_stat.test41
-rw-r--r--mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test69
-rw-r--r--mysql-test/include/ctype_8bit.inc46
-rw-r--r--mysql-test/include/ctype_czech.inc12
-rw-r--r--mysql-test/include/ctype_like_ignorable.inc11
-rw-r--r--mysql-test/include/io_thd_fault_injection.inc21
-rw-r--r--mysql-test/include/restart_mysqld.inc6
-rw-r--r--mysql-test/include/show_slave_status.inc2
-rw-r--r--mysql-test/r/archive.result6
-rw-r--r--mysql-test/r/auto_increment.result21
-rw-r--r--mysql-test/r/ctype_cp1251.result308
-rw-r--r--mysql-test/r/ctype_like_range.result2310
-rw-r--r--mysql-test/r/ctype_many.result22
-rw-r--r--mysql-test/r/ctype_uca.result98
-rw-r--r--mysql-test/r/ctype_utf16_uca.result46
-rw-r--r--mysql-test/r/ctype_utf32_uca.result46
-rw-r--r--mysql-test/r/derived.result26
-rw-r--r--mysql-test/r/func_gconcat.result12
-rw-r--r--mysql-test/r/func_group.result15
-rw-r--r--mysql-test/r/func_group_innodb.result47
-rw-r--r--mysql-test/r/func_misc.result6
-rw-r--r--mysql-test/r/func_str.result12
-rw-r--r--mysql-test/r/join_outer_innodb.result35
-rw-r--r--mysql-test/r/lock_multi.result2
-rw-r--r--mysql-test/r/mdl_sync.result2
-rw-r--r--mysql-test/r/merge.result2
-rw-r--r--mysql-test/r/multi_update.result11
-rw-r--r--mysql-test/r/mysql.result69
-rw-r--r--mysql-test/r/mysqld--help-notwin.result20
-rw-r--r--mysql-test/r/mysqld--help-win.result20
-rw-r--r--mysql-test/r/partition_binlog.result49
-rw-r--r--mysql-test/r/plugin_auth.result10
-rw-r--r--mysql-test/r/plugin_not_embedded.result2
-rw-r--r--mysql-test/r/show_check.result2
-rw-r--r--mysql-test/r/variables.result33
-rw-r--r--mysql-test/r/view.result15
-rw-r--r--mysql-test/suite/binlog/r/binlog_index.result36
-rw-r--r--mysql-test/suite/binlog/r/binlog_innodb.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_max_extension.result3
-rw-r--r--mysql-test/suite/binlog/r/binlog_mix_innodb_stat.result25
-rw-r--r--mysql-test/suite/binlog/r/binlog_mixed_cache_stat.result66
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result63
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_cache_stat.result66
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_innodb_stat.result25
-rw-r--r--mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result10
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result63
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_cache_stat.result66
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_innodb_stat.result25
-rw-r--r--mysql-test/suite/binlog/t/binlog_index.test28
-rw-r--r--mysql-test/suite/binlog/t/binlog_max_extension.test3
-rw-r--r--mysql-test/suite/binlog/t/binlog_mixed_cache_stat.test (renamed from mysql-test/suite/binlog/t/binlog_mix_innodb_stat.test)2
-rw-r--r--mysql-test/suite/binlog/t/binlog_row_cache_stat.test (renamed from mysql-test/suite/binlog/t/binlog_row_innodb_stat.test)2
-rw-r--r--mysql-test/suite/binlog/t/binlog_stm_cache_stat.test (renamed from mysql-test/suite/binlog/t/binlog_stm_innodb_stat.test)2
-rw-r--r--mysql-test/suite/federated/federated_bug_35333.result67
-rw-r--r--mysql-test/suite/federated/federated_bug_35333.test74
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc.result18
-rw-r--r--mysql-test/suite/innodb/r/innodb_multi_update.result8
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc.test49
-rw-r--r--mysql-test/suite/innodb/t/innodb_multi_update.test9
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc23
-rw-r--r--mysql-test/suite/parts/inc/partition_decimal.inc9
-rw-r--r--mysql-test/suite/parts/inc/partition_double.inc51
-rw-r--r--mysql-test/suite/parts/inc/partition_float.inc50
-rw-r--r--mysql-test/suite/parts/r/partition_decimal_innodb.result108
-rw-r--r--mysql-test/suite/parts/r/partition_decimal_myisam.result108
-rw-r--r--mysql-test/suite/perfschema/include/privilege.inc8
-rw-r--r--mysql-test/suite/perfschema/r/dml_cond_instances.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_events_waits_current.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_events_waits_history.result7
-rw-r--r--mysql-test/suite/perfschema/r/dml_events_waits_history_long.result7
-rw-r--r--mysql-test/suite/perfschema/r/dml_ews_by_instance.result11
-rw-r--r--mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_ews_global_by_event_name.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_file_instances.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_mutex_instances.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_rwlock_instances.result3
-rw-r--r--mysql-test/suite/perfschema/r/dml_threads.result3
-rw-r--r--mysql-test/suite/perfschema/r/misc.result4
-rw-r--r--mysql-test/suite/perfschema/r/myisam_file_io.result1
-rw-r--r--mysql-test/suite/perfschema/r/privilege.result32
-rw-r--r--mysql-test/suite/perfschema/r/thread_cache.result5
-rw-r--r--mysql-test/suite/perfschema/t/dml_cond_instances.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_current.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_history.test5
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_history_long.test5
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_instance.test7
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_file_instances.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_mutex_instances.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_rwlock_instances.test3
-rw-r--r--mysql-test/suite/perfschema/t/dml_threads.test3
-rw-r--r--mysql-test/suite/perfschema/t/misc.test4
-rw-r--r--mysql-test/suite/perfschema/t/myisam_file_io.test8
-rw-r--r--mysql-test/suite/perfschema/t/thread_cache.test52
-rw-r--r--mysql-test/suite/rpl/r/rpl_binlog_errors.result274
-rw-r--r--mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result9
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result9
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_EE_err2.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result9
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result8
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_errors-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_errors.test415
-rw-r--r--mysql-test/suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc154
-rw-r--r--mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_32.result108
-rw-r--r--mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_64.result108
-rw-r--r--mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result152
-rw-r--r--mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_32.test7
-rw-r--r--mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_64.test7
-rw-r--r--mysql-test/suite/sys_vars/t/max_binlog_cache_size_func-master.opt2
-rw-r--r--mysql-test/suite/sys_vars/t/max_binlog_stmt_cache_size_basic.test184
-rw-r--r--mysql-test/t/archive.test8
-rw-r--r--mysql-test/t/auto_increment.test21
-rw-r--r--mysql-test/t/ctype_cp1251.test10
-rw-r--r--mysql-test/t/ctype_like_range.test87
-rw-r--r--mysql-test/t/ctype_many.test20
-rw-r--r--mysql-test/t/ctype_uca.test16
-rw-r--r--mysql-test/t/ctype_utf16_uca.test7
-rw-r--r--mysql-test/t/ctype_utf32_uca.test8
-rw-r--r--mysql-test/t/derived.test33
-rw-r--r--mysql-test/t/func_gconcat.test11
-rw-r--r--mysql-test/t/func_group.test11
-rw-r--r--mysql-test/t/func_group_innodb.test50
-rw-r--r--mysql-test/t/func_misc.test7
-rw-r--r--mysql-test/t/func_str.test7
-rw-r--r--mysql-test/t/join_outer_innodb.test37
-rw-r--r--mysql-test/t/multi_update.test11
-rw-r--r--mysql-test/t/mysql.test143
-rw-r--r--mysql-test/t/partition_binlog.test42
-rw-r--r--mysql-test/t/partition_innodb.test3
-rw-r--r--mysql-test/t/plugin_auth.test14
-rw-r--r--mysql-test/t/plugin_not_embedded.test12
-rw-r--r--mysql-test/t/variables.test44
-rw-r--r--mysql-test/t/view.test16
-rw-r--r--mysql-test/valgrind.supp41
-rw-r--r--mysys/errors.c2
-rw-r--r--mysys/mf_pack.c3
-rw-r--r--mysys/my_init.c194
-rw-r--r--mysys/my_seek.c15
-rw-r--r--mysys/my_symlink.c3
-rw-r--r--mysys/stacktrace.c106
-rw-r--r--packaging/WiX/ca/CMakeLists.txt2
-rw-r--r--packaging/WiX/ca/CustomAction.rc18
-rw-r--r--sql/ha_partition.cc7
-rw-r--r--sql/ha_partition.h2
-rw-r--r--sql/handler.cc36
-rw-r--r--sql/item.cc11
-rw-r--r--sql/item_cmpfunc.cc10
-rw-r--r--sql/item_create.cc52
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/item_row.cc8
-rw-r--r--sql/item_strfunc.cc35
-rw-r--r--sql/item_strfunc.h40
-rw-r--r--sql/item_subselect.cc20
-rw-r--r--sql/item_subselect.h1
-rw-r--r--sql/item_sum.cc88
-rw-r--r--sql/item_sum.h36
-rw-r--r--sql/log.cc558
-rw-r--r--sql/log.h18
-rw-r--r--sql/log_event.cc3
-rw-r--r--sql/log_event.h2
-rw-r--r--sql/mysqld.cc65
-rw-r--r--sql/mysqld.h8
-rw-r--r--sql/opt_range.cc4
-rw-r--r--sql/opt_sum.cc2
-rw-r--r--sql/rpl_injector.cc6
-rw-r--r--sql/share/charsets/cp1251.xml2
-rw-r--r--sql/share/errmsg-utf8.txt2
-rw-r--r--sql/slave.cc16
-rw-r--r--sql/slave.h2
-rw-r--r--sql/sp_head.cc2
-rw-r--r--sql/sql_audit.cc27
-rw-r--r--sql/sql_audit.h41
-rw-r--r--sql/sql_base.cc18
-rw-r--r--sql/sql_binlog.cc8
-rw-r--r--sql/sql_class.cc34
-rw-r--r--sql/sql_class.h5
-rw-r--r--sql/sql_connect.cc13
-rw-r--r--sql/sql_cursor.cc2
-rw-r--r--sql/sql_db.cc22
-rw-r--r--sql/sql_derived.cc21
-rw-r--r--sql/sql_derived.h12
-rw-r--r--sql/sql_insert.cc78
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h16
-rw-r--r--sql/sql_load.cc7
-rw-r--r--sql/sql_parse.cc57
-rw-r--r--sql/sql_partition_admin.cc11
-rw-r--r--sql/sql_plugin.cc24
-rw-r--r--sql/sql_plugin.h1
-rw-r--r--sql/sql_prepare.cc20
-rw-r--r--sql/sql_priv.h39
-rw-r--r--sql/sql_reload.cc21
-rw-r--r--sql/sql_reload.h2
-rw-r--r--sql/sql_repl.cc2
-rw-r--r--sql/sql_select.cc20
-rw-r--r--sql/sql_show.cc70
-rw-r--r--sql/sql_udf.cc12
-rw-r--r--sql/sql_update.cc16
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/sys_vars.cc28
-rw-r--r--storage/archive/ha_archive.cc3
-rw-r--r--storage/innobase/row/row0mysql.c14
-rw-r--r--storage/myisam/mi_check.c2
-rw-r--r--storage/perfschema/ha_perfschema.cc35
-rw-r--r--storage/perfschema/ha_perfschema.h5
-rw-r--r--storage/perfschema/pfs_engine_table.cc111
-rw-r--r--storage/perfschema/table_setup_consumers.cc1
-rw-r--r--storage/perfschema/table_setup_instruments.cc1
-rw-r--r--storage/perfschema/table_setup_timers.cc1
-rw-r--r--strings/CHARSET_INFO.txt11
-rw-r--r--strings/ctype-extra.c10
-rw-r--r--strings/ctype-mb.c188
-rw-r--r--strings/ctype-uca.c6
-rw-r--r--strings/ctype-ucs2.c333
-rw-r--r--strings/my_strchr.c67
252 files changed, 8941 insertions, 1742 deletions
diff --git a/.bzrignore b/.bzrignore
index e420b1590d1..ea2554de265 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -3115,3 +3115,4 @@ libmysqld/mysqlserver_depends.c
libmysqld/examples/mysql_embedded
sql/.empty
mysys/thr_lock
+VERSION.dep
diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh
index f29a2f1db34..004194961d5 100755
--- a/BUILD/build_mccge.sh
+++ b/BUILD/build_mccge.sh
@@ -42,9 +42,7 @@ cat <<EOF
Options used with this script always override any default behaviour.
The default package is MySQL Cluster Carrier Grade (standard) Edition.
For developers, the default package is MySQL Cluster Carrier Grade
- Extended Edition, and the default build behaviour is to build with
- autotools. If you want to skip autotools and start from a source code
- release you can use the --no-autotools flag.
+ Extended Edition.
More information for developers can be found in --help,
--sysadmin-help, and --extended-help.
@@ -102,7 +100,8 @@ cat <<EOF
If your building on a Solaris SPARC machine and you want to compile
using SunStudio you must set
--compiler=forte; if you want to build using the Intel compiler on
- Linux, you need to set --compiler=icc.
+ Linux, you need to set --compiler=icc. If you want to use the AMD
+ compiler Open64 set --compiler=open64.
A synonym for forte is SunStudio, so one can also use
--compiler=SunStudio.
@@ -150,14 +149,32 @@ Usage: $0 [options]
--without-debug Build non-debug version
--use-comment Set the comment in the build
--with-fast-mutexes Use try/retry method of acquiring mutex
+ --without-fast-mutexes Don't use try/retry method of acquiring mutex
+ --without-perfschema Don't build with performance schema
+ --generate-feedback path Compile with feedback using the specified directory
+ to store the feedback files
+ --use-feedback path Compile using feedback information from the specified
+ directory
--with-debug Build debug version
+ --extra-debug-flag flag Add -Dflag to compiler flags
+ InnoDB supports the following debug flags,
+ UNIV_DEBUG, UNIV_SYNC_DEBUG, UNIV_MEM_DEBUG,
+ UNIV_DEBUG_THREAD_CREATION, UNIV_DEBUG_LOCK_VALIDATE,
+ UNIV_DEBUG_PRINT, UNIV_DEBUG_FILE_ACCESS,
+ UNIV_LIGHT_MEM_DEBUG, UNIV_LOG_DEBUG,
+ UNIV_IBUF_COUNT_DEBUG, UNIV_SEARCH_DEBUG,
+ UNIV_LOG_LSN_DEBUG, UNIV_ZIP_DEBUG, UNIV_AHI_DEBUG,
+ UNIV_DEBUG_VALGRIND, UNIV_SQL_DEBUG, UNIV_AIO_DEBUG,
+ UNIV_BTR_DEBUG, UNIV_LRU_DEBUG, UNIV_BUF_DEBUG,
+ UNIV_HASH_DEBUG, UNIV_LIST_DEBUG, UNIV_IBUF_DEBUG
--with-link-time-optimizer
Link time optimizations enabled (Requires GCC 4.5
if GCC used), available for icc as well. This flag
is only considered if also fast is set.
+ --with-mso Special flag used by Open64 compiler (requres at
+ least version 4.2.3) that enables optimisations
+ for multi-core scalability.
--configure-only Stop after running configure.
- --use-autotools Start by running autoconf, automake,.. tools
- --no-autotools Start from configure
--print-only Print commands that the script will execute,
but do not actually execute
--prefix=path Build with prefix 'path'
@@ -170,7 +187,7 @@ Usage: $0 [options]
MySQL use
--commercial Use commercial libraries
--gpl Use gpl libraries
- --compiler=[gcc|icc|forte|SunStudio] Select compiler
+ --compiler=[gcc|icc|forte|SunStudio|open64] Select compiler
--cpu=[x86|x86_64|sparc|itanium] Select CPU type
x86 => x86 and 32-bit binary
x86_64 => x86 and 64 bit binary
@@ -389,7 +406,8 @@ extended_usage()
platforms supported by this script.
The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides
- support for Nocona, K8, and other processors).
+ support for Nocona, K8, and other processors), this option is valid
+ when gcc is the compiler.
Use of the --debug option adds -g to the C/C++ flags.
@@ -397,10 +415,35 @@ extended_usage()
by calling the script as follows:
CC="/usr/local/bin/gcc" CXX="/usr/local/bin/gcc" BUILD/build_mccge.sh
- FreeBSD/x86/gcc
- ---------------
- No flags are used. Instead, configure determines the proper flags to
- use.
+ Feedback profiler on gcc
+ ------------------------
+ Using gcc --generate-feedback=path causes the following flags to be added
+ to the compiler flags.
+
+ --fprofile-generate
+ --fprofile-dir=path
+
+ Using gcc with --use-feedback=path causes the following flags to be added
+ to the compiler flags. --fprofile-correction indicates MySQL is a multi-
+ threaded application and thus counters can be inconsistent with each other
+ and the compiler should take this into account.
+
+ --fprofile-use
+ --fprofile-dir=path
+ --fprofile-correction
+
+ Feedback compilation using Open64
+ ---------------------------------
+
+ Using Open64 with --generate-feedback=path causes the following flags to
+ be added to the compiler flags.
+
+ -fb-create path/feedback
+
+ Using Open64 with --use-feedback=path causes the following flags to be
+ added to the compiler flags.
+
+ --fb-opt path/feedback
Linux/x86+Itanium/gcc
-------------
@@ -410,6 +453,9 @@ extended_usage()
added to the C/C++ flags. (To build a 32-bit binary on a 64-bit CPU,
use the --32 option as described previously.)
+ When gcc 4.5 is used and the user set --with-link-time-optimizer then
+ also --flto is added to compiler flags and linker flags.
+
Linux/x86+Itanium/icc
-------------
Flags used:
@@ -433,6 +479,19 @@ extended_usage()
added to the C/C++ flags; this provides optimisations specific to Core
2 Duo. This is added only when the --fast flag is set.
+ Linux/x86/Open64
+ ----------------
+ For normal builds use -O3, when fast flag is set one also adds
+ --march=auto to generate optimized builds for the CPU used. If
+ --with-link-time-optimizer is set also -ipa is set. There is also
+ a special flag --with-mso which can be set to get --mso set which
+ activates optimisation for multi-core scalability.
+
+ FreeBSD/x86/gcc
+ ---------------
+ No flags are used. Instead, configure determines the proper flags to
+ use.
+
Solaris/x86/gcc
---------------
All builds on Solaris are by default 64-bit, so -m64 is always used in
@@ -653,6 +712,9 @@ parse_compiler()
forte | SunStudio | sunstudio )
compiler="forte"
;;
+ open64 | Open64 )
+ compiler="open64"
+ ;;
*)
echo "Unknown compiler '$compiler'"
exit 1
@@ -686,6 +748,15 @@ parse_options()
--with-fast-mutexes)
with_fast_mutexes="yes"
;;
+ --without-fast-mutexes)
+ with_fast_mutexes="no"
+ ;;
+ --without-perfschema)
+ with_perfschema="no"
+ ;;
+ --with-mso)
+ with_mso="yes"
+ ;;
--use-tcmalloc)
use_tcmalloc="yes"
;;
@@ -693,6 +764,10 @@ parse_options()
with_debug_flag="yes"
fast_flag="no"
;;
+ --extra-debug-flag)
+ shift
+ extra_debug_flags="$extra_debug_flags -D$1"
+ ;;
--debug)
compile_debug_flag="yes"
;;
@@ -712,6 +787,14 @@ parse_options()
compiler=`get_key_value "$1"`
parse_compiler
;;
+ --generate-feedback)
+ shift
+ GENERATE_FEEDBACK_PATH="$1"
+ ;;
+ --use-feedback)
+ shift
+ USE_FEEDBACK_PATH="$1"
+ ;;
--cpu=*)
cpu_type=`get_key_value "$1"`
parse_cpu_type
@@ -746,12 +829,6 @@ parse_options()
--parallelism=*)
parallelism=`get_key_value "$1"`
;;
- --use-autotools)
- use_autotools="yes"
- ;;
- --no-autotools)
- use_autotools="no"
- ;;
--configure-only)
just_configure="yes"
;;
@@ -896,6 +973,9 @@ set_cpu_base()
#
init_configure_commands()
{
+ path=`dirname $0`
+ cp $path/cmake_configure.sh $path/../configure
+ chmod +x $path/../configure
cflags="$c_warnings $base_cflags $compiler_flags"
cxxflags="$cxx_warnings $base_cxxflags $compiler_flags"
configure="./configure $base_configs $with_flags"
@@ -1084,6 +1164,7 @@ set_with_debug_flags()
loc_debug_flags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
compiler_flags="$compiler_flags $loc_debug_flags"
fi
+ compiler_flags="$compiler_flags $extra_debug_flags"
fi
}
@@ -1105,7 +1186,7 @@ set_no_omit_frame_pointer_for_developers()
#
set_debug_flag()
{
- if test "x$compile_debug_flags" = "xyes" ; then
+ if test "x$compile_debug_flag" = "xyes" ; then
compiler_flags="$compiler_flags -g"
fi
}
@@ -1152,7 +1233,9 @@ set_base_configs()
fi
base_configs="$base_configs --with-pic"
base_configs="$base_configs --with-csv-storage-engine"
- base_configs="$base_configs --with-perfschema"
+ if test "x$with_perfschema" != "xno" ; then
+ base_configs="$base_configs --with-perfschema"
+ fi
}
#
@@ -1251,6 +1334,19 @@ set_gcc_special_options()
fi
}
+#
+# If we discover a Core 2 Duo architecture and we have enabled the fast
+# flag, we enable a compile especially optimised for Core 2 Duo. This
+# feature is currently available on Intel's icc compiler only.
+#
+set_icc_special_options()
+{
+ if test "x$fast_flag" = "xyes" && test "x$cpu_arg" = "xcore2" && \
+ test "x$compiler" = "xicc" ; then
+ compiler_flags="$compiler_flags -xT"
+ fi
+}
+
set_cc_and_cxx_for_gcc()
{
if test "x$CC" = "x" ; then
@@ -1271,26 +1367,23 @@ set_cc_and_cxx_for_icc()
fi
}
-set_cc_and_cxx_for_forte()
+set_cc_and_cxx_for_open64()
{
if test "x$CC" = "x" ; then
- CC="cc"
+ CC="opencc -static-libgcc -fno-exceptions"
fi
if test "x$CXX" = "x" ; then
- CXX="CC"
+ CXX="openCC -static-libgcc -fno-exceptions"
fi
}
-#
-# If we discover a Core 2 Duo architecture and we have enabled the fast
-# flag, we enable a compile especially optimised for Core 2 Duo. This
-# feature is currently available on Intel's icc compiler only.
-#
-set_icc_special_options()
+set_cc_and_cxx_for_forte()
{
- if test "x$fast_flag" = "xyes" && test "x$cpu_arg" = "xcore2" && \
- test "x$compiler" = "xicc" ; then
- compiler_flags="$compiler_flags -xT"
+ if test "x$CC" = "x" ; then
+ CC="cc"
+ fi
+ if test "x$CXX" = "x" ; then
+ CXX="CC"
fi
}
@@ -1358,11 +1451,44 @@ get_gcc_version()
}
#
+# Link time optimizer (interprocedural optimizations) for Open64
+#
+check_for_open64_link_time_optimizer()
+{
+ if test "x$with_link_time_optimizer" = "xyes" ; then
+ compiler_flags="$compiler_flags -ipa"
+ LDFLAGS="$LDFLAGS -ipa"
+ fi
+}
+
+#
+# Link time optimizer (interprocedural optimizations) for icc
+#
+check_for_icc_link_time_optimizer()
+{
+ if test "x$with_link_time_optimizer" = "xyes" ; then
+ compiler_flags="$compiler_flags -ipo"
+ LDFLAGS="$LDFLAGS -ipo"
+ fi
+}
+
+#
+# Link time optimizer (interprocedural optimizations) for forte
+#
+check_for_forte_link_time_optimizer()
+{
+ if test "x$with_link_time_optimizer" = "xyes" ; then
+ compiler_flags="$compiler_flags -ipo"
+ LDFLAGS="$LDFLAGS -ipo"
+ fi
+}
+
+#
# Link Time Optimizer in GCC (LTO) uses a parameter -flto
# which was added to GCC 4.5, if --with-link-time-optimizer
# is set then use this feature
#
-check_for_link_time_optimizer()
+check_for_gcc_link_time_optimizer()
{
get_gcc_version
if test "$gcc_version" -ge 405 && \
@@ -1371,11 +1497,37 @@ check_for_link_time_optimizer()
LDFLAGS="$LDFLAGS -flto"
fi
}
+
+set_feedback_for_gcc()
+{
+ if test "x$GENERATE_FEEDBACK_PATH" != "x" ; then
+ compiler_flags="$compiler_flags -fprofile-generate"
+ compiler_flags="$compiler_flags -fprofile-dir=$GENERATE_FEEDBACK_PATH"
+ elif test "x$USE_FEEDBACK_PATH" != "x" ; then
+ compiler_flags="$compiler_flags -fprofile-use"
+ compiler_flags="$compiler_flags -fprofile-correction"
+ compiler_flags="$compiler_flags -fprofile-dir=$USE_FEEDBACK_PATH"
+ fi
+}
+
+set_feedback_for_open64()
+{
+ if test "x$GENERATE_FEEDBACK_PATH" != "x" ; then
+ compiler_flags="$compiler_flags --fb-create=$GENERATE_FEEDBACK_PATH/feedback"
+ elif test "x$USE_FEEDBACK_PATH" != "x" ; then
+ compiler_flags="$compiler_flags --fb-opt=$USE_FEEDBACK_PATH/feedback"
+ fi
+}
+
#
# Linux Section
#
set_linux_configs()
{
+# Default to use --with-fast-mutexes on Linux
+ if test "x$with_fast_mutexes" = "x" ; then
+ base_configs="$base_configs --with-fast-mutexes"
+ fi
if test "x$cpu_base_type" != "xx86" && \
test "x$cpu_base_type" != "xitanium" ; then
usage "Only x86 and Itanium CPUs supported for Linux"
@@ -1392,19 +1544,14 @@ set_linux_configs()
if test "x$fast_flag" != "xno" ; then
if test "x$fast_flag" = "xyes" ; then
compiler_flags="$compiler_flags -O3"
- check_for_link_time_optimizer
+ check_for_gcc_link_time_optimizer
else
- compiler_flags="$compiler_flags -O2"
+ compiler_flags="$compiler_flags -O3"
fi
else
compiler_flags="$compiler_flags -O0"
fi
- check_64_bits
- if test "x$m64" = "xyes" ; then
- compiler_flags="$compiler_flags -m64"
- else
- compiler_flags="$compiler_flags -m32"
- fi
+ set_feedback_for_gcc
# configure will set proper compiler flags for gcc on Linux
elif test "x$compiler" = "xicc" ; then
compiler_flags="$compiler_flags -mp -restrict"
@@ -1414,16 +1561,36 @@ set_linux_configs()
fi
if test "x$fast_flag" != "xno" ; then
compiler_flags="$compiler_flags -O3 -unroll2 -ip"
- if test "x$fast_flag" = "xyes" && \
- test "x$with_link_time_optimizer" = "xyes" ; then
- compiler_flags="$compiler_flags -ipo"
- LDFLAGS="$LDFLAGS -ipo"
+ if test "x$fast_flag" = "xyes" ; then
+ check_for_icc_link_time_optimizer
+ fi
+ fi
+ elif test "x$compiler" = "xopen64" ; then
+ set_cc_and_cxx_for_open64
+ if test "x$fast_flag" != "xno" ; then
+ if test "x$fast_flag" = "xyes" ; then
+ compiler_flags="$compiler_flags -O3"
+# Generate code specific for the machine you run on
+ compiler_flags="$compiler_flags -march=auto"
+ check_for_open64_link_time_optimizer
+ if test "x$with_mso" = "xyes" ; then
+ compiler_flags="$compiler_flags -mso"
+ fi
+ else
+ compiler_flags="$compiler_flags -O3"
fi
fi
+ set_feedback_for_open64
else
- usage "Only gcc and icc compilers supported for Linux"
+ usage "Only gcc,icc and Open64 compilers supported for Linux"
exit 1
fi
+ check_64_bits
+ if test "x$m64" = "xyes" ; then
+ compiler_flags="$compiler_flags -m64"
+ else
+ compiler_flags="$compiler_flags -m32"
+ fi
}
#
@@ -1475,7 +1642,7 @@ set_solaris_configs()
if test "x$fast_flag" = "xyes" ; then
LDFLAGS="$LDFLAGS -O3"
compiler_flags="$compiler_flags -O3"
- check_for_link_time_optimizer
+ check_for_gcc_link_time_optimizer
else
if test "x$fast_flag" = "xgeneric" ; then
LDFLAGS="$LDFLAGS -O2"
@@ -1498,10 +1665,7 @@ set_solaris_configs()
if test "x$fast_flag" = "xyes" ; then
compiler_flags="$compiler_flags -xtarget=native"
compiler_flags="$compiler_flags -xunroll=3"
- if test "x$with_link_time_optimizer" = "xyes" ; then
- compiler_flags="$compiler_flags -xipo"
- LDFLAGS="$LDFLAGS -xipo"
- fi
+ check_for_forte_link_time_optimizer
else
compiler_flags="$compiler_flags -xtarget=generic"
fi
@@ -1612,17 +1776,6 @@ set_default_package()
fi
}
-set_autotool_flags()
-{
- if test "x$use_autotools" = "x" ; then
- if test "x$developer_flag" = "xno" ; then
- use_autotools="no"
- else
- use_autotools="yes"
- fi
- fi
-}
-
set_defaults_based_on_environment()
{
if test ! -z "$MYSQL_DEVELOPER" ; then
@@ -1674,25 +1827,28 @@ base_cxxflags=
base_configs=
debug_flags=
cxxflags=
+extra_debug_flags=
m64=
explicit_size_set=
datadir=
commands=
-use_autotools=
engine_configs=
ASFLAGS=
LDFLAGS=
use_tcmalloc=
without_comment="yes"
with_fast_mutexes=
+with_perfschema="yes"
with_link_time_optimizer=
+with_mso=
gcc_version="0"
+generate_feedback_path=
+use_feedback_path=
set_defaults_based_on_environment
parse_options "$@"
-set_autotool_flags
set_default_package
set -e
@@ -1793,9 +1949,6 @@ set_ccache_usage
# Set up commands variable from variables prepared for base
# configurations, compiler flags, and warnings flags.
#
-if test "x$use_autotools" = "xyes" ; then
- init_auto_commands
-fi
init_configure_commands
if test "x$just_configure" != "xyes" ; then
@@ -1806,8 +1959,8 @@ fi
# The commands variable now contains the entire command to be run for
# the build; we either execute it, or merely print it out.
#
-if test "x$just_print" = "xyes" ; then
- echo "$commands"
-else
+echo "Running command:"
+echo "$commands"
+if test "x$just_print" != "xyes" ; then
eval "set -x; $commands"
fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07809a8e29b..059d68e0a3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,30 +115,24 @@ ENDIF()
# Control aspects of the development environment which are
# specific to MySQL maintainers and developers.
#
-INCLUDE (CheckCCompilerFlag)
-OPTION(MYSQL_MAINTAINER_MODE "MySQL maintainer-specific development environment" OFF)
-# Whether the maintainer mode should be enabled.
+INCLUDE(maintainer)
+
+OPTION(MYSQL_MAINTAINER_MODE
+ "MySQL maintainer-specific development environment" OFF)
+
+# Whether the maintainer mode compiler options should be enabled.
IF(MYSQL_MAINTAINER_MODE)
- IF(CMAKE_COMPILER_IS_GNUCC)
- CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" HAVE_DECLARATION_AFTER_STATEMENT)
- IF(HAVE_DECLARATION_AFTER_STATEMENT)
- SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT "-Wdeclaration-after-statement")
- ENDIF()
- SET(MY_MAINTAINER_C_WARNINGS
- "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
+ IF(CMAKE_C_COMPILER_ID MATCHES "GNU")
+ SET_MYSQL_MAINTAINER_GNU_C_OPTIONS()
ENDIF()
- IF(CMAKE_COMPILER_IS_GNUCXX)
- SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_C_WARNINGS} -Wno-unused-parameter"
- CACHE STRING "C++ warning options used in maintainer builds.")
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS()
ENDIF()
- IF(CMAKE_COMPILER_IS_GNUCC)
- SET(MY_MAINTAINER_C_WARNINGS
- "${MY_MAINTAINER_C_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
- CACHE STRING "C warning options used in maintainer builds.")
+ IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
+ SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS()
ENDIF()
- # Do not make warnings in checks into errors.
- IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
- SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS()
ENDIF()
ENDIF()
diff --git a/client/mysql.cc b/client/mysql.cc
index 51c8b34b0a8..241cca49a5d 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1456,8 +1456,8 @@ static struct my_option my_long_options[] =
&opt_sigint_ignore, &opt_sigint_ignore, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"one-database", 'o',
- "Only update the default database. This is useful for skipping updates "
- "to other database in the update log.",
+ "Ignore statements except those that occur while the default "
+ "database is the one named at the command line.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef USE_POPEN
{"pager", OPT_PAGER,
@@ -2692,6 +2692,10 @@ static void get_current_db()
{
MYSQL_RES *res;
+ /* If one_database is set, current_db is not supposed to change. */
+ if (one_database)
+ return;
+
my_free(current_db);
current_db= NULL;
/* In case of error below current_db will be NULL */
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 342a67fbc29..4c4747c25de 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -44,6 +44,7 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
static uint opt_count_iterations= 0, my_end_arg;
static ulong opt_connect_timeout, opt_shutdown_timeout;
static char * unix_port=0;
+static char *opt_plugin_dir= 0, *opt_default_auth;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@@ -206,6 +207,13 @@ static struct my_option my_long_options[] =
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", &opt_shutdown_timeout,
&opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG,
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_PLUGIN_DIR,
+ "Default authentication client-side plugin to use.",
+ (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -342,6 +350,12 @@ int main(int argc,char *argv[])
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
error_flags= (myf)(opt_nobeep ? 0 : ME_BELL);
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (sql_connect(&mysql, option_wait))
{
/*
diff --git a/client/mysqldump.c b/client/mysqldump.c
index b47d88290a5..2d38e94f0fb 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -137,6 +137,7 @@ FILE *stderror_file=0;
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth;
/*
Dynamic_string wrapper functions. In this file use these
@@ -499,6 +500,13 @@ static struct my_option my_long_options[] =
&where, &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+ (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default_auth", OPT_PLUGIN_DIR,
+ "Default authentication client-side plugin to use.",
+ (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -1452,6 +1460,13 @@ static int connect_to_db(char *host, char *user,char *passwd)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
+
+ if (opt_plugin_dir && *opt_plugin_dir)
+ mysql_options(&mysql_connection, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+ if (opt_default_auth && *opt_default_auth)
+ mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd,
NULL,opt_mysql_port,opt_mysql_unix_port,
0)))
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index c47ba99b645..a755e11890e 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -8090,13 +8090,16 @@ static void dump_backtrace(void)
{
struct st_connection *conn= cur_con;
- my_safe_print_str("read_command_buf", read_command_buf,
- sizeof(read_command_buf));
+ fprintf(stderr, "read_command_buf (%p): ", read_command_buf);
+ my_safe_print_str(read_command_buf, sizeof(read_command_buf));
+
if (conn)
{
- my_safe_print_str("conn->name", conn->name, conn->name_len);
+ fprintf(stderr, "conn->name (%p): ", conn->name);
+ my_safe_print_str(conn->name, conn->name_len);
#ifdef EMBEDDED_LIBRARY
- my_safe_print_str("conn->cur_query", conn->cur_query, conn->cur_query_len);
+ fprintf(stderr, "conn->cur_query (%p): ", conn->cur_query);
+ my_safe_print_str(conn->cur_query, conn->cur_query_len);
#endif
}
fputs("Attempting backtrace...\n", stderr);
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake
index 56a6d897318..91d598db465 100644
--- a/cmake/build_configurations/mysql_release.cmake
+++ b/cmake/build_configurations/mysql_release.cmake
@@ -117,19 +117,26 @@ IF(UNIX)
OPTION(WITH_PIC "" ON) # Why?
- # Ensure aio is available on Linux (required by InnoDB)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
- CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
- IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO)
- MESSAGE(FATAL_ERROR "
- aio is required on Linux, you need to install the required library:
-
- Debian/Ubuntu: apt-get install libaio-dev
- RedHat/Fedora/Oracle Linux: yum install libaio-devel
- SuSE: zypper install libaio-devel
- ")
+ IF(NOT IGNORE_AIO_CHECK)
+ # Ensure aio is available on Linux (required by InnoDB)
+ CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
+ CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
+ IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO)
+ MESSAGE(FATAL_ERROR "
+ aio is required on Linux, you need to install the required library:
+
+ Debian/Ubuntu: apt-get install libaio-dev
+ RedHat/Fedora/Oracle Linux: yum install libaio-devel
+ SuSE: zypper install libaio-devel
+
+ If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.
+ ")
+ ENDIF()
ENDIF()
+
+ # Enable fast mutexes on Linux
+ OPTION(WITH_FAST_MUTEXES "" ON)
ENDIF()
ENDIF()
diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake
index 78006bd018c..96943e1a4c4 100644
--- a/cmake/do_abi_check.cmake
+++ b/cmake/do_abi_check.cmake
@@ -53,23 +53,27 @@
SET(abi_check_out ${BINARY_DIR}/abi_check.out)
FOREACH(file ${ABI_HEADERS})
- SET(tmpfile ${file}.pp.tmp)
- EXECUTE_PROCESS(
- COMMAND ${COMPILER}
- -E -nostdinc -dI -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include
- -I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql
- ${file}
- ERROR_QUIET OUTPUT_FILE ${tmpfile})
- EXECUTE_PROCESS(
- COMMAND sed -e
- "/^# /d" -e "/^[ ]*$/d" -e "/^#pragma GCC set_debug_pwd/d" -e "/^#ident/d"
- RESULT_VARIABLE result OUTPUT_FILE ${abi_check_out} INPUT_FILE ${tmpfile})
+ GET_FILENAME_COMPONENT(header_basename ${file} NAME)
+ SET(tmpfile ${BINARY_DIR}/${header_basename}.pp.tmp)
+
+ EXECUTE_PROCESS(
+ COMMAND ${COMPILER}
+ -E -nostdinc -dI -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include
+ -I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql
+ ${file}
+ ERROR_QUIET OUTPUT_FILE ${tmpfile})
+ EXECUTE_PROCESS(
+ COMMAND sed -e "/^# /d"
+ -e "/^[ ]*$/d"
+ -e "/^#pragma GCC set_debug_pwd/d"
+ -e "/^#ident/d"
+ RESULT_VARIABLE result OUTPUT_FILE ${abi_check_out} INPUT_FILE ${tmpfile})
IF(NOT ${result} EQUAL 0)
MESSAGE(FATAL_ERROR "sed returned error ${result}")
ENDIF()
FILE(REMOVE ${tmpfile})
- EXECUTE_PROCESS(COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE
- result)
+ EXECUTE_PROCESS(
+ COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result)
IF(NOT ${result} EQUAL 0)
MESSAGE(FATAL_ERROR
"ABI check found difference between ${file}.pp and ${abi_check_out}")
diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake
index c12a74cba31..5beb45ca524 100644
--- a/cmake/dtrace.cmake
+++ b/cmake/dtrace.cmake
@@ -153,13 +153,23 @@ ENDFUNCTION()
# to mysqld.
MACRO (DTRACE_INSTRUMENT_STATIC_LIBS target libs)
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND ENABLE_DTRACE)
+ # Filter out non-static libraries in the list, if any
+ SET(static_libs)
FOREACH(lib ${libs})
+ GET_TARGET_PROPERTY(libtype ${lib} TYPE)
+ IF(libtype MATCHES STATIC_LIBRARY)
+ SET(static_libs ${static_lics} ${lib})
+ ENDIF()
+ ENDFOREACH()
+
+ FOREACH(lib ${static_libs})
SET(dirs ${dirs} ${TARGET_OBJECT_DIRECTORY_${lib}})
ENDFOREACH()
+
SET (obj ${CMAKE_CURRENT_BINARY_DIR}/${target}_dtrace_all.o)
ADD_CUSTOM_COMMAND(
OUTPUT ${obj}
- DEPENDS ${libs}
+ DEPENDS ${static_libs}
COMMAND ${CMAKE_COMMAND}
-DDTRACE=${DTRACE}
-DOUTFILE=${obj}
diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake
new file mode 100644
index 00000000000..468b2f40084
--- /dev/null
+++ b/cmake/maintainer.cmake
@@ -0,0 +1,54 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# 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(CheckCCompilerFlag)
+
+# Setup GCC (GNU C compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS)
+ SET(MY_MAINTAINER_WARNINGS
+ "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
+ CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
+ HAVE_DECLARATION_AFTER_STATEMENT)
+ IF(HAVE_DECLARATION_AFTER_STATEMENT)
+ SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT
+ "-Wdeclaration-after-statement")
+ ENDIF()
+ SET(MY_MAINTAINER_C_WARNINGS
+ "${MY_MAINTAINER_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
+ CACHE STRING "C warning options used in maintainer builds.")
+ # Do not make warnings in checks into errors.
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
+ENDMACRO()
+
+# Setup G++ (GNU C++ compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS)
+ SET(MY_MAINTAINER_CXX_WARNINGS
+ "${MY_MAINTAINER_WARNINGS} -Wno-unused-parameter"
+ CACHE STRING "C++ warning options used in maintainer builds.")
+ENDMACRO()
+
+# Setup ICC (Intel C Compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS)
+ SET(MY_MAINTAINER_WARNINGS "-Wcheck")
+ SET(MY_MAINTAINER_C_WARNINGS "${MY_MAINTAINER_WARNINGS}"
+ CACHE STRING "C warning options used in maintainer builds.")
+ENDMACRO()
+
+# Setup ICPC (Intel C++ Compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS)
+ SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_WARNINGS}"
+ CACHE STRING "C++ warning options used in maintainer builds.")
+ENDMACRO()
+
diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake
index b4be85ff657..3ed93020e8a 100644
--- a/cmake/mysql_version.cmake
+++ b/cmake/mysql_version.cmake
@@ -21,17 +21,21 @@ SET(SHARED_LIB_MAJOR_VERSION "16")
SET(PROTOCOL_VERSION "10")
SET(DOT_FRM_VERSION "6")
+# Generate "something" to trigger cmake rerun when VERSION changes
+CONFIGURE_FILE(
+ ${CMAKE_SOURCE_DIR}/VERSION
+ ${CMAKE_BINARY_DIR}/VERSION.dep
+)
+
# Read value for a variable from VERSION.
MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
IF(NOT ${var})
- IF (EXISTS ${CMAKE_SOURCE_DIR}/VERSION)
- FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
- IF(str)
- STRING(REPLACE "${keyword}=" "" str ${str})
- STRING(REGEX REPLACE "[ ].*" "" str "${str}")
- SET(${var} ${str})
- ENDIF()
+ FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
+ IF(str)
+ STRING(REPLACE "${keyword}=" "" str ${str})
+ STRING(REGEX REPLACE "[ ].*" "" str "${str}")
+ SET(${var} ${str})
ENDIF()
ENDIF()
ENDMACRO()
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index bf34407db25..c6dd3fc451f 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -123,7 +123,7 @@ MACRO(MYSQL_ADD_PLUGIN)
# Update mysqld dependencies
SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
- ${target} CACHE INTERNAL "" FORCE)
+ ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE)
IF(ARG_MANDATORY)
SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server"
diff --git a/cmd-line-utils/libedit/CMakeLists.txt b/cmd-line-utils/libedit/CMakeLists.txt
index b0e375dfcbd..76fcfc3204e 100644
--- a/cmd-line-utils/libedit/CMakeLists.txt
+++ b/cmd-line-utils/libedit/CMakeLists.txt
@@ -26,6 +26,21 @@ int main()
tgoto(0,0,0);
return 0;
}" HAVE_DECL_TGOTO)
+IF(NOT HAVE_DECL_TGOTO)
+ # On Solaris 11, term.h is broken, curses.h is also required.
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <curses.h>
+ #include <term.h>
+ int main()
+ {
+ tgoto(0,0,0);
+ return 0;
+ }" HAVE_DECL_TGOTO2)
+ IF(HAVE_DECL_TGOTO2)
+ SET(HAVE_DECL_TGOTO 1 CACHE INTERNAL "" FORCE)
+ ENDIF()
+ENDIF()
+
SET(CMAKE_REQUIRED_LIBRARIES)
diff --git a/dbug/dbug.c b/dbug/dbug.c
index df26e2ee8ef..74568f55fe0 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -2377,6 +2377,25 @@ void _db_flush_()
}
+#ifndef __WIN__
+void _db_suicide_()
+{
+ int retval;
+ sigset_t new_mask;
+ sigfillset(&new_mask);
+
+ fprintf(stderr, "SIGKILL myself\n");
+ fflush(stderr);
+
+ retval= kill(getpid(), SIGKILL);
+ assert(retval == 0);
+ retval= sigsuspend(&new_mask);
+ fprintf(stderr, "sigsuspend returned %d errno %d \n", retval, errno);
+ assert(FALSE); /* With full signal mask, we should never return here. */
+}
+#endif /* ! __WIN__ */
+
+
void _db_lock_file_()
{
CODE_STATE *cs;
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
index 90602ef900c..ea3202aa9c9 100644
--- a/include/atomic/x86-gcc.h
+++ b/include/atomic/x86-gcc.h
@@ -78,15 +78,15 @@
: "memory")
/*
- Actually 32-bit reads/writes are always atomic on x86
- But we add LOCK_prefix here anyway to force memory barriers
+ Actually 32/64-bit reads/writes are always atomic on x86_64,
+ nonetheless issue memory barriers as appropriate.
*/
#define make_atomic_load_body(S) \
- ret=0; \
- asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
- : "=m" (*a), "=a" (ret) \
- : "r" (ret), "m" (*a) \
- : "memory")
+ /* Serialize prior load and store operations. */ \
+ asm volatile ("mfence" ::: "memory"); \
+ ret= *a; \
+ /* Prevent compiler from reordering instructions. */ \
+ asm volatile ("" ::: "memory")
#define make_atomic_store_body(S) \
asm volatile ("; xchg %0, %1;" \
: "=m" (*a), "+r" (v) \
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 42e8f88cc0e..bb7f5ddfb3d 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -356,6 +356,32 @@ extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
#define MY_UTF8MB4 "utf8mb4"
+/* Helper functions to handle contraction */
+static inline my_bool
+my_cs_have_contractions(CHARSET_INFO *cs)
+{
+ return cs->contractions != NULL;
+}
+
+static inline my_bool
+my_cs_can_be_contraction_head(CHARSET_INFO *cs, my_wc_t wc)
+{
+ return ((const char *)cs->contractions)[0x40*0x40 + (wc & 0xFF)];
+}
+
+static inline my_bool
+my_cs_can_be_contraction_tail(CHARSET_INFO *cs, my_wc_t wc)
+{
+ return ((const char *)cs->contractions)[0x40*0x40 + (wc & 0xFF)];
+}
+
+static inline uint16*
+my_cs_contraction2_weight(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2)
+{
+ return &cs->contractions[(wc1 - 0x40) * 0x40 + wc2 - 0x40];
+}
+
+
/* declarations for simple charsets */
extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
const uchar *, size_t);
@@ -430,6 +456,7 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs,
void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill);
+/* For 8-bit character set */
my_bool my_like_range_simple(CHARSET_INFO *cs,
const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many,
@@ -437,6 +464,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
char *min_str, char *max_str,
size_t *min_length, size_t *max_length);
+/* For ASCII-based multi-byte character sets with mbminlen=1 */
my_bool my_like_range_mb(CHARSET_INFO *cs,
const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many,
@@ -444,26 +472,13 @@ my_bool my_like_range_mb(CHARSET_INFO *cs,
char *min_str, char *max_str,
size_t *min_length, size_t *max_length);
-my_bool my_like_range_ucs2(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str, char *max_str,
- size_t *min_length, size_t *max_length);
-
-my_bool my_like_range_utf16(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str, char *max_str,
- size_t *min_length, size_t *max_length);
-
-my_bool my_like_range_utf32(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str, char *max_str,
- size_t *min_length, size_t *max_length);
+/* For other character sets, with arbitrary mbminlen and mbmaxlen numbers */
+my_bool my_like_range_generic(CHARSET_INFO *cs,
+ const char *ptr, size_t ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_length, size_t *max_length);
int my_wildcmp_8bit(CHARSET_INFO *,
const char *str,const char *str_end,
@@ -554,6 +569,8 @@ extern my_bool my_parse_charset_xml(const char *bug, size_t len,
int (*add)(CHARSET_INFO *cs));
extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
pchar c);
+extern size_t my_strcspn(CHARSET_INFO *cs, const char *str, const char *end,
+ const char *accept);
my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
diff --git a/include/my_dbug.h b/include/my_dbug.h
index e1cb3252601..7f8f5a1578d 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -132,7 +132,8 @@ extern const char* _db_get_func_(void);
#ifdef __WIN__
#define DBUG_SUICIDE() DBUG_ABORT()
#else
-#define DBUG_SUICIDE() (_db_flush_(), kill(getpid(), SIGKILL), pause())
+extern void _db_suicide_();
+#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
#endif
#else /* No debugger */
diff --git a/include/my_global.h b/include/my_global.h
index 8540c3f100e..a411ab8a118 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -611,6 +611,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#ifdef _WIN32
#define FN_LIBCHAR '\\'
#define FN_LIBCHAR2 '/'
+#define FN_DIRSEP "/\\" /* Valid directory separators */
#define FN_ROOTDIR "\\"
#define FN_DEVCHAR ':'
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
@@ -618,6 +619,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#else
#define FN_LIBCHAR '/'
#define FN_LIBCHAR2 '/'
+#define FN_DIRSEP "/" /* Valid directory separators */
#define FN_ROOTDIR "/"
#endif
diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h
index 78e3dbca577..8c2c97c68e5 100644
--- a/include/my_stacktrace.h
+++ b/include/my_stacktrace.h
@@ -45,7 +45,7 @@ C_MODE_START
#if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
void my_init_stacktrace();
void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
-void my_safe_print_str(const char* name, const char* val, int max_len);
+void my_safe_print_str(const char* val, int max_len);
void my_write_core(int sig);
#if BACKTRACE_DEMANGLE
char *my_demangle(const char *mangled_name, int *status);
diff --git a/include/my_sys.h b/include/my_sys.h
index 7b437e2a745..50abfb124f5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -456,7 +456,8 @@ typedef struct st_io_cache /* Used when cacheing files */
IO_CACHE_CALLBACK pre_close;
/*
Counts the number of times, when we were forced to use disk. We use it to
- increase the binlog_cache_disk_use status variable.
+ increase the binlog_cache_disk_use and binlog_stmt_cache_disk_use status
+ variables.
*/
ulong disk_writes;
void* arg; /* for use by pre/post_read */
diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h
index 41505da64af..8811c832949 100644
--- a/include/mysql/plugin_audit.h
+++ b/include/mysql/plugin_audit.h
@@ -42,6 +42,8 @@ struct mysql_event
LOG events occurs before emitting to the general query log.
ERROR events occur before transmitting errors to the user.
RESULT events occur after transmitting a resultset to the user.
+ STATUS events occur after transmitting a resultset or errors
+ to the user.
*/
#define MYSQL_AUDIT_GENERAL_CLASS 0
@@ -49,6 +51,7 @@ struct mysql_event
#define MYSQL_AUDIT_GENERAL_LOG 0
#define MYSQL_AUDIT_GENERAL_ERROR 1
#define MYSQL_AUDIT_GENERAL_RESULT 2
+#define MYSQL_AUDIT_GENERAL_STATUS 3
struct mysql_event_general
{
@@ -68,6 +71,43 @@ struct mysql_event_general
};
+/*
+ AUDIT CLASS : CONNECTION
+
+ CONNECT occurs after authentication phase is completed.
+ DISCONNECT occurs after connection is terminated.
+ CHANGE_USER occurs after COM_CHANGE_USER RPC is completed.
+*/
+
+#define MYSQL_AUDIT_CONNECTION_CLASS 1
+#define MYSQL_AUDIT_CONNECTION_CLASSMASK (1 << MYSQL_AUDIT_CONNECTION_CLASS)
+#define MYSQL_AUDIT_CONNECTION_CONNECT 0
+#define MYSQL_AUDIT_CONNECTION_DISCONNECT 1
+#define MYSQL_AUDIT_CONNECTION_CHANGE_USER 2
+
+struct mysql_event_connection
+{
+ unsigned int event_class;
+ unsigned int event_subclass;
+ int status;
+ unsigned long thread_id;
+ const char *user;
+ unsigned int user_length;
+ const char *priv_user;
+ unsigned int priv_user_length;
+ const char *external_user;
+ unsigned int external_user_length;
+ const char *proxy_user;
+ unsigned int proxy_user_length;
+ const char *host;
+ unsigned int host_length;
+ const char *ip;
+ unsigned int ip_length;
+ const char *database;
+ unsigned int database_length;
+};
+
+
/*************************************************************************
Here we define the descriptor structure, that is referred from
st_mysql_plugin.
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index b48cbca2e87..0e5b97d8717 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -208,6 +208,27 @@ struct mysql_event_general
unsigned long long general_time;
unsigned long long general_rows;
};
+struct mysql_event_connection
+{
+ unsigned int event_class;
+ unsigned int event_subclass;
+ int status;
+ unsigned long thread_id;
+ const char *user;
+ unsigned int user_length;
+ const char *priv_user;
+ unsigned int priv_user_length;
+ const char *external_user;
+ unsigned int external_user_length;
+ const char *proxy_user;
+ unsigned int proxy_user_length;
+ const char *host;
+ unsigned int host_length;
+ const char *ip;
+ unsigned int ip_length;
+ const char *database;
+ unsigned int database_length;
+};
struct st_mysql_audit
{
int interface_version;
diff --git a/include/mysys_err.h b/include/mysys_err.h
index 4067a3cfbd1..22ac74302a2 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -65,7 +65,8 @@ extern const char *globerrs[]; /* my_error_messages is here */
#define EE_FILE_NOT_CLOSED 30
#define EE_CHANGE_OWNERSHIP 31
#define EE_CHANGE_PERMISSIONS 32
-#define EE_ERROR_LAST 32 /* Copy last error nr */
+#define EE_CANT_SEEK 33
+#define EE_ERROR_LAST 33 /* Copy last error nr */
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */
/* exit codes for all MySQL programs */
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 545d03532c1..25f4b752a30 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -26,7 +26,6 @@ ${CMAKE_SOURCE_DIR}/regex
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${SSL_INTERNAL_INCLUDE_DIRS}
-${NDB_CLUSTER_INCLUDES}
${CMAKE_SOURCE_DIR}/sql/backup
)
@@ -110,7 +109,7 @@ SET(LIBS
dbug strings regex mysys vio
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
${LIBWRAP} ${LIBCRYPT} ${LIBDL}
- ${MYSQLD_STATIC_PLUGIN_LIBS} ${NDB_CLIENT_LIBS}
+ ${MYSQLD_STATIC_PLUGIN_LIBS}
sql_embedded
)
diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly
index 33d13d8edfd..426bcfa53c4 100644
--- a/mysql-test/collections/default.weekly
+++ b/mysql-test/collections/default.weekly
@@ -1,2 +1,2 @@
-perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
-perl mysql-test-run.pl --timer --force --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 large_tests.alter_table main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_1_2_ndb parts.partition_alter1_1_ndb parts.partition_alter1_2_innodb parts.partition_alter1_2_ndb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb rpl_ndb.rpl_truncate_7ndb_2
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=1st --experimental=collections/default.experimental 1st
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_1_2_ndb parts.partition_alter1_1_ndb parts.partition_alter1_2_innodb parts.partition_alter1_2_ndb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb rpl_ndb.rpl_truncate_7ndb_2
diff --git a/mysql-test/collections/test-bt b/mysql-test/collections/test-bt
index 3127e2aecb9..58f0c2c3cde 100644
--- a/mysql-test/collections/test-bt
+++ b/mysql-test/collections/test-bt
@@ -1,10 +1,10 @@
-perl mysql-test-run.pl --force --timer --comment=normal --skip-ndbcluster --report-features --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=ps --skip-ndbcluster --ps-protocol --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=funcs1+ps --suite=funcs_1 --ps-protocol --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=funcs2 --suite=funcs_2 --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=partitions --suite=parts --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=stress --suite=stress --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=jp --suite=jp --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=embedded --embedded-server --skip-rpl --skip-ndbcluster --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=nist --suite=nist --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=nist+ps --suite=nist --ps-protocol --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=normal --skip-ndbcluster --report-features --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs1+ps --suite=funcs_1 --ps-protocol --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs2 --suite=funcs_2 --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=partitions --suite=parts --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=jp --suite=jp --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=embedded --embedded-server --skip-rpl --skip-ndbcluster --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist --suite=nist --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist+ps --suite=nist --ps-protocol --experimental=collections/default.experimental
diff --git a/mysql-test/collections/test-bt-debug b/mysql-test/collections/test-bt-debug
index aec3d9fbef5..5fc1e15e0d2 100644
--- a/mysql-test/collections/test-bt-debug
+++ b/mysql-test/collections/test-bt-debug
@@ -1 +1 @@
-perl mysql-test-run.pl --force --timer --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental
diff --git a/mysql-test/collections/test-bt-fast b/mysql-test/collections/test-bt-fast
index c3ded443518..7978c8082f0 100644
--- a/mysql-test/collections/test-bt-fast
+++ b/mysql-test/collections/test-bt-fast
@@ -1,2 +1,2 @@
-perl mysql-test-run.pl --force --timer --comment=ps --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --comment=stress --suite=stress --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental
+perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index 900e46ff90a..54aa08ff3ab 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -304,5 +304,58 @@ BINLOG '
SHOW BINLOG EVENTS;
DROP TABLE t1;
+
+--echo
+--echo # BUG#54903 BINLOG statement toggles session variables
+--echo # ----------------------------------------------------------------------
+--echo # This test verify that BINLOG statement doesn't change current session's
+--echo # variables foreign_key_checks and unique_checks.
+--echo
+CREATE TABLE t1 (c1 INT KEY);
+
+SET @@SESSION.foreign_key_checks= ON;
+SET @@SESSION.unique_checks= ON;
+
+--echo # INSERT INTO t1 VALUES (1)
+--echo # foreign_key_checks=0 and unique_checks=0
+BINLOG '
+dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be ON
+SHOW SESSION VARIABLES LIKE "%_checks";
+
+--echo
+SET @@SESSION.foreign_key_checks= OFF;
+SET @@SESSION.unique_checks= OFF;
+
+--echo # INSERT INTO t1 VALUES(2)
+--echo # foreign_key_checks=1 and unique_checks=1
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+
+--echo # INSERT INTO t1 VALUES(2)
+--echo # foreign_key_checks=1 and unique_checks=1
+--echo # It should not change current session's variables, even error happens
+--error 1062
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+
+DROP TABLE t1;
+
disconnect fresh;
diff --git a/mysql-test/extra/binlog_tests/binlog_cache_stat.test b/mysql-test/extra/binlog_tests/binlog_cache_stat.test
new file mode 100644
index 00000000000..a602b098201
--- /dev/null
+++ b/mysql-test/extra/binlog_tests/binlog_cache_stat.test
@@ -0,0 +1,251 @@
+# Embedded server doesn't support binlog
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+# Creating tables
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (a int) engine=innodb;
+create table t2 (a int) engine=myisam;
+
+#
+# This test checks binlog_cache_use and binlog_cache_disk_use when
+# transactions are committed and after when they are aborted.
+#
+
+#
+# Checking commit.
+#
+--echo **** Preparing the enviroment to check commit and its effect on status variables.
+--echo **** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+let $exp_cache= 0;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 0;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which are long enough so they will be flushed to disk...
+--echo **** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+let $1=2000;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+commit;
+enable_query_log;
+let $exp_cache= 1;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+commit;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Non-Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+commit;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 1;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Mixed changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+commit;
+let $exp_cache= 3;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 2;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+#
+# Checking abort.
+#
+--echo **** Preparing the enviroment to check abort and its effect on the status variables.
+--echo **** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+let $exp_cache= 0;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 0;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which are long enough so they will be flushed to disk...
+--echo **** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+let $1=2000;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+rollback;
+enable_query_log;
+let $exp_cache= 1;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+rollback;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Non-Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+rollback;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 1;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Mixed changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+rollback;
+let $exp_cache= 3;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 2;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+drop table t1, t2;
diff --git a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
index 2526b2dd149..7b31a3ebf17 100644
--- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
+++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test
@@ -34,11 +34,11 @@ create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
let $table=t1;
let $count=0;
-insert delayed into t1 values (207);
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
inc $count;
--source include/wait_until_rows_count.inc
-insert delayed into t1 values (null);
+insert /*! delayed */ into t1 values (null);
inc $count;
--source include/wait_until_rows_count.inc
diff --git a/mysql-test/extra/binlog_tests/innodb_stat.test b/mysql-test/extra/binlog_tests/innodb_stat.test
deleted file mode 100644
index b31e99dfe71..00000000000
--- a/mysql-test/extra/binlog_tests/innodb_stat.test
+++ /dev/null
@@ -1,41 +0,0 @@
-# Embedded server doesn't support binlog
--- source include/not_embedded.inc
--- source include/have_innodb.inc
-
-#
-# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
-# Actually this test has nothing to do with innodb per se, it just requires
-# transactional table.
-#
-flush status;
-show status like "binlog_cache_use";
-show status like "binlog_cache_disk_use";
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-create table t1 (a int) engine=innodb;
-
-# Now we are going to create transaction which is long enough so its
-# transaction binlog will be flushed to disk...
-let $1=2000;
-disable_query_log;
-begin;
-while ($1)
-{
- eval insert into t1 values( $1 );
- dec $1;
-}
-commit;
-enable_query_log;
-show status like "binlog_cache_use";
-show status like "binlog_cache_disk_use";
-
-# Transaction which should not be flushed to disk and so should not
-# increase binlog_cache_disk_use.
-begin;
-delete from t1;
-commit;
-show status like "binlog_cache_use";
-show status like "binlog_cache_disk_use";
-drop table t1;
diff --git a/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test b/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
index 3d97ad10d17..385a82baa77 100644
--- a/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
+++ b/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
@@ -25,11 +25,13 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state
let $old_max_binlog_cache_size= query_get_value(SHOW VARIABLES LIKE "max_binlog_cache_size", Value, 1);
let $old_binlog_cache_size= query_get_value(SHOW VARIABLES LIKE "binlog_cache_size", Value, 1);
+let $old_max_binlog_stmt_cache_size= query_get_value(SHOW VARIABLES LIKE "max_binlog_stmt_cache_size", Value, 1);
+let $old_binlog_stmt_cache_size= query_get_value(SHOW VARIABLES LIKE "binlog_stmt_cache_size", Value, 1);
SET GLOBAL max_binlog_cache_size = 4096;
-# Becuase of bug#55377, we have to set binlog_cache_size until the bug is
-# fixed.
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
disconnect master;
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
@@ -47,14 +49,14 @@ connection master;
--echo *** Single statement on transactional table ***
--disable_query_log
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
eval INSERT INTO t1 (a, data) VALUES (1,
CONCAT($data, $data, $data, $data, $data));
--enable_query_log
--echo *** Single statement on non-transactional table ***
--disable_query_log
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
eval INSERT INTO t2 (a, data) VALUES (2,
CONCAT($data, $data, $data, $data, $data, $data));
--enable_query_log
@@ -74,7 +76,7 @@ eval INSERT INTO t2 (a, data) VALUES (5, $data);
--echo *** Single statement on both transactional and non-transactional tables. ***
--disable_query_log
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
eval UPDATE t2, t1 SET t2.data = CONCAT($data, $data, $data, $data),
t1.data = CONCAT($data, $data, $data, $data);
--enable_query_log
@@ -103,11 +105,11 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (1, $data);
--eval INSERT INTO t1 (a, data) VALUES (2, $data);
--eval INSERT INTO t1 (a, data) VALUES (3, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (4, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (5, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (6, $data);
--eval INSERT INTO t1 (a, data) VALUES (7, 's');
--eval INSERT INTO t2 (a, data) VALUES (8, 's');
@@ -130,9 +132,9 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (14, $data);
--eval INSERT INTO t1 (a, data) VALUES (15, $data);
--eval INSERT INTO t1 (a, data) VALUES (16, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (17, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (18, $data);
--eval INSERT INTO t1 (a, data) VALUES (19, 's');
--eval INSERT INTO t2 (a, data) VALUES (20, 's');
@@ -148,7 +150,7 @@ if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
if (`SELECT @@binlog_format = 'ROW'`)
{
--disable_query_log
- --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+ --error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
CREATE TABLE t4 SELECT * FROM t1;
--enable_query_log
}
@@ -162,9 +164,9 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (22, $data);
--eval INSERT INTO t1 (a, data) VALUES (23, $data);
--eval INSERT INTO t1 (a, data) VALUES (24, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (25, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (26, $data);
--eval INSERT INTO t1 (a, data) VALUES (27, 's');
--eval INSERT INTO t2 (a, data) VALUES (28, 's');
@@ -192,11 +194,11 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (1, $data);
--eval INSERT INTO t1 (a, data) VALUES (2, $data);
--eval INSERT INTO t1 (a, data) VALUES (3, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (4, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (5, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (6, $data);
--eval INSERT INTO t1 (a, data) VALUES (7, 's');
--eval INSERT INTO t2 (a, data) VALUES (8, 's');
@@ -221,11 +223,11 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (1, $data);
--eval INSERT INTO t1 (a, data) VALUES (2, $data);
--eval INSERT INTO t1 (a, data) VALUES (3, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (4, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (5, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (6, $data);
--eval INSERT INTO t1 (a, data) VALUES (7, 's');
--eval INSERT INTO t2 (a, data) VALUES (8, 's');
@@ -268,7 +270,7 @@ TRUNCATE TABLE t1;
BEGIN;
--disable_query_log
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
eval CALL p1($data);
--enable_query_log
COMMIT;
@@ -277,7 +279,7 @@ TRUNCATE TABLE t1;
BEGIN;
--disable_query_log
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
eval CALL p1($data);
--enable_query_log
ROLLBACK;
@@ -299,12 +301,12 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (1, $data);
--eval INSERT INTO t1 (a, data) VALUES (2, $data);
--eval INSERT INTO t1 (a, data) VALUES (3, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (4, $data);
SAVEPOINT sv;
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (5, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (6, $data);
--eval INSERT INTO t1 (a, data) VALUES (7, 's');
--eval INSERT INTO t2 (a, data) VALUES (8, 's');
@@ -331,11 +333,11 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (2, $data);
--eval INSERT INTO t2 (a, data) VALUES (3, $data);
--eval INSERT INTO t1 (a, data) VALUES (4, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (5, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (6, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (7, $data);
--eval UPDATE t2 SET data= CONCAT($data, $data);
--eval INSERT INTO t1 (a, data) VALUES (8, 's');
@@ -351,7 +353,7 @@ BEGIN;
--eval INSERT INTO t1 (a, data) VALUES (16, $data);
--eval INSERT INTO t2 (a, data) VALUES (17, $data);
--eval INSERT INTO t1 (a, data) VALUES (18, $data);
---error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--error ER_TRANS_CACHE_FULL, ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
--eval INSERT INTO t1 (a, data) VALUES (19, $data);
--enable_query_log
COMMIT;
@@ -367,10 +369,13 @@ let $diff_statement= SELECT * FROM t1;
--echo # [ On Slave ]
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
source include/stop_slave.inc;
source include/start_slave.inc;
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
+CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
connection master;
@@ -385,6 +390,10 @@ connection master;
--eval SET GLOBAL max_binlog_cache_size= $old_max_binlog_cache_size
--replace_result $old_binlog_cache_size ORIGINAL_VALUE
--eval SET GLOBAL binlog_cache_size= $old_binlog_cache_size
+--replace_result $old_max_binlog_stmt_cache_size ORIGINAL_VALUE
+--eval SET GLOBAL max_binlog_stmt_cache_size= $old_max_binlog_stmt_cache_size
+--replace_result $old_binlog_stmt_cache_size ORIGINAL_VALUE
+--eval SET GLOBAL binlog_stmt_cache_size= $old_binlog_stmt_cache_size
disconnect master;
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
@@ -415,6 +424,10 @@ source include/show_binlog_events.inc;
--eval SET GLOBAL max_binlog_cache_size= $old_max_binlog_cache_size
--replace_result $old_binlog_cache_size ORIGINAL_VALUE
--eval SET GLOBAL binlog_cache_size= $old_binlog_cache_size
+--replace_result $old_max_binlog_stmt_cache_size ORIGINAL_VALUE
+--eval SET GLOBAL max_binlog_stmt_cache_size= $old_max_binlog_stmt_cache_size
+--replace_result $old_binlog_stmt_cache_size ORIGINAL_VALUE
+--eval SET GLOBAL binlog_stmt_cache_size= $old_binlog_stmt_cache_size
source include/stop_slave.inc;
source include/start_slave.inc;
diff --git a/mysql-test/include/ctype_8bit.inc b/mysql-test/include/ctype_8bit.inc
new file mode 100644
index 00000000000..7259db54d05
--- /dev/null
+++ b/mysql-test/include/ctype_8bit.inc
@@ -0,0 +1,46 @@
+#
+# Test Unicode conversion, upper, lower
+#
+SELECT @@collation_connection;
+CREATE TABLE t1 AS SELECT ' ' AS a LIMIT 0;
+INSERT INTO t1 VALUES (0x00),(0x01),(0x02),(0x03),(0x04),(0x05),(0x06),(0x07);
+INSERT INTO t1 VALUES (0x08),(0x09),(0x0A),(0x0B),(0x0C),(0x0D),(0x0E),(0x0F);
+INSERT INTO t1 VALUES (0x10),(0x11),(0x12),(0x13),(0x14),(0x15),(0x16),(0x17);
+INSERT INTO t1 VALUES (0x18),(0x19),(0x1A),(0x1B),(0x1C),(0x1D),(0x1E),(0x1F);
+INSERT INTO t1 VALUES (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27);
+INSERT INTO t1 VALUES (0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+INSERT INTO t1 VALUES (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37);
+INSERT INTO t1 VALUES (0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+INSERT INTO t1 VALUES (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47);
+INSERT INTO t1 VALUES (0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+INSERT INTO t1 VALUES (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57);
+INSERT INTO t1 VALUES (0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+INSERT INTO t1 VALUES (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67);
+INSERT INTO t1 VALUES (0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+INSERT INTO t1 VALUES (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77);
+INSERT INTO t1 VALUES (0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+INSERT INTO t1 VALUES (0x80),(0x81),(0x82),(0x83),(0x84),(0x85),(0x86),(0x87);
+INSERT INTO t1 VALUES (0x88),(0x89),(0x8A),(0x8B),(0x8C),(0x8D),(0x8E),(0x8F);
+INSERT INTO t1 VALUES (0x90),(0x91),(0x92),(0x93),(0x94),(0x95),(0x96),(0x97);
+INSERT INTO t1 VALUES (0x98),(0x99),(0x9A),(0x9B),(0x9C),(0x9D),(0x9E),(0x9F);
+INSERT INTO t1 VALUES (0xA0),(0xA1),(0xA2),(0xA3),(0xA4),(0xA5),(0xA6),(0xA7);
+INSERT INTO t1 VALUES (0xA8),(0xA9),(0xAA),(0xAB),(0xAC),(0xAD),(0xAE),(0xAF);
+INSERT INTO t1 VALUES (0xB0),(0xB1),(0xB2),(0xB3),(0xB4),(0xB5),(0xB6),(0xB7);
+INSERT INTO t1 VALUES (0xB8),(0xB9),(0xBA),(0xBB),(0xBC),(0xBD),(0xBE),(0xBF);
+INSERT INTO t1 VALUES (0xC0),(0xC1),(0xC2),(0xC3),(0xC4),(0xC5),(0xC6),(0xC7);
+INSERT INTO t1 VALUES (0xC8),(0xC9),(0xCA),(0xCB),(0xCC),(0xCD),(0xCE),(0xCF);
+INSERT INTO t1 VALUES (0xD0),(0xD1),(0xD2),(0xD3),(0xD4),(0xD5),(0xD6),(0xD7);
+INSERT INTO t1 VALUES (0xD8),(0xD9),(0xDA),(0xDB),(0xDC),(0xDD),(0xDE),(0xDF);
+INSERT INTO t1 VALUES (0xE0),(0xE1),(0xE2),(0xE3),(0xE4),(0xE5),(0xE6),(0xE7);
+INSERT INTO t1 VALUES (0xE8),(0xE9),(0xEA),(0xEB),(0xEC),(0xED),(0xEE),(0xEF);
+INSERT INTO t1 VALUES (0xF0),(0xF1),(0xF2),(0xF3),(0xF4),(0xF5),(0xF6),(0xF7);
+INSERT INTO t1 VALUES (0xF8),(0xF9),(0xFA),(0xFB),(0xFC),(0xFD),(0xFE),(0xFF);
+SELECT
+ HEX(a) AS chr,
+ HEX(LOWER(a)) AS upper,
+ HEX(LOWER(a)) AS lower,
+ HEX(@utf8:=CONVERT(a USING utf8)) AS utf8,
+ HEX(@roundtrip:=CAST(@utf8 AS CHAR)) AS roundtrip,
+ if(a=BINARY @roundtrip,'','Round trip unsafe') AS issafe
+FROM t1 ORDER BY chr;
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_czech.inc b/mysql-test/include/ctype_czech.inc
new file mode 100644
index 00000000000..bc83d462a22
--- /dev/null
+++ b/mysql-test/include/ctype_czech.inc
@@ -0,0 +1,12 @@
+SELECT @@collation_connection;
+--echo #
+--echo # Bug#57737 Character sets: search fails with like, contraction, index
+--echo #
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch');
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1));
+SELECT * FROM t1 WHERE s1 LIKE 'ch';
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_like_ignorable.inc b/mysql-test/include/ctype_like_ignorable.inc
new file mode 100644
index 00000000000..9f2fa7ae741
--- /dev/null
+++ b/mysql-test/include/ctype_like_ignorable.inc
@@ -0,0 +1,11 @@
+SELECT @@collation_connection;
+--echo #
+--echo # Bug#57737 Character sets: search fails with like, contraction, index
+--echo # Part#2 - ignorable characters
+--echo #
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e');
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+DROP TABLE t1;
diff --git a/mysql-test/include/io_thd_fault_injection.inc b/mysql-test/include/io_thd_fault_injection.inc
new file mode 100644
index 00000000000..a76e46d772a
--- /dev/null
+++ b/mysql-test/include/io_thd_fault_injection.inc
@@ -0,0 +1,21 @@
+#
+# Takes the flag as an argument:
+# -- let $io_thd_injection_fault_flag=+d,fault_injection_new_file_rotate_event
+# -- source include/io_thd_fault_injection.inc
+#
+
+SET @old_debug=@@global.debug;
+-- disable_warnings
+-- source include/stop_slave.inc
+-- enable_warnings
+-- eval SET GLOBAL debug="+d,$io_thd_injection_fault_flag"
+
+START SLAVE io_thread;
+-- source include/wait_for_slave_io_to_stop.inc
+-- source include/wait_for_slave_io_error.inc
+
+-- eval SET GLOBAL debug="-d,$io_thd_injection_fault_flag"
+SET GLOBAL debug=@old_debug;
+
+# restart because slave is in bad shape
+-- source include/restart_mysqld.inc
diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc
index d92115f0a61..f750385e300 100644
--- a/mysql-test/include/restart_mysqld.inc
+++ b/mysql-test/include/restart_mysqld.inc
@@ -1,14 +1,16 @@
# Write file to make mysql-test-run.pl expect the "crash", but don't start
# it until it's told to
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
shutdown_server 10;
# Write file to make mysql-test-run.pl start up the server again
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--exec echo "restart" > $_expect_file_name
# Turn on reconnect
--enable_reconnect
diff --git a/mysql-test/include/show_slave_status.inc b/mysql-test/include/show_slave_status.inc
index 5cc04993487..235d3a08965 100644
--- a/mysql-test/include/show_slave_status.inc
+++ b/mysql-test/include/show_slave_status.inc
@@ -2,7 +2,7 @@
# that varies depending on where the test is executed.
--let $_items=$status_items
-if (`SELECT "XX$status_items" = "XX"`)
+if (!$status_items)
{
--die 'Variable status_items is NULL'
}
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index 028c8b32f87..231b7acb5b4 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -12801,3 +12801,9 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
DROP TABLE t1;
+#
+# BUG#58205 - Valgrind failure in fn_format when called from
+# archive_discover
+#
+CREATE TABLE `a/../`(a INT) ENGINE=ARCHIVE;
+DROP TABLE `a/../`;
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index dbeedb481cd..5adbefe104c 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -476,3 +476,24 @@ SELECT a FROM t2;
a
2
DROP TABLE t1, t2;
+#
+# Bug#39828 autoinc wraps around when offset and increment > 1
+#
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) engine=MyISAM;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES (18446744073709551601);
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=10;
+SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
+@@SESSION.AUTO_INCREMENT_OFFSET
+1
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+ERROR 22003: Out of range value for column 't1' at row 167
+SELECT * FROM t1;
+c1
+1
+18446744073709551601
+18446744073709551611
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=default;
+SET @@SESSION.AUTO_INCREMENT_OFFSET=default;
+DROP TABLE t1;
+End of 5.1 tests
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result
index d5ee7214cde..b65230e94b4 100644
--- a/mysql-test/r/ctype_cp1251.result
+++ b/mysql-test/r/ctype_cp1251.result
@@ -82,6 +82,314 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=cp1251
DROP TABLE t1;
#
+# Start of 5.1 tests
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp1251_general_ci
+CREATE TABLE t1 AS SELECT ' ' AS a LIMIT 0;
+INSERT INTO t1 VALUES (0x00),(0x01),(0x02),(0x03),(0x04),(0x05),(0x06),(0x07);
+INSERT INTO t1 VALUES (0x08),(0x09),(0x0A),(0x0B),(0x0C),(0x0D),(0x0E),(0x0F);
+INSERT INTO t1 VALUES (0x10),(0x11),(0x12),(0x13),(0x14),(0x15),(0x16),(0x17);
+INSERT INTO t1 VALUES (0x18),(0x19),(0x1A),(0x1B),(0x1C),(0x1D),(0x1E),(0x1F);
+INSERT INTO t1 VALUES (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27);
+INSERT INTO t1 VALUES (0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+INSERT INTO t1 VALUES (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37);
+INSERT INTO t1 VALUES (0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+INSERT INTO t1 VALUES (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47);
+INSERT INTO t1 VALUES (0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+INSERT INTO t1 VALUES (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57);
+INSERT INTO t1 VALUES (0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+INSERT INTO t1 VALUES (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67);
+INSERT INTO t1 VALUES (0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+INSERT INTO t1 VALUES (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77);
+INSERT INTO t1 VALUES (0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+INSERT INTO t1 VALUES (0x80),(0x81),(0x82),(0x83),(0x84),(0x85),(0x86),(0x87);
+INSERT INTO t1 VALUES (0x88),(0x89),(0x8A),(0x8B),(0x8C),(0x8D),(0x8E),(0x8F);
+INSERT INTO t1 VALUES (0x90),(0x91),(0x92),(0x93),(0x94),(0x95),(0x96),(0x97);
+INSERT INTO t1 VALUES (0x98),(0x99),(0x9A),(0x9B),(0x9C),(0x9D),(0x9E),(0x9F);
+INSERT INTO t1 VALUES (0xA0),(0xA1),(0xA2),(0xA3),(0xA4),(0xA5),(0xA6),(0xA7);
+INSERT INTO t1 VALUES (0xA8),(0xA9),(0xAA),(0xAB),(0xAC),(0xAD),(0xAE),(0xAF);
+INSERT INTO t1 VALUES (0xB0),(0xB1),(0xB2),(0xB3),(0xB4),(0xB5),(0xB6),(0xB7);
+INSERT INTO t1 VALUES (0xB8),(0xB9),(0xBA),(0xBB),(0xBC),(0xBD),(0xBE),(0xBF);
+INSERT INTO t1 VALUES (0xC0),(0xC1),(0xC2),(0xC3),(0xC4),(0xC5),(0xC6),(0xC7);
+INSERT INTO t1 VALUES (0xC8),(0xC9),(0xCA),(0xCB),(0xCC),(0xCD),(0xCE),(0xCF);
+INSERT INTO t1 VALUES (0xD0),(0xD1),(0xD2),(0xD3),(0xD4),(0xD5),(0xD6),(0xD7);
+INSERT INTO t1 VALUES (0xD8),(0xD9),(0xDA),(0xDB),(0xDC),(0xDD),(0xDE),(0xDF);
+INSERT INTO t1 VALUES (0xE0),(0xE1),(0xE2),(0xE3),(0xE4),(0xE5),(0xE6),(0xE7);
+INSERT INTO t1 VALUES (0xE8),(0xE9),(0xEA),(0xEB),(0xEC),(0xED),(0xEE),(0xEF);
+INSERT INTO t1 VALUES (0xF0),(0xF1),(0xF2),(0xF3),(0xF4),(0xF5),(0xF6),(0xF7);
+INSERT INTO t1 VALUES (0xF8),(0xF9),(0xFA),(0xFB),(0xFC),(0xFD),(0xFE),(0xFF);
+SELECT
+HEX(a) AS chr,
+HEX(LOWER(a)) AS upper,
+HEX(LOWER(a)) AS lower,
+HEX(@utf8:=CONVERT(a USING utf8)) AS utf8,
+HEX(@roundtrip:=CAST(@utf8 AS CHAR)) AS roundtrip,
+if(a=BINARY @roundtrip,'','Round trip unsafe') AS issafe
+FROM t1 ORDER BY chr;
+chr upper lower utf8 roundtrip issafe
+00 00 00 00 00
+01 01 01 01 01
+02 02 02 02 02
+03 03 03 03 03
+04 04 04 04 04
+05 05 05 05 05
+06 06 06 06 06
+07 07 07 07 07
+08 08 08 08 08
+09 09 09 09 09
+0A 0A 0A 0A 0A
+0B 0B 0B 0B 0B
+0C 0C 0C 0C 0C
+0D 0D 0D 0D 0D
+0E 0E 0E 0E 0E
+0F 0F 0F 0F 0F
+10 10 10 10 10
+11 11 11 11 11
+12 12 12 12 12
+13 13 13 13 13
+14 14 14 14 14
+15 15 15 15 15
+16 16 16 16 16
+17 17 17 17 17
+18 18 18 18 18
+19 19 19 19 19
+1A 1A 1A 1A 1A
+1B 1B 1B 1B 1B
+1C 1C 1C 1C 1C
+1D 1D 1D 1D 1D
+1E 1E 1E 1E 1E
+1F 1F 1F 1F 1F
+20 20 20 20 20
+21 21 21 21 21
+22 22 22 22 22
+23 23 23 23 23
+24 24 24 24 24
+25 25 25 25 25
+26 26 26 26 26
+27 27 27 27 27
+28 28 28 28 28
+29 29 29 29 29
+2A 2A 2A 2A 2A
+2B 2B 2B 2B 2B
+2C 2C 2C 2C 2C
+2D 2D 2D 2D 2D
+2E 2E 2E 2E 2E
+2F 2F 2F 2F 2F
+30 30 30 30 30
+31 31 31 31 31
+32 32 32 32 32
+33 33 33 33 33
+34 34 34 34 34
+35 35 35 35 35
+36 36 36 36 36
+37 37 37 37 37
+38 38 38 38 38
+39 39 39 39 39
+3A 3A 3A 3A 3A
+3B 3B 3B 3B 3B
+3C 3C 3C 3C 3C
+3D 3D 3D 3D 3D
+3E 3E 3E 3E 3E
+3F 3F 3F 3F 3F
+40 40 40 40 40
+41 61 61 41 41
+42 62 62 42 42
+43 63 63 43 43
+44 64 64 44 44
+45 65 65 45 45
+46 66 66 46 46
+47 67 67 47 47
+48 68 68 48 48
+49 69 69 49 49
+4A 6A 6A 4A 4A
+4B 6B 6B 4B 4B
+4C 6C 6C 4C 4C
+4D 6D 6D 4D 4D
+4E 6E 6E 4E 4E
+4F 6F 6F 4F 4F
+50 70 70 50 50
+51 71 71 51 51
+52 72 72 52 52
+53 73 73 53 53
+54 74 74 54 54
+55 75 75 55 55
+56 76 76 56 56
+57 77 77 57 57
+58 78 78 58 58
+59 79 79 59 59
+5A 7A 7A 5A 5A
+5B 5B 5B 5B 5B
+5C 5C 5C 5C 5C
+5D 5D 5D 5D 5D
+5E 5E 5E 5E 5E
+5F 5F 5F 5F 5F
+60 60 60 60 60
+61 61 61 61 61
+62 62 62 62 62
+63 63 63 63 63
+64 64 64 64 64
+65 65 65 65 65
+66 66 66 66 66
+67 67 67 67 67
+68 68 68 68 68
+69 69 69 69 69
+6A 6A 6A 6A 6A
+6B 6B 6B 6B 6B
+6C 6C 6C 6C 6C
+6D 6D 6D 6D 6D
+6E 6E 6E 6E 6E
+6F 6F 6F 6F 6F
+70 70 70 70 70
+71 71 71 71 71
+72 72 72 72 72
+73 73 73 73 73
+74 74 74 74 74
+75 75 75 75 75
+76 76 76 76 76
+77 77 77 77 77
+78 78 78 78 78
+79 79 79 79 79
+7A 7A 7A 7A 7A
+7B 7B 7B 7B 7B
+7C 7C 7C 7C 7C
+7D 7D 7D 7D 7D
+7E 7E 7E 7E 7E
+7F 7F 7F 7F 7F
+80 90 90 D082 80
+81 83 83 D083 81
+82 82 82 E2809A 82
+83 83 83 D193 83
+84 84 84 E2809E 84
+85 85 85 E280A6 85
+86 86 86 E280A0 86
+87 87 87 E280A1 87
+88 88 88 E282AC 88
+89 89 89 E280B0 89
+8A 9A 9A D089 8A
+8B 8B 8B E280B9 8B
+8C 9C 9C D08A 8C
+8D 9D 9D D08C 8D
+8E 9E 9E D08B 8E
+8F 9F 9F D08F 8F
+90 90 90 D192 90
+91 91 91 E28098 91
+92 92 92 E28099 92
+93 93 93 E2809C 93
+94 94 94 E2809D 94
+95 95 95 E280A2 95
+96 96 96 E28093 96
+97 97 97 E28094 97
+98 98 98 3F 3F Round trip unsafe
+99 99 99 E284A2 99
+9A 9A 9A D199 9A
+9B 9B 9B E280BA 9B
+9C 9C 9C D19A 9C
+9D 9D 9D D19C 9D
+9E 9E 9E D19B 9E
+9F 9F 9F D19F 9F
+A0 A0 A0 C2A0 A0
+A1 A2 A2 D08E A1
+A2 A2 A2 D19E A2
+A3 BC BC D088 A3
+A4 A4 A4 C2A4 A4
+A5 B4 B4 D290 A5
+A6 A6 A6 C2A6 A6
+A7 A7 A7 C2A7 A7
+A8 B8 B8 D081 A8
+A9 A9 A9 C2A9 A9
+AA BA BA D084 AA
+AB AB AB C2AB AB
+AC AC AC C2AC AC
+AD AD AD C2AD AD
+AE AE AE C2AE AE
+AF BF BF D087 AF
+B0 B0 B0 C2B0 B0
+B1 B1 B1 C2B1 B1
+B2 B3 B3 D086 B2
+B3 B3 B3 D196 B3
+B4 B4 B4 D291 B4
+B5 B5 B5 C2B5 B5
+B6 B6 B6 C2B6 B6
+B7 B7 B7 C2B7 B7
+B8 B8 B8 D191 B8
+B9 B9 B9 E28496 B9
+BA BA BA D194 BA
+BB BB BB C2BB BB
+BC BC BC D198 BC
+BD BE BE D085 BD
+BE BE BE D195 BE
+BF BF BF D197 BF
+C0 E0 E0 D090 C0
+C1 E1 E1 D091 C1
+C2 E2 E2 D092 C2
+C3 E3 E3 D093 C3
+C4 E4 E4 D094 C4
+C5 E5 E5 D095 C5
+C6 E6 E6 D096 C6
+C7 E7 E7 D097 C7
+C8 E8 E8 D098 C8
+C9 E9 E9 D099 C9
+CA EA EA D09A CA
+CB EB EB D09B CB
+CC EC EC D09C CC
+CD ED ED D09D CD
+CE EE EE D09E CE
+CF EF EF D09F CF
+D0 F0 F0 D0A0 D0
+D1 F1 F1 D0A1 D1
+D2 F2 F2 D0A2 D2
+D3 F3 F3 D0A3 D3
+D4 F4 F4 D0A4 D4
+D5 F5 F5 D0A5 D5
+D6 F6 F6 D0A6 D6
+D7 F7 F7 D0A7 D7
+D8 F8 F8 D0A8 D8
+D9 F9 F9 D0A9 D9
+DA FA FA D0AA DA
+DB FB FB D0AB DB
+DC FC FC D0AC DC
+DD FD FD D0AD DD
+DE FE FE D0AE DE
+DF FF FF D0AF DF
+E0 E0 E0 D0B0 E0
+E1 E1 E1 D0B1 E1
+E2 E2 E2 D0B2 E2
+E3 E3 E3 D0B3 E3
+E4 E4 E4 D0B4 E4
+E5 E5 E5 D0B5 E5
+E6 E6 E6 D0B6 E6
+E7 E7 E7 D0B7 E7
+E8 E8 E8 D0B8 E8
+E9 E9 E9 D0B9 E9
+EA EA EA D0BA EA
+EB EB EB D0BB EB
+EC EC EC D0BC EC
+ED ED ED D0BD ED
+EE EE EE D0BE EE
+EF EF EF D0BF EF
+F0 F0 F0 D180 F0
+F1 F1 F1 D181 F1
+F2 F2 F2 D182 F2
+F3 F3 F3 D183 F3
+F4 F4 F4 D184 F4
+F5 F5 F5 D185 F5
+F6 F6 F6 D186 F6
+F7 F7 F7 D187 F7
+F8 F8 F8 D188 F8
+F9 F9 F9 D189 F9
+FA FA FA D18A FA
+FB FB FB D18B FB
+FC FC FC D18C FC
+FD FD FD D18D FD
+FE FE FE D18E FE
+FF FF FF D18F FF
+DROP TABLE t1;
+#
+# End of 5.1 tests
+#
+#
# Start of 5.5 tests
#
#
diff --git a/mysql-test/r/ctype_like_range.result b/mysql-test/r/ctype_like_range.result
new file mode 100644
index 00000000000..a06c6ad9ed8
--- /dev/null
+++ b/mysql-test/r/ctype_like_range.result
@@ -0,0 +1,2310 @@
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a VARBINARY(32));
+INSERT INTO t1 (a) VALUES (''),('_'),('%'),('\_'),('\%'),('\\');
+INSERT INTO t1 (a) VALUES ('a'),('c');
+INSERT INTO t1 (a) VALUES ('a_'),('c_');
+INSERT INTO t1 (a) VALUES ('a%'),('c%');
+INSERT INTO t1 (a) VALUES ('aa'),('cc'),('ch');
+INSERT INTO t1 (a) VALUES ('aa_'),('cc_'),('ch_');
+INSERT INTO t1 (a) VALUES ('aa%'),('cc%'),('ch%');
+INSERT INTO t1 (a) VALUES ('aaa'),('ccc'),('cch');
+INSERT INTO t1 (a) VALUES ('aaa_'),('ccc_'),('cch_');
+INSERT INTO t1 (a) VALUES ('aaa%'),('ccc%'),('cch%');
+INSERT INTO t1 (a) VALUES ('aaaaaaaaaaaaaaaaaaaa');
+CREATE VIEW v1 AS
+SELECT id, 'a' AS name, a AS val FROM t1
+UNION
+SELECT id, 'mn', HEX(LIKE_RANGE_MIN(a, 16)) AS min FROM t1
+UNION
+SELECT id, 'mx', HEX(LIKE_RANGE_MAX(a, 16)) AS max FROM t1
+UNION
+SELECT id, 'sp', REPEAT('-', 32) AS sep FROM t1
+ORDER BY id, name;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00
+2 mx FF
+2 sp --------------------------------
+3 a %
+3 mn
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 6100
+9 mx 61FF
+9 sp --------------------------------
+10 a c_
+10 mn 6300
+10 mx 63FF
+10 sp --------------------------------
+11 a a%
+11 mn 61
+11 mx 61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 63
+12 mx 63FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 616100
+16 mx 6161FF
+16 sp --------------------------------
+17 a cc_
+17 mn 636300
+17 mx 6363FF
+17 sp --------------------------------
+18 a ch_
+18 mn 636800
+18 mx 6368FF
+18 sp --------------------------------
+19 a aa%
+19 mn 6161
+19 mx 6161FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 6363
+20 mx 6363FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 6368
+21 mx 6368FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61616100
+25 mx 616161FF
+25 sp --------------------------------
+26 a ccc_
+26 mn 63636300
+26 mx 636363FF
+26 sp --------------------------------
+27 a cch_
+27 mn 63636800
+27 mx 636368FF
+27 sp --------------------------------
+28 a aaa%
+28 mn 616161
+28 mx 616161FFFFFFFFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 636363
+29 mx 636363FFFFFFFFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 636368
+30 mx 636368FFFFFFFFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 61616161616161616161616161616161
+31 mx 61616161616161616161616161616161
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET latin1;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00
+2 mx FF
+2 sp --------------------------------
+3 a %
+3 mn 00000000000000000000000000000000
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 6100
+9 mx 61FF
+9 sp --------------------------------
+10 a c_
+10 mn 6300
+10 mx 63FF
+10 sp --------------------------------
+11 a a%
+11 mn 61000000000000000000000000000000
+11 mx 61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 63000000000000000000000000000000
+12 mx 63FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 616100
+16 mx 6161FF
+16 sp --------------------------------
+17 a cc_
+17 mn 636300
+17 mx 6363FF
+17 sp --------------------------------
+18 a ch_
+18 mn 636800
+18 mx 6368FF
+18 sp --------------------------------
+19 a aa%
+19 mn 61610000000000000000000000000000
+19 mx 6161FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 63630000000000000000000000000000
+20 mx 6363FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 63680000000000000000000000000000
+21 mx 6368FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61616100
+25 mx 616161FF
+25 sp --------------------------------
+26 a ccc_
+26 mn 63636300
+26 mx 636363FF
+26 sp --------------------------------
+27 a cch_
+27 mn 63636800
+27 mx 636368FF
+27 sp --------------------------------
+28 a aaa%
+28 mn 61616100000000000000000000000000
+28 mx 616161FFFFFFFFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 63636300000000000000000000000000
+29 mx 636363FFFFFFFFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 63636800000000000000000000000000
+30 mx 636368FFFFFFFFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 61616161616161616161616161616161
+31 mx 61616161616161616161616161616161
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00000000000000000000000000000000
+2 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+2 sp --------------------------------
+3 a %
+3 mn 00000000000000000000000000000000
+3 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 61000000000000000000000000000000
+9 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+9 sp --------------------------------
+10 a c_
+10 mn 63000000000000000000000000000000
+10 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+10 sp --------------------------------
+11 a a%
+11 mn 61000000000000000000000000000000
+11 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+11 sp --------------------------------
+12 a c%
+12 mn 63000000000000000000000000000000
+12 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 61610000000000000000000000000000
+16 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+16 sp --------------------------------
+17 a cc_
+17 mn 63630000000000000000000000000000
+17 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+17 sp --------------------------------
+18 a ch_
+18 mn 63680000000000000000000000000000
+18 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+18 sp --------------------------------
+19 a aa%
+19 mn 61610000000000000000000000000000
+19 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+19 sp --------------------------------
+20 a cc%
+20 mn 63630000000000000000000000000000
+20 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+20 sp --------------------------------
+21 a ch%
+21 mn 63680000000000000000000000000000
+21 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61616100000000000000000000000000
+25 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+25 sp --------------------------------
+26 a ccc_
+26 mn 63636300000000000000000000000000
+26 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+26 sp --------------------------------
+27 a cch_
+27 mn 63636800000000000000000000000000
+27 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+27 sp --------------------------------
+28 a aaa%
+28 mn 61616100000000000000000000000000
+28 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+28 sp --------------------------------
+29 a ccc%
+29 mn 63636300000000000000000000000000
+29 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+29 sp --------------------------------
+30 a cch%
+30 mn 63636800000000000000000000000000
+30 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 6161616161
+31 mx 6161616161
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 09090909090909090909090909090909
+2 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+2 sp --------------------------------
+3 a %
+3 mn 09090909090909090909090909090909
+3 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 61090909090909090909090909090909
+9 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+9 sp --------------------------------
+10 a c_
+10 mn 63090909090909090909090909090909
+10 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+10 sp --------------------------------
+11 a a%
+11 mn 61090909090909090909090909090909
+11 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+11 sp --------------------------------
+12 a c%
+12 mn 63090909090909090909090909090909
+12 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 61610909090909090909090909090909
+16 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+16 sp --------------------------------
+17 a cc_
+17 mn 63630909090909090909090909090909
+17 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+17 sp --------------------------------
+18 a ch_
+18 mn 63680909090909090909090909090909
+18 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+18 sp --------------------------------
+19 a aa%
+19 mn 61610909090909090909090909090909
+19 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+19 sp --------------------------------
+20 a cc%
+20 mn 63630909090909090909090909090909
+20 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+20 sp --------------------------------
+21 a ch%
+21 mn 63680909090909090909090909090909
+21 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61616109090909090909090909090909
+25 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+25 sp --------------------------------
+26 a ccc_
+26 mn 63636309090909090909090909090909
+26 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+26 sp --------------------------------
+27 a cch_
+27 mn 63636809090909090909090909090909
+27 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+27 sp --------------------------------
+28 a aaa%
+28 mn 61616109090909090909090909090909
+28 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+28 sp --------------------------------
+29 a ccc%
+29 mn 63636309090909090909090909090909
+29 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+29 sp --------------------------------
+30 a cch%
+30 mn 63636809090909090909090909090909
+30 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 6161616161
+31 mx 6161616161
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_czech_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 09090909090909090909090909090909
+2 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+2 sp --------------------------------
+3 a %
+3 mn 09090909090909090909090909090909
+3 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 61090909090909090909090909090909
+9 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+9 sp --------------------------------
+10 a c_
+10 mn 09090909090909090909090909090909
+10 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+10 sp --------------------------------
+11 a a%
+11 mn 61090909090909090909090909090909
+11 mx 61EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+11 sp --------------------------------
+12 a c%
+12 mn 09090909090909090909090909090909
+12 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 61610909090909090909090909090909
+16 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+16 sp --------------------------------
+17 a cc_
+17 mn 63090909090909090909090909090909
+17 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+17 sp --------------------------------
+18 a ch_
+18 mn 63680909090909090909090909090909
+18 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+18 sp --------------------------------
+19 a aa%
+19 mn 61610909090909090909090909090909
+19 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+19 sp --------------------------------
+20 a cc%
+20 mn 63090909090909090909090909090909
+20 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+20 sp --------------------------------
+21 a ch%
+21 mn 63680909090909090909090909090909
+21 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61616109090909090909090909090909
+25 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+25 sp --------------------------------
+26 a ccc_
+26 mn 63630909090909090909090909090909
+26 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+26 sp --------------------------------
+27 a cch_
+27 mn 63636809090909090909090909090909
+27 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+27 sp --------------------------------
+28 a aaa%
+28 mn 61616109090909090909090909090909
+28 mx 616161EFBFBFEFBFBFEFBFBFEFBFBF20
+28 sp --------------------------------
+29 a ccc%
+29 mn 63630909090909090909090909090909
+29 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+29 sp --------------------------------
+30 a cch%
+30 mn 63636809090909090909090909090909
+30 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 6161616161
+31 mx 6161616161
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_danish_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 09090909090909090909090909090909
+2 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+2 sp --------------------------------
+3 a %
+3 mn 09090909090909090909090909090909
+3 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+3 sp --------------------------------
+4 a \_
+4 mn 5F
+4 mx 5F
+4 sp --------------------------------
+5 a \%
+5 mn 25
+5 mx 25
+5 sp --------------------------------
+6 a \
+6 mn 5C
+6 mx 5C
+6 sp --------------------------------
+7 a a
+7 mn 61
+7 mx 61
+7 sp --------------------------------
+8 a c
+8 mn 63
+8 mx 63
+8 sp --------------------------------
+9 a a_
+9 mn 09090909090909090909090909090909
+9 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+9 sp --------------------------------
+10 a c_
+10 mn 63090909090909090909090909090909
+10 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+10 sp --------------------------------
+11 a a%
+11 mn 09090909090909090909090909090909
+11 mx EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF20
+11 sp --------------------------------
+12 a c%
+12 mn 63090909090909090909090909090909
+12 mx 63EFBFBFEFBFBFEFBFBFEFBFBFEFBFBF
+12 sp --------------------------------
+13 a aa
+13 mn 6161
+13 mx 6161
+13 sp --------------------------------
+14 a cc
+14 mn 6363
+14 mx 6363
+14 sp --------------------------------
+15 a ch
+15 mn 6368
+15 mx 6368
+15 sp --------------------------------
+16 a aa_
+16 mn 61610909090909090909090909090909
+16 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+16 sp --------------------------------
+17 a cc_
+17 mn 63630909090909090909090909090909
+17 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+17 sp --------------------------------
+18 a ch_
+18 mn 63680909090909090909090909090909
+18 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+18 sp --------------------------------
+19 a aa%
+19 mn 61610909090909090909090909090909
+19 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+19 sp --------------------------------
+20 a cc%
+20 mn 63630909090909090909090909090909
+20 mx 6363EFBFBFEFBFBFEFBFBFEFBFBF2020
+20 sp --------------------------------
+21 a ch%
+21 mn 63680909090909090909090909090909
+21 mx 6368EFBFBFEFBFBFEFBFBFEFBFBF2020
+21 sp --------------------------------
+22 a aaa
+22 mn 616161
+22 mx 616161
+22 sp --------------------------------
+23 a ccc
+23 mn 636363
+23 mx 636363
+23 sp --------------------------------
+24 a cch
+24 mn 636368
+24 mx 636368
+24 sp --------------------------------
+25 a aaa_
+25 mn 61610909090909090909090909090909
+25 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+25 sp --------------------------------
+26 a ccc_
+26 mn 63636309090909090909090909090909
+26 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+26 sp --------------------------------
+27 a cch_
+27 mn 63636809090909090909090909090909
+27 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+27 sp --------------------------------
+28 a aaa%
+28 mn 61610909090909090909090909090909
+28 mx 6161EFBFBFEFBFBFEFBFBFEFBFBF2020
+28 sp --------------------------------
+29 a ccc%
+29 mn 63636309090909090909090909090909
+29 mx 636363EFBFBFEFBFBFEFBFBFEFBFBF20
+29 sp --------------------------------
+30 a cch%
+30 mn 63636809090909090909090909090909
+30 mx 636368EFBFBFEFBFBFEFBFBFEFBFBF20
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 61616161090909090909090909090909
+31 mx 61616161EFBFBFEFBFBFEFBFBFEFBFBF
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0000
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000000000000000000000000000000
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610000
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630000
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610000000000000000000000000000
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630000000000000000000000000000
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610000
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630000
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680000
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000000000000000000000000
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000000000000000000000000
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000000000000000000000000
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610000
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630000
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680000
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100000000000000000000
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300000000000000000000
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800000000000000000000
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00610061006100610061006100610061
+31 mx 00610061006100610061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610009
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630009
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610009000900090009000900090009
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630009000900090009000900090009
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630009
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000900090009000900090009
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610009
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630009
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100090009000900090009
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300090009000900090009
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00610061006100610061006100610061
+31 mx 00610061006100610061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_czech_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610009
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00090009000900090009000900090009
+10 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610009000900090009000900090009
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00090009000900090009000900090009
+12 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 00630009000900090009000900090009
+17 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630009000900090009000900090009
+20 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610009
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00630063000900090009000900090009
+26 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100090009000900090009
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063000900090009000900090009
+29 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00610061006100610061006100610061
+31 mx 00610061006100610061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_danish_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00090009000900090009000900090009
+9 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630009
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00090009000900090009000900090009
+11 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630009000900090009000900090009
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630009
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000900090009000900090009
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00610061000900090009000900090009
+25 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630009
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061000900090009000900090009
+28 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300090009000900090009
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00610061006100610061006100610061
+31 mx 00610061006100610061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0000
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000000000000000000000000000000
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610000
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630000
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610000000000000000000000000000
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630000000000000000000000000000
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610000
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630000
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680000
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000000000000000000000000
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000000000000000000000000
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000000000000000000000000
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610000
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630000
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680000
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100000000000000000000
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300000000000000000000
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800000000000000000000
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 0061006100610061
+31 mx 0061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_unicode_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610009
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630009
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610009000900090009000900090009
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630009000900090009000900090009
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630009
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000900090009000900090009
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610009
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630009
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100090009000900090009
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300090009000900090009
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 0061006100610061
+31 mx 0061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_czech_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00610009
+9 mx 0061FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00090009000900090009000900090009
+10 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00610009000900090009000900090009
+11 mx 0061FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00090009000900090009000900090009
+12 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 00630009000900090009000900090009
+17 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630009000900090009000900090009
+20 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 0061006100610009
+25 mx 006100610061FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00630063000900090009000900090009
+26 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061006100090009000900090009
+28 mx 006100610061FFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063000900090009000900090009
+29 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 0061006100610061
+31 mx 0061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_danish_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 0009
+2 mx FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00090009000900090009000900090009
+3 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+3 sp --------------------------------
+4 a \_
+4 mn 005F
+4 mx 005F
+4 sp --------------------------------
+5 a \%
+5 mn 0025
+5 mx 0025
+5 sp --------------------------------
+6 a \
+6 mn 005C
+6 mx 005C
+6 sp --------------------------------
+7 a a
+7 mn 0061
+7 mx 0061
+7 sp --------------------------------
+8 a c
+8 mn 0063
+8 mx 0063
+8 sp --------------------------------
+9 a a_
+9 mn 00090009000900090009000900090009
+9 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00630009
+10 mx 0063FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00090009000900090009000900090009
+11 mx FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00630009000900090009000900090009
+12 mx 0063FFFFFFFFFFFFFFFFFFFFFFFFFFFF
+12 sp --------------------------------
+13 a aa
+13 mn 00610061
+13 mx 00610061
+13 sp --------------------------------
+14 a cc
+14 mn 00630063
+14 mx 00630063
+14 sp --------------------------------
+15 a ch
+15 mn 00630068
+15 mx 00630068
+15 sp --------------------------------
+16 a aa_
+16 mn 006100610009
+16 mx 00610061FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 006300630009
+17 mx 00630063FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 006300680009
+18 mx 00630068FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00610061000900090009000900090009
+19 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00630063000900090009000900090009
+20 mx 00630063FFFFFFFFFFFFFFFFFFFFFFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00630068000900090009000900090009
+21 mx 00630068FFFFFFFFFFFFFFFFFFFFFFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 006100610061
+22 mx 006100610061
+22 sp --------------------------------
+23 a ccc
+23 mn 006300630063
+23 mx 006300630063
+23 sp --------------------------------
+24 a cch
+24 mn 006300630068
+24 mx 006300630068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00610061000900090009000900090009
+25 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 0063006300630009
+26 mx 006300630063FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 0063006300680009
+27 mx 006300630068FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00610061000900090009000900090009
+28 mx 00610061FFFFFFFFFFFFFFFFFFFFFFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00630063006300090009000900090009
+29 mx 006300630063FFFFFFFFFFFFFFFFFFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00630063006800090009000900090009
+30 mx 006300630068FFFFFFFFFFFFFFFFFFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 0061006100610061
+31 mx 0061006100610061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00000000
+2 mx 0000FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000000000000000000000000000000
+3 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+3 sp --------------------------------
+4 a \_
+4 mn 0000005F
+4 mx 0000005F
+4 sp --------------------------------
+5 a \%
+5 mn 00000025
+5 mx 00000025
+5 sp --------------------------------
+6 a \
+6 mn 0000005C
+6 mx 0000005C
+6 sp --------------------------------
+7 a a
+7 mn 00000061
+7 mx 00000061
+7 sp --------------------------------
+8 a c
+8 mn 00000063
+8 mx 00000063
+8 sp --------------------------------
+9 a a_
+9 mn 0000006100000000
+9 mx 000000610000FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 0000006300000000
+10 mx 000000630000FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00000061000000000000000000000000
+11 mx 000000610000FFFF0000FFFF0000FFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00000063000000000000000000000000
+12 mx 000000630000FFFF0000FFFF0000FFFF
+12 sp --------------------------------
+13 a aa
+13 mn 0000006100000061
+13 mx 0000006100000061
+13 sp --------------------------------
+14 a cc
+14 mn 0000006300000063
+14 mx 0000006300000063
+14 sp --------------------------------
+15 a ch
+15 mn 0000006300000068
+15 mx 0000006300000068
+15 sp --------------------------------
+16 a aa_
+16 mn 000000610000006100000000
+16 mx 00000061000000610000FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 000000630000006300000000
+17 mx 00000063000000630000FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 000000630000006800000000
+18 mx 00000063000000680000FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00000061000000610000000000000000
+19 mx 00000061000000610000FFFF0000FFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00000063000000630000000000000000
+20 mx 00000063000000630000FFFF0000FFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00000063000000680000000000000000
+21 mx 00000063000000680000FFFF0000FFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 000000610000006100000061
+22 mx 000000610000006100000061
+22 sp --------------------------------
+23 a ccc
+23 mn 000000630000006300000063
+23 mx 000000630000006300000063
+23 sp --------------------------------
+24 a cch
+24 mn 000000630000006300000068
+24 mx 000000630000006300000068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00000061000000610000006100000000
+25 mx 0000006100000061000000610000FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00000063000000630000006300000000
+26 mx 0000006300000063000000630000FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 00000063000000630000006800000000
+27 mx 0000006300000063000000680000FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00000061000000610000006100000000
+28 mx 0000006100000061000000610000FFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00000063000000630000006300000000
+29 mx 0000006300000063000000630000FFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00000063000000630000006800000000
+30 mx 0000006300000063000000680000FFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00000061000000610000006100000061
+31 mx 00000061000000610000006100000061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_unicode_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00000009
+2 mx 0000FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000009000000090000000900000009
+3 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+3 sp --------------------------------
+4 a \_
+4 mn 0000005F
+4 mx 0000005F
+4 sp --------------------------------
+5 a \%
+5 mn 00000025
+5 mx 00000025
+5 sp --------------------------------
+6 a \
+6 mn 0000005C
+6 mx 0000005C
+6 sp --------------------------------
+7 a a
+7 mn 00000061
+7 mx 00000061
+7 sp --------------------------------
+8 a c
+8 mn 00000063
+8 mx 00000063
+8 sp --------------------------------
+9 a a_
+9 mn 0000006100000009
+9 mx 000000610000FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 0000006300000009
+10 mx 000000630000FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00000061000000090000000900000009
+11 mx 000000610000FFFF0000FFFF0000FFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00000063000000090000000900000009
+12 mx 000000630000FFFF0000FFFF0000FFFF
+12 sp --------------------------------
+13 a aa
+13 mn 0000006100000061
+13 mx 0000006100000061
+13 sp --------------------------------
+14 a cc
+14 mn 0000006300000063
+14 mx 0000006300000063
+14 sp --------------------------------
+15 a ch
+15 mn 0000006300000068
+15 mx 0000006300000068
+15 sp --------------------------------
+16 a aa_
+16 mn 000000610000006100000009
+16 mx 00000061000000610000FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 000000630000006300000009
+17 mx 00000063000000630000FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 000000630000006800000009
+18 mx 00000063000000680000FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00000061000000610000000900000009
+19 mx 00000061000000610000FFFF0000FFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00000063000000630000000900000009
+20 mx 00000063000000630000FFFF0000FFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00000063000000680000000900000009
+21 mx 00000063000000680000FFFF0000FFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 000000610000006100000061
+22 mx 000000610000006100000061
+22 sp --------------------------------
+23 a ccc
+23 mn 000000630000006300000063
+23 mx 000000630000006300000063
+23 sp --------------------------------
+24 a cch
+24 mn 000000630000006300000068
+24 mx 000000630000006300000068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00000061000000610000006100000009
+25 mx 0000006100000061000000610000FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00000063000000630000006300000009
+26 mx 0000006300000063000000630000FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 00000063000000630000006800000009
+27 mx 0000006300000063000000680000FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00000061000000610000006100000009
+28 mx 0000006100000061000000610000FFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00000063000000630000006300000009
+29 mx 0000006300000063000000630000FFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00000063000000630000006800000009
+30 mx 0000006300000063000000680000FFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00000061000000610000006100000061
+31 mx 00000061000000610000006100000061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_czech_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00000009
+2 mx 0000FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000009000000090000000900000009
+3 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+3 sp --------------------------------
+4 a \_
+4 mn 0000005F
+4 mx 0000005F
+4 sp --------------------------------
+5 a \%
+5 mn 00000025
+5 mx 00000025
+5 sp --------------------------------
+6 a \
+6 mn 0000005C
+6 mx 0000005C
+6 sp --------------------------------
+7 a a
+7 mn 00000061
+7 mx 00000061
+7 sp --------------------------------
+8 a c
+8 mn 00000063
+8 mx 00000063
+8 sp --------------------------------
+9 a a_
+9 mn 0000006100000009
+9 mx 000000610000FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 00000009000000090000000900000009
+10 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00000061000000090000000900000009
+11 mx 000000610000FFFF0000FFFF0000FFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00000009000000090000000900000009
+12 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+12 sp --------------------------------
+13 a aa
+13 mn 0000006100000061
+13 mx 0000006100000061
+13 sp --------------------------------
+14 a cc
+14 mn 0000006300000063
+14 mx 0000006300000063
+14 sp --------------------------------
+15 a ch
+15 mn 0000006300000068
+15 mx 0000006300000068
+15 sp --------------------------------
+16 a aa_
+16 mn 000000610000006100000009
+16 mx 00000061000000610000FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 00000063000000090000000900000009
+17 mx 000000630000FFFF0000FFFF0000FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 000000630000006800000009
+18 mx 00000063000000680000FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00000061000000610000000900000009
+19 mx 00000061000000610000FFFF0000FFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00000063000000090000000900000009
+20 mx 000000630000FFFF0000FFFF0000FFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00000063000000680000000900000009
+21 mx 00000063000000680000FFFF0000FFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 000000610000006100000061
+22 mx 000000610000006100000061
+22 sp --------------------------------
+23 a ccc
+23 mn 000000630000006300000063
+23 mx 000000630000006300000063
+23 sp --------------------------------
+24 a cch
+24 mn 000000630000006300000068
+24 mx 000000630000006300000068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00000061000000610000006100000009
+25 mx 0000006100000061000000610000FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00000063000000630000000900000009
+26 mx 00000063000000630000FFFF0000FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 00000063000000630000006800000009
+27 mx 0000006300000063000000680000FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00000061000000610000006100000009
+28 mx 0000006100000061000000610000FFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00000063000000630000000900000009
+29 mx 00000063000000630000FFFF0000FFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00000063000000630000006800000009
+30 mx 0000006300000063000000680000FFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00000061000000610000006100000061
+31 mx 00000061000000610000006100000061
+31 sp --------------------------------
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_danish_ci;
+SELECT * FROM v1;
+id name val
+1 a
+1 mn
+1 mx
+1 sp --------------------------------
+2 a _
+2 mn 00000009
+2 mx 0000FFFF
+2 sp --------------------------------
+3 a %
+3 mn 00000009000000090000000900000009
+3 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+3 sp --------------------------------
+4 a \_
+4 mn 0000005F
+4 mx 0000005F
+4 sp --------------------------------
+5 a \%
+5 mn 00000025
+5 mx 00000025
+5 sp --------------------------------
+6 a \
+6 mn 0000005C
+6 mx 0000005C
+6 sp --------------------------------
+7 a a
+7 mn 00000061
+7 mx 00000061
+7 sp --------------------------------
+8 a c
+8 mn 00000063
+8 mx 00000063
+8 sp --------------------------------
+9 a a_
+9 mn 00000009000000090000000900000009
+9 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+9 sp --------------------------------
+10 a c_
+10 mn 0000006300000009
+10 mx 000000630000FFFF
+10 sp --------------------------------
+11 a a%
+11 mn 00000009000000090000000900000009
+11 mx 0000FFFF0000FFFF0000FFFF0000FFFF
+11 sp --------------------------------
+12 a c%
+12 mn 00000063000000090000000900000009
+12 mx 000000630000FFFF0000FFFF0000FFFF
+12 sp --------------------------------
+13 a aa
+13 mn 0000006100000061
+13 mx 0000006100000061
+13 sp --------------------------------
+14 a cc
+14 mn 0000006300000063
+14 mx 0000006300000063
+14 sp --------------------------------
+15 a ch
+15 mn 0000006300000068
+15 mx 0000006300000068
+15 sp --------------------------------
+16 a aa_
+16 mn 000000610000006100000009
+16 mx 00000061000000610000FFFF
+16 sp --------------------------------
+17 a cc_
+17 mn 000000630000006300000009
+17 mx 00000063000000630000FFFF
+17 sp --------------------------------
+18 a ch_
+18 mn 000000630000006800000009
+18 mx 00000063000000680000FFFF
+18 sp --------------------------------
+19 a aa%
+19 mn 00000061000000610000000900000009
+19 mx 00000061000000610000FFFF0000FFFF
+19 sp --------------------------------
+20 a cc%
+20 mn 00000063000000630000000900000009
+20 mx 00000063000000630000FFFF0000FFFF
+20 sp --------------------------------
+21 a ch%
+21 mn 00000063000000680000000900000009
+21 mx 00000063000000680000FFFF0000FFFF
+21 sp --------------------------------
+22 a aaa
+22 mn 000000610000006100000061
+22 mx 000000610000006100000061
+22 sp --------------------------------
+23 a ccc
+23 mn 000000630000006300000063
+23 mx 000000630000006300000063
+23 sp --------------------------------
+24 a cch
+24 mn 000000630000006300000068
+24 mx 000000630000006300000068
+24 sp --------------------------------
+25 a aaa_
+25 mn 00000061000000610000000900000009
+25 mx 00000061000000610000FFFF0000FFFF
+25 sp --------------------------------
+26 a ccc_
+26 mn 00000063000000630000006300000009
+26 mx 0000006300000063000000630000FFFF
+26 sp --------------------------------
+27 a cch_
+27 mn 00000063000000630000006800000009
+27 mx 0000006300000063000000680000FFFF
+27 sp --------------------------------
+28 a aaa%
+28 mn 00000061000000610000000900000009
+28 mx 00000061000000610000FFFF0000FFFF
+28 sp --------------------------------
+29 a ccc%
+29 mn 00000063000000630000006300000009
+29 mx 0000006300000063000000630000FFFF
+29 sp --------------------------------
+30 a cch%
+30 mn 00000063000000630000006800000009
+30 mx 0000006300000063000000680000FFFF
+30 sp --------------------------------
+31 a aaaaaaaaaaaaaaaaaaaa
+31 mn 00000061000000610000006100000061
+31 mx 00000061000000610000006100000061
+31 sp --------------------------------
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result
index 4730b4df668..0b061f507a7 100644
--- a/mysql-test/r/ctype_many.result
+++ b/mysql-test/r/ctype_many.result
@@ -1684,6 +1684,9 @@ ARMENIAN CAPIT ECH 2
ARMENIAN CAPIT ZA 2
DROP TABLE t1;
#
+# Start of 5.5 tests
+#
+#
# WL#1213 Implement 4-byte UTF8, UTF16 and UTF32
# Testing that only utf8mb4 is superset for utf8
# No other Unicode character set pairs have superset/subset relations
@@ -1739,3 +1742,22 @@ ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf8mb4_
SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1;
ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat'
DROP TABLE t1;
+#
+# Bug#58321 No warning when characters outside BMP0 is converted to UCS2
+#
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (0x10082), (0x12345);
+INSERT INTO t2 SELECT * FROM t1;
+Warnings:
+Warning 1366 Incorrect string value: '\x00\x01\x00\x82' for column 'a' at row 1
+Warning 1366 Incorrect string value: '\x00\x01\x23\x45' for column 'a' at row 2
+SELECT HEX(a) FROM t2;
+HEX(a)
+003F
+003F
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# End of 5.5 tests
+#
diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result
index 04727f84ff2..7b9023578b3 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -2888,3 +2888,101 @@ a hex(b) c
DROP TABLE t1;
set names utf8;
End for 5.0 tests
+#
+# Start of 5.5 tests
+#
+SET collation_connection=utf8_czech_ci;
+SELECT @@collation_connection;
+@@collation_connection
+utf8_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch');
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1));
+SELECT * FROM t1 WHERE s1 LIKE 'ch';
+s1
+ch
+DROP TABLE t1;
+SELECT @@collation_connection;
+@@collation_connection
+utf8_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+# Part#2 - ignorable characters
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e');
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+61000000000009
+61
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+61000000000009
+61
+DROP TABLE t1;
+SET collation_connection=ucs2_czech_ci;
+SELECT @@collation_connection;
+@@collation_connection
+ucs2_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch');
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1));
+SELECT * FROM t1 WHERE s1 LIKE 'ch';
+s1
+ch
+DROP TABLE t1;
+SELECT @@collation_connection;
+@@collation_connection
+ucs2_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+# Part#2 - ignorable characters
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e');
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+0061000000000000000000000009
+0061
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+0061000000000000000000000009
+0061
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result
index d83ef2af09e..18adaf2f79c 100644
--- a/mysql-test/r/ctype_utf16_uca.result
+++ b/mysql-test/r/ctype_utf16_uca.result
@@ -2368,6 +2368,52 @@ NULL
NULL
NULL
drop table t1;
+SET collation_connection=utf16_czech_ci;
+SELECT @@collation_connection;
+@@collation_connection
+utf16_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch');
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1));
+SELECT * FROM t1 WHERE s1 LIKE 'ch';
+s1
+ch
+DROP TABLE t1;
+SELECT @@collation_connection;
+@@collation_connection
+utf16_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+# Part#2 - ignorable characters
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e');
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+0061000000000000000000000009
+0061
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+0061000000000000000000000009
+0061
+DROP TABLE t1;
#
# End of 5.5 tests
#
diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result
index 5006009fc9c..fd5a4199217 100644
--- a/mysql-test/r/ctype_utf32_uca.result
+++ b/mysql-test/r/ctype_utf32_uca.result
@@ -2368,6 +2368,52 @@ NULL
NULL
NULL
drop table t1;
+SET collation_connection=utf32_czech_ci;
+SELECT @@collation_connection;
+@@collation_connection
+utf32_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch');
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT * FROM t1 WHERE s1 LIKE 'c%';
+s1
+c
+ce
+cé
+ch
+ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1));
+SELECT * FROM t1 WHERE s1 LIKE 'ch';
+s1
+ch
+DROP TABLE t1;
+SELECT @@collation_connection;
+@@collation_connection
+utf32_czech_ci
+#
+# Bug#57737 Character sets: search fails with like, contraction, index
+# Part#2 - ignorable characters
+#
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e');
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+00000061000000000000000000000000000000000000000000000009
+00000061
+ALTER TABLE t1 ADD KEY s1 (s1);
+SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%';
+HEX(s1)
+00000061000000000000000000000000000000000000000000000009
+00000061
+DROP TABLE t1;
#
# End of 5.5 tests
#
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 53cd89c13c1..a86eabc3192 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -400,4 +400,30 @@ SELECT 0 FROM
(SELECT 0) t61;
0
0
+#
+# A nested materialized derived table is used before being populated.
+# (addon for bug#19077)
+#
+CREATE TABLE t1 (i INT, j BIGINT);
+INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
+SELECT * FROM (SELECT MIN(i) FROM t1
+WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
+MIN(i)
+1
+DROP TABLE t1;
# End of 5.0 tests
+#
+# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
+# temptable views
+#
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT, KEY (b));
+INSERT INTO t1 VALUES (1),(1);
+INSERT INTO t2 VALUES (1),(1);
+CREATE algorithm=temptable VIEW v1 AS
+SELECT 1 FROM t1 LEFT JOIN t1 t3 ON 1 > (SELECT 1 FROM t1);
+CREATE algorithm=temptable VIEW v2 AS SELECT 1 FROM t2;
+EXPLAIN SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2);
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1, t2;
+DROP VIEW v1, v2;
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index 69be0107b8f..01b93df6894 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -1046,6 +1046,18 @@ INSERT INTO t1 values (0),(0);
SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d));
ERROR 22007: Illegal non geometric '(select 1 from (select (1 = group_concat(`test`.`t1`.`f1` separator ',')) AS `1 IN (GROUP_CONCAT(t1.f1))` from `test`.`t1` join `test`.`t1` `t` group by `t`.`f1`) `d`)' value found during parsing
DROP TABLE t1;
+#
+# Bug#58396 group_concat and explain extended are still crashy
+#
+CREATE TABLE t1(a INT);
+EXPLAIN EXTENDED SELECT UPDATEXML('1', a, '1')
+FROM t1 ORDER BY (SELECT GROUP_CONCAT(1) FROM t1);
+ERROR HY000: Only constant XPATH queries are supported
+SHOW WARNINGS;
+Level Code Message
+Error 1105 Only constant XPATH queries are supported
+Note 1003 select updatexml('1',`test`.`t1`.`a`,'1') AS `UPDATEXML('1', a, '1')` from `test`.`t1` order by (select group_concat(1 separator ',') from `test`.`t1`)
+DROP TABLE t1;
End of 5.1 tests
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a VARCHAR(6), b INT);
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 5f874f4665d..bc295ec7b44 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -1746,3 +1746,18 @@ MAX(c1) MIN(c1)
-00:00:01 -00:00:01
DROP TABLE t1;
# End of the bug#56120
+#
+# Bug#57932 "query with AVG(DISTINCT) returns NULL if last
+# aggregated value was NULL"
+#
+CREATE TABLE t1 (col_int_nokey int(11));
+INSERT INTO t1 VALUES (7),(8),(NULL);
+SELECT AVG(DISTINCT col_int_nokey) FROM t1;
+AVG(DISTINCT col_int_nokey)
+7.5000
+SELECT AVG(DISTINCT outr.col_int_nokey) FROM t1 AS outr LEFT JOIN t1 AS outr2 ON
+outr.col_int_nokey = outr2.col_int_nokey;
+AVG(DISTINCT outr.col_int_nokey)
+7.5000
+DROP TABLE t1;
+# End of the bug#57932
diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result
index 908e85c1652..8412317c91d 100644
--- a/mysql-test/r/func_group_innodb.result
+++ b/mysql-test/r/func_group_innodb.result
@@ -145,3 +145,50 @@ select count(*), min(7), max(7) from t2m, t1i;
count(*) min(7) max(7)
0 NULL NULL
drop table t1m, t1i, t2m, t2i;
+#
+# Bug #57954: BIT_AND function returns incorrect results when
+# semijoin=on
+CREATE TABLE c (
+pk INT,
+col_varchar_key VARCHAR(1),
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO c VALUES (11,NULL);
+INSERT INTO c VALUES (16,'c');
+CREATE TABLE bb (
+pk INT,
+col_varchar_key VARCHAR(1),
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO bb VALUES (10,NULL);
+SELECT straight_join BIT_AND(c.pk)
+FROM
+bb, c
+WHERE c.col_varchar_key='ABC'
+ORDER BY c.pk;
+BIT_AND(c.pk)
+18446744073709551615
+DROP TABLE c,bb;
+#
+# Bug #58050: BIT_OR and BIT_XOR return incorrect results when
+# semijoin=on
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1, 1, 1);
+CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1, 1, NULL);
+SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+pk b c
+SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+BIT_OR(t1.b)
+0
+SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+BIT_AND(t1.b)
+18446744073709551615
+SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+BIT_XOR(t1.b)
+0
+DROP TABLE t1, t2;
+End of 5.5 tests
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index 068ab343c89..c9552d9e39f 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -351,6 +351,12 @@ GREATEST(a, (SELECT b FROM t1 LIMIT 1))
3
1
DROP TABLE t1;
+SELECT INET_NTOA(0);
+INET_NTOA(0)
+0.0.0.0
+SELECT '1' IN ('1', INET_NTOA(0));
+'1' IN ('1', INET_NTOA(0))
+1
#
# Bug #52165: Assertion failed: file .\dtoa.c, line 465
#
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index f01d46a9f41..41fe9c096b0 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -2603,6 +2603,18 @@ ORDER BY QUOTE(t1.a);
1
1
DROP TABLE t1;
+#
+# Bug#57913 large negative number to string conversion functions crash
+# Bug#57810 case/when/then : Assertion failed: length || !scale
+#
+SELECT '1' IN ('1', SUBSTRING(-9223372036854775809, 1));
+'1' IN ('1', SUBSTRING(-9223372036854775809, 1))
+1
+SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3));
+CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3))
+1
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
End of 5.1 tests
Start of 5.4 tests
SELECT format(12345678901234567890.123, 3);
diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result
index e8a2d6f668b..7f6d4fb8553 100644
--- a/mysql-test/r/join_outer_innodb.result
+++ b/mysql-test/r/join_outer_innodb.result
@@ -17,3 +17,38 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
DROP TABLE t1,t2;
+#
+# BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output
+# in opt_range.h
+#
+CREATE TABLE t1 (
+col_int INT,
+col_int_key INT,
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4);
+INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5);
+CREATE TABLE t2 (
+pk INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+EXPLAIN SELECT t1.pk
+FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int
+WHERE t1.col_int_key BETWEEN 5 AND 6
+AND t1.pk IS NULL OR t1.pk IN (5)
+ORDER BY pk;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY,col_int_key PRIMARY 4 const 2 Using where
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.col_int 1 Using index
+
+SELECT t1.pk
+FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int
+WHERE t1.col_int_key BETWEEN 5 AND 6
+AND t1.pk IS NULL OR t1.pk IN (5)
+ORDER BY pk;
+pk
+
+DROP TABLE t1,t2;
+# End BUG#58456
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index 99e1f54e762..1a8ef2deefd 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -430,6 +430,8 @@ SELECT table_name, table_comment FROM information_schema.tables
WHERE table_schema= 'test' AND table_name= 't1';
table_name table_comment
t1 Lock wait timeout exceeded; try restarting transaction
+Warnings:
+Warning 1205 Lock wait timeout exceeded; try restarting transaction
# Connection default
UNLOCK TABLES;
# Connection con3
diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result
index 594cf433692..b2e71faf741 100644
--- a/mysql-test/r/mdl_sync.result
+++ b/mysql-test/r/mdl_sync.result
@@ -2322,6 +2322,8 @@ select table_name, table_type, auto_increment, table_comment
from information_schema.tables where table_schema='test' and table_name='t2';
table_name table_type auto_increment table_comment
t2 BASE TABLE NULL Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
+Warnings:
+Warning 1684 Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
# Switching to connection 'default'.
unlock tables;
# Switching to connection 'con46044'.
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index ace834a26c2..f668761cb16 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -2084,6 +2084,8 @@ SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE
TABLE_SCHEMA = 'test' and TABLE_NAME='tm1';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
def test tm1 BASE TABLE NULL NULL NULL # # # # # # # # # # NULL # # Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+Warnings:
+Warning 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE tm1;
CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 07a92e2abf0..e36bef1f338 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -669,4 +669,15 @@ Error 1242 Subquery returns more than 1 row
Error 1242 Subquery returns more than 1 row
DROP TABLE t1, t2, t3;
SET SESSION sql_safe_updates = DEFAULT;
+#
+# Bug#52157 various crashes and assertions with multi-table update, stored function
+#
+CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
+CREATE TABLE t1 (f1 DATE);
+INSERT INTO t1 VALUES('2001-01-01');
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '1'
+DROP FUNCTION f1;
+DROP TABLE t1;
end of tests
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index 3c53faff526..9923ba03b3d 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -433,4 +433,73 @@ Bug #47147: mysql client option --skip-column-names does not apply to vertical o
*************************** 1. row ***************************
1
+#
+# Bug #54899: --one-database option cannot handle DROP/CREATE DATABASE
+# commands.
+#
+CREATE DATABASE connected_db;
+USE connected_db;
+SHOW TABLES;
+Tables_in_connected_db
+table_in_connected_db
+DROP DATABASE connected_db;
+
+#
+# Testing --one-database option
+#
+CREATE DATABASE connected_db;
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+t1
+SHOW TABLES IN test;
+Tables_in_test
+t1
+USE test;
+DROP TABLE t1;
+DROP DATABASE connected_db;
+
+SHOW TABLES IN test;
+Tables_in_test
+SHOW TABLES IN test1;
+Tables_in_test1
+DROP DATABASE test1;
+
+#
+# Checking --one-database option followed by the execution of
+# connect command.
+#
+CREATE DATABASE connected_db;
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+t1
+t2
+SHOW TABLES IN test;
+Tables_in_test
+t1
+t2
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP DATABASE connected_db;
+
+#
+# Checking --one-database option with no database specified
+# at command-line.
+#
+SHOW TABLES IN test;
+Tables_in_test
+
+#
+# Checking --one-database option with non_existent_db
+# specified with USE command
+#
+CREATE DATABASE connected_db;
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+table_in_connected_db
+
+SHOW TABLES IN connected_db;
+Tables_in_connected_db
+table_in_connected_db
+DROP DATABASE connected_db;
+
End of tests
diff --git a/mysql-test/r/mysqld--help-notwin.result b/mysql-test/r/mysqld--help-notwin.result
index fc269e1dd82..60ba06c8f7e 100644
--- a/mysql-test/r/mysqld--help-notwin.result
+++ b/mysql-test/r/mysqld--help-notwin.result
@@ -32,10 +32,10 @@ The following options may be given as the first argument:
file (Solves most 'table full' errors)
--bind-address=name IP address to bind to.
--binlog-cache-size=#
- The size of the cache to hold the SQL statements for the
- binary log during a transaction. If you often use big,
- multi-statement transactions you can increase this to get
- more performance
+ The size of the transactional cache for updates to
+ transactional engines for the binary log. If you often
+ use transactions containing many statements, you can
+ increase this to get more performance
--binlog-direct-non-transactional-updates
Causes updates to non-transactional engines using
statement format to be written directly to binary log.
@@ -66,6 +66,11 @@ The following options may be given as the first argument:
The maximum size of a row-based binary log event in
bytes. Rows will be grouped into events smaller than this
size if possible. The value has to be a multiple of 256.
+ --binlog-stmt-cache-size=#
+ The size of the statement cache for updates to
+ non-transactional engines for the binary log. If you
+ often use statements updating a great number of rows, you
+ can increase this to get more performance
--bootstrap Used by mysql installation scripts.
--bulk-insert-buffer-size=#
Size of tree cache used in bulk insert optimisation. Note
@@ -278,14 +283,15 @@ The following options may be given as the first argument:
--max-allowed-packet=#
Max packet length to send to or receive from the server
--max-binlog-cache-size=#
- Can be used to restrict the total size used to cache a
- multi-transaction query
+ Sets the total size of the transactional cache
--max-binlog-dump-events=#
Option used by mysql-test for debugging and testing of
replication.
--max-binlog-size=# Binary log will be rotated automatically when the size
exceeds this value. Will also apply to relay logs if
max_relay_log_size is 0
+ --max-binlog-stmt-cache-size=#
+ Sets the total size of the statement cache
--max-connect-errors=#
If there is more than this number of interrupted
connections from a host this host will be blocked from
@@ -734,6 +740,7 @@ binlog-cache-size 32768
binlog-direct-non-transactional-updates FALSE
binlog-format STATEMENT
binlog-row-event-max-size 1024
+binlog-stmt-cache-size 32768
bulk-insert-buffer-size 8388608
character-set-client-handshake TRUE
character-set-filesystem binary
@@ -813,6 +820,7 @@ max-allowed-packet 1048576
max-binlog-cache-size 18446744073709547520
max-binlog-dump-events 0
max-binlog-size 1073741824
+max-binlog-stmt-cache-size 18446744073709547520
max-connect-errors 10
max-connections 151
max-delayed-threads 20
diff --git a/mysql-test/r/mysqld--help-win.result b/mysql-test/r/mysqld--help-win.result
index c5d7bb458c3..dfb53937245 100644
--- a/mysql-test/r/mysqld--help-win.result
+++ b/mysql-test/r/mysqld--help-win.result
@@ -32,10 +32,10 @@ The following options may be given as the first argument:
file (Solves most 'table full' errors)
--bind-address=name IP address to bind to.
--binlog-cache-size=#
- The size of the cache to hold the SQL statements for the
- binary log during a transaction. If you often use big,
- multi-statement transactions you can increase this to get
- more performance
+ The size of the transactional cache for updates to
+ transactional engines for the binary log. If you often
+ use transactions containing many statements, you can
+ increase this to get more performance
--binlog-direct-non-transactional-updates
Causes updates to non-transactional engines using
statement format to be written directly to binary log.
@@ -66,6 +66,11 @@ The following options may be given as the first argument:
The maximum size of a row-based binary log event in
bytes. Rows will be grouped into events smaller than this
size if possible. The value has to be a multiple of 256.
+ --binlog-stmt-cache-size=#
+ The size of the statement cache for updates to
+ non-transactional engines for the binary log. If you
+ often use statements updating a great number of rows, you
+ can increase this to get more performance
--bootstrap Used by mysql installation scripts.
--bulk-insert-buffer-size=#
Size of tree cache used in bulk insert optimisation. Note
@@ -277,14 +282,15 @@ The following options may be given as the first argument:
--max-allowed-packet=#
Max packet length to send to or receive from the server
--max-binlog-cache-size=#
- Can be used to restrict the total size used to cache a
- multi-transaction query
+ Sets the total size of the transactional cache
--max-binlog-dump-events=#
Option used by mysql-test for debugging and testing of
replication.
--max-binlog-size=# Binary log will be rotated automatically when the size
exceeds this value. Will also apply to relay logs if
max_relay_log_size is 0
+ --max-binlog-stmt-cache-size=#
+ Sets the total size of the statement cache
--max-connect-errors=#
If there is more than this number of interrupted
connections from a host this host will be blocked from
@@ -738,6 +744,7 @@ binlog-cache-size 32768
binlog-direct-non-transactional-updates FALSE
binlog-format STATEMENT
binlog-row-event-max-size 1024
+binlog-stmt-cache-size 32768
bulk-insert-buffer-size 8388608
character-set-client-handshake TRUE
character-set-filesystem binary
@@ -816,6 +823,7 @@ max-allowed-packet 1048576
max-binlog-cache-size 18446744073709547520
max-binlog-dump-events 0
max-binlog-size 1073741824
+max-binlog-stmt-cache-size 18446744073709547520
max-connect-errors 10
max-connections 151
max-delayed-threads 20
diff --git a/mysql-test/r/partition_binlog.result b/mysql-test/r/partition_binlog.result
new file mode 100644
index 00000000000..c8fa02c4b99
--- /dev/null
+++ b/mysql-test/r/partition_binlog.result
@@ -0,0 +1,49 @@
+DROP TABLE IF EXISTS t1;
+#
+# Bug#58147: ALTER TABLE w/ TRUNCATE PARTITION fails
+# but the statement is written to binlog
+#
+CREATE TABLE t1(id INT)
+PARTITION BY RANGE (id)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION pmax VALUES LESS THAN (MAXVALUE));
+INSERT INTO t1 VALUES (1), (10), (100), (1000);
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ERROR HY000: Incorrect partition name
+ALTER TABLE t1 DROP PARTITION p1;
+ERROR HY000: Error in list of partitions to DROP
+# No error returned, output in table format instead:
+ALTER TABLE t1 ANALYZE PARTITION p1;
+Table Op Msg_type Msg_text
+test.t1 analyze error Error in list of partitions to test.t1
+ALTER TABLE t1 CHECK PARTITION p1;
+Table Op Msg_type Msg_text
+test.t1 check error Error in list of partitions to test.t1
+ALTER TABLE t1 OPTIMIZE PARTITION p1;
+Table Op Msg_type Msg_text
+test.t1 optimize error Error in list of partitions to test.t1
+ALTER TABLE t1 REPAIR PARTITION p1;
+Table Op Msg_type Msg_text
+test.t1 repair error Error in list of partitions to test.t1
+ALTER TABLE t1 ANALYZE PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+ALTER TABLE t1 CHECK PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+ALTER TABLE t1 OPTIMIZE PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+ALTER TABLE t1 REPAIR PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 DROP PARTITION p0;
+show binlog events in 'master-bin.000001' from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; ALTER TABLE t1 ANALYZE PARTITION p0
+master-bin.000001 # Query # # use `test`; ALTER TABLE t1 OPTIMIZE PARTITION p0
+master-bin.000001 # Query # # use `test`; ALTER TABLE t1 REPAIR PARTITION p0
+master-bin.000001 # Query # # use `test`; ALTER TABLE t1 TRUNCATE PARTITION p0
+master-bin.000001 # Query # # use `test`; ALTER TABLE t1 DROP PARTITION p0
+DROP TABLE t1;
diff --git a/mysql-test/r/plugin_auth.result b/mysql-test/r/plugin_auth.result
index 8a649f63598..b155b296ac1 100644
--- a/mysql-test/r/plugin_auth.result
+++ b/mysql-test/r/plugin_auth.result
@@ -318,4 +318,14 @@ Proxied_host
Proxied_user
With_grant 1
FLUSH PRIVILEGES;
+#
+# Bug#58139 : default-auth option not recognized in MySQL standardi
+# command line clients
+#
+# Executing 'mysql'
+1
+1
+# Executing 'mysqladmin'
+mysqld is alive
+# Executing 'mysqldump'
End of 5.5 tests
diff --git a/mysql-test/r/plugin_not_embedded.result b/mysql-test/r/plugin_not_embedded.result
index 82cfe7b23b8..27553366660 100644
--- a/mysql-test/r/plugin_not_embedded.result
+++ b/mysql-test/r/plugin_not_embedded.result
@@ -8,3 +8,5 @@ ERROR 42000: DELETE command denied to user 'bug51770'@'localhost' for table 'plu
GRANT DELETE ON mysql.plugin TO bug51770@localhost;
UNINSTALL PLUGIN example;
DROP USER bug51770@localhost;
+INSTALL PLUGIN example SONAME '../ha_example.so';
+ERROR HY000: No paths allowed for shared library
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 5e41e6b29c6..d42cb680112 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -663,6 +663,8 @@ flush tables;
SHOW TABLE STATUS like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 NULL NULL NULL NULL # # # # NULL NULL NULL NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm'
+Warnings:
+Warning 1033 Incorrect information in file: './test/t1.frm'
show create table t1;
ERROR HY000: Incorrect information in file: './test/t1.frm'
drop table if exists t1;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index be81afe1a43..ee180169916 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1511,6 +1511,39 @@ SELECT @@skip_name_resolve;
SHOW VARIABLES LIKE 'skip_name_resolve';
Variable_name Value
skip_name_resolve OFF
+#
+# Bug #43233 : Some server variables are clipped during "update,"
+# not "check" stage
+#
+SET @kbs=@@global.key_buffer_size;
+SET @kcbs=@@global.key_cache_block_size;
+throw errors in STRICT mode
+SET SQL_MODE=STRICT_ALL_TABLES;
+SET @@global.max_binlog_cache_size=-1;
+ERROR 42000: Variable 'max_binlog_cache_size' can't be set to the value of '-1'
+SET @@global.max_join_size=0;
+ERROR 42000: Variable 'max_join_size' can't be set to the value of '0'
+SET @@global.key_buffer_size=0;
+ERROR HY000: Cannot drop default keycache
+SET @@global.key_cache_block_size=0;
+ERROR 42000: Variable 'key_cache_block_size' can't be set to the value of '0'
+throw warnings in default mode
+SET SQL_MODE=DEFAULT;
+SET @@global.max_binlog_cache_size=-1;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1'
+SET @@global.max_join_size=0;
+Warnings:
+Warning 1292 Truncated incorrect max_join_size value: '0'
+SET @@global.key_buffer_size=0;
+ERROR HY000: Cannot drop default keycache
+SET @@global.key_cache_block_size=0;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_block_size value: '0'
+SET @@global.max_binlog_cache_size=DEFAULT;
+SET @@global.max_join_size=DEFAULT;
+SET @@global.key_buffer_size=@kbs;
+SET @@global.key_cache_block_size=@kcbs;
End of 5.1 tests
#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 777ac9c258f..fdeed10701d 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -840,6 +840,8 @@ show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL # NULL NULL NULL # # NULL NULL NULL NULL View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+Warnings:
+Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
drop view v1;
drop table t1;
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
@@ -3997,6 +3999,19 @@ CREATE VIEW v1 AS SELECT 1 from t1
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+#
+# Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
+#
+CREATE TABLE t1(a int);
+CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
+SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# Bug#57352 valgrind warnings when creating view
+#
+CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
+DROP VIEW v1;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/suite/binlog/r/binlog_index.result b/mysql-test/suite/binlog/r/binlog_index.result
index 52d698e9f96..11cf43b8a5e 100644
--- a/mysql-test/suite/binlog/r/binlog_index.result
+++ b/mysql-test/suite/binlog/r/binlog_index.result
@@ -2,7 +2,9 @@ call mtr.add_suppression('Attempting backtrace');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
+call mtr.add_suppression('Could not open .*');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
+RESET MASTER;
flush logs;
flush logs;
flush logs;
@@ -116,11 +118,31 @@ master-bin.000011
# This should put the server in unsafe state and stop
# accepting any command. If we inject a fault at this
# point and continue the execution the server crashes.
-# Besides the flush command does not report an error.
#
+SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
+SELECT @index;
+@index
+master-bin.000006
+master-bin.000007
+master-bin.000008
+master-bin.000009
+master-bin.000010
+master-bin.000011
+
# fault_injection_registering_index
SET SESSION debug="+d,fault_injection_registering_index";
flush logs;
+ERROR HY000: Can't open file: 'master-bin.000012' (errno: 1)
+SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
+SELECT @index;
+@index
+master-bin.000006
+master-bin.000007
+master-bin.000008
+master-bin.000009
+master-bin.000010
+master-bin.000011
+
SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
SELECT @index;
@index
@@ -135,6 +157,18 @@ master-bin.000012
# fault_injection_updating_index
SET SESSION debug="+d,fault_injection_updating_index";
flush logs;
+ERROR HY000: Can't open file: 'master-bin.000013' (errno: 1)
+SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
+SELECT @index;
+@index
+master-bin.000006
+master-bin.000007
+master-bin.000008
+master-bin.000009
+master-bin.000010
+master-bin.000011
+master-bin.000012
+
SET @index=LOAD_FILE('MYSQLTEST_VARDIR/mysqld.1/data//master-bin.index');
SELECT @index;
@index
diff --git a/mysql-test/suite/binlog/r/binlog_innodb.result b/mysql-test/suite/binlog/r/binlog_innodb.result
index dc170361026..cdb72aad902 100644
--- a/mysql-test/suite/binlog/r/binlog_innodb.result
+++ b/mysql-test/suite/binlog/r/binlog_innodb.result
@@ -123,7 +123,7 @@ Binlog_cache_disk_use 0
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name Value
-Binlog_cache_use 2
+Binlog_cache_use 1
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
@@ -132,7 +132,7 @@ delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name Value
-Binlog_cache_use 4
+Binlog_cache_use 2
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
diff --git a/mysql-test/suite/binlog/r/binlog_max_extension.result b/mysql-test/suite/binlog/r/binlog_max_extension.result
index af341db4536..f69ffcce16a 100644
--- a/mysql-test/suite/binlog/r/binlog_max_extension.result
+++ b/mysql-test/suite/binlog/r/binlog_max_extension.result
@@ -3,6 +3,5 @@ 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)
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
diff --git a/mysql-test/suite/binlog/r/binlog_mix_innodb_stat.result b/mysql-test/suite/binlog/r/binlog_mix_innodb_stat.result
deleted file mode 100644
index 637be940383..00000000000
--- a/mysql-test/suite/binlog/r/binlog_mix_innodb_stat.result
+++ /dev/null
@@ -1,25 +0,0 @@
-flush status;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 0
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 0
-drop table if exists t1;
-create table t1 (a int) engine=innodb;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 2
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-begin;
-delete from t1;
-commit;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 4
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-drop table t1;
diff --git a/mysql-test/suite/binlog/r/binlog_mixed_cache_stat.result b/mysql-test/suite/binlog/r/binlog_mixed_cache_stat.result
new file mode 100644
index 00000000000..09cdab8414a
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_mixed_cache_stat.result
@@ -0,0 +1,66 @@
+drop table if exists t1, t2;
+create table t1 (a int) engine=innodb;
+create table t2 (a int) engine=myisam;
+**** Preparing the enviroment to check commit and its effect on status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+commit;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+commit;
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+commit;
+**** Preparing the enviroment to check abort and its effect on the status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+rollback;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+drop table t1, t2;
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index e45f4a76643..abb02164d91 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -1218,8 +1218,8 @@ master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
drop table t1,t2,t3,tt1;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-insert delayed into t1 values (207);
-insert delayed into t1 values (null);
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+insert /*! delayed */ into t1 values (null);
insert delayed into t1 values (300);
FLUSH TABLES;
show binlog events from <binlog_start>;
@@ -1330,3 +1330,62 @@ Log_name Pos Event_type Server_id End_log_pos Info
# # Write_rows 1 # table_id: # flags: STMT_END_F
# # Query 1 # COMMIT
DROP TABLE t1;
+
+# BUG#54903 BINLOG statement toggles session variables
+# ----------------------------------------------------------------------
+# This test verify that BINLOG statement doesn't change current session's
+# variables foreign_key_checks and unique_checks.
+
+CREATE TABLE t1 (c1 INT KEY);
+SET @@SESSION.foreign_key_checks= ON;
+SET @@SESSION.unique_checks= ON;
+# INSERT INTO t1 VALUES (1)
+# foreign_key_checks=0 and unique_checks=0
+BINLOG '
+dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
+';
+SELECT * FROM t1;
+c1
+1
+# Their values should be ON
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks ON
+unique_checks ON
+
+SET @@SESSION.foreign_key_checks= OFF;
+SET @@SESSION.unique_checks= OFF;
+# INSERT INTO t1 VALUES(2)
+# foreign_key_checks=1 and unique_checks=1
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+SELECT * FROM t1;
+c1
+1
+2
+# Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks OFF
+unique_checks OFF
+# INSERT INTO t1 VALUES(2)
+# foreign_key_checks=1 and unique_checks=1
+# It should not change current session's variables, even error happens
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+SELECT * FROM t1;
+c1
+1
+2
+# Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks OFF
+unique_checks OFF
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_row_cache_stat.result b/mysql-test/suite/binlog/r/binlog_row_cache_stat.result
new file mode 100644
index 00000000000..09cdab8414a
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_row_cache_stat.result
@@ -0,0 +1,66 @@
+drop table if exists t1, t2;
+create table t1 (a int) engine=innodb;
+create table t2 (a int) engine=myisam;
+**** Preparing the enviroment to check commit and its effect on status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+commit;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+commit;
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+commit;
+**** Preparing the enviroment to check abort and its effect on the status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+rollback;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+drop table t1, t2;
diff --git a/mysql-test/suite/binlog/r/binlog_row_innodb_stat.result b/mysql-test/suite/binlog/r/binlog_row_innodb_stat.result
deleted file mode 100644
index 637be940383..00000000000
--- a/mysql-test/suite/binlog/r/binlog_row_innodb_stat.result
+++ /dev/null
@@ -1,25 +0,0 @@
-flush status;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 0
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 0
-drop table if exists t1;
-create table t1 (a int) engine=innodb;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 2
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-begin;
-delete from t1;
-commit;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 4
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-drop table t1;
diff --git a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
index 2219961aca0..cdcc96b94b0 100644
--- a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
+++ b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
@@ -1,6 +1,6 @@
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-insert delayed into t1 values (207);
-insert delayed into t1 values (null);
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+insert /*! delayed */ into t1 values (null);
insert delayed into t1 values (300);
FLUSH TABLES;
show binlog events from <binlog_start>;
@@ -10,14 +10,14 @@ master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `test`; insert delayed into t1 values (207)
+master-bin.000001 # Query # # use `test`; insert /* before delayed */ /* after delayed */ into t1 values (207)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=208
-master-bin.000001 # Query # # use `test`; insert delayed into t1 values (null)
+master-bin.000001 # Query # # use `test`; insert /*! */ into t1 values (null)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `test`; insert delayed into t1 values (300)
+master-bin.000001 # Query # # use `test`; insert into t1 values (300)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; FLUSH TABLES
RESET MASTER;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index 187a778d9cc..5960952e22e 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -717,8 +717,8 @@ master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhos
master-bin.000001 # Query # # COMMIT
drop table t1,t2,t3,tt1;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-insert delayed into t1 values (207);
-insert delayed into t1 values (null);
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+insert /*! delayed */ into t1 values (null);
insert delayed into t1 values (300);
FLUSH TABLES;
show binlog events from <binlog_start>;
@@ -820,3 +820,62 @@ Log_name Pos Event_type Server_id End_log_pos Info
# # Write_rows 1 # table_id: # flags: STMT_END_F
# # Query 1 # COMMIT
DROP TABLE t1;
+
+# BUG#54903 BINLOG statement toggles session variables
+# ----------------------------------------------------------------------
+# This test verify that BINLOG statement doesn't change current session's
+# variables foreign_key_checks and unique_checks.
+
+CREATE TABLE t1 (c1 INT KEY);
+SET @@SESSION.foreign_key_checks= ON;
+SET @@SESSION.unique_checks= ON;
+# INSERT INTO t1 VALUES (1)
+# foreign_key_checks=0 and unique_checks=0
+BINLOG '
+dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
+';
+SELECT * FROM t1;
+c1
+1
+# Their values should be ON
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks ON
+unique_checks ON
+
+SET @@SESSION.foreign_key_checks= OFF;
+SET @@SESSION.unique_checks= OFF;
+# INSERT INTO t1 VALUES(2)
+# foreign_key_checks=1 and unique_checks=1
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+SELECT * FROM t1;
+c1
+1
+2
+# Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks OFF
+unique_checks OFF
+# INSERT INTO t1 VALUES(2)
+# foreign_key_checks=1 and unique_checks=1
+# It should not change current session's variables, even error happens
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+SELECT * FROM t1;
+c1
+1
+2
+# Their values should be OFF
+SHOW SESSION VARIABLES LIKE "%_checks";
+Variable_name Value
+foreign_key_checks OFF
+unique_checks OFF
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_cache_stat.result b/mysql-test/suite/binlog/r/binlog_stm_cache_stat.result
new file mode 100644
index 00000000000..09cdab8414a
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_stm_cache_stat.result
@@ -0,0 +1,66 @@
+drop table if exists t1, t2;
+create table t1 (a int) engine=innodb;
+create table t2 (a int) engine=myisam;
+**** Preparing the enviroment to check commit and its effect on status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+commit;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+commit;
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+commit;
+**** Preparing the enviroment to check abort and its effect on the status variables.
+**** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+**** Transactional changes which are long enough so they will be flushed to disk...
+**** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+**** Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+rollback;
+**** Non-Transactional changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+**** Mixed changes which should not be flushed to disk and so should not
+**** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+**** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+**** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+drop table t1, t2;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_innodb_stat.result b/mysql-test/suite/binlog/r/binlog_stm_innodb_stat.result
deleted file mode 100644
index 637be940383..00000000000
--- a/mysql-test/suite/binlog/r/binlog_stm_innodb_stat.result
+++ /dev/null
@@ -1,25 +0,0 @@
-flush status;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 0
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 0
-drop table if exists t1;
-create table t1 (a int) engine=innodb;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 2
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-begin;
-delete from t1;
-commit;
-show status like "binlog_cache_use";
-Variable_name Value
-Binlog_cache_use 4
-show status like "binlog_cache_disk_use";
-Variable_name Value
-Binlog_cache_disk_use 1
-drop table t1;
diff --git a/mysql-test/suite/binlog/t/binlog_index.test b/mysql-test/suite/binlog/t/binlog_index.test
index 9d4a49602a6..b735574fdb9 100644
--- a/mysql-test/suite/binlog/t/binlog_index.test
+++ b/mysql-test/suite/binlog/t/binlog_index.test
@@ -10,9 +10,12 @@ call mtr.add_suppression('Attempting backtrace');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
+call mtr.add_suppression('Could not open .*');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
let $old=`select @@debug`;
+RESET MASTER;
+
let $MYSQLD_DATADIR= `select @@datadir`;
let $INDEX=$MYSQLD_DATADIR/master-bin.index;
@@ -205,12 +208,26 @@ SELECT @index;
--echo # This should put the server in unsafe state and stop
--echo # accepting any command. If we inject a fault at this
--echo # point and continue the execution the server crashes.
---echo # Besides the flush command does not report an error.
--echo #
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
--echo # fault_injection_registering_index
SET SESSION debug="+d,fault_injection_registering_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
flush logs;
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
--source include/restart_mysqld.inc
--chmod 0644 $INDEX
@@ -221,7 +238,16 @@ SELECT @index;
--echo # fault_injection_updating_index
SET SESSION debug="+d,fault_injection_updating_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
flush logs;
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
--source include/restart_mysqld.inc
--chmod 0644 $INDEX
diff --git a/mysql-test/suite/binlog/t/binlog_max_extension.test b/mysql-test/suite/binlog/t/binlog_max_extension.test
index 4525ce41aed..e5274d87b85 100644
--- a/mysql-test/suite/binlog/t/binlog_max_extension.test
+++ b/mysql-test/suite/binlog/t/binlog_max_extension.test
@@ -58,7 +58,8 @@ EOF
# Assertion
###########
-# assertion: should throw warning
+# assertion: should raise error
+-- error ER_NO_UNIQUE_LOGFILE
FLUSH LOGS;
##############
diff --git a/mysql-test/suite/binlog/t/binlog_mix_innodb_stat.test b/mysql-test/suite/binlog/t/binlog_mixed_cache_stat.test
index 0be097c78ed..3e63fb3bc9c 100644
--- a/mysql-test/suite/binlog/t/binlog_mix_innodb_stat.test
+++ b/mysql-test/suite/binlog/t/binlog_mixed_cache_stat.test
@@ -2,4 +2,4 @@
# For both statement and row based bin logs 9/19/2005 [jbm]
-- source include/have_binlog_format_mixed.inc
--- source extra/binlog_tests/innodb_stat.test
+-- source extra/binlog_tests/binlog_cache_stat.test
diff --git a/mysql-test/suite/binlog/t/binlog_row_innodb_stat.test b/mysql-test/suite/binlog/t/binlog_row_cache_stat.test
index e4e6762226b..03f9c53f0cc 100644
--- a/mysql-test/suite/binlog/t/binlog_row_innodb_stat.test
+++ b/mysql-test/suite/binlog/t/binlog_row_cache_stat.test
@@ -2,4 +2,4 @@
# For both statement and row based bin logs 9/19/2005 [jbm]
-- source include/have_binlog_format_row.inc
--- source extra/binlog_tests/innodb_stat.test
+-- source extra/binlog_tests/binlog_cache_stat.test
diff --git a/mysql-test/suite/binlog/t/binlog_stm_innodb_stat.test b/mysql-test/suite/binlog/t/binlog_stm_cache_stat.test
index c6017246e6d..0f5aa9f6013 100644
--- a/mysql-test/suite/binlog/t/binlog_stm_innodb_stat.test
+++ b/mysql-test/suite/binlog/t/binlog_stm_cache_stat.test
@@ -2,4 +2,4 @@
# For both statement and row based bin logs 9/19/2005 [jbm]
-- source include/have_binlog_format_statement.inc
--- source extra/binlog_tests/innodb_stat.test
+-- source extra/binlog_tests/binlog_cache_stat.test
diff --git a/mysql-test/suite/federated/federated_bug_35333.result b/mysql-test/suite/federated/federated_bug_35333.result
new file mode 100644
index 00000000000..ca7aa960b73
--- /dev/null
+++ b/mysql-test/suite/federated/federated_bug_35333.result
@@ -0,0 +1,67 @@
+#
+# Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata"
+#
+# Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail
+# when encountering a federated table that cannot connect to its remote table.
+#
+# The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear
+# the remote connection error and push a warning instead. This allows the SELECT operation
+# to complete while still indicating a problem. This fix applies to any non-fatal system
+# error that occurs during a query against I_S.TABLES.de
+CREATE DATABASE federated;
+CREATE DATABASE federated;
+CREATE DATABASE IF NOT EXISTS realdb;
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
+#
+# Create the base table to be referenced
+#
+CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM;
+#
+# Create a federated table with a bogus port number
+#
+CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED
+CONNECTION='mysql://root@127.0.0.1:63333/realdb/t0';
+#
+# Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query
+#
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'realdb' or TABLE_SCHEMA = 'federated';
+TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT
+federated t0 BASE TABLE FEDERATED NULL 0 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
+realdb t0 BASE TABLE MyISAM Dynamic 0 0
+Warnings:
+Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
+SHOW WARNINGS;
+Level Code Message
+Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
+#
+# Create a MyISAM table then corrupt the file
+#
+USE realdb;
+CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
+#
+# Corrupt the MyISAM table by deleting the base file
+#
+#
+# Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query
+#
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT
+realdb t1 BASE TABLE NULL NULL NULL NULL Can't find file: 't1' (errno: 2)
+Warnings:
+Warning 1017 Can't find file: 't1' (errno: 2)
+SHOW WARNINGS;
+Level Code Message
+Warning 1017 Can't find file: 't1' (errno: 2)
+#
+# Cleanup
+#
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
+DROP DATABASE realdb;
+DROP TABLE IF EXISTS federated.t1;
+DROP DATABASE federated;
+DROP TABLE IF EXISTS federated.t1;
+DROP DATABASE federated;
diff --git a/mysql-test/suite/federated/federated_bug_35333.test b/mysql-test/suite/federated/federated_bug_35333.test
new file mode 100644
index 00000000000..58c217d24f2
--- /dev/null
+++ b/mysql-test/suite/federated/federated_bug_35333.test
@@ -0,0 +1,74 @@
+--echo #
+--echo # Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata"
+--echo #
+--echo # Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail
+--echo # when encountering a federated table that cannot connect to its remote table.
+--echo #
+--echo # The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear
+--echo # the remote connection error and push a warning instead. This allows the SELECT operation
+--echo # to complete while still indicating a problem. This fix applies to any non-fatal system
+--echo # error that occurs during a query against I_S.TABLES.de
+
+--source federated.inc
+
+--disable_warnings
+CREATE DATABASE IF NOT EXISTS realdb;
+# Federated database exists
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
+--enable_warnings
+
+--echo #
+--echo # Create the base table to be referenced
+--echo #
+CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM;
+
+--echo #
+--echo # Create a federated table with a bogus port number
+--echo #
+CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED
+ CONNECTION='mysql://root@127.0.0.1:63333/realdb/t0';
+
+#--warning ER_CONNECT_TO_FOREIGN_DATA_SOURCE
+
+--echo #
+--echo # Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query
+--echo #
+# Remove O/S-specific socket error
+--replace_regex /\(.*\)/(socket errno)/
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'realdb' or TABLE_SCHEMA = 'federated';
+
+# Remove O/S-specific socket error
+--replace_regex /\(.*\)/(socket errno)/
+SHOW WARNINGS;
+
+--echo #
+--echo # Create a MyISAM table then corrupt the file
+--echo #
+USE realdb;
+CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
+--echo #
+--echo # Corrupt the MyISAM table by deleting the base file
+--echo #
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--remove_file $MYSQLD_DATADIR/realdb/t1.MYD
+--remove_file $MYSQLD_DATADIR/realdb/t1.MYI
+
+--echo #
+--echo # Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query
+--echo #
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+
+SHOW WARNINGS;
+--echo #
+--echo # Cleanup
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
+DROP DATABASE realdb;
+--enable_warnings
+
+--source federated_cleanup.inc
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result
index 350c7ebd541..0c8d16f27fb 100644
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result
@@ -471,17 +471,12 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 2
auto_increment_offset 10
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
SELECT * FROM t1;
c1
1
18446744073709551603
-18446744073709551604
-18446744073709551606
-18446744073709551608
-18446744073709551610
-18446744073709551612
-18446744073709551614
DROP TABLE t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SET @@INSERT_ID=1;
@@ -504,13 +499,12 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 5
auto_increment_offset 7
-INSERT INTO t1 VALUES (NULL),(NULL);
+INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
SELECT * FROM t1;
c1
1
18446744073709551603
-18446744073709551607
-18446744073709551612
DROP TABLE t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SET @@INSERT_ID=1;
@@ -572,12 +566,12 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 65535
auto_increment_offset 65535
-INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (NULL),(NULL);
+ERROR 22003: Out of range value for column 't1' at row 167
SELECT * FROM t1;
c1
1
18446744073709551610
-18446744073709551615
DROP TABLE t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SET @@INSERT_ID=1;
diff --git a/mysql-test/suite/innodb/r/innodb_multi_update.result b/mysql-test/suite/innodb/r/innodb_multi_update.result
index 7af9b030d1f..558fc3938a8 100644
--- a/mysql-test/suite/innodb/r/innodb_multi_update.result
+++ b/mysql-test/suite/innodb/r/innodb_multi_update.result
@@ -74,3 +74,11 @@ a b
4 14
5 15
drop table bug38999_1,bug38999_2;
+#
+# Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
+#
+CREATE TABLE t1(f1 INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
+ERROR 21000: Operand should contain 1 column(s)
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test
index da0783bdc7c..ab8a7d69ab2 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc.test
@@ -293,21 +293,8 @@ INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
SHOW VARIABLES LIKE "%auto_inc%";
-# This should fail because of overflow but it doesn't, it seems to be
-# a MySQL server bug. It wraps around to 0 for the last value.
-# See MySQL Bug# 39828
-#
-# Instead of wrapping around, it asserts when MySQL is compiled --with-debug
-# (see sql/handler.cc:handler::update_auto_increment()). Don't test for
-# overflow until Bug #39828 is fixed.
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#endif
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
SELECT * FROM t1;
DROP TABLE t1;
@@ -325,20 +312,8 @@ INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
SHOW VARIABLES LIKE "%auto_inc%";
-# This should fail because of overflow but it doesn't. It fails with
-# a duplicate entry message because of a MySQL server bug, it wraps
-# around. See MySQL Bug# 39828, once MySQL fix the bug we can replace
-# the ER_DUP_ENTRY, 1062 below with the appropriate error message
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-# Still need to fix this error code, error should mention overflow
-#-- error ER_DUP_ENTRY,1062
-#INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL);
-#endif
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
SELECT * FROM t1;
DROP TABLE t1;
@@ -376,20 +351,8 @@ INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
SHOW VARIABLES LIKE "%auto_inc%";
-# This should fail because of overflow but it doesn't. It wraps around
-# and the autoinc values look bogus too.
-# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error
-# code expected test.
-# -- error ER_AUTOINC_READ_FAILED,1467
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-#-- error ER_AUTOINC_READ_FAILED,1467
-#INSERT INTO t1 VALUES (NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL);
-#endif
+--error ER_WARN_DATA_OUT_OF_RANGE
+INSERT INTO t1 VALUES (NULL),(NULL);
SELECT * FROM t1;
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb_multi_update.test b/mysql-test/suite/innodb/t/innodb_multi_update.test
index 7ab17ccf70a..778f4e980ca 100644
--- a/mysql-test/suite/innodb/t/innodb_multi_update.test
+++ b/mysql-test/suite/innodb/t/innodb_multi_update.test
@@ -27,3 +27,12 @@ select * from bug38999_1;
select * from bug38999_2;
drop table bug38999_1,bug38999_2;
+
+--echo #
+--echo # Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
+--echo #
+CREATE TABLE t1(f1 INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+--error ER_OPERAND_COLUMNS
+UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
index 25a9774d2a1..45d77225a23 100644
--- a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
@@ -39,29 +39,6 @@ let $val3 = 17 ;
let $val4 = 15 ;
--source suite/parts/inc/partition_supported_sql_funcs.inc
-
-let $sqlfunc = ceiling(col1);
-let $valsqlfunc = ceiling(15);
-let $coltype = float(7,4);
-let $infile = part_supported_sql_funcs_int_float.inc;
-let $val1 = 5.1230;
-let $val2 = 13.345;
-let $val3 = 17.987;
-let $val4 = 15.654 ;
-# DISABLED due to bug 30577
-#--source suite/parts/inc/partition_supported_sql_funcs.inc
-
-let $sqlfunc = floor(col1);
-let $valsqlfunc = floor(15.123);
-let $coltype = float(7,4);
-let $infile = part_supported_sql_funcs_int_float.inc;
-let $val1 = 5.1230;
-let $val2 = 13.345;
-let $val3 = 17.987;
-let $val4 = 15.654 ;
-# DISABLED due to bug 30577
-#--source suite/parts/inc/partition_supported_sql_funcs.inc
-
let $sqlfunc = mod(col1,10);
let $valsqlfunc = mod(15,10);
let $coltype = int;
diff --git a/mysql-test/suite/parts/inc/partition_decimal.inc b/mysql-test/suite/parts/inc/partition_decimal.inc
index 17cef08e275..7d3fe058de9 100644
--- a/mysql-test/suite/parts/inc/partition_decimal.inc
+++ b/mysql-test/suite/parts/inc/partition_decimal.inc
@@ -37,10 +37,8 @@ drop table t2;
# Bug 30577: FLOOR() and CEILING() not usable as partition functions
# Partition functions are required to return INT_RESULT; FLOOR() and
-# CEILING() do not, unless they have an INT argument. Disable this
-# portion of the test until bug 30577 is fixed.
+# CEILING() do not, unless they have an INT or DECIMAL argument.
---disable_parsing
eval create table t3 (a decimal(18,9) not null, primary key(a)) engine=$engine
partition by range (floor(a)) subpartition by key (a) subpartitions 2 (
@@ -65,7 +63,7 @@ select count(*) from t3;
drop table t3;
eval create table t4 (a decimal(18,9) not null, primary key(a)) engine=$engine
-partition by list (floor(a)) subpartition by key (a) subpartitions 2 (
+partition by list (ceiling(a)) subpartition by key (a) subpartitions 2 (
partition pa2 values in (1,2),
partition pa4 values in (3,4),
partition pa6 values in (5,6),
@@ -85,6 +83,3 @@ dec $count;
--enable_query_log
select count(*) from t4;
drop table t4;
-
-# Disabled due to Bug 30577
---enable_parsing
diff --git a/mysql-test/suite/parts/inc/partition_double.inc b/mysql-test/suite/parts/inc/partition_double.inc
index befbe860b86..cfae95022ce 100644
--- a/mysql-test/suite/parts/inc/partition_double.inc
+++ b/mysql-test/suite/parts/inc/partition_double.inc
@@ -34,54 +34,3 @@ dec $count;
--enable_query_log
select count(*) from t2;
drop table t2;
-
-
-# Bug 30577: FLOOR() and CEILING() not usable as partition functions
-# Partition functions are required to return INT_RESULT; FLOOR() and
-# CEILING() do not, unless they have an INT argument. Disable this
-# portion of the test until bug 30577 is fixed.
-
---disable_parsing
-
-eval create table t3 (a double not null, primary key(a)) engine=$engine
-partition by range (floor(a)) subpartition by key (a) subpartitions 3 (
-partition pa1 values less than (3),
-partition pa3 values less than (6),
-partition pa10 values less than (10)
-);
-show create table t3;
-let $count=9;
---echo $count*3 inserts;
-while ($count)
-{
-eval insert into t3 values ($count);
-eval insert into t3 values ($count+0.33);
-eval insert into t3 values ($count+0.75);
-dec $count;
-}
-select count(*) from t3;
-select * from t3;
-drop table t3;
-
-eval create table t4 (a double not null, primary key(a)) engine=$engine
-partition by list (floor(a)) subpartition by key (a) subpartitions 3 (
-partition pa1 values in (1,2,3),
-partition pa3 values in (4,5,6),
-partition pa10 values in (7,8,9,10)
-);
-show create table t4;
-let $count=9;
---echo $count*3 inserts;
-while ($count)
-{
-eval insert into t4 values ($count);
-eval insert into t4 values ($count+0.33);
-eval insert into t4 values ($count+0.75);
-dec $count;
-}
-select count(*) from t4;
-select * from t4;
-drop table t4;
-
-# Disabled due to Bug 30577
---enable_parsing
diff --git a/mysql-test/suite/parts/inc/partition_float.inc b/mysql-test/suite/parts/inc/partition_float.inc
index 34f14137d4d..7fa6b3043be 100644
--- a/mysql-test/suite/parts/inc/partition_float.inc
+++ b/mysql-test/suite/parts/inc/partition_float.inc
@@ -38,53 +38,3 @@ dec $count;
--enable_query_log
select count(*) from t2;
drop table t2;
-
-# Bug 30577: FLOOR() and CEILING() not usable as partition functions
-# Partition functions are required to return INT_RESULT; FLOOR() and
-# CEILING() do not, unless they have an INT argument. Disable this
-# portion of the test until bug 30577 is fixed.
-
---disable_parsing
-
-eval create table t3 (a float not null, primary key(a)) engine=$engine
-partition by range (floor(a)) subpartition by key (a) subpartitions 3 (
-partition pa1 values less than (3),
-partition pa3 values less than (6),
-partition pa10 values less than (10)
-);
-show create table t3;
-let $count=9;
---echo $count*3 inserts;
-while ($count)
-{
-eval insert into t3 values ($count);
-eval insert into t3 values ($count+0.33);
-eval insert into t3 values ($count+0.75);
-dec $count;
-}
-select count(*) from t3;
-select * from t3;
-drop table t3;
-
-eval create table t4 (a float not null, primary key(a)) engine=$engine
-partition by list (floor(a)) subpartition by key (a) subpartitions 3 (
-partition pa1 values in (1,2,3),
-partition pa3 values in (4,5,6),
-partition pa10 values in (7,8,9,10)
-);
-show create table t4;
-let $count=9;
---echo $count*3 inserts;
-while ($count)
-{
-eval insert into t4 values ($count);
-eval insert into t4 values ($count+0.33);
-eval insert into t4 values ($count+0.75);
-dec $count;
-}
-select count(*) from t4;
-select * from t4;
-drop table t4;
-
-# Disabled due to Bug 30577
---enable_parsing
diff --git a/mysql-test/suite/parts/r/partition_decimal_innodb.result b/mysql-test/suite/parts/r/partition_decimal_innodb.result
index 70debf3c595..c69c880cc6f 100644
--- a/mysql-test/suite/parts/r/partition_decimal_innodb.result
+++ b/mysql-test/suite/parts/r/partition_decimal_innodb.result
@@ -86,3 +86,111 @@ select count(*) from t2;
count(*)
3072
drop table t2;
+create table t3 (a decimal(18,9) not null, primary key(a)) engine='InnoDB'
+partition by range (floor(a)) subpartition by key (a) subpartitions 2 (
+partition pa2 values less than (2),
+partition pa4 values less than (4),
+partition pa6 values less than (6),
+partition pa8 values less than (8),
+partition pa10 values less than (10)
+);
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` decimal(18,9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (floor(a))
+SUBPARTITION BY KEY (a)
+SUBPARTITIONS 2
+(PARTITION pa2 VALUES LESS THAN (2) ENGINE = InnoDB,
+ PARTITION pa4 VALUES LESS THAN (4) ENGINE = InnoDB,
+ PARTITION pa6 VALUES LESS THAN (6) ENGINE = InnoDB,
+ PARTITION pa8 VALUES LESS THAN (8) ENGINE = InnoDB,
+ PARTITION pa10 VALUES LESS THAN (10) ENGINE = InnoDB) */
+9*3 inserts;
+insert into t3 values (9);
+insert into t3 values (9+0.333333333);
+insert into t3 values (9+0.755555555);
+insert into t3 values (8);
+insert into t3 values (8+0.333333333);
+insert into t3 values (8+0.755555555);
+insert into t3 values (7);
+insert into t3 values (7+0.333333333);
+insert into t3 values (7+0.755555555);
+insert into t3 values (6);
+insert into t3 values (6+0.333333333);
+insert into t3 values (6+0.755555555);
+insert into t3 values (5);
+insert into t3 values (5+0.333333333);
+insert into t3 values (5+0.755555555);
+insert into t3 values (4);
+insert into t3 values (4+0.333333333);
+insert into t3 values (4+0.755555555);
+insert into t3 values (3);
+insert into t3 values (3+0.333333333);
+insert into t3 values (3+0.755555555);
+insert into t3 values (2);
+insert into t3 values (2+0.333333333);
+insert into t3 values (2+0.755555555);
+insert into t3 values (1);
+insert into t3 values (1+0.333333333);
+insert into t3 values (1+0.755555555);
+select count(*) from t3;
+count(*)
+27
+drop table t3;
+create table t4 (a decimal(18,9) not null, primary key(a)) engine='InnoDB'
+partition by list (ceiling(a)) subpartition by key (a) subpartitions 2 (
+partition pa2 values in (1,2),
+partition pa4 values in (3,4),
+partition pa6 values in (5,6),
+partition pa8 values in (7,8),
+partition pa10 values in (9,10)
+);
+show create table t4;
+Table Create Table
+t4 CREATE TABLE `t4` (
+ `a` decimal(18,9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY LIST (ceiling(a))
+SUBPARTITION BY KEY (a)
+SUBPARTITIONS 2
+(PARTITION pa2 VALUES IN (1,2) ENGINE = InnoDB,
+ PARTITION pa4 VALUES IN (3,4) ENGINE = InnoDB,
+ PARTITION pa6 VALUES IN (5,6) ENGINE = InnoDB,
+ PARTITION pa8 VALUES IN (7,8) ENGINE = InnoDB,
+ PARTITION pa10 VALUES IN (9,10) ENGINE = InnoDB) */
+9*3 inserts;
+insert into t4 values (9);
+insert into t4 values (9+0.333333333);
+insert into t4 values (9+0.755555555);
+insert into t4 values (8);
+insert into t4 values (8+0.333333333);
+insert into t4 values (8+0.755555555);
+insert into t4 values (7);
+insert into t4 values (7+0.333333333);
+insert into t4 values (7+0.755555555);
+insert into t4 values (6);
+insert into t4 values (6+0.333333333);
+insert into t4 values (6+0.755555555);
+insert into t4 values (5);
+insert into t4 values (5+0.333333333);
+insert into t4 values (5+0.755555555);
+insert into t4 values (4);
+insert into t4 values (4+0.333333333);
+insert into t4 values (4+0.755555555);
+insert into t4 values (3);
+insert into t4 values (3+0.333333333);
+insert into t4 values (3+0.755555555);
+insert into t4 values (2);
+insert into t4 values (2+0.333333333);
+insert into t4 values (2+0.755555555);
+insert into t4 values (1);
+insert into t4 values (1+0.333333333);
+insert into t4 values (1+0.755555555);
+select count(*) from t4;
+count(*)
+27
+drop table t4;
diff --git a/mysql-test/suite/parts/r/partition_decimal_myisam.result b/mysql-test/suite/parts/r/partition_decimal_myisam.result
index f9f7a1e4fe2..cdafb721ea4 100644
--- a/mysql-test/suite/parts/r/partition_decimal_myisam.result
+++ b/mysql-test/suite/parts/r/partition_decimal_myisam.result
@@ -86,3 +86,111 @@ select count(*) from t2;
count(*)
196605
drop table t2;
+create table t3 (a decimal(18,9) not null, primary key(a)) engine='MYISAM'
+partition by range (floor(a)) subpartition by key (a) subpartitions 2 (
+partition pa2 values less than (2),
+partition pa4 values less than (4),
+partition pa6 values less than (6),
+partition pa8 values less than (8),
+partition pa10 values less than (10)
+);
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` decimal(18,9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (floor(a))
+SUBPARTITION BY KEY (a)
+SUBPARTITIONS 2
+(PARTITION pa2 VALUES LESS THAN (2) ENGINE = MyISAM,
+ PARTITION pa4 VALUES LESS THAN (4) ENGINE = MyISAM,
+ PARTITION pa6 VALUES LESS THAN (6) ENGINE = MyISAM,
+ PARTITION pa8 VALUES LESS THAN (8) ENGINE = MyISAM,
+ PARTITION pa10 VALUES LESS THAN (10) ENGINE = MyISAM) */
+9*3 inserts;
+insert into t3 values (9);
+insert into t3 values (9+0.333333333);
+insert into t3 values (9+0.755555555);
+insert into t3 values (8);
+insert into t3 values (8+0.333333333);
+insert into t3 values (8+0.755555555);
+insert into t3 values (7);
+insert into t3 values (7+0.333333333);
+insert into t3 values (7+0.755555555);
+insert into t3 values (6);
+insert into t3 values (6+0.333333333);
+insert into t3 values (6+0.755555555);
+insert into t3 values (5);
+insert into t3 values (5+0.333333333);
+insert into t3 values (5+0.755555555);
+insert into t3 values (4);
+insert into t3 values (4+0.333333333);
+insert into t3 values (4+0.755555555);
+insert into t3 values (3);
+insert into t3 values (3+0.333333333);
+insert into t3 values (3+0.755555555);
+insert into t3 values (2);
+insert into t3 values (2+0.333333333);
+insert into t3 values (2+0.755555555);
+insert into t3 values (1);
+insert into t3 values (1+0.333333333);
+insert into t3 values (1+0.755555555);
+select count(*) from t3;
+count(*)
+27
+drop table t3;
+create table t4 (a decimal(18,9) not null, primary key(a)) engine='MYISAM'
+partition by list (ceiling(a)) subpartition by key (a) subpartitions 2 (
+partition pa2 values in (1,2),
+partition pa4 values in (3,4),
+partition pa6 values in (5,6),
+partition pa8 values in (7,8),
+partition pa10 values in (9,10)
+);
+show create table t4;
+Table Create Table
+t4 CREATE TABLE `t4` (
+ `a` decimal(18,9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY LIST (ceiling(a))
+SUBPARTITION BY KEY (a)
+SUBPARTITIONS 2
+(PARTITION pa2 VALUES IN (1,2) ENGINE = MyISAM,
+ PARTITION pa4 VALUES IN (3,4) ENGINE = MyISAM,
+ PARTITION pa6 VALUES IN (5,6) ENGINE = MyISAM,
+ PARTITION pa8 VALUES IN (7,8) ENGINE = MyISAM,
+ PARTITION pa10 VALUES IN (9,10) ENGINE = MyISAM) */
+9*3 inserts;
+insert into t4 values (9);
+insert into t4 values (9+0.333333333);
+insert into t4 values (9+0.755555555);
+insert into t4 values (8);
+insert into t4 values (8+0.333333333);
+insert into t4 values (8+0.755555555);
+insert into t4 values (7);
+insert into t4 values (7+0.333333333);
+insert into t4 values (7+0.755555555);
+insert into t4 values (6);
+insert into t4 values (6+0.333333333);
+insert into t4 values (6+0.755555555);
+insert into t4 values (5);
+insert into t4 values (5+0.333333333);
+insert into t4 values (5+0.755555555);
+insert into t4 values (4);
+insert into t4 values (4+0.333333333);
+insert into t4 values (4+0.755555555);
+insert into t4 values (3);
+insert into t4 values (3+0.333333333);
+insert into t4 values (3+0.755555555);
+insert into t4 values (2);
+insert into t4 values (2+0.333333333);
+insert into t4 values (2+0.755555555);
+insert into t4 values (1);
+insert into t4 values (1+0.333333333);
+insert into t4 values (1+0.755555555);
+select count(*) from t4;
+count(*)
+27
+drop table t4;
diff --git a/mysql-test/suite/perfschema/include/privilege.inc b/mysql-test/suite/perfschema/include/privilege.inc
index 3973c41b51b..f29ef65f519 100644
--- a/mysql-test/suite/perfschema/include/privilege.inc
+++ b/mysql-test/suite/perfschema/include/privilege.inc
@@ -100,16 +100,16 @@ create trigger performance_schema.bi_file_instances
before insert on performance_schema.file_instances
for each row begin end;
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1(a int) engine=PERFORMANCE_SCHEMA;
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1 like performance_schema.setup_instruments;
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1 like performance_schema.events_waits_current;
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1 like performance_schema.file_instances;
--error ER_TABLEACCESS_DENIED_ERROR
diff --git a/mysql-test/suite/perfschema/r/dml_cond_instances.result b/mysql-test/suite/perfschema/r/dml_cond_instances.result
index 922effc59ae..285c32090af 100644
--- a/mysql-test/suite/perfschema/r/dml_cond_instances.result
+++ b/mysql-test/suite/perfschema/r/dml_cond_instances.result
@@ -1,9 +1,6 @@
select * from performance_schema.cond_instances limit 1;
-NAME OBJECT_INSTANCE_BEGIN
-# #
select * from performance_schema.cond_instances
where name='FOO';
-NAME OBJECT_INSTANCE_BEGIN
insert into performance_schema.cond_instances
set name='FOO', object_instance_begin=12;
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'cond_instances'
diff --git a/mysql-test/suite/perfschema/r/dml_events_waits_current.result b/mysql-test/suite/perfschema/r/dml_events_waits_current.result
index 9b0bcf7f876..122cfcce4a1 100644
--- a/mysql-test/suite/perfschema/r/dml_events_waits_current.result
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_current.result
@@ -1,10 +1,7 @@
select * from performance_schema.events_waits_current
where event_name like 'Wait/Synch/%' limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.events_waits_current
where event_name='FOO';
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
insert into performance_schema.events_waits_current
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
diff --git a/mysql-test/suite/perfschema/r/dml_events_waits_history.result b/mysql-test/suite/perfschema/r/dml_events_waits_history.result
index 5fc95584c7f..199ccc1cfa5 100644
--- a/mysql-test/suite/perfschema/r/dml_events_waits_history.result
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_history.result
@@ -1,18 +1,11 @@
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.events_waits_history
where event_name='FOO';
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
insert into performance_schema.events_waits_history
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
diff --git a/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result b/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result
index 2ce949b2228..773dcd3b1dc 100644
--- a/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result
@@ -1,18 +1,11 @@
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.events_waits_history_long
where event_name='FOO';
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
insert into performance_schema.events_waits_history_long
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
diff --git a/mysql-test/suite/perfschema/r/dml_ews_by_instance.result b/mysql-test/suite/perfschema/r/dml_ews_by_instance.result
index 0a745a2c38a..6ba37025d3b 100644
--- a/mysql-test/suite/perfschema/r/dml_ews_by_instance.result
+++ b/mysql-test/suite/perfschema/r/dml_ews_by_instance.result
@@ -1,26 +1,15 @@
select * from performance_schema.events_waits_summary_by_instance
where event_name like 'Wait/Synch/%' limit 1;
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
select * from performance_schema.events_waits_summary_by_instance
where event_name='FOO';
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
select * from performance_schema.events_waits_summary_by_instance
order by count_star limit 1;
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
select * from performance_schema.events_waits_summary_by_instance
order by count_star desc limit 1;
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
select * from performance_schema.events_waits_summary_by_instance
where min_timer_wait > 0 order by count_star limit 1;
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
select * from performance_schema.events_waits_summary_by_instance
where min_timer_wait > 0 order by count_star desc limit 1;
-EVENT_NAME OBJECT_INSTANCE_BEGIN COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
insert into performance_schema.events_waits_summary_by_instance
set event_name='FOO', object_instance_begin=0,
count_star=1, sum_timer_wait=2, min_timer_wait=3,
diff --git a/mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result b/mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result
index c64bcdd40f6..a98acb5f536 100644
--- a/mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result
+++ b/mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result
@@ -1,10 +1,7 @@
select * from performance_schema.events_waits_summary_by_thread_by_event_name
where event_name like 'Wait/Synch/%' limit 1;
-THREAD_ID EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # # #
select * from performance_schema.events_waits_summary_by_thread_by_event_name
where event_name='FOO';
-THREAD_ID EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
insert into performance_schema.events_waits_summary_by_thread_by_event_name
set event_name='FOO', thread_id=1,
count_star=1, sum_timer_wait=2, min_timer_wait=3,
diff --git a/mysql-test/suite/perfschema/r/dml_ews_global_by_event_name.result b/mysql-test/suite/perfschema/r/dml_ews_global_by_event_name.result
index c59451922c5..159adbd8022 100644
--- a/mysql-test/suite/perfschema/r/dml_ews_global_by_event_name.result
+++ b/mysql-test/suite/perfschema/r/dml_ews_global_by_event_name.result
@@ -1,10 +1,7 @@
select * from performance_schema.events_waits_summary_global_by_event_name
where event_name like 'Wait/Synch/%' limit 1;
-EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
-# # # # # #
select * from performance_schema.events_waits_summary_global_by_event_name
where event_name='FOO';
-EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
insert into performance_schema.events_waits_summary_global_by_event_name
set event_name='FOO', count_star=1, sum_timer_wait=2, min_timer_wait=3,
avg_timer_wait=4, max_timer_wait=5;
diff --git a/mysql-test/suite/perfschema/r/dml_file_instances.result b/mysql-test/suite/perfschema/r/dml_file_instances.result
index 5a51a4ca018..4a8a7ac4d47 100644
--- a/mysql-test/suite/perfschema/r/dml_file_instances.result
+++ b/mysql-test/suite/perfschema/r/dml_file_instances.result
@@ -1,9 +1,6 @@
select * from performance_schema.file_instances limit 1;
-FILE_NAME EVENT_NAME OPEN_COUNT
-# # #
select * from performance_schema.file_instances
where file_name='FOO';
-FILE_NAME EVENT_NAME OPEN_COUNT
insert into performance_schema.file_instances
set file_name='FOO', event_name='BAR', open_count=12;
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'file_instances'
diff --git a/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result b/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result
index 97a196dbf19..a8a9fe852bb 100644
--- a/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result
+++ b/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result
@@ -1,10 +1,7 @@
select * from performance_schema.file_summary_by_event_name
where event_name like 'Wait/io/%' limit 1;
-EVENT_NAME COUNT_READ COUNT_WRITE SUM_NUMBER_OF_BYTES_READ SUM_NUMBER_OF_BYTES_WRITE
-# # # # #
select * from performance_schema.file_summary_by_event_name
where event_name='FOO';
-EVENT_NAME COUNT_READ COUNT_WRITE SUM_NUMBER_OF_BYTES_READ SUM_NUMBER_OF_BYTES_WRITE
insert into performance_schema.file_summary_by_event_name
set event_name='FOO', count_read=1, count_write=2,
sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
diff --git a/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result b/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result
index d85e23cb6f4..456d6e31173 100644
--- a/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result
+++ b/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result
@@ -1,10 +1,7 @@
select * from performance_schema.file_summary_by_instance
where event_name like 'Wait/io/%' limit 1;
-FILE_NAME EVENT_NAME COUNT_READ COUNT_WRITE SUM_NUMBER_OF_BYTES_READ SUM_NUMBER_OF_BYTES_WRITE
-# # # # # #
select * from performance_schema.file_summary_by_instance
where event_name='FOO';
-FILE_NAME EVENT_NAME COUNT_READ COUNT_WRITE SUM_NUMBER_OF_BYTES_READ SUM_NUMBER_OF_BYTES_WRITE
insert into performance_schema.file_summary_by_instance
set event_name='FOO', count_read=1, count_write=2,
sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
diff --git a/mysql-test/suite/perfschema/r/dml_mutex_instances.result b/mysql-test/suite/perfschema/r/dml_mutex_instances.result
index 1ea7311b149..665517c7227 100644
--- a/mysql-test/suite/perfschema/r/dml_mutex_instances.result
+++ b/mysql-test/suite/perfschema/r/dml_mutex_instances.result
@@ -1,9 +1,6 @@
select * from performance_schema.mutex_instances limit 1;
-NAME OBJECT_INSTANCE_BEGIN LOCKED_BY_THREAD_ID
-# # #
select * from performance_schema.mutex_instances
where name='FOO';
-NAME OBJECT_INSTANCE_BEGIN LOCKED_BY_THREAD_ID
insert into performance_schema.mutex_instances
set name='FOO', object_instance_begin=12;
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'mutex_instances'
diff --git a/mysql-test/suite/perfschema/r/dml_rwlock_instances.result b/mysql-test/suite/perfschema/r/dml_rwlock_instances.result
index 964fa0fa46f..b072eea3955 100644
--- a/mysql-test/suite/perfschema/r/dml_rwlock_instances.result
+++ b/mysql-test/suite/perfschema/r/dml_rwlock_instances.result
@@ -1,9 +1,6 @@
select * from performance_schema.rwlock_instances limit 1;
-NAME OBJECT_INSTANCE_BEGIN WRITE_LOCKED_BY_THREAD_ID READ_LOCKED_BY_COUNT
-# # # #
select * from performance_schema.rwlock_instances
where name='FOO';
-NAME OBJECT_INSTANCE_BEGIN WRITE_LOCKED_BY_THREAD_ID READ_LOCKED_BY_COUNT
insert into performance_schema.rwlock_instances
set name='FOO', object_instance_begin=12;
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'rwlock_instances'
diff --git a/mysql-test/suite/perfschema/r/dml_threads.result b/mysql-test/suite/perfschema/r/dml_threads.result
index 8c61521d091..b78d1934d1f 100644
--- a/mysql-test/suite/perfschema/r/dml_threads.result
+++ b/mysql-test/suite/perfschema/r/dml_threads.result
@@ -1,10 +1,7 @@
select * from performance_schema.threads
where name like 'Thread/%' limit 1;
-THREAD_ID PROCESSLIST_ID NAME
-# # #
select * from performance_schema.threads
where name='FOO';
-THREAD_ID PROCESSLIST_ID NAME
insert into performance_schema.threads
set name='FOO', thread_id=1, processlist_id=2;
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'threads'
diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result
index 4e9b08e00ef..2f66f80ed75 100644
--- a/mysql-test/suite/perfschema/r/misc.result
+++ b/mysql-test/suite/perfschema/r/misc.result
@@ -6,9 +6,9 @@ AND EVENT_NAME IN
WHERE NAME LIKE "wait/synch/%")
LIMIT 1;
create table test.t1(a int) engine=performance_schema;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.events_waits_current;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table performance_schema.t1(a int);
ERROR 42000: CREATE command denied to user 'root'@'localhost' for table 't1'
drop table if exists test.ghost;
diff --git a/mysql-test/suite/perfschema/r/myisam_file_io.result b/mysql-test/suite/perfschema/r/myisam_file_io.result
index 287abd43d74..5cdcf6ac789 100644
--- a/mysql-test/suite/perfschema/r/myisam_file_io.result
+++ b/mysql-test/suite/perfschema/r/myisam_file_io.result
@@ -16,6 +16,7 @@ operation, number_of_bytes,
substring(object_name, locate("no_index_tab", object_name)) as short_name
from performance_schema.events_waits_history_long
where operation not like "tell"
+ and event_name like "wait/io/file/myisam/%"
order by thread_id, event_id;
event_name short_source operation number_of_bytes short_name
wait/io/file/myisam/kfile mi_create.c: create NULL no_index_tab.MYI
diff --git a/mysql-test/suite/perfschema/r/privilege.result b/mysql-test/suite/perfschema/r/privilege.result
index 61f5adac354..d1831c9c4be 100644
--- a/mysql-test/suite/perfschema/r/privilege.result
+++ b/mysql-test/suite/perfschema/r/privilege.result
@@ -152,13 +152,13 @@ before insert on performance_schema.file_instances
for each row begin end;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
create table test.t1(a int) engine=PERFORMANCE_SCHEMA;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.setup_instruments;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.events_waits_current;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.file_instances;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
insert into performance_schema.setup_instruments
set name="foo";
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'setup_instruments'
@@ -250,13 +250,13 @@ before insert on performance_schema.file_instances
for each row begin end;
ERROR 42000: Access denied for user 'pfs_user_1'@'localhost' to database 'performance_schema'
create table test.t1(a int) engine=PERFORMANCE_SCHEMA;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.setup_instruments;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.events_waits_current;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.file_instances;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
insert into performance_schema.setup_instruments
set name="foo";
ERROR 42000: INSERT command denied to user 'pfs_user_1'@'localhost' for table 'setup_instruments'
@@ -348,13 +348,13 @@ before insert on performance_schema.file_instances
for each row begin end;
ERROR 42000: Access denied for user 'pfs_user_2'@'localhost' to database 'performance_schema'
create table test.t1(a int) engine=PERFORMANCE_SCHEMA;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.setup_instruments;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.events_waits_current;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.file_instances;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
insert into performance_schema.setup_instruments
set name="foo";
ERROR 42000: INSERT command denied to user 'pfs_user_2'@'localhost' for table 'setup_instruments'
@@ -446,13 +446,13 @@ before insert on performance_schema.file_instances
for each row begin end;
ERROR 42000: Access denied for user 'pfs_user_3'@'localhost' to database 'performance_schema'
create table test.t1(a int) engine=PERFORMANCE_SCHEMA;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.setup_instruments;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.events_waits_current;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
create table test.t1 like performance_schema.file_instances;
-ERROR HY000: Invalid performance_schema usage.
+ERROR HY000: Can't create table 'test.t1' (errno: 131)
insert into performance_schema.setup_instruments
set name="foo";
ERROR 42000: INSERT command denied to user 'pfs_user_3'@'localhost' for table 'setup_instruments'
diff --git a/mysql-test/suite/perfschema/r/thread_cache.result b/mysql-test/suite/perfschema/r/thread_cache.result
index de4d19f9c64..f64cadc2705 100644
--- a/mysql-test/suite/perfschema/r/thread_cache.result
+++ b/mysql-test/suite/perfschema/r/thread_cache.result
@@ -1,3 +1,4 @@
+flush status;
SET @saved_thread_cache_size = @@global.thread_cache_size;
set global thread_cache_size = 0;
show variables like "thread_cache_size";
@@ -32,3 +33,7 @@ select @thread_id_increment;
@thread_id_increment
1
set global thread_cache_size = @saved_thread_cache_size;
+show status like "performance_schema_thread%";
+Variable_name Value
+Performance_schema_thread_classes_lost 0
+Performance_schema_thread_instances_lost 0
diff --git a/mysql-test/suite/perfschema/t/dml_cond_instances.test b/mysql-test/suite/perfschema/t/dml_cond_instances.test
index 528dae80dfa..e2773d15252 100644
--- a/mysql-test/suite/perfschema/t/dml_cond_instances.test
+++ b/mysql-test/suite/perfschema/t/dml_cond_instances.test
@@ -18,11 +18,12 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 #
+--disable_result_log
select * from performance_schema.cond_instances limit 1;
select * from performance_schema.cond_instances
where name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.cond_instances
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_current.test b/mysql-test/suite/perfschema/t/dml_events_waits_current.test
index f82fac63df9..43a70618b4d 100644
--- a/mysql-test/suite/perfschema/t/dml_events_waits_current.test
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_current.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.events_waits_current
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_current
where event_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_current
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_history.test b/mysql-test/suite/perfschema/t/dml_events_waits_history.test
index 865d261d7f9..51937a75f49 100644
--- a/mysql-test/suite/perfschema/t/dml_events_waits_history.test
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history.test
@@ -18,20 +18,19 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_history
where event_name='FOO';
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.events_waits_history
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_history
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test b/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
index 606e33b3e80..a7fc1937529 100644
--- a/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
@@ -18,20 +18,19 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_history_long
where event_name='FOO';
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.events_waits_history_long
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_history_long
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_instance.test b/mysql-test/suite/perfschema/t/dml_ews_by_instance.test
index 2e4ab9bcc74..2f25f842dcc 100644
--- a/mysql-test/suite/perfschema/t/dml_ews_by_instance.test
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_instance.test
@@ -18,28 +18,25 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
+--disable_result_log
select * from performance_schema.events_waits_summary_by_instance
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_summary_by_instance
where event_name='FOO';
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
select * from performance_schema.events_waits_summary_by_instance
order by count_star limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
select * from performance_schema.events_waits_summary_by_instance
order by count_star desc limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
select * from performance_schema.events_waits_summary_by_instance
where min_timer_wait > 0 order by count_star limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
select * from performance_schema.events_waits_summary_by_instance
where min_timer_wait > 0 order by count_star desc limit 1;
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_summary_by_instance
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test
index bdbee9a90c1..a1b41fdab42 100644
--- a/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
+--disable_result_log
select * from performance_schema.events_waits_summary_by_thread_by_event_name
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_summary_by_thread_by_event_name
where event_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_summary_by_thread_by_event_name
diff --git a/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test
index 4f1b50bb7c0..bf311c7b470 100644
--- a/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test
+++ b/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 #
+--disable_result_log
select * from performance_schema.events_waits_summary_global_by_event_name
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.events_waits_summary_global_by_event_name
where event_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.events_waits_summary_global_by_event_name
diff --git a/mysql-test/suite/perfschema/t/dml_file_instances.test b/mysql-test/suite/perfschema/t/dml_file_instances.test
index f3a13eaee32..d7a1002b040 100644
--- a/mysql-test/suite/perfschema/t/dml_file_instances.test
+++ b/mysql-test/suite/perfschema/t/dml_file_instances.test
@@ -18,11 +18,12 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 #
+--disable_result_log
select * from performance_schema.file_instances limit 1;
select * from performance_schema.file_instances
where file_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.file_instances
diff --git a/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test b/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test
index f5e1f90e9c9..8060c4a4cbe 100644
--- a/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test
+++ b/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 #
+--disable_result_log
select * from performance_schema.file_summary_by_event_name
where event_name like 'Wait/io/%' limit 1;
select * from performance_schema.file_summary_by_event_name
where event_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.file_summary_by_event_name
diff --git a/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test b/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test
index 2ac32b97f56..c24f57390a4 100644
--- a/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test
+++ b/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 #
+--disable_result_log
select * from performance_schema.file_summary_by_instance
where event_name like 'Wait/io/%' limit 1;
select * from performance_schema.file_summary_by_instance
where event_name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.file_summary_by_instance
diff --git a/mysql-test/suite/perfschema/t/dml_mutex_instances.test b/mysql-test/suite/perfschema/t/dml_mutex_instances.test
index c0bbd5276a0..1a48bd9d8ea 100644
--- a/mysql-test/suite/perfschema/t/dml_mutex_instances.test
+++ b/mysql-test/suite/perfschema/t/dml_mutex_instances.test
@@ -18,11 +18,12 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 #
+--disable_result_log
select * from performance_schema.mutex_instances limit 1;
select * from performance_schema.mutex_instances
where name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.mutex_instances
diff --git a/mysql-test/suite/perfschema/t/dml_rwlock_instances.test b/mysql-test/suite/perfschema/t/dml_rwlock_instances.test
index c0fd89a8e75..b588502c996 100644
--- a/mysql-test/suite/perfschema/t/dml_rwlock_instances.test
+++ b/mysql-test/suite/perfschema/t/dml_rwlock_instances.test
@@ -18,11 +18,12 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 #
+--disable_result_log
select * from performance_schema.rwlock_instances limit 1;
select * from performance_schema.rwlock_instances
where name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.rwlock_instances
diff --git a/mysql-test/suite/perfschema/t/dml_threads.test b/mysql-test/suite/perfschema/t/dml_threads.test
index e7188497061..6cb372e2c96 100644
--- a/mysql-test/suite/perfschema/t/dml_threads.test
+++ b/mysql-test/suite/perfschema/t/dml_threads.test
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 #
+--disable_result_log
select * from performance_schema.threads
where name like 'Thread/%' limit 1;
select * from performance_schema.threads
where name='FOO';
+--enable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
insert into performance_schema.threads
diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test
index 72e891ca805..dee18f0fa21 100644
--- a/mysql-test/suite/perfschema/t/misc.test
+++ b/mysql-test/suite/perfschema/t/misc.test
@@ -38,14 +38,14 @@ LIMIT 1;
# Bug#45088 Should not be able to create tables of engine PERFORMANCE_SCHEMA
#
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1(a int) engine=performance_schema;
#
# Bug#44897 Performance Schema: can create a ghost table in another database
#
---error ER_WRONG_PERFSCHEMA_USAGE
+--error ER_CANT_CREATE_TABLE
create table test.t1 like performance_schema.events_waits_current;
#
diff --git a/mysql-test/suite/perfschema/t/myisam_file_io.test b/mysql-test/suite/perfschema/t/myisam_file_io.test
index c2502b5895a..de9f6f48480 100644
--- a/mysql-test/suite/perfschema/t/myisam_file_io.test
+++ b/mysql-test/suite/perfschema/t/myisam_file_io.test
@@ -46,6 +46,13 @@ insert into no_index_tab set a = 'foo', b = 1;
# Verification
# Note that mi_create.c contains mysql_file_tell() calls in debug only,
# so the result are filtered to remove 'tell'.
+# Note that even after setting other instruments to enabled='NO'
+# and truncating the events_waits_history_long table,
+# some events -- that were already started but not completed --
+# for other instruments could still be added in the history.
+# To protect against that, an extra where clause
+# "and event_name like "wait/io/file/myisam/%"
+# is added to the select to filter out the result.
select event_name,
left(source, locate(":", source)) as short_source,
@@ -53,6 +60,7 @@ select event_name,
substring(object_name, locate("no_index_tab", object_name)) as short_name
from performance_schema.events_waits_history_long
where operation not like "tell"
+ and event_name like "wait/io/file/myisam/%"
order by thread_id, event_id;
# In case of failures, this will tell if file io are lost.
diff --git a/mysql-test/suite/perfschema/t/thread_cache.test b/mysql-test/suite/perfschema/t/thread_cache.test
index 488b359cd34..e839552ed19 100644
--- a/mysql-test/suite/perfschema/t/thread_cache.test
+++ b/mysql-test/suite/perfschema/t/thread_cache.test
@@ -20,6 +20,8 @@
# Setup
+flush status;
+
SET @saved_thread_cache_size = @@global.thread_cache_size;
set global thread_cache_size = 0;
@@ -40,7 +42,7 @@ let $con2_ID=`select connection_id()`;
let $con2_THREAD_ID=`select thread_id from performance_schema.threads
where PROCESSLIST_ID = connection_id()`;
-connection default;
+--connection default
--disable_query_log
eval select ($con2_ID - $con1_ID) into @id_increment;
@@ -52,7 +54,15 @@ select @id_increment;
# Expect 1, THREAD_ID is incremented for each new connection
select @thread_id_increment;
-disconnect con2;
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect con2 to complete
+let $wait_condition=
+ select count(*) = 2 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
connect (con3, localhost, root, , );
@@ -61,10 +71,16 @@ let $con3_ID=`select connection_id()`;
let $con3_THREAD_ID=`select thread_id from performance_schema.threads
where PROCESSLIST_ID = connection_id()`;
-disconnect con3;
-disconnect con1;
+--disconnect con3
+--disconnect con1
+
+--connection default
-connection default;
+# Wait for the disconnect con1 and con3 to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
--disable_query_log
eval select ($con3_ID - $con2_ID) into @id_increment;
@@ -92,7 +108,7 @@ let $con2_ID=`select connection_id()`;
let $con2_THREAD_ID=`select thread_id from performance_schema.threads
where PROCESSLIST_ID = connection_id()`;
-connection default;
+--connection default
--disable_query_log
eval select ($con2_ID - $con1_ID) into @id_increment;
@@ -102,7 +118,15 @@ eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment;
select @id_increment;
select @thread_id_increment;
-disconnect con2;
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect con2 to complete
+let $wait_condition=
+ select count(*) = 2 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
connect (con3, localhost, root, , );
@@ -111,10 +135,16 @@ let $con3_ID=`select connection_id()`;
let $con3_THREAD_ID=`select thread_id from performance_schema.threads
where PROCESSLIST_ID = connection_id()`;
-disconnect con3;
-disconnect con1;
+--disconnect con3
+--disconnect con1
-connection default;
+--connection default
+
+# Wait for the disconnect con1 and con3 to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
--disable_query_log
eval select ($con3_ID - $con2_ID) into @id_increment;
@@ -132,3 +162,5 @@ select @thread_id_increment;
set global thread_cache_size = @saved_thread_cache_size;
+show status like "performance_schema_thread%";
+
diff --git a/mysql-test/suite/rpl/r/rpl_binlog_errors.result b/mysql-test/suite/rpl/r/rpl_binlog_errors.result
new file mode 100644
index 00000000000..6c8c750bc79
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_binlog_errors.result
@@ -0,0 +1,274 @@
+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;
+#######################################################################
+####################### PART 1: MASTER TESTS ##########################
+#######################################################################
+include/stop_slave.inc
+call mtr.add_suppression("Can't generate a unique log-filename");
+call mtr.add_suppression("Writing one row to the row-based binary log failed.*");
+call mtr.add_suppression("Error writing file .*");
+SET @old_debug= @@global.debug;
+SELECT repeat('x',8192) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data';
+SELECT repeat('x',10) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data';
+RESET MASTER;
+###################### TEST #1
+FLUSH LOGS;
+# assert: must show two binlogs
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+master-bin.000002 #
+###################### TEST #2
+RESET MASTER;
+SET GLOBAL debug="+d,error_unique_log_filename";
+FLUSH LOGS;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# assert: must show one binlog
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+SET GLOBAL debug="";
+RESET MASTER;
+###################### TEST #3
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a VARCHAR(16384)) Engine=InnoDB;
+CREATE TABLE t4 (a VARCHAR(16384));
+INSERT INTO t1 VALUES (1);
+RESET MASTER;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2;
+# assert: must show two binlog
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+master-bin.000002 #
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+###################### TEST #4
+SET GLOBAL debug="+d,error_unique_log_filename";
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# assert: must show one entry
+SELECT count(*) FROM t2;
+count(*)
+1
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+###################### TEST #5
+SET GLOBAL debug="+d,error_unique_log_filename";
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data' INTO TABLE t2;
+# assert: must show one entry
+SELECT count(*) FROM t2;
+count(*)
+1
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+###################### TEST #6
+SET GLOBAL debug="+d,error_unique_log_filename";
+SET AUTOCOMMIT=0;
+INSERT INTO t2 VALUES ('muse');
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2;
+INSERT INTO t2 VALUES ('muse');
+COMMIT;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# assert: must show three entries
+SELECT count(*) FROM t2;
+count(*)
+3
+SET AUTOCOMMIT= 1;
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+###################### TEST #7
+SET GLOBAL debug="+d,error_unique_log_filename";
+SELECT count(*) FROM t4;
+count(*)
+0
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t4;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# assert: must show 1 entry
+SELECT count(*) FROM t4;
+count(*)
+1
+### check that the incident event is written to the current log
+SET GLOBAL debug="-d,error_unique_log_filename";
+FLUSH LOGS;
+SHOW BINLOG EVENTS IN 'BINLOG_FILE' FROM <binlog_start> LIMIT 1;
+Log_name Pos Event_type Server_id End_log_pos Info
+BINLOG_FILE # Incident # # #1 (LOST_EVENTS)
+DELETE FROM t4;
+RESET MASTER;
+###################### TEST #8
+SET GLOBAL debug="+d,error_unique_log_filename";
+# must show 0 entries
+SELECT count(*) FROM t4;
+count(*)
+0
+SELECT count(*) FROM t2;
+count(*)
+0
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t4;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc');
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# INFO: Count(*) Before Offending DELETEs
+# assert: must show 1 entry
+SELECT count(*) FROM t4;
+count(*)
+1
+# assert: must show 4 entries
+SELECT count(*) FROM t2;
+count(*)
+4
+DELETE FROM t4;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+DELETE FROM t2;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+# INFO: Count(*) After Offending DELETEs
+# assert: must show zero entries
+SELECT count(*) FROM t4;
+count(*)
+0
+SELECT count(*) FROM t2;
+count(*)
+0
+SET GLOBAL debug="-d,error_unique_log_filename";
+###################### TEST #9
+SET GLOBAL debug="+d,error_unique_log_filename";
+SET SQL_LOG_BIN=0;
+INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd');
+INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh');
+# assert: must show four entries
+SELECT count(*) FROM t2;
+count(*)
+4
+SELECT count(*) FROM t4;
+count(*)
+4
+DELETE FROM t2;
+DELETE FROM t4;
+# assert: must show zero entries
+SELECT count(*) FROM t2;
+count(*)
+0
+SELECT count(*) FROM t4;
+count(*)
+0
+SET SQL_LOG_BIN=1;
+SET GLOBAL debug="-d,error_unique_log_filename";
+###################### TEST #10
+call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
+call mtr.add_suppression("Could not open .*");
+RESET MASTER;
+SHOW WARNINGS;
+Level Code Message
+SET GLOBAL debug="+d,fault_injection_registering_index";
+FLUSH LOGS;
+ERROR HY000: Can't open file: 'master-bin.000002' (errno: 1)
+SET GLOBAL debug="-d,fault_injection_registering_index";
+SHOW BINARY LOGS;
+ERROR HY000: You are not using binary logging
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+###################### TEST #11
+SET GLOBAL debug="+d,fault_injection_openning_index";
+FLUSH LOGS;
+ERROR HY000: Can't open file: 'master-bin.index' (errno: 1)
+SET GLOBAL debug="-d,fault_injection_openning_index";
+RESET MASTER;
+ERROR HY000: Binlog closed, cannot RESET MASTER
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+###################### TEST #12
+SET GLOBAL debug="+d,fault_injection_new_file_rotate_event";
+FLUSH LOGS;
+ERROR HY000: Can't open file: 'master-bin' (errno: 2)
+SET GLOBAL debug="-d,fault_injection_new_file_rotate_event";
+RESET MASTER;
+ERROR HY000: Binlog closed, cannot RESET MASTER
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+SET GLOBAL debug= @old_debug;
+DROP TABLE t1, t2, t4;
+RESET MASTER;
+include/start_slave.inc
+#######################################################################
+####################### PART 2: SLAVE TESTS ###########################
+#######################################################################
+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;
+call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
+call mtr.add_suppression("Error writing file .*");
+call mtr.add_suppression("Could not open .*");
+call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
+call mtr.add_suppression("Can't generate a unique log-filename .*");
+###################### TEST #13
+SET @old_debug=@@global.debug;
+include/stop_slave.inc
+SET GLOBAL debug="+d,error_unique_log_filename";
+START SLAVE io_thread;
+Last_IO_Error = Relay log write failure: could not queue event from master
+SET GLOBAL debug="-d,error_unique_log_filename";
+SET GLOBAL debug=@old_debug;
+###################### TEST #14
+SET @old_debug=@@global.debug;
+include/stop_slave.inc
+SET GLOBAL debug="+d,fault_injection_new_file_rotate_event";
+START SLAVE io_thread;
+Last_IO_Error = Relay log write failure: could not queue event from master
+SET GLOBAL debug="-d,fault_injection_new_file_rotate_event";
+SET GLOBAL debug=@old_debug;
+###################### TEST #15
+SET @old_debug=@@global.debug;
+include/stop_slave.inc
+SET GLOBAL debug="+d,fault_injection_registering_index";
+START SLAVE io_thread;
+Last_IO_Error = Relay log write failure: could not queue event from master
+SET GLOBAL debug="-d,fault_injection_registering_index";
+SET GLOBAL debug=@old_debug;
+###################### TEST #16
+SET @old_debug=@@global.debug;
+include/stop_slave.inc
+SET GLOBAL debug="+d,fault_injection_openning_index";
+START SLAVE io_thread;
+Last_IO_Error = Relay log write failure: could not queue event from master
+SET GLOBAL debug="-d,fault_injection_openning_index";
+SET GLOBAL debug=@old_debug;
+include/stop_slave.inc
+SET GLOBAL debug=@old_debug;
+RESET SLAVE;
+RESET MASTER;
+include/start_slave.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
index 479caed8e6b..c7f2ffab47a 100644
--- a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
+++ b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
@@ -7,6 +7,8 @@ start slave;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -129,13 +131,18 @@ source include/diff_master_slave.inc;
# [ On Slave ]
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
include/stop_slave.inc
include/start_slave.inc
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
+CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
TRUNCATE t1;
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
BEGIN;
Repeat statement 'INSERT INTO t1 VALUES($n, repeat("a", 32))' 128 times
COMMIT;
@@ -146,6 +153,8 @@ show binlog events in 'slave-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/start_slave.inc
SELECT count(*) FROM t1;
diff --git a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
index 9c1dfebebaf..f04c229a9b6 100644
--- a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
+++ b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
@@ -7,6 +7,8 @@ start slave;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -130,13 +132,18 @@ source include/diff_master_slave.inc;
# [ On Slave ]
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
include/stop_slave.inc
include/start_slave.inc
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
+CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
TRUNCATE t1;
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
BEGIN;
Repeat statement 'INSERT INTO t1 VALUES($n, repeat("a", 32))' 128 times
COMMIT;
@@ -147,6 +154,8 @@ show binlog events in 'slave-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/start_slave.inc
SELECT count(*) FROM t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result b/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
index e69952787fb..4bbbc0e99c6 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
@@ -11,6 +11,6 @@ set sql_log_bin=1;
insert into t1 values(1),(2);
ERROR 23000: Duplicate entry '2' for key 'a'
drop table t1;
-Error: "Query caused different errors on master and slave. Error on master: 'Duplicate entry '%-.192s' for key %d' (1062), Error on slave: 'no error' (0). Default database: 'test'. Query: 'insert into t1 values(1),(2)'" (expected different error codes on master and slave)
+Error: "Query caused different errors on master and slave. Error on master: message (format)='Duplicate entry '%-.192s' for key %d' error code=1062 ; Error on slave: actual message='no error', error code=0. Default database: 'test'. Query: 'insert into t1 values(1),(2)'" (expected different error codes on master and slave)
Errno: "0" (expected 0)
drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
index 479caed8e6b..c7f2ffab47a 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
@@ -7,6 +7,8 @@ start slave;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -129,13 +131,18 @@ source include/diff_master_slave.inc;
# [ On Slave ]
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
+SET GLOBAL max_binlog_stmt_cache_size = 4096;
+SET GLOBAL binlog_stmt_cache_size = 4096;
include/stop_slave.inc
include/start_slave.inc
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
+CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
TRUNCATE t1;
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
BEGIN;
Repeat statement 'INSERT INTO t1 VALUES($n, repeat("a", 32))' 128 times
COMMIT;
@@ -146,6 +153,8 @@ show binlog events in 'slave-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
+SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
+SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/start_slave.inc
SELECT count(*) FROM t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result b/mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result
index 6b0c1c38c16..14ba6080ec0 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_insert_delayed.result
@@ -51,8 +51,8 @@ CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
-use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
-use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+use `test`; INSERT IGNORE INTO t1 VALUES(1)
+use `test`; INSERT IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
@@ -60,10 +60,10 @@ On slave
show binlog events in 'slave-bin.000002' from <binlog_start> limit 1,6;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Query # # BEGIN
-slave-bin.000002 # Query # # use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
slave-bin.000002 # Query # # COMMIT
slave-bin.000002 # Query # # BEGIN
-slave-bin.000002 # Query # # use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
slave-bin.000002 # Query # # COMMIT
select * from t1;
a
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_errors-master.opt b/mysql-test/suite/rpl/t/rpl_binlog_errors-master.opt
new file mode 100644
index 00000000000..f8e46a44854
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_binlog_errors-master.opt
@@ -0,0 +1 @@
+--max_binlog_size=4096
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_errors.test b/mysql-test/suite/rpl/t/rpl_binlog_errors.test
new file mode 100644
index 00000000000..e4eb212e1cd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_binlog_errors.test
@@ -0,0 +1,415 @@
+# BUG#46166: MYSQL_BIN_LOG::new_file_impl is not propagating error
+# when generating new name.
+#
+# WHY
+# ===
+#
+# We want to check whether error is reported or not when
+# new_file_impl fails (this may happen when rotation is not
+# possible because there is some problem finding an
+# unique filename).
+#
+# HOW
+# ===
+#
+# Test cases are documented inline.
+
+-- source include/master-slave.inc
+-- source include/have_innodb.inc
+-- source include/have_debug.inc
+
+-- echo #######################################################################
+-- echo ####################### PART 1: MASTER TESTS ##########################
+-- echo #######################################################################
+
+
+### ACTION: stopping slave as it is not needed for the first part of
+### the test
+
+-- connection slave
+-- source include/stop_slave.inc
+-- connection master
+
+call mtr.add_suppression("Can't generate a unique log-filename");
+call mtr.add_suppression("Writing one row to the row-based binary log failed.*");
+call mtr.add_suppression("Error writing file .*");
+
+SET @old_debug= @@global.debug;
+
+### ACTION: create a large file (> 4096 bytes) that will be later used
+### in LOAD DATA INFILE to check binlog errors in its vacinity
+-- let $load_file= $MYSQLTEST_VARDIR/tmp/bug_46166.data
+-- let $MYSQLD_DATADIR= `select @@datadir`
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SELECT repeat('x',8192) INTO OUTFILE '$load_file'
+
+### ACTION: create a small file (< 4096 bytes) that will be later used
+### in LOAD DATA INFILE to check for absence of binlog errors
+### when file loading this file does not force flushing and
+### rotating the binary log
+-- let $load_file2= $MYSQLTEST_VARDIR/tmp/bug_46166-2.data
+-- let $MYSQLD_DATADIR= `select @@datadir`
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SELECT repeat('x',10) INTO OUTFILE '$load_file2'
+
+RESET MASTER;
+
+-- echo ###################### TEST #1
+
+### ASSERTION: no problem flushing logs (should show two binlogs)
+FLUSH LOGS;
+-- echo # assert: must show two binlogs
+-- source include/show_binary_logs.inc
+
+-- echo ###################### TEST #2
+
+### ASSERTION: check that FLUSH LOGS actually fails and reports
+### failure back to the user if find_uniq_filename fails
+### (should show just one binlog)
+
+RESET MASTER;
+SET GLOBAL debug="+d,error_unique_log_filename";
+-- error ER_NO_UNIQUE_LOGFILE
+FLUSH LOGS;
+-- echo # assert: must show one binlog
+-- source include/show_binary_logs.inc
+
+### ACTION: clean up and move to next test
+SET GLOBAL debug="";
+RESET MASTER;
+
+-- echo ###################### TEST #3
+
+### ACTION: create some tables (t1, t2, t4) and insert some values in
+### table t1
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a VARCHAR(16384)) Engine=InnoDB;
+CREATE TABLE t4 (a VARCHAR(16384));
+INSERT INTO t1 VALUES (1);
+RESET MASTER;
+
+### ASSERTION: we force rotation of the binary log because it exceeds
+### the max_binlog_size option (should show two binary
+### logs)
+
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
+
+# shows two binary logs
+-- echo # assert: must show two binlog
+-- source include/show_binary_logs.inc
+
+# clean up the table and the binlog to be used in next part of test
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+
+-- echo ###################### TEST #4
+
+### ASSERTION: load the big file into a transactional table and check
+### that it reports error. The table will contain the
+### changes performed despite the fact that it reported an
+### error.
+
+SET GLOBAL debug="+d,error_unique_log_filename";
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- error ER_NO_UNIQUE_LOGFILE
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
+
+# show table
+-- echo # assert: must show one entry
+SELECT count(*) FROM t2;
+
+# clean up the table and the binlog to be used in next part of test
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+
+-- echo ###################### TEST #5
+
+### ASSERTION: load the small file into a transactional table and
+### check that it succeeds
+
+SET GLOBAL debug="+d,error_unique_log_filename";
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$load_file2' INTO TABLE t2
+
+# show table
+-- echo # assert: must show one entry
+SELECT count(*) FROM t2;
+
+# clean up the table and the binlog to be used in next part of test
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+
+-- echo ###################### TEST #6
+
+### ASSERTION: check that even if one is using a transactional table
+### and explicit transactions (no autocommit) if rotation
+### fails we get the error. Transaction is not rolledback
+### because rotation happens after the commit.
+
+SET GLOBAL debug="+d,error_unique_log_filename";
+SET AUTOCOMMIT=0;
+INSERT INTO t2 VALUES ('muse');
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
+INSERT INTO t2 VALUES ('muse');
+-- error ER_NO_UNIQUE_LOGFILE
+COMMIT;
+
+### ACTION: Show the contents of the table after the test
+-- echo # assert: must show three entries
+SELECT count(*) FROM t2;
+
+### ACTION: clean up and move to the next test
+SET AUTOCOMMIT= 1;
+SET GLOBAL debug="-d,error_unique_log_filename";
+DELETE FROM t2;
+RESET MASTER;
+
+-- echo ###################### TEST #7
+
+### ASSERTION: check that on a non-transactional table, if rotation
+### fails then an error is reported and an incident event
+### is written to the current binary log.
+
+SET GLOBAL debug="+d,error_unique_log_filename";
+SELECT count(*) FROM t4;
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- error ER_NO_UNIQUE_LOGFILE
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t4
+
+-- echo # assert: must show 1 entry
+SELECT count(*) FROM t4;
+
+-- echo ### check that the incident event is written to the current log
+SET GLOBAL debug="-d,error_unique_log_filename";
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+
+# 53 is the size of the incident event, so we start from 22 bytes before the
+# current position
+-- let $binlog_start = `SELECT $binlog_start - 53`
+FLUSH LOGS;
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start> $binlog_file BINLOG_FILE
+-- replace_column 2 # 4 # 5 #
+-- eval SHOW BINLOG EVENTS IN '$binlog_file' FROM $binlog_start LIMIT 1
+
+# clean up and move to next test
+DELETE FROM t4;
+RESET MASTER;
+
+-- echo ###################### TEST #8
+
+### ASSERTION: check that statements end up in error but they succeed
+### on changing the data.
+
+SET GLOBAL debug="+d,error_unique_log_filename";
+-- echo # must show 0 entries
+SELECT count(*) FROM t4;
+SELECT count(*) FROM t2;
+
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- error ER_NO_UNIQUE_LOGFILE
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t4
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- error ER_NO_UNIQUE_LOGFILE
+-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
+-- error ER_NO_UNIQUE_LOGFILE
+INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc');
+
+-- echo # INFO: Count(*) Before Offending DELETEs
+-- echo # assert: must show 1 entry
+SELECT count(*) FROM t4;
+-- echo # assert: must show 4 entries
+SELECT count(*) FROM t2;
+
+-- error ER_NO_UNIQUE_LOGFILE
+DELETE FROM t4;
+-- error ER_NO_UNIQUE_LOGFILE
+DELETE FROM t2;
+
+-- echo # INFO: Count(*) After Offending DELETEs
+-- echo # assert: must show zero entries
+SELECT count(*) FROM t4;
+SELECT count(*) FROM t2;
+
+# remove fault injection
+SET GLOBAL debug="-d,error_unique_log_filename";
+
+-- echo ###################### TEST #9
+
+### ASSERTION: check that if we disable binlogging, then statements
+### succeed.
+SET GLOBAL debug="+d,error_unique_log_filename";
+SET SQL_LOG_BIN=0;
+INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd');
+INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh');
+-- echo # assert: must show four entries
+SELECT count(*) FROM t2;
+SELECT count(*) FROM t4;
+DELETE FROM t2;
+DELETE FROM t4;
+-- echo # assert: must show zero entries
+SELECT count(*) FROM t2;
+SELECT count(*) FROM t4;
+SET SQL_LOG_BIN=1;
+SET GLOBAL debug="-d,error_unique_log_filename";
+
+-- echo ###################### TEST #10
+
+### ASSERTION: check that error is reported if there is a failure
+### while registering the index file and the binary log
+### file or failure to write the rotate event.
+
+call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
+call mtr.add_suppression("Could not open .*");
+
+RESET MASTER;
+SHOW WARNINGS;
+
+# +d,fault_injection_registering_index => injects fault on MYSQL_BIN_LOG::open
+SET GLOBAL debug="+d,fault_injection_registering_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
+FLUSH LOGS;
+SET GLOBAL debug="-d,fault_injection_registering_index";
+
+-- error ER_NO_BINARY_LOGGING
+SHOW BINARY LOGS;
+
+# issue some statements and check that they don't fail
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+
+-- echo ###################### TEST #11
+
+### ASSERTION: check that error is reported if there is a failure
+### while opening the index file and the binary log file or
+### failure to write the rotate event.
+
+# restart the server so that we have binlog again
+--source include/restart_mysqld.inc
+
+# +d,fault_injection_openning_index => injects fault on MYSQL_BIN_LOG::open_index_file
+SET GLOBAL debug="+d,fault_injection_openning_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
+FLUSH LOGS;
+SET GLOBAL debug="-d,fault_injection_openning_index";
+
+-- error ER_FLUSH_MASTER_BINLOG_CLOSED
+RESET MASTER;
+
+# issue some statements and check that they don't fail
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+
+# restart the server so that we have binlog again
+-- source include/restart_mysqld.inc
+
+-- echo ###################### TEST #12
+
+### ASSERTION: check that error is reported if there is a failure
+### while writing the rotate event when creating a new log
+### file.
+
+# +d,fault_injection_new_file_rotate_event => injects fault on MYSQL_BIN_LOG::MYSQL_BIN_LOG::new_file_impl
+SET GLOBAL debug="+d,fault_injection_new_file_rotate_event";
+-- error ER_ERROR_ON_WRITE
+FLUSH LOGS;
+SET GLOBAL debug="-d,fault_injection_new_file_rotate_event";
+
+-- error ER_FLUSH_MASTER_BINLOG_CLOSED
+RESET MASTER;
+
+# issue some statements and check that they don't fail
+CREATE TABLE t5 (a INT);
+INSERT INTO t4 VALUES ('bbbbb');
+INSERT INTO t2 VALUES ('aaaaa');
+DELETE FROM t4;
+DELETE FROM t2;
+DROP TABLE t5;
+
+# restart the server so that we have binlog again
+-- source include/restart_mysqld.inc
+
+## clean up
+SET GLOBAL debug= @old_debug;
+DROP TABLE t1, t2, t4;
+RESET MASTER;
+
+# restart slave again
+-- connection slave
+-- source include/start_slave.inc
+-- connection master
+
+-- echo #######################################################################
+-- echo ####################### PART 2: SLAVE TESTS ###########################
+-- echo #######################################################################
+
+### setup
+-- connection master
+# master-slave-reset starts the slave automatically
+-- source include/master-slave-reset.inc
+-- connection slave
+
+# slave suppressions
+
+call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
+call mtr.add_suppression("Error writing file .*");
+call mtr.add_suppression("Could not open .*");
+call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
+call mtr.add_suppression("Can't generate a unique log-filename .*");
+-- echo ###################### TEST #13
+
+#### ASSERTION: check against unique log filename error
+-- let $io_thd_injection_fault_flag= error_unique_log_filename
+-- let $slave_io_errno= 1595
+-- let $show_slave_io_error= 1
+-- source include/io_thd_fault_injection.inc
+
+-- echo ###################### TEST #14
+
+#### ASSERTION: check against rotate failing
+-- let $io_thd_injection_fault_flag= fault_injection_new_file_rotate_event
+-- let $slave_io_errno= 1595
+-- let $show_slave_io_error= 1
+-- source include/io_thd_fault_injection.inc
+
+-- echo ###################### TEST #15
+
+#### ASSERTION: check against relay log open failure
+-- let $io_thd_injection_fault_flag= fault_injection_registering_index
+-- let $slave_io_errno= 1595
+-- let $show_slave_io_error= 1
+-- source include/io_thd_fault_injection.inc
+
+-- echo ###################### TEST #16
+
+#### ASSERTION: check against relay log index open failure
+-- let $io_thd_injection_fault_flag= fault_injection_openning_index
+-- let $slave_io_errno= 1595
+-- let $show_slave_io_error= 1
+-- source include/io_thd_fault_injection.inc
+
+### clean up
+-- disable_warnings
+-- source include/stop_slave.inc
+-- enable_warnings
+SET GLOBAL debug=@old_debug;
+RESET SLAVE;
+RESET MASTER;
+-- source include/start_slave.inc
+-- connection master
+-- source include/master-slave-end.inc
diff --git a/mysql-test/suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc b/mysql-test/suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc
new file mode 100644
index 00000000000..f5df54b7acd
--- /dev/null
+++ b/mysql-test/suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc
@@ -0,0 +1,154 @@
+################ mysql-test\t\binlog_stmt_cache_size_basic.test ################
+# #
+# Variable Name: binlog_stmt_cache_size #
+# Scope: GLOBAL #
+# Access Type: Dynamic #
+# Data Type: Numeric #
+# Default Value: 32768 #
+# Range: 4096 - 4294967295 #
+# #
+# #
+# Creation Date: 2010-10-12 #
+# Author: Alfranio Correia #
+# #
+# Description: Test Cases of Dynamic System Variable "binlog_stmt_cache_size" #
+# that checks behavior of this variable in the following ways #
+# * Default Value #
+# * Valid & Invalid values #
+# * Scope & Access method #
+# * Data Integrity . #
+# #
+# Reference: http://dev.mysql.com/doc/refman/5.5/en/ #
+# server-system-variables.html#option_mysqld_binlog_stmt_cache_size #
+# #
+################################################################################
+
+#################################################################
+# START OF binlog_stmt_cache_size TESTS #
+#################################################################
+
+#########################################################################
+# Saving initial value of binlog_stmt_cache_size in a temporary variable #
+#########################################################################
+
+SET @start_value = @@global.binlog_stmt_cache_size;
+SELECT @start_value;
+
+--echo '#--------------------FN_DYNVARS_006_01------------------------#'
+#########################################################################
+# Display the DEFAULT value of binlog_stmt_cache_size #
+#########################################################################
+
+SET @@global.binlog_stmt_cache_size = 100;
+SET @@global.binlog_stmt_cache_size = DEFAULT;
+SELECT @@global.binlog_stmt_cache_size;
+
+
+--echo '#---------------------FN_DYNVARS_006_02-------------------------#'
+###############################################
+# Verify default value of variable #
+###############################################
+
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size = 32768;
+
+
+--echo '#--------------------FN_DYNVARS_006_03------------------------#'
+#########################################################################
+# Change the value of binlog_stmt_cache_size to a valid value #
+#########################################################################
+
+SET @@global.binlog_stmt_cache_size = 4096;
+SELECT @@global.binlog_stmt_cache_size;
+SET @@global.binlog_stmt_cache_size = 4294967295;
+SELECT @@global.binlog_stmt_cache_size;
+SET @@global.binlog_stmt_cache_size = 10000;
+SELECT @@global.binlog_stmt_cache_size;
+SET @@global.binlog_stmt_cache_size = 21221204;
+SELECT @@global.binlog_stmt_cache_size;
+echo 'Bug: Invalid values are coming in variable on assigning valid values';
+
+
+--echo '#--------------------FN_DYNVARS_006_04-------------------------#'
+############################################################################
+# Change the value of binlog_stmt_cache_size to invalid value #
+############################################################################
+
+SET @@global.binlog_stmt_cache_size = 1024;
+SELECT @@global.binlog_stmt_cache_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.binlog_stmt_cache_size = 10000.01;
+SET @@global.binlog_stmt_cache_size = -1024;
+SELECT @@global.binlog_stmt_cache_size;
+SET @@global.binlog_stmt_cache_size = 42949672950;
+SELECT @@global.binlog_stmt_cache_size;
+echo 'Bug: Errors are not coming on assigning invalid values to variable';
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.binlog_stmt_cache_size = ON;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.binlog_stmt_cache_size = 'test';
+
+
+--echo '#-------------------FN_DYNVARS_006_05----------------------------#'
+############################################################################
+# Test if accessing session binlog_stmt_cache_size gives error #
+############################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET @@session.binlog_stmt_cache_size = 0;
+
+
+--echo '#----------------------FN_DYNVARS_006_06------------------------#'
+##############################################################################
+# Check if the value in GLOBAL Tables matches values in variable #
+##############################################################################
+
+SELECT @@global.binlog_stmt_cache_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='binlog_stmt_cache_size';
+
+--echo '#---------------------FN_DYNVARS_006_07----------------------#'
+###################################################################
+# Check if TRUE and FALSE values can be used on variable #
+###################################################################
+
+SET @@global.binlog_stmt_cache_size = TRUE;
+SELECT @@global.binlog_stmt_cache_size;
+SET @@global.binlog_stmt_cache_size = FALSE;
+SELECT @@global.binlog_stmt_cache_size;
+echo 'Bug: Errors are not coming on assigning TRUE/FALSE to variable';
+
+--echo '#---------------------FN_DYNVARS_006_08----------------------#'
+###############################################################################
+# Check if accessing variable without SCOPE points to same global variable #
+###############################################################################
+
+SET @@global.binlog_stmt_cache_size = 1;
+SELECT @@binlog_stmt_cache_size = @@global.binlog_stmt_cache_size;
+
+--echo '#---------------------FN_DYNVARS_006_09----------------------#'
+###########################################################################
+# Check if binlog_stmt_cache_size can be accessed with and without @@ sign#
+###########################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET binlog_stmt_cache_size = 1;
+--Error ER_PARSE_ERROR
+SET global.binlog_stmt_cache_size = 1;
+--Error ER_UNKNOWN_TABLE
+SELECT global.binlog_stmt_cache_size;
+--Error ER_BAD_FIELD_ERROR
+SELECT binlog_stmt_cache_size = @@session.binlog_stmt_cache_size;
+
+
+##############################
+# Restore initial value #
+##############################
+
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size;
+
+
+###########################################################
+# END OF binlog_stmt_cache_size TESTS #
+###########################################################
diff --git a/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_32.result
new file mode 100644
index 00000000000..604f671d5a4
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_32.result
@@ -0,0 +1,108 @@
+SET @start_value = @@global.binlog_stmt_cache_size;
+SELECT @start_value;
+@start_value
+32768
+'#--------------------FN_DYNVARS_006_01------------------------#'
+SET @@global.binlog_stmt_cache_size = 100;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '100'
+SET @@global.binlog_stmt_cache_size = DEFAULT;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+32768
+'#---------------------FN_DYNVARS_006_02-------------------------#'
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size = 32768;
+@@global.binlog_stmt_cache_size = 32768
+1
+'#--------------------FN_DYNVARS_006_03------------------------#'
+SET @@global.binlog_stmt_cache_size = 4096;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '4294967295'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4294963200
+SET @@global.binlog_stmt_cache_size = 10000;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '10000'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+8192
+SET @@global.binlog_stmt_cache_size = 21221204;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '21221204'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+21217280
+'Bug: Invalid values are coming in variable on assigning valid values'
+'#--------------------FN_DYNVARS_006_04-------------------------#'
+SET @@global.binlog_stmt_cache_size = 1024;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1024'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 10000.01;
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+SET @@global.binlog_stmt_cache_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '-1024'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 42949672950;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '42949672950'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4294963200
+'Bug: Errors are not coming on assigning invalid values to variable'
+SET @@global.binlog_stmt_cache_size = ON;
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+SET @@global.binlog_stmt_cache_size = 'test';
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+'#-------------------FN_DYNVARS_006_05----------------------------#'
+SET @@session.binlog_stmt_cache_size = 0;
+ERROR HY000: Variable 'binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+'#----------------------FN_DYNVARS_006_06------------------------#'
+SELECT @@global.binlog_stmt_cache_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='binlog_stmt_cache_size';
+@@global.binlog_stmt_cache_size = VARIABLE_VALUE
+1
+'#---------------------FN_DYNVARS_006_07----------------------#'
+SET @@global.binlog_stmt_cache_size = TRUE;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = FALSE;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '0'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+'Bug: Errors are not coming on assigning TRUE/FALSE to variable'
+'#---------------------FN_DYNVARS_006_08----------------------#'
+SET @@global.binlog_stmt_cache_size = 1;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1'
+SELECT @@binlog_stmt_cache_size = @@global.binlog_stmt_cache_size;
+@@binlog_stmt_cache_size = @@global.binlog_stmt_cache_size
+1
+'#---------------------FN_DYNVARS_006_09----------------------#'
+SET binlog_stmt_cache_size = 1;
+ERROR HY000: Variable 'binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+SET global.binlog_stmt_cache_size = 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 'binlog_stmt_cache_size = 1' at line 1
+SELECT global.binlog_stmt_cache_size;
+ERROR 42S02: Unknown table 'global' in field list
+SELECT binlog_stmt_cache_size = @@session.binlog_stmt_cache_size;
+ERROR 42S22: Unknown column 'binlog_stmt_cache_size' in 'field list'
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+32768
diff --git a/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_64.result
new file mode 100644
index 00000000000..7cb553e48ee
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/binlog_stmt_cache_size_basic_64.result
@@ -0,0 +1,108 @@
+SET @start_value = @@global.binlog_stmt_cache_size;
+SELECT @start_value;
+@start_value
+32768
+'#--------------------FN_DYNVARS_006_01------------------------#'
+SET @@global.binlog_stmt_cache_size = 100;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '100'
+SET @@global.binlog_stmt_cache_size = DEFAULT;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+32768
+'#---------------------FN_DYNVARS_006_02-------------------------#'
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size = 32768;
+@@global.binlog_stmt_cache_size = 32768
+1
+'#--------------------FN_DYNVARS_006_03------------------------#'
+SET @@global.binlog_stmt_cache_size = 4096;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '4294967295'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4294963200
+SET @@global.binlog_stmt_cache_size = 10000;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '10000'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+8192
+SET @@global.binlog_stmt_cache_size = 21221204;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '21221204'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+21217280
+'Bug: Invalid values are coming in variable on assigning valid values'
+'#--------------------FN_DYNVARS_006_04-------------------------#'
+SET @@global.binlog_stmt_cache_size = 1024;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1024'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 10000.01;
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+SET @@global.binlog_stmt_cache_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '-1024'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = 42949672950;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '42949672950'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+42949668864
+'Bug: Errors are not coming on assigning invalid values to variable'
+SET @@global.binlog_stmt_cache_size = ON;
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+SET @@global.binlog_stmt_cache_size = 'test';
+ERROR 42000: Incorrect argument type to variable 'binlog_stmt_cache_size'
+'#-------------------FN_DYNVARS_006_05----------------------------#'
+SET @@session.binlog_stmt_cache_size = 0;
+ERROR HY000: Variable 'binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+'#----------------------FN_DYNVARS_006_06------------------------#'
+SELECT @@global.binlog_stmt_cache_size = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='binlog_stmt_cache_size';
+@@global.binlog_stmt_cache_size = VARIABLE_VALUE
+1
+'#---------------------FN_DYNVARS_006_07----------------------#'
+SET @@global.binlog_stmt_cache_size = TRUE;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+SET @@global.binlog_stmt_cache_size = FALSE;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '0'
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+4096
+'Bug: Errors are not coming on assigning TRUE/FALSE to variable'
+'#---------------------FN_DYNVARS_006_08----------------------#'
+SET @@global.binlog_stmt_cache_size = 1;
+Warnings:
+Warning 1292 Truncated incorrect binlog_stmt_cache_size value: '1'
+SELECT @@binlog_stmt_cache_size = @@global.binlog_stmt_cache_size;
+@@binlog_stmt_cache_size = @@global.binlog_stmt_cache_size
+1
+'#---------------------FN_DYNVARS_006_09----------------------#'
+SET binlog_stmt_cache_size = 1;
+ERROR HY000: Variable 'binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+SET global.binlog_stmt_cache_size = 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 'binlog_stmt_cache_size = 1' at line 1
+SELECT global.binlog_stmt_cache_size;
+ERROR 42S02: Unknown table 'global' in field list
+SELECT binlog_stmt_cache_size = @@session.binlog_stmt_cache_size;
+ERROR 42S22: Unknown column 'binlog_stmt_cache_size' in 'field list'
+SET @@global.binlog_stmt_cache_size = @start_value;
+SELECT @@global.binlog_stmt_cache_size;
+@@global.binlog_stmt_cache_size
+32768
diff --git a/mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result b/mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result
new file mode 100644
index 00000000000..f2229a0090b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result
@@ -0,0 +1,152 @@
+SET @start_value = @@global.max_binlog_stmt_cache_size;
+SELECT @start_value;
+@start_value
+18446744073709547520
+'#--------------------FN_DYNVARS_072_01------------------------#'
+SET @@global.max_binlog_stmt_cache_size = 5000;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '5000'
+SET @@global.max_binlog_stmt_cache_size = DEFAULT;
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+18446744073709547520
+'#---------------------FN_DYNVARS_072_02-------------------------#'
+SET @@global.max_binlog_stmt_cache_size = @start_value;
+SELECT @@global.max_binlog_stmt_cache_size = 4294967295;
+@@global.max_binlog_stmt_cache_size = 4294967295
+0
+'#--------------------FN_DYNVARS_072_03------------------------#'
+SET @@global.max_binlog_stmt_cache_size = 4096;
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '4294967295'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4294963200
+SET @@global.max_binlog_stmt_cache_size = 4294967294;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '4294967294'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4294963200
+SET @@global.max_binlog_stmt_cache_size = 4097;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '4097'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 65535;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '65535'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+61440
+'#--------------------FN_DYNVARS_072_04-------------------------#'
+SET @@global.max_binlog_stmt_cache_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '-1'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 100000000000;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '100000000000'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+99999997952
+SET @@global.max_binlog_stmt_cache_size = 10000.01;
+ERROR 42000: Incorrect argument type to variable 'max_binlog_stmt_cache_size'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+99999997952
+SET @@global.max_binlog_stmt_cache_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '-1024'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 1024;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '1024'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 4294967296;
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4294967296
+SET @@global.max_binlog_stmt_cache_size = 4095;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '4095'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = ON;
+ERROR 42000: Incorrect argument type to variable 'max_binlog_stmt_cache_size'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = 'test';
+ERROR 42000: Incorrect argument type to variable 'max_binlog_stmt_cache_size'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+'#-------------------FN_DYNVARS_072_05----------------------------#'
+SET @@session.max_binlog_stmt_cache_size = 4096;
+ERROR HY000: Variable 'max_binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@session.max_binlog_stmt_cache_size;
+ERROR HY000: Variable 'max_binlog_stmt_cache_size' is a GLOBAL variable
+'#----------------------FN_DYNVARS_072_06------------------------#'
+SELECT @@global.max_binlog_stmt_cache_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='max_binlog_stmt_cache_size';
+@@global.max_binlog_stmt_cache_size = VARIABLE_VALUE
+1
+SELECT @@max_binlog_stmt_cache_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='max_binlog_stmt_cache_size';
+@@max_binlog_stmt_cache_size = VARIABLE_VALUE
+1
+'#---------------------FN_DYNVARS_072_07----------------------#'
+SET @@global.max_binlog_stmt_cache_size = TRUE;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '1'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+SET @@global.max_binlog_stmt_cache_size = FALSE;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '0'
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+4096
+'#---------------------FN_DYNVARS_072_08----------------------#'
+SET @@global.max_binlog_stmt_cache_size = 5000;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_stmt_cache_size value: '5000'
+SELECT @@max_binlog_stmt_cache_size = @@global.max_binlog_stmt_cache_size;
+@@max_binlog_stmt_cache_size = @@global.max_binlog_stmt_cache_size
+1
+'#---------------------FN_DYNVARS_072_09----------------------#'
+SET max_binlog_stmt_cache_size = 6000;
+ERROR HY000: Variable 'max_binlog_stmt_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@max_binlog_stmt_cache_size;
+@@max_binlog_stmt_cache_size
+4096
+SET local.max_binlog_stmt_cache_size = 7000;
+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 'max_binlog_stmt_cache_size = 7000' at line 1
+SELECT local.max_binlog_stmt_cache_size;
+ERROR 42S02: Unknown table 'local' in field list
+SET global.max_binlog_stmt_cache_size = 8000;
+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 'max_binlog_stmt_cache_size = 8000' at line 1
+SELECT global.max_binlog_stmt_cache_size;
+ERROR 42S02: Unknown table 'global' in field list
+SELECT max_binlog_stmt_cache_size = @@session.max_binlog_stmt_cache_size;
+ERROR 42S22: Unknown column 'max_binlog_stmt_cache_size' in 'field list'
+SET @@global.max_binlog_stmt_cache_size = @start_value;
+SELECT @@global.max_binlog_stmt_cache_size;
+@@global.max_binlog_stmt_cache_size
+18446744073709547520
diff --git a/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_32.test b/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_32.test
new file mode 100644
index 00000000000..fe8f89ccc16
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_32.test
@@ -0,0 +1,7 @@
+################################################################################
+# Wrapper for 32 bit machines #
+################################################################################
+
+--source include/have_32bit.inc
+--source suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc
+
diff --git a/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_64.test b/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_64.test
new file mode 100644
index 00000000000..c4a2c95d42b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/binlog_stmt_cache_size_basic_64.test
@@ -0,0 +1,7 @@
+################################################################################
+# Wrapper for 64 bit machines #
+################################################################################
+
+--source include/have_64bit.inc
+--source suite/sys_vars/inc/binlog_stmt_cache_size_basic.inc
+
diff --git a/mysql-test/suite/sys_vars/t/max_binlog_cache_size_func-master.opt b/mysql-test/suite/sys_vars/t/max_binlog_cache_size_func-master.opt
deleted file mode 100644
index 6e00d7157d6..00000000000
--- a/mysql-test/suite/sys_vars/t/max_binlog_cache_size_func-master.opt
+++ /dev/null
@@ -1,2 +0,0 @@
---log-bin
---innodb
diff --git a/mysql-test/suite/sys_vars/t/max_binlog_stmt_cache_size_basic.test b/mysql-test/suite/sys_vars/t/max_binlog_stmt_cache_size_basic.test
new file mode 100644
index 00000000000..07a030c35a7
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/max_binlog_stmt_cache_size_basic.test
@@ -0,0 +1,184 @@
+############ mysql-test\t\max_binlog_stmt_cache_size_basic.test ###############
+# #
+# Variable Name: max_binlog_stmt_cache_size #
+# Scope: GLOBAL #
+# Access Type: Dynamic #
+# Data Type: numeric #
+# Default Value:4294967295 #
+# Range: 4096-4294967295 #
+# #
+# #
+# #
+# #
+# #
+# Creation Date: 2010-11-05 #
+# Author: Alfranio #
+# #
+# Description: Test Cases of Dynamic System Variable #
+# max_binlog_stmt_cache_size that checks #
+# the behavior of this variable in the following ways #
+# * Default Value #
+# * Valid & Invalid values #
+# * Scope & Access method #
+# * Data Integrity #
+# #
+# Reference: http://dev.mysql.com/doc/refman/5.5/en/ #
+# server-system-variables.html #
+# #
+###############################################################################
+
+--source include/load_sysvars.inc
+
+##########################################################################
+# START OF max_binlog_stmt_cache_size TESTS #
+##########################################################################
+
+
+##############################################################################
+# Saving initial value of max_binlog_stmt_cache_size in a temporary variable #
+##############################################################################
+
+SET @start_value = @@global.max_binlog_stmt_cache_size;
+SELECT @start_value;
+
+
+--echo '#--------------------FN_DYNVARS_072_01------------------------#'
+########################################################################
+# Display the DEFAULT value of max_binlog_stmt_cache_size #
+########################################################################
+
+SET @@global.max_binlog_stmt_cache_size = 5000;
+SET @@global.max_binlog_stmt_cache_size = DEFAULT;
+SELECT @@global.max_binlog_stmt_cache_size;
+
+
+--echo '#---------------------FN_DYNVARS_072_02-------------------------#'
+###############################################
+# Verify default value of variable #
+###############################################
+
+SET @@global.max_binlog_stmt_cache_size = @start_value;
+SELECT @@global.max_binlog_stmt_cache_size = 4294967295;
+
+--echo '#--------------------FN_DYNVARS_072_03------------------------#'
+########################################################################
+# Change the value of max_binlog_stmt_cache_size to a valid value #
+########################################################################
+
+SET @@global.max_binlog_stmt_cache_size = 4096;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 4294967295;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 4294967294;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 4097;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 65535;
+SELECT @@global.max_binlog_stmt_cache_size;
+
+
+--echo '#--------------------FN_DYNVARS_072_04-------------------------#'
+###########################################################################
+# Change the value of max_binlog_stmt_cache_size to invalid value #
+###########################################################################
+
+SET @@global.max_binlog_stmt_cache_size = -1;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 100000000000;
+SELECT @@global.max_binlog_stmt_cache_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.max_binlog_stmt_cache_size = 10000.01;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = -1024;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 1024;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 4294967296;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = 4095;
+SELECT @@global.max_binlog_stmt_cache_size;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.max_binlog_stmt_cache_size = ON;
+SELECT @@global.max_binlog_stmt_cache_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.max_binlog_stmt_cache_size = 'test';
+SELECT @@global.max_binlog_stmt_cache_size;
+
+
+--echo '#-------------------FN_DYNVARS_072_05----------------------------#'
+###########################################################################
+# Test if accessing session max_binlog_stmt_cache_size gives error #
+###########################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET @@session.max_binlog_stmt_cache_size = 4096;
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.max_binlog_stmt_cache_size;
+
+
+--echo '#----------------------FN_DYNVARS_072_06------------------------#'
+##############################################################################
+# Check if the value in GLOBAL & SESSION Tables matches values in variable #
+##############################################################################
+
+SELECT @@global.max_binlog_stmt_cache_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='max_binlog_stmt_cache_size';
+
+SELECT @@max_binlog_stmt_cache_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='max_binlog_stmt_cache_size';
+
+
+--echo '#---------------------FN_DYNVARS_072_07----------------------#'
+###################################################################
+# Check if TRUE and FALSE values can be used on variable #
+###################################################################
+
+SET @@global.max_binlog_stmt_cache_size = TRUE;
+SELECT @@global.max_binlog_stmt_cache_size;
+SET @@global.max_binlog_stmt_cache_size = FALSE;
+SELECT @@global.max_binlog_stmt_cache_size;
+
+
+--echo '#---------------------FN_DYNVARS_072_08----------------------#'
+########################################################################################################
+# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
+########################################################################################################
+
+SET @@global.max_binlog_stmt_cache_size = 5000;
+SELECT @@max_binlog_stmt_cache_size = @@global.max_binlog_stmt_cache_size;
+
+
+--echo '#---------------------FN_DYNVARS_072_09----------------------#'
+################################################################################
+# Check if max_binlog_stmt_cache_size can be accessed with and without @@ sign #
+################################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET max_binlog_stmt_cache_size = 6000;
+SELECT @@max_binlog_stmt_cache_size;
+--Error ER_PARSE_ERROR
+SET local.max_binlog_stmt_cache_size = 7000;
+--Error ER_UNKNOWN_TABLE
+SELECT local.max_binlog_stmt_cache_size;
+--Error ER_PARSE_ERROR
+SET global.max_binlog_stmt_cache_size = 8000;
+--Error ER_UNKNOWN_TABLE
+SELECT global.max_binlog_stmt_cache_size;
+--Error ER_BAD_FIELD_ERROR
+SELECT max_binlog_stmt_cache_size = @@session.max_binlog_stmt_cache_size;
+
+
+##############################
+# Restore initial value #
+##############################
+
+SET @@global.max_binlog_stmt_cache_size = @start_value;
+SELECT @@global.max_binlog_stmt_cache_size;
+
+
+########################################################################
+# END OF max_binlog_stmt_cache_size TESTS #
+########################################################################
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index c3a080612a9..ce5047124a2 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1722,3 +1722,11 @@ INSERT INTO t1 VALUES (2);
SELECT * FROM t1 ORDER BY a;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+
+--echo #
+--echo # BUG#58205 - Valgrind failure in fn_format when called from
+--echo # archive_discover
+--echo #
+CREATE TABLE `a/../`(a INT) ENGINE=ARCHIVE;
+remove_file $MYSQLD_DATADIR/test/a@002f@002e@002e@002f.frm;
+DROP TABLE `a/../`;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 42751b8ce06..9da8c759d45 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -342,3 +342,24 @@ SELECT a FROM t2;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug#39828 autoinc wraps around when offset and increment > 1
+--echo #
+
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) engine=MyISAM;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES (18446744073709551601);
+
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=10;
+
+SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
+--error ER_WARN_DATA_OUT_OF_RANGE
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT * FROM t1;
+
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=default;
+SET @@SESSION.AUTO_INCREMENT_OFFSET=default;
+
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test
index 4dfb0be3892..3203a1032b4 100644
--- a/mysql-test/t/ctype_cp1251.test
+++ b/mysql-test/t/ctype_cp1251.test
@@ -60,6 +60,16 @@ DROP TABLE t1;
# End of 4.1 tests
--echo #
+--echo # Start of 5.1 tests
+--echo #
+
+--source include/ctype_8bit.inc
+
+--echo #
+--echo # End of 5.1 tests
+--echo #
+
+--echo #
--echo # Start of 5.5 tests
--echo #
diff --git a/mysql-test/t/ctype_like_range.test b/mysql-test/t/ctype_like_range.test
new file mode 100644
index 00000000000..34a7637222b
--- /dev/null
+++ b/mysql-test/t/ctype_like_range.test
@@ -0,0 +1,87 @@
+--source include/have_debug.inc
+--source include/have_ucs2.inc
+--source include/have_utf16.inc
+--source include/have_utf32.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a VARBINARY(32));
+INSERT INTO t1 (a) VALUES (''),('_'),('%'),('\_'),('\%'),('\\');
+INSERT INTO t1 (a) VALUES ('a'),('c');
+INSERT INTO t1 (a) VALUES ('a_'),('c_');
+INSERT INTO t1 (a) VALUES ('a%'),('c%');
+INSERT INTO t1 (a) VALUES ('aa'),('cc'),('ch');
+INSERT INTO t1 (a) VALUES ('aa_'),('cc_'),('ch_');
+INSERT INTO t1 (a) VALUES ('aa%'),('cc%'),('ch%');
+INSERT INTO t1 (a) VALUES ('aaa'),('ccc'),('cch');
+INSERT INTO t1 (a) VALUES ('aaa_'),('ccc_'),('cch_');
+INSERT INTO t1 (a) VALUES ('aaa%'),('ccc%'),('cch%');
+INSERT INTO t1 (a) VALUES ('aaaaaaaaaaaaaaaaaaaa');
+
+CREATE VIEW v1 AS
+ SELECT id, 'a' AS name, a AS val FROM t1
+UNION
+ SELECT id, 'mn', HEX(LIKE_RANGE_MIN(a, 16)) AS min FROM t1
+UNION
+ SELECT id, 'mx', HEX(LIKE_RANGE_MAX(a, 16)) AS max FROM t1
+UNION
+ SELECT id, 'sp', REPEAT('-', 32) AS sep FROM t1
+ORDER BY id, name;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET latin1;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_danish_ci;
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
index 67726c53585..5aa1f6e7c7d 100644
--- a/mysql-test/t/ctype_many.test
+++ b/mysql-test/t/ctype_many.test
@@ -217,6 +217,10 @@ DROP TABLE t1;
--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
--echo # WL#1213 Implement 4-byte UTF8, UTF16 and UTF32
--echo # Testing that only utf8mb4 is superset for utf8
--echo # No other Unicode character set pairs have superset/subset relations
@@ -284,3 +288,19 @@ SELECT CHARSET(CONCAT(utf32, utf8mb4)) FROM t1;
SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#58321 No warning when characters outside BMP0 is converted to UCS2
+--echo #
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (0x10082), (0x12345);
+INSERT INTO t2 SELECT * FROM t1;
+SELECT HEX(a) FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test
index 11a489ba24d..723962bbb3f 100644
--- a/mysql-test/t/ctype_uca.test
+++ b/mysql-test/t/ctype_uca.test
@@ -545,3 +545,19 @@ set collation_connection=ucs2_unicode_ci;
set names utf8;
-- echo End for 5.0 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf8_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+SET collation_connection=ucs2_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf16_uca.test b/mysql-test/t/ctype_utf16_uca.test
index 5314777c6f4..a6295c82dec 100644
--- a/mysql-test/t/ctype_utf16_uca.test
+++ b/mysql-test/t/ctype_utf16_uca.test
@@ -284,6 +284,13 @@ DROP TABLE IF EXISTS t1;
set collation_connection=utf16_unicode_ci;
--source include/ctype_regex.inc
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf16_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+
--echo #
--echo # End of 5.5 tests
diff --git a/mysql-test/t/ctype_utf32_uca.test b/mysql-test/t/ctype_utf32_uca.test
index 9386cc9e65e..a62ffbf95c7 100644
--- a/mysql-test/t/ctype_utf32_uca.test
+++ b/mysql-test/t/ctype_utf32_uca.test
@@ -286,6 +286,14 @@ set collation_connection=utf32_unicode_ci;
--source include/ctype_regex.inc
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf32_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+
+
--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 27e85ee237b..9711482c639 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -301,4 +301,37 @@ SELECT 0 FROM
(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60,
(SELECT 0) t61; # 61 == MAX_TABLES
+--echo #
+--echo # A nested materialized derived table is used before being populated.
+--echo # (addon for bug#19077)
+--echo #
+
+CREATE TABLE t1 (i INT, j BIGINT);
+INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
+SELECT * FROM (SELECT MIN(i) FROM t1
+WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
+DROP TABLE t1;
+
--echo # End of 5.0 tests
+
+
+--echo #
+--echo # Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
+--echo # temptable views
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT, KEY (b));
+INSERT INTO t1 VALUES (1),(1);
+INSERT INTO t2 VALUES (1),(1);
+
+CREATE algorithm=temptable VIEW v1 AS
+ SELECT 1 FROM t1 LEFT JOIN t1 t3 ON 1 > (SELECT 1 FROM t1);
+CREATE algorithm=temptable VIEW v2 AS SELECT 1 FROM t2;
+
+# This caused the assert to be triggered.
+--error ER_SUBQUERY_NO_1_ROW
+EXPLAIN SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2);
+
+DROP TABLE t1, t2;
+DROP VIEW v1, v2;
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 13b3697cbf6..e4a1206fa9c 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -750,6 +750,17 @@ SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t G
--enable_ps_protocol
DROP TABLE t1;
+--echo #
+--echo # Bug#58396 group_concat and explain extended are still crashy
+--echo #
+
+CREATE TABLE t1(a INT);
+--error ER_UNKNOWN_ERROR
+EXPLAIN EXTENDED SELECT UPDATEXML('1', a, '1')
+FROM t1 ORDER BY (SELECT GROUP_CONCAT(1) FROM t1);
+SHOW WARNINGS;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 6d128be7f34..9a9c5442d87 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1118,3 +1118,14 @@ SELECT MAX(c1),MIN(c1) FROM t1;
DROP TABLE t1;
--echo # End of the bug#56120
+--echo #
+--echo # Bug#57932 "query with AVG(DISTINCT) returns NULL if last
+--echo # aggregated value was NULL"
+--echo #
+CREATE TABLE t1 (col_int_nokey int(11));
+INSERT INTO t1 VALUES (7),(8),(NULL);
+SELECT AVG(DISTINCT col_int_nokey) FROM t1;
+SELECT AVG(DISTINCT outr.col_int_nokey) FROM t1 AS outr LEFT JOIN t1 AS outr2 ON
+outr.col_int_nokey = outr2.col_int_nokey;
+DROP TABLE t1;
+--echo # End of the bug#57932
diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test
index 1bdfd8f54bb..bbc576b0fc7 100644
--- a/mysql-test/t/func_group_innodb.test
+++ b/mysql-test/t/func_group_innodb.test
@@ -83,3 +83,53 @@ explain select count(*), min(7), max(7) from t2m, t1i;
select count(*), min(7), max(7) from t2m, t1i;
drop table t1m, t1i, t2m, t2i;
+
+
+--echo #
+--echo # Bug #57954: BIT_AND function returns incorrect results when
+--echo # semijoin=on
+
+CREATE TABLE c (
+ pk INT,
+ col_varchar_key VARCHAR(1),
+ PRIMARY KEY (pk),
+ KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO c VALUES (11,NULL);
+INSERT INTO c VALUES (16,'c');
+CREATE TABLE bb (
+ pk INT,
+ col_varchar_key VARCHAR(1),
+ PRIMARY KEY (pk),
+ KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO bb VALUES (10,NULL);
+
+SELECT straight_join BIT_AND(c.pk)
+FROM
+ bb, c
+ WHERE c.col_varchar_key='ABC'
+ORDER BY c.pk;
+
+DROP TABLE c,bb;
+
+--echo #
+--echo # Bug #58050: BIT_OR and BIT_XOR return incorrect results when
+--echo # semijoin=on
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1, 1, 1);
+
+CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1, 1, NULL);
+
+SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+
+DROP TABLE t1, t2;
+
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 1a5c5373841..9257314013d 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -480,6 +480,13 @@ SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
DROP TABLE t1;
+#
+# Bug #57283: inet_ntoa() crashes
+#
+SELECT INET_NTOA(0);
+SELECT '1' IN ('1', INET_NTOA(0));
+
+
--echo #
--echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465
--echo #
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 7b7bffd0bbc..aff99d7e303 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1363,6 +1363,13 @@ SELECT 1 FROM t1, t1 t2
ORDER BY QUOTE(t1.a);
DROP TABLE t1;
+--echo #
+--echo # Bug#57913 large negative number to string conversion functions crash
+--echo # Bug#57810 case/when/then : Assertion failed: length || !scale
+--echo #
+SELECT '1' IN ('1', SUBSTRING(-9223372036854775809, 1));
+SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3));
+
--echo End of 5.1 tests
--echo Start of 5.4 tests
diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test
index 40add7f488f..0d47c4ea57b 100644
--- a/mysql-test/t/join_outer_innodb.test
+++ b/mysql-test/t/join_outer_innodb.test
@@ -24,3 +24,40 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
DROP TABLE t1,t2;
+
+--echo #
+--echo # BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output
+--echo # in opt_range.h
+--echo #
+
+CREATE TABLE t1 (
+ col_int INT,
+ col_int_key INT,
+ pk INT NOT NULL,
+ PRIMARY KEY (pk),
+ KEY col_int_key (col_int_key)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4);
+INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5);
+
+CREATE TABLE t2 (
+ pk INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+let $query=
+SELECT t1.pk
+FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int
+WHERE t1.col_int_key BETWEEN 5 AND 6
+ AND t1.pk IS NULL OR t1.pk IN (5)
+ORDER BY pk;
+
+--echo
+--eval EXPLAIN $query
+--echo
+--eval $query
+--echo
+
+DROP TABLE t1,t2;
+
+--echo # End BUG#58456
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 8ed0ed45b82..0e2abe578ce 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -672,4 +672,15 @@ SET t3.a = 0;
DROP TABLE t1, t2, t3;
SET SESSION sql_safe_updates = DEFAULT;
+--echo #
+--echo # Bug#52157 various crashes and assertions with multi-table update, stored function
+--echo #
+
+CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
+CREATE TABLE t1 (f1 DATE);
+INSERT INTO t1 VALUES('2001-01-01');
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
+DROP FUNCTION f1;
+DROP TABLE t1;
+
--echo end of tests
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 3a2084aef08..7b5b2a0ded0 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -426,4 +426,147 @@ drop table t1;
--exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
--echo
+
+--echo #
+--echo # Bug #54899: --one-database option cannot handle DROP/CREATE DATABASE
+--echo # commands.
+--echo #
+--write_file $MYSQLTEST_VARDIR/tmp/bug54899.sql
+DROP DATABASE connected_db;
+CREATE DATABASE connected_db;
+USE connected_db;
+CREATE TABLE `table_in_connected_db`(a INT);
+EOF
+
+CREATE DATABASE connected_db;
+--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/bug54899.sql
+USE connected_db;
+SHOW TABLES;
+DROP DATABASE connected_db;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug54899.sql
+
+--echo
+
+--echo #
+--echo # Testing --one-database option
+--echo #
+--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+CREATE TABLE t1 (i INT);
+CREATE TABLE test.t1 (i INT);
+USE test;
+# Following statements should be filtered.
+CREATE TABLE connected_db.t2 (i INT);
+CREATE TABLE t2 (i INT);
+EOF
+
+CREATE DATABASE connected_db;
+--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql
+SHOW TABLES IN connected_db;
+SHOW TABLES IN test;
+USE test;
+DROP TABLE t1;
+DROP DATABASE connected_db;
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+
+--echo
+--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+CREATE DATABASE test1;
+USE test1;
+USE test1;
+# Following statements should be filtered.
+CREATE TABLE connected_db.t1 (i INT);
+EOF
+
+--exec $MYSQL --one-database test < $MYSQLTEST_VARDIR/tmp/one_db.sql
+SHOW TABLES IN test;
+SHOW TABLES IN test1;
+DROP DATABASE test1;
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+
+--echo
+
+--echo #
+--echo # Checking --one-database option followed by the execution of
+--echo # connect command.
+--echo #
+--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+CREATE TABLE t1 (i INT);
+CREATE TABLE test.t1 (i INT);
+CONNECT test;
+CREATE TABLE connected_db.t2 (i INT);
+CREATE TABLE t2 (i INT);
+USE connected_db;
+# Following statements should be filtered.
+CREATE TABLE connected_db.t3 (i INT);
+CREATE TABLE t3 (i INT);
+EOF
+
+CREATE DATABASE connected_db;
+--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql
+SHOW TABLES IN connected_db;
+SHOW TABLES IN test;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP DATABASE connected_db;
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+
+--echo
+
+--echo #
+--echo # Checking --one-database option with no database specified
+--echo # at command-line.
+--echo #
+--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+# All following statements should be filtered.
+CREATE TABLE t1 (i INT);
+CREATE TABLE test.t1 (i INT);
+USE test;
+CREATE TABLE test.t2 (i INT);
+CREATE TABLE t2 (i INT);
+EOF
+
+--exec $MYSQL --one-database < $MYSQLTEST_VARDIR/tmp/one_db.sql
+SHOW TABLES IN test;
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
+
+--echo
+
+--echo #
+--echo # Checking --one-database option with non_existent_db
+--echo # specified with USE command
+--echo #
+
+# CASE 1 : When 'connected_db' database exists and passed at commandline.
+--write_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql
+CREATE TABLE `table_in_connected_db`(i INT);
+USE non_existent_db;
+# Following statement should be filtered out.
+CREATE TABLE `table_in_non_existent_db`(i INT);
+EOF
+
+# CASE 2 : When 'connected_db' database exists but dropped and recreated in
+# load file.
+--write_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql
+DROP DATABASE connected_db;
+CREATE DATABASE connected_db;
+USE non_existent_db;
+# Following statements should be filtered out.
+CREATE TABLE `table_in_non_existent_db`(i INT);
+USE connected_db;
+# Following statements should not be filtered out.
+CREATE TABLE `table_in_connected_db`(i INT);
+EOF
+
+CREATE DATABASE connected_db;
+--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_1.sql
+SHOW TABLES IN connected_db;
+--echo
+--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_2.sql
+SHOW TABLES IN connected_db;
+DROP DATABASE connected_db;
+
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql
+
+--echo
--echo End of tests
diff --git a/mysql-test/t/partition_binlog.test b/mysql-test/t/partition_binlog.test
new file mode 100644
index 00000000000..c1f618b794f
--- /dev/null
+++ b/mysql-test/t/partition_binlog.test
@@ -0,0 +1,42 @@
+--source include/have_log_bin.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Bug#58147: ALTER TABLE w/ TRUNCATE PARTITION fails
+--echo # but the statement is written to binlog
+--echo #
+
+CREATE TABLE t1(id INT)
+PARTITION BY RANGE (id)
+(PARTITION p0 VALUES LESS THAN (100),
+ PARTITION pmax VALUES LESS THAN (MAXVALUE));
+
+INSERT INTO t1 VALUES (1), (10), (100), (1000);
+
+--let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1)
+--let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--error ER_WRONG_PARTITION_NAME
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION p1;
+
+--echo # No error returned, output in table format instead:
+ALTER TABLE t1 ANALYZE PARTITION p1;
+ALTER TABLE t1 CHECK PARTITION p1;
+ALTER TABLE t1 OPTIMIZE PARTITION p1;
+ALTER TABLE t1 REPAIR PARTITION p1;
+
+ALTER TABLE t1 ANALYZE PARTITION p0;
+ALTER TABLE t1 CHECK PARTITION p0;
+ALTER TABLE t1 OPTIMIZE PARTITION p0;
+ALTER TABLE t1 REPAIR PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 DROP PARTITION p0;
+
+--source include/show_binlog_events.inc
+
+DROP TABLE t1;
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index 86bbe359873..cd371a8f79a 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -33,6 +33,7 @@ SELECT count(*) FROM t1 p where c3 in
DROP TABLE t1;
+
--echo #
--echo # Bug#54747: Deadlock between REORGANIZE PARTITION and
--echo # SELECT is not detected
@@ -134,6 +135,7 @@ SELECT * FROM t1;
COMMIT;
DROP TABLE t1;
+
--echo #
--echo # Bug#51830: Incorrect partition pruning on range partition (regression)
--echo #
@@ -588,6 +590,7 @@ CREATE TABLE t1 (i1 int NOT NULL primary key, f1 int) ENGINE = InnoDB
INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 WHERE i1 = ( SELECT i1 FROM t1 WHERE f1=0 LIMIT 1 );
+
DROP TABLE t1;
--enable_parsing
diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test
index 3b1dd93c4d1..49fbfa6995b 100644
--- a/mysql-test/t/plugin_auth.test
+++ b/mysql-test/t/plugin_auth.test
@@ -394,4 +394,18 @@ FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
+--echo #
+--echo # Bug#58139 : default-auth option not recognized in MySQL standardi
+--echo # command line clients
+--echo #
+
+--echo # Executing 'mysql'
+--exec $MYSQL -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT -e "SELECT 1"
+
+--echo # Executing 'mysqladmin'
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT ping
+
+--echo # Executing 'mysqldump'
+--exec $MYSQL_DUMP -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --compact --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT test
+
--echo End of 5.5 tests
diff --git a/mysql-test/t/plugin_not_embedded.test b/mysql-test/t/plugin_not_embedded.test
index 15aff548c29..40024efcaad 100644
--- a/mysql-test/t/plugin_not_embedded.test
+++ b/mysql-test/t/plugin_not_embedded.test
@@ -18,3 +18,15 @@ UNINSTALL PLUGIN example;
disconnect con1;
connection default;
DROP USER bug51770@localhost;
+
+#
+# BUG#58246: INSTALL PLUGIN not secure & crashable
+#
+# The bug consisted of not recognizing / on Windows, so checking / on
+# all platforms should cover this case.
+
+let $path = `select CONCAT_WS('/', '..', $HA_EXAMPLE_SO)`;
+--replace_regex /\.dll/.so/
+--error ER_UDF_NO_PATHS
+eval INSTALL PLUGIN example SONAME '$path';
+
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 75099523062..d31939ed3dd 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1243,6 +1243,50 @@ SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size;
SELECT @@skip_name_resolve;
SHOW VARIABLES LIKE 'skip_name_resolve';
+--echo #
+--echo # Bug #43233 : Some server variables are clipped during "update,"
+--echo # not "check" stage
+--echo #
+
+SET @kbs=@@global.key_buffer_size;
+SET @kcbs=@@global.key_cache_block_size;
+
+--echo throw errors in STRICT mode
+SET SQL_MODE=STRICT_ALL_TABLES;
+
+# sys_var_ulonglong_ptr: sys_max_binlog_cache_size
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.max_binlog_cache_size=-1;
+
+# sys_var_thd_ha_rows: "max_join_size" et al.
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.max_join_size=0;
+
+# sys_var_key_buffer_size: "key_buffer_size"
+--error ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
+SET @@global.key_buffer_size=0;
+
+# sys_var_key_cache_long: "key_cache_block_size" et al.
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.key_cache_block_size=0;
+
+--echo throw warnings in default mode
+SET SQL_MODE=DEFAULT;
+
+SET @@global.max_binlog_cache_size=-1;
+SET @@global.max_join_size=0;
+# this is an exception. since this is a new error/warning, let's stay
+# compatible with the upcoming 5.6.
+--error ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
+SET @@global.key_buffer_size=0;
+SET @@global.key_cache_block_size=0;
+
+# cleanup
+SET @@global.max_binlog_cache_size=DEFAULT;
+SET @@global.max_join_size=DEFAULT;
+SET @@global.key_buffer_size=@kbs;
+SET @@global.key_cache_block_size=@kcbs;
+
--echo End of 5.1 tests
###########################################################################
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 236f2e84770..c82443e792f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3963,6 +3963,22 @@ WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
+--echo #
+
+CREATE TABLE t1(a int);
+CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
+SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#57352 valgrind warnings when creating view
+--echo #
+CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
+DROP VIEW v1;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 0d63c2cb3ff..bb3a95208bb 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -770,13 +770,52 @@
fun:lf_hash_insert
}
+#
+# Note that initialize_bucket() is reccursive,
+# can't provide more stack context.
+#
{
missing shutdown_performance_schema 3
Memcheck:Leak
fun:malloc
fun:my_malloc
fun:initialize_bucket
+}
+
+{
+ missing shutdown_performance_schema 4
+ Memcheck:Leak
+ fun:malloc
+ fun:my_malloc
+ fun:_lf_dynarray_lvalue
+ fun:_lf_pinbox_get_pins
+ fun:lf_pinbox_get_pins
+}
+
+{
+ missing shutdown_performance_schema 5
+ Memcheck:Leak
+ fun:malloc
+ fun:my_malloc
+ fun:_lf_dynarray_lvalue
+ fun:lf_hash_insert
+}
+
+{
+ missing shutdown_performance_schema 6
+ Memcheck:Leak
+ fun:malloc
+ fun:my_malloc
+ fun:_lf_dynarray_lvalue
+ fun:lf_hash_delete
+}
+
+{
+ missing shutdown_performance_schema 7
+ Memcheck:Leak
+ fun:malloc
+ fun:my_malloc
+ fun:_lf_dynarray_lvalue
fun:lf_hash_search
- fun:_Z19find_or_create_fileP10PFS_threadP14PFS_file_classPKcj
}
diff --git a/mysys/errors.c b/mysys/errors.c
index 8bc310652f1..c74ed292906 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -52,6 +52,7 @@ const char *globerrs[GLOBERRS]=
"File '%s' (fileno: %d) was not closed",
"Can't change ownership of the file '%s' (Errcode: %d)",
"Can't change permissions of the file '%s' (Errcode: %d)",
+ "Can't seek in file '%s' (Errcode: %d)"
};
void init_glob_errs(void)
@@ -94,6 +95,7 @@ void init_glob_errs()
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)";
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)";
+ EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %d)";
}
#endif
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index c6e6a3a429e..a9482187138 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -192,7 +192,8 @@ size_t cleanup_dirname(register char *to, const char *from)
end_parentdir=pos;
while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */
pos--;
- if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0)
+ if (pos[1] == FN_HOMELIB ||
+ (pos > start && memcmp(pos, parent, length) == 0))
{ /* Don't remove ~user/ */
pos=strmov(end_parentdir+1,parent);
*pos=FN_LIBCHAR;
diff --git a/mysys/my_init.c b/mysys/my_init.c
index e3b189c27bb..ab6ffef7ac7 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -311,6 +311,89 @@ int handle_rtc_failure(int err_type, const char *file, int line,
#pragma runtime_checks("", restore)
#endif
+#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
+#define MS 10000000
+
+static void win_init_time(void)
+{
+ /* The following is used by time functions */
+ FILETIME ft;
+ LARGE_INTEGER li, t_cnt;
+
+ DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
+
+ if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
+ query_performance_frequency= 0;
+ else
+ {
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart= ft.dwLowDateTime;
+ li.HighPart= ft.dwHighDateTime;
+ query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
+ QueryPerformanceCounter(&t_cnt);
+ query_performance_offset-= (t_cnt.QuadPart /
+ query_performance_frequency * MS +
+ t_cnt.QuadPart %
+ query_performance_frequency * MS /
+ query_performance_frequency);
+ }
+}
+
+
+/*
+ Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
+ there as environment variables
+*/
+static void win_init_registry(void)
+{
+ HKEY key_handle;
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
+ 0, KEY_READ, &key_handle) == ERROR_SUCCESS)
+ {
+ LONG ret;
+ DWORD index= 0;
+ DWORD type;
+ char key_name[256], key_data[1024];
+ DWORD key_name_len= sizeof(key_name) - 1;
+ DWORD key_data_len= sizeof(key_data) - 1;
+
+ while ((ret= RegEnumValue(key_handle, index++,
+ key_name, &key_name_len,
+ NULL, &type, (LPBYTE)&key_data,
+ &key_data_len)) != ERROR_NO_MORE_ITEMS)
+ {
+ char env_string[sizeof(key_name) + sizeof(key_data) + 2];
+
+ if (ret == ERROR_MORE_DATA)
+ {
+ /* Registry value larger than 'key_data', skip it */
+ DBUG_PRINT("error", ("Skipped registry value that was too large"));
+ }
+ else if (ret == ERROR_SUCCESS)
+ {
+ if (type == REG_SZ)
+ {
+ strxmov(env_string, key_name, "=", key_data, NullS);
+
+ /* variable for putenv must be allocated ! */
+ putenv(strdup(env_string)) ;
+ }
+ }
+ else
+ {
+ /* Unhandled error, break out of loop */
+ break;
+ }
+
+ key_name_len= sizeof(key_name) - 1;
+ key_data_len= sizeof(key_data) - 1;
+ }
+
+ RegCloseKey(key_handle);
+ }
+}
+
static void my_win_init(void)
{
@@ -318,17 +401,18 @@ static void my_win_init(void)
#if defined(_MSC_VER)
#if _MSC_VER < 1300
- /*
+ /*
Clear the OS system variable TZ and avoid the 100% CPU usage
Only for old versions of Visual C++
*/
- _putenv( "TZ=" );
-#endif
+ _putenv("TZ=");
+#endif
#if _MSC_VER >= 1400
/* this is required to make crt functions return -1 appropriately */
_set_invalid_parameter_handler(my_parameter_handler);
#endif
-#endif
+#endif
+
#ifdef __MSVC_RUNTIME_CHECKS
/*
Install handler to send RTC (Runtime Error Check) warnings
@@ -339,106 +423,10 @@ static void my_win_init(void)
_tzset();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /* The following is used by time functions */
-#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
-#define MS 10000000
- {
- FILETIME ft;
- LARGE_INTEGER li, t_cnt;
- DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
- if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
- query_performance_frequency= 0;
- else
- {
- GetSystemTimeAsFileTime(&ft);
- li.LowPart= ft.dwLowDateTime;
- li.HighPart= ft.dwHighDateTime;
- query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
- QueryPerformanceCounter(&t_cnt);
- query_performance_offset-= (t_cnt.QuadPart /
- query_performance_frequency * MS +
- t_cnt.QuadPart %
- query_performance_frequency * MS /
- query_performance_frequency);
- }
- }
+ win_init_time();
+ win_init_registry();
- {
- /*
- Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
- there as environment variables
- */
- HKEY key_handle;
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
- 0, KEY_READ, &key_handle) == ERROR_SUCCESS)
- {
- LONG ret;
- DWORD index= 0;
- DWORD type;
- char key_name[256], key_data[1024];
- DWORD key_name_len= sizeof(key_name) - 1;
- DWORD key_data_len= sizeof(key_data) - 1;
-
- while ((ret= RegEnumValue(key_handle, index++,
- key_name, &key_name_len,
- NULL, &type, (LPBYTE)&key_data,
- &key_data_len)) != ERROR_NO_MORE_ITEMS)
- {
- char env_string[sizeof(key_name) + sizeof(key_data) + 2];
-
- if (ret == ERROR_MORE_DATA)
- {
- /* Registry value larger than 'key_data', skip it */
- DBUG_PRINT("error", ("Skipped registry value that was too large"));
- }
- else if (ret == ERROR_SUCCESS)
- {
- if (type == REG_SZ)
- {
- strxmov(env_string, key_name, "=", key_data, NullS);
-
- /* variable for putenv must be allocated ! */
- putenv(strdup(env_string)) ;
- }
- }
- else
- {
- /* Unhandled error, break out of loop */
- break;
- }
-
- key_name_len= sizeof(key_name) - 1;
- key_data_len= sizeof(key_data) - 1;
- }
-
- RegCloseKey(key_handle) ;
- }
- }
- DBUG_VOID_RETURN ;
+ DBUG_VOID_RETURN;
}
diff --git a/mysys/my_seek.c b/mysys/my_seek.c
index 8502c259353..ca12a2e95d1 100644
--- a/mysys/my_seek.c
+++ b/mysys/my_seek.c
@@ -14,6 +14,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysys_priv.h"
+#include "mysys_err.h"
/*
Seek to a position in a file.
@@ -42,8 +43,7 @@
actual error.
*/
-my_off_t my_seek(File fd, my_off_t pos, int whence,
- myf MyFlags __attribute__((unused)))
+my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags)
{
os_off_t newpos= -1;
DBUG_ENTER("my_seek");
@@ -63,7 +63,9 @@ my_off_t my_seek(File fd, my_off_t pos, int whence,
if (newpos == (os_off_t) -1)
{
my_errno= errno;
- DBUG_PRINT("error",("lseek: %llu errno: %d", (ulonglong) newpos,errno));
+ if (MyFlags & MY_WME)
+ my_error(EE_CANT_SEEK, MYF(0), my_filename(fd), my_errno);
+ DBUG_PRINT("error", ("lseek: %llu errno: %d", (ulonglong) newpos, errno));
DBUG_RETURN(MY_FILEPOS_ERROR);
}
if ((my_off_t) newpos != pos)
@@ -77,7 +79,7 @@ my_off_t my_seek(File fd, my_off_t pos, int whence,
/* Tell current position of file */
/* ARGSUSED */
-my_off_t my_tell(File fd, myf MyFlags __attribute__((unused)))
+my_off_t my_tell(File fd, myf MyFlags)
{
os_off_t pos;
DBUG_ENTER("my_tell");
@@ -89,7 +91,12 @@ my_off_t my_tell(File fd, myf MyFlags __attribute__((unused)))
pos= my_seek(fd, 0L, MY_SEEK_CUR,0);
#endif
if (pos == (os_off_t) -1)
+ {
my_errno= errno;
+ if (MyFlags & MY_WME)
+ my_error(EE_CANT_SEEK, MYF(0), my_filename(fd), my_errno);
+ DBUG_PRINT("error", ("tell: %llu errno: %d", (ulonglong) pos, my_errno));
+ }
DBUG_PRINT("exit",("pos: %llu", (ulonglong) pos));
DBUG_RETURN((my_off_t) pos);
} /* my_tell */
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index b57edd2179a..59d929f9a61 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -118,8 +118,7 @@ int my_is_symlink(const char *filename __attribute__((unused)))
'to' may be equal to 'filename'
*/
-int my_realpath(char *to, const char *filename,
- myf MyFlags __attribute__((unused)))
+int my_realpath(char *to, const char *filename, myf MyFlags)
{
#if defined(HAVE_REALPATH) && !defined(HAVE_BROKEN_REALPATH)
int result=0;
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 451a2c7d06a..48cdaaa6c91 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -24,6 +24,11 @@
#include <unistd.h>
#include <strings.h>
+#ifdef __linux__
+#include <ctype.h> /* isprint */
+#include <sys/syscall.h> /* SYS_gettid */
+#endif
+
#if HAVE_EXECINFO_H
#include <execinfo.h>
#endif
@@ -43,10 +48,99 @@ void my_init_stacktrace()
#endif
}
-void my_safe_print_str(const char* name, const char* val, int max_len)
+#ifdef __linux__
+
+static void print_buffer(char *buffer, size_t count)
+{
+ for (; count && *buffer; --count)
+ {
+ int c= (int) *buffer++;
+ fputc(isprint(c) ? c : ' ', stderr);
+ }
+}
+
+/**
+ Access the pages of this process through /proc/self/task/<tid>/mem
+ in order to safely print the contents of a memory address range.
+
+ @param addr The address at the start of the memory region.
+ @param max_len The length of the memory region.
+
+ @return Zero on success.
+*/
+static int safe_print_str(const char *addr, int max_len)
{
- char *heap_end= (char*) sbrk(0);
- fprintf(stderr, "%s at %p ", name, val);
+ int fd;
+ pid_t tid;
+ off_t offset;
+ ssize_t nbytes= 0;
+ size_t total, count;
+ char buf[256];
+
+ tid= (pid_t) syscall(SYS_gettid);
+
+ sprintf(buf, "/proc/self/task/%d/mem", tid);
+
+ if ((fd= open(buf, O_RDONLY)) < 0)
+ return -1;
+
+ /* Ensure that off_t can hold a pointer. */
+ compile_time_assert(sizeof(off_t) >= sizeof(intptr));
+
+ total= max_len;
+ offset= (intptr) addr;
+
+ /* Read up to the maximum number of bytes. */
+ while (total)
+ {
+ count= min(sizeof(buf), total);
+
+ if ((nbytes= pread(fd, buf, count, offset)) < 0)
+ {
+ /* Just in case... */
+ if (errno == EINTR)
+ continue;
+ else
+ break;
+ }
+
+ /* Advance offset into memory. */
+ total-= nbytes;
+ offset+= nbytes;
+ addr+= nbytes;
+
+ /* Output the printable characters. */
+ print_buffer(buf, nbytes);
+
+ /* Break if less than requested... */
+ if ((count - nbytes))
+ break;
+ }
+
+ /* Output a new line if something was printed. */
+ if (total != (size_t) max_len)
+ fputc('\n', stderr);
+
+ if (nbytes == -1)
+ fprintf(stderr, "Can't read from address %p: %m.\n", addr);
+
+ close(fd);
+
+ return 0;
+}
+
+#endif
+
+void my_safe_print_str(const char* val, int max_len)
+{
+ char *heap_end;
+
+#ifdef __linux__
+ if (!safe_print_str(val, max_len))
+ return;
+#endif
+
+ heap_end= (char*) sbrk(0);
if (!PTR_SANE(val))
{
@@ -54,7 +148,6 @@ void my_safe_print_str(const char* name, const char* val, int max_len)
return;
}
- fprintf(stderr, "= ");
for (; max_len && PTR_SANE(val) && *val; --max_len)
fputc(*val++, stderr);
fputc('\n', stderr);
@@ -607,10 +700,9 @@ void my_write_core(int unused)
}
-void my_safe_print_str(const char *name, const char *val, int len)
+void my_safe_print_str(const char *val, int len)
{
- fprintf(stderr,"%s at %p", name, val);
- __try
+ __try
{
fprintf(stderr,"=%.*s\n", len, val);
}
diff --git a/packaging/WiX/ca/CMakeLists.txt b/packaging/WiX/ca/CMakeLists.txt
index c74b51284c7..a03ceb9a5d2 100644
--- a/packaging/WiX/ca/CMakeLists.txt
+++ b/packaging/WiX/ca/CMakeLists.txt
@@ -16,7 +16,7 @@
INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/inc)
LINK_DIRECTORIES(${WIX_DIR}/../SDK/lib)
-SET(WIXCA_SOURCES CustomAction.cpp CustomAction.rc CustomAction.def)
+SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
LINK_LIBRARIES(wcautil_x64 dutil_x64 msi version)
diff --git a/packaging/WiX/ca/CustomAction.rc b/packaging/WiX/ca/CustomAction.rc
deleted file mode 100644
index 3f37126ee77..00000000000
--- a/packaging/WiX/ca/CustomAction.rc
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "afxres.h"
-#undef APSTUDIO_READONLY_SYMBOLS
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x0L
- FILESUBTYPE 0x0L
-BEGIN
-END
-
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index f4e240e5cc1..4e0fb7c804a 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3428,7 +3428,7 @@ int ha_partition::truncate()
ALTER TABLE t TRUNCATE PARTITION ...
*/
-int ha_partition::truncate_partition(Alter_info *alter_info)
+int ha_partition::truncate_partition(Alter_info *alter_info, bool *binlog_stmt)
{
int error= 0;
List_iterator<partition_element> part_it(m_part_info->partitions);
@@ -3440,6 +3440,9 @@ int ha_partition::truncate_partition(Alter_info *alter_info)
PART_ADMIN);
DBUG_ENTER("ha_partition::truncate_partition");
+ /* Only binlog when it starts any call to the partitions handlers */
+ *binlog_stmt= false;
+
/*
TRUNCATE also means resetting auto_increment. Hence, reset
it so that it will be initialized again at the next use.
@@ -3453,6 +3456,8 @@ int ha_partition::truncate_partition(Alter_info *alter_info)
(!(alter_info->flags & ALTER_ALL_PARTITION)))
DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND);
+ *binlog_stmt= true;
+
do
{
partition_element *part_elem= part_it++;
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index f1abc0cefe2..57456ddf8ae 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -362,7 +362,7 @@ public:
@remark This method is a partitioning-specific hook
and thus not a member of the general SE API.
*/
- int truncate_partition(Alter_info *);
+ int truncate_partition(Alter_info *, bool *binlog_stmt);
virtual bool is_fatal_error(int error, uint flags)
{
diff --git a/sql/handler.cc b/sql/handler.cc
index 38b57c16ee0..4e8af034fd8 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1237,7 +1237,11 @@ int ha_commit_trans(THD *thd, bool all)
error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0;
DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE(););
if (cookie)
- tc_log->unlog(cookie, xid);
+ if(tc_log->unlog(cookie, xid))
+ {
+ error= 2;
+ goto end;
+ }
DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););
RUN_HOOK(transaction, after_commit, (thd, FALSE));
end:
@@ -2209,7 +2213,8 @@ int handler::read_first_row(uchar * buf, uint primary_key)
computes the lowest number
- strictly greater than "nr"
- of the form: auto_increment_offset + N * auto_increment_increment
-
+ If overflow happened then return MAX_ULONGLONG value as an
+ indication of overflow.
In most cases increment= offset= 1, in which case we get:
@verbatim 1,2,3,4,5,... @endverbatim
If increment=10 and offset=5 and previous number is 1, we get:
@@ -2218,13 +2223,23 @@ int handler::read_first_row(uchar * buf, uint primary_key)
inline ulonglong
compute_next_insert_id(ulonglong nr,struct system_variables *variables)
{
+ const ulonglong save_nr= nr;
+
if (variables->auto_increment_increment == 1)
- return (nr+1); // optimization of the formula below
- nr= (((nr+ variables->auto_increment_increment -
- variables->auto_increment_offset)) /
- (ulonglong) variables->auto_increment_increment);
- return (nr* (ulonglong) variables->auto_increment_increment +
- variables->auto_increment_offset);
+ nr= nr + 1; // optimization of the formula below
+ else
+ {
+ nr= (((nr+ variables->auto_increment_increment -
+ variables->auto_increment_offset)) /
+ (ulonglong) variables->auto_increment_increment);
+ nr= (nr* (ulonglong) variables->auto_increment_increment +
+ variables->auto_increment_offset);
+ }
+
+ if (unlikely(nr <= save_nr))
+ return ULONGLONG_MAX;
+
+ return nr;
}
@@ -2435,7 +2450,7 @@ int handler::update_auto_increment()
variables->auto_increment_increment,
nb_desired_values, &nr,
&nb_reserved_values);
- if (nr == ~(ulonglong) 0)
+ if (nr == ULONGLONG_MAX)
DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED); // Mark failure
/*
@@ -2466,6 +2481,9 @@ int handler::update_auto_increment()
}
}
+ if (unlikely(nr == ULONGLONG_MAX))
+ DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
+
DBUG_PRINT("info",("auto_increment: %lu", (ulong) nr));
if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
diff --git a/sql/item.cc b/sql/item.cc
index 8957e6e7133..b1e453121bd 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1812,16 +1812,7 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
- {
- /*
- We should disable const subselect item evaluation because
- subselect transformation does not happen in view_prepare_mode
- and thus val_...() methods can not be called for const items.
- */
- bool resolve_const= ((*arg)->type() == Item::SUBSELECT_ITEM &&
- thd->lex->view_prepare_mode) ? FALSE : TRUE;
- conv= new Item_func_conv_charset(*arg, coll.collation, resolve_const);
- }
+ conv= new Item_func_conv_charset(*arg, coll.collation, 1);
if (!conv)
{
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index f89eabaa868..737fa02bcd2 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -403,7 +403,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
Field *field= field_item->field;
int result= 0;
- if (!(*item)->with_subselect && (*item)->const_item())
+ if ((*item)->const_item())
{
TABLE *table= field->table;
ulonglong orig_sql_mode= thd->variables.sql_mode;
@@ -499,7 +499,7 @@ void Item_bool_func2::fix_length_and_dec()
}
thd= current_thd;
- if (!thd->is_context_analysis_only())
+ if (!thd->lex->is_ps_or_view_context_analysis())
{
if (args[0]->real_item()->type() == FIELD_ITEM)
{
@@ -803,7 +803,7 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
confuse storage engines since in context analysis mode tables
aren't locked.
*/
- if (!thd->is_context_analysis_only() &&
+ if (!thd->lex->is_ps_or_view_context_analysis() &&
cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
(str_arg->type() != Item::FUNC_ITEM ||
((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
@@ -1036,7 +1036,7 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
Item_result type)
{
/* Don't need cache if doing context analysis only. */
- if (!thd_arg->is_context_analysis_only() &&
+ if (!thd->lex->is_ps_or_view_context_analysis() &&
(*value)->const_item() && type != (*value)->result_type())
{
Item_cache *cache= Item_cache::get_cache(*value, type);
@@ -4714,7 +4714,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
return TRUE;
}
- if (escape_item->const_item() && !thd->lex->view_prepare_mode)
+ if (escape_item->const_item())
{
/* If we are on execution stage */
String *escape_str= escape_item->val_str(&cmp.value1);
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 672e59986d5..1ae65926013 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -1330,6 +1330,34 @@ protected:
};
+#ifndef DBUG_OFF
+class Create_func_like_range_min : public Create_func_arg2
+{
+public:
+ virtual Item *create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_like_range_min s_singleton;
+
+protected:
+ Create_func_like_range_min() {}
+ virtual ~Create_func_like_range_min() {}
+};
+
+
+class Create_func_like_range_max : public Create_func_arg2
+{
+public:
+ virtual Item *create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_like_range_max s_singleton;
+
+protected:
+ Create_func_like_range_max() {}
+ virtual ~Create_func_like_range_max() {}
+};
+#endif
+
+
class Create_func_ln : public Create_func_arg1
{
public:
@@ -3836,6 +3864,26 @@ Create_func_length::create(THD *thd, Item *arg1)
}
+#ifndef DBUG_OFF
+Create_func_like_range_min Create_func_like_range_min::s_singleton;
+
+Item*
+Create_func_like_range_min::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_like_range_min(arg1, arg2);
+}
+
+
+Create_func_like_range_max Create_func_like_range_max::s_singleton;
+
+Item*
+Create_func_like_range_max::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_like_range_max(arg1, arg2);
+}
+#endif
+
+
Create_func_ln Create_func_ln::s_singleton;
Item*
@@ -4924,6 +4972,10 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
{ { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
{ { C_STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)},
+#ifndef DBUG_OFF
+ { { C_STRING_WITH_LEN("LIKE_RANGE_MIN") }, BUILDER(Create_func_like_range_min)},
+ { { C_STRING_WITH_LEN("LIKE_RANGE_MAX") }, BUILDER(Create_func_like_range_max)},
+#endif
{ { C_STRING_WITH_LEN("LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
{ { C_STRING_WITH_LEN("LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
{ { C_STRING_WITH_LEN("LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 92b80e274f4..ecc4f30e25d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6492,7 +6492,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (res)
DBUG_RETURN(res);
- if (thd->lex->view_prepare_mode)
+ if (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)
{
/*
Here we check privileges of the stored routine only during view
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 2fbf0c12499..94515640625 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -80,12 +80,8 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
used_tables_cache |= item->used_tables();
const_item_cache&= item->const_item() && !with_null;
not_null_tables_cache|= item->not_null_tables();
- /*
- Some subqueries transformations aren't done in the view_prepare_mode thus
- is_null() will fail. So we skip is_null() calculation for CREATE VIEW as
- not necessary.
- */
- if (const_item_cache && !thd->lex->view_prepare_mode)
+
+ if (const_item_cache)
{
if (item->cols() > 1)
with_null|= item->null_inside();
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index c71d8226f77..2a93bcd0153 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3176,6 +3176,41 @@ String *Item_func_unhex::val_str(String *str)
}
+#ifndef DBUG_OFF
+String *Item_func_like_range::val_str(String *str)
+{
+ DBUG_ASSERT(fixed == 1);
+ longlong nbytes= args[1]->val_int();
+ String *res= args[0]->val_str(str);
+ size_t min_len, max_len;
+ CHARSET_INFO *cs= collation.collation;
+
+ if (!res || args[0]->null_value || args[1]->null_value ||
+ nbytes < 0 || nbytes > MAX_BLOB_WIDTH ||
+ min_str.alloc(nbytes) || max_str.alloc(nbytes))
+ goto err;
+ null_value=0;
+
+ if (cs->coll->like_range(cs, res->ptr(), res->length(),
+ '\\', '_', '%', nbytes,
+ (char*) min_str.ptr(), (char*) max_str.ptr(),
+ &min_len, &max_len))
+ goto err;
+
+ min_str.set_charset(collation.collation);
+ max_str.set_charset(collation.collation);
+ min_str.length(min_len);
+ max_str.length(max_len);
+
+ return is_min ? &min_str : &max_str;
+
+err:
+ null_value= 1;
+ return 0;
+}
+#endif
+
+
void Item_func_binary::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("cast("));
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 5dcef2e671f..d76e139883c 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -657,6 +657,46 @@ public:
};
+#ifndef DBUG_OFF
+class Item_func_like_range :public Item_str_func
+{
+protected:
+ String min_str;
+ String max_str;
+ const bool is_min;
+public:
+ Item_func_like_range(Item *a, Item *b, bool is_min_arg)
+ :Item_str_func(a, b), is_min(is_min_arg)
+ { maybe_null= 1; }
+ String *val_str(String *);
+ void fix_length_and_dec()
+ {
+ collation.set(args[0]->collation);
+ decimals=0;
+ max_length= MAX_BLOB_WIDTH;
+ }
+};
+
+
+class Item_func_like_range_min :public Item_func_like_range
+{
+public:
+ Item_func_like_range_min(Item *a, Item *b)
+ :Item_func_like_range(a, b, true) { }
+ const char *func_name() const { return "like_range_min"; }
+};
+
+
+class Item_func_like_range_max :public Item_func_like_range
+{
+public:
+ Item_func_like_range_max(Item *a, Item *b)
+ :Item_func_like_range(a, b, false) { }
+ const char *func_name() const { return "like_range_max"; }
+};
+#endif
+
+
class Item_func_binary :public Item_str_func
{
public:
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index c1b1f47e5e9..7ed24a03025 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -131,20 +131,6 @@ void Item_subselect::cleanup()
}
-/*
- We cannot use generic Item::safe_charset_converter() because
- Subselect transformation does not happen in view_prepare_mode
- and thus we can not evaluate val_...() for const items.
-*/
-
-Item *Item_subselect::safe_charset_converter(CHARSET_INFO *tocs)
-{
- Item_func_conv_charset *conv=
- new Item_func_conv_charset(this, tocs, thd->lex->view_prepare_mode ? 0 : 1);
- return conv->safe ? conv : NULL;
-}
-
-
void Item_singlerow_subselect::cleanup()
{
DBUG_ENTER("Item_singlerow_subselect::cleanup");
@@ -279,6 +265,7 @@ bool Item_subselect::exec()
if (thd->is_error() || thd->killed)
return 1;
+ DBUG_ASSERT(!thd->lex->context_analysis_only);
/*
Simulate a failure in sub-query execution. Used to test e.g.
out of memory or query being killed conditions.
@@ -315,7 +302,7 @@ table_map Item_subselect::used_tables() const
bool Item_subselect::const_item() const
{
- return const_item_cache;
+ return thd->lex->context_analysis_only ? FALSE : const_item_cache;
}
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
@@ -1646,7 +1633,8 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
bool result = 0;
- if (thd_arg->lex->view_prepare_mode && left_expr && !left_expr->fixed)
+ if ((thd_arg->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
+ left_expr && !left_expr->fixed)
result = left_expr->fix_fields(thd_arg, &left_expr);
return result || Item_subselect::fix_fields(thd_arg, ref);
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index d8d18fd8ef6..3f8726eddc7 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -138,7 +138,6 @@ public:
virtual void reset_value_registration() {}
enum_parsing_place place() { return parsing_place; }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
- Item *safe_charset_converter(CHARSET_INFO *tocs);
/**
Get the SELECT_LEX structure associated with this Item.
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 8cd8e1bb222..107634e196d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1325,27 +1325,11 @@ void Item_sum_sum::fix_length_and_dec()
bool Item_sum_sum::add()
{
DBUG_ENTER("Item_sum_sum::add");
- bool arg_is_null;
if (hybrid_type == DECIMAL_RESULT)
{
- my_decimal value, *val;
- if (aggr->use_distinct_values)
- {
- /*
- We are aggregating distinct rows. Get the value from the distinct
- table pointer
- */
- Aggregator_distinct *daggr= (Aggregator_distinct *)aggr;
- val= daggr->table->field[0]->val_decimal (&value);
- arg_is_null= daggr->table->field[0]->is_null();
- }
- else
- {
- /* non-distinct aggregation */
- val= args[0]->val_decimal(&value);
- arg_is_null= args[0]->null_value;
- }
- if (!arg_is_null)
+ my_decimal value;
+ const my_decimal *val= aggr->arg_val_decimal(&value);
+ if (!aggr->arg_is_null())
{
my_decimal_add(E_DEC_FATAL_ERROR, dec_buffs + (curr_dec_buff^1),
val, dec_buffs + curr_dec_buff);
@@ -1355,25 +1339,8 @@ bool Item_sum_sum::add()
}
else
{
- double val;
- if (aggr->use_distinct_values)
- {
- /*
- We are aggregating distinct rows. Get the value from the distinct
- table pointer
- */
- Aggregator_distinct *daggr= (Aggregator_distinct *)aggr;
- val= daggr->table->field[0]->val_real ();
- arg_is_null= daggr->table->field[0]->is_null();
- }
- else
- {
- /* non-distinct aggregation */
- val= args[0]->val_real();
- arg_is_null= args[0]->null_value;
- }
- sum+= val;
- if (!arg_is_null)
+ sum+= aggr->arg_val_real();
+ if (!aggr->arg_is_null())
null_value= 0;
}
DBUG_RETURN(0);
@@ -1471,6 +1438,45 @@ Aggregator_distinct::~Aggregator_distinct()
}
+my_decimal *Aggregator_simple::arg_val_decimal(my_decimal *value)
+{
+ return item_sum->args[0]->val_decimal(value);
+}
+
+
+double Aggregator_simple::arg_val_real()
+{
+ return item_sum->args[0]->val_real();
+}
+
+
+bool Aggregator_simple::arg_is_null()
+{
+ return item_sum->args[0]->null_value;
+}
+
+
+my_decimal *Aggregator_distinct::arg_val_decimal(my_decimal * value)
+{
+ return use_distinct_values ? table->field[0]->val_decimal(value) :
+ item_sum->args[0]->val_decimal(value);
+}
+
+
+double Aggregator_distinct::arg_val_real()
+{
+ return use_distinct_values ? table->field[0]->val_real() :
+ item_sum->args[0]->val_real();
+}
+
+
+bool Aggregator_distinct::arg_is_null()
+{
+ return use_distinct_values ? table->field[0]->is_null() :
+ item_sum->args[0]->null_value;
+}
+
+
Item *Item_sum_count::copy_or_same(THD* thd)
{
return new (thd->mem_root) Item_sum_count(thd, this);
@@ -1576,7 +1582,7 @@ bool Item_sum_avg::add()
{
if (Item_sum_sum::add())
return TRUE;
- if (!args[0]->null_value)
+ if (!aggr->arg_is_null())
count++;
return FALSE;
}
@@ -2229,7 +2235,7 @@ void Item_sum_avg::reset_field()
void Item_sum_bit::reset_field()
{
- reset();
+ reset_and_add();
int8store(result_field->ptr, bits);
}
@@ -3028,6 +3034,7 @@ Item_func_group_concat(Name_resolution_context *context_arg,
order_item->item= arg_ptr++;
}
}
+ memcpy(orig_args, args, sizeof(Item*) * arg_count);
}
@@ -3239,7 +3246,6 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- memcpy (orig_args, args, sizeof (Item *) * arg_count);
fixed= 1;
return FALSE;
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 06a8c2c58a4..3ea79fb8cee 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -101,6 +101,15 @@ public:
*/
virtual void endup() = 0;
+ /** Decimal value of being-aggregated argument */
+ virtual my_decimal *arg_val_decimal(my_decimal * value) = 0;
+ /** Floating point value of being-aggregated argument */
+ virtual double arg_val_real() = 0;
+ /**
+ NULLness of being-aggregated argument; can be called only after
+ arg_val_decimal() or arg_val_real().
+ */
+ virtual bool arg_is_null() = 0;
};
@@ -304,6 +313,7 @@ class st_select_lex;
class Item_sum :public Item_result_field
{
friend class Aggregator_distinct;
+ friend class Aggregator_simple;
protected:
/**
@@ -396,14 +406,22 @@ public:
Item_sum(THD *thd, Item_sum *item);
enum Type type() const { return SUM_FUNC_ITEM; }
virtual enum Sumfunctype sum_func () const=0;
- inline bool reset() { aggregator_clear(); return aggregator_add(); };
+ /**
+ Resets the aggregate value to its default and aggregates the current
+ value of its attribute(s).
+ */
+ inline bool reset_and_add()
+ {
+ aggregator_clear();
+ return aggregator_add();
+ };
/*
Called when new group is started and results are being saved in
- a temporary table. Similar to reset(), but must also store value in
- result_field. Like reset() it is supposed to reset start value to
- default.
- This set of methods (reult_field(), reset_field, update_field()) of
+ a temporary table. Similarly to reset_and_add() it resets the
+ value to its default and aggregates the value of its
+ attribute(s), but must also store it in result_field.
+ This set of methods (result_item(), reset_field, update_field()) of
Item_sum is used only if quick_group is not null. Otherwise
copy_or_same() is used to obtain a copy of this item.
*/
@@ -446,7 +464,7 @@ public:
set_aggregator(with_distinct ?
Aggregator::DISTINCT_AGGREGATOR :
Aggregator::SIMPLE_AGGREGATOR);
- reset();
+ aggregator_clear();
}
virtual void make_unique() { force_copy_fields= TRUE; }
Item *get_tmp_table_item(THD *thd);
@@ -600,6 +618,9 @@ public:
void clear();
bool add();
void endup();
+ virtual my_decimal *arg_val_decimal(my_decimal * value);
+ virtual double arg_val_real();
+ virtual bool arg_is_null();
bool unique_walk_function(void *element);
static int composite_key_cmp(void* arg, uchar* key1, uchar* key2);
@@ -623,6 +644,9 @@ public:
void clear() { item_sum->clear(); }
bool add() { return item_sum->add(); }
void endup() {};
+ virtual my_decimal *arg_val_decimal(my_decimal * value);
+ virtual double arg_val_real();
+ virtual bool arg_is_null();
};
diff --git a/sql/log.cc b/sql/log.cc
index bfc5018b556..b9be66f8ce7 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -209,11 +209,11 @@ class binlog_cache_data
{
public:
binlog_cache_data(): m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF),
- incident(FALSE), changes_to_non_trans_temp_table_flag(FALSE)
- {
- cache_log.end_of_file= max_binlog_cache_size;
- }
-
+ incident(FALSE), changes_to_non_trans_temp_table_flag(FALSE),
+ saved_max_binlog_cache_size(0), ptr_binlog_cache_use(0),
+ ptr_binlog_cache_disk_use(0)
+ { }
+
~binlog_cache_data()
{
DBUG_ASSERT(empty());
@@ -257,11 +257,19 @@ public:
void reset()
{
+ compute_statistics();
truncate(0);
changes_to_non_trans_temp_table_flag= FALSE;
incident= FALSE;
before_stmt_pos= MY_OFF_T_UNDEF;
- cache_log.end_of_file= max_binlog_cache_size;
+ /*
+ The truncate function calls reinit_io_cache that calls my_b_flush_io_cache
+ which may increase disk_writes. This breaks the disk_writes use by the
+ binary log which aims to compute the ratio between in-memory cache usage
+ and disk cache usage. To avoid this undesirable behavior, we reset the
+ variable after truncating the cache.
+ */
+ cache_log.disk_writes= 0;
DBUG_ASSERT(empty());
}
@@ -292,6 +300,36 @@ public:
before_stmt_pos= MY_OFF_T_UNDEF;
}
+ void set_binlog_cache_info(ulong param_max_binlog_cache_size,
+ ulong *param_ptr_binlog_cache_use,
+ ulong *param_ptr_binlog_cache_disk_use)
+ {
+ /*
+ The assertions guarantee that the set_binlog_cache_info is
+ called just once and information passed as parameters are
+ never zero.
+
+ This is done while calling the constructor binlog_cache_mngr.
+ We cannot set informaton in the constructor binlog_cache_data
+ because the space for binlog_cache_mngr is allocated through
+ a placement new.
+
+ In the future, we can refactor this and change it to avoid
+ the set_binlog_info.
+ */
+ DBUG_ASSERT(saved_max_binlog_cache_size == 0 &&
+ param_max_binlog_cache_size != 0 &&
+ ptr_binlog_cache_use == 0 &&
+ param_ptr_binlog_cache_use != 0 &&
+ ptr_binlog_cache_disk_use == 0 &&
+ param_ptr_binlog_cache_disk_use != 0);
+
+ saved_max_binlog_cache_size= param_max_binlog_cache_size;
+ ptr_binlog_cache_use= param_ptr_binlog_cache_use;
+ ptr_binlog_cache_disk_use= param_ptr_binlog_cache_disk_use;
+ cache_log.end_of_file= saved_max_binlog_cache_size;
+ }
+
/*
Cache to store data before copying it to the binary log.
*/
@@ -321,6 +359,40 @@ private:
*/
bool changes_to_non_trans_temp_table_flag;
+ /**
+ This function computes binlog cache and disk usage.
+ */
+ void compute_statistics()
+ {
+ if (!empty())
+ {
+ statistic_increment(*ptr_binlog_cache_use, &LOCK_status);
+ if (cache_log.disk_writes != 0)
+ statistic_increment(*ptr_binlog_cache_disk_use, &LOCK_status);
+ }
+ }
+
+ /*
+ Stores the values of maximum size of the cache allowed when this cache
+ is configured. This corresponds to either
+ . max_binlog_cache_size or max_binlog_stmt_cache_size.
+ */
+ ulong saved_max_binlog_cache_size;
+
+ /*
+ Stores a pointer to the status variable that keeps track of the in-memory
+ cache usage. This corresponds to either
+ . binlog_cache_use or binlog_stmt_cache_use.
+ */
+ ulong *ptr_binlog_cache_use;
+
+ /*
+ Stores a pointer to the status variable that keeps track of the disk
+ cache usage. This corresponds to either
+ . binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+ */
+ ulong *ptr_binlog_cache_disk_use;
+
/*
It truncates the cache to a certain position. This includes deleting the
pending event.
@@ -334,7 +406,7 @@ private:
set_pending(0);
}
reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, 0);
- cache_log.end_of_file= max_binlog_cache_size;
+ cache_log.end_of_file= saved_max_binlog_cache_size;
}
binlog_cache_data& operator=(const binlog_cache_data& info);
@@ -343,7 +415,20 @@ private:
class binlog_cache_mngr {
public:
- binlog_cache_mngr() {}
+ binlog_cache_mngr(ulong param_max_binlog_stmt_cache_size,
+ ulong param_max_binlog_cache_size,
+ ulong *param_ptr_binlog_stmt_cache_use,
+ ulong *param_ptr_binlog_stmt_cache_disk_use,
+ ulong *param_ptr_binlog_cache_use,
+ ulong *param_ptr_binlog_cache_disk_use)
+ {
+ stmt_cache.set_binlog_cache_info(param_max_binlog_stmt_cache_size,
+ param_ptr_binlog_stmt_cache_use,
+ param_ptr_binlog_stmt_cache_disk_use);
+ trx_cache.set_binlog_cache_info(param_max_binlog_cache_size,
+ param_ptr_binlog_cache_use,
+ param_ptr_binlog_cache_disk_use);
+ }
void reset_cache(binlog_cache_data* cache_data)
{
@@ -1506,57 +1591,122 @@ static int binlog_close_connection(handlerton *hton, THD *thd)
}
/**
- This function flushes a transactional cache upon commit/rollback.
+ This function flushes a cache upon commit/rollback.
- @param thd The thread whose transaction should be flushed
- @param cache_mngr Pointer to the cache data to be flushed
- @param end_ev The end event either commit/rollback.
+ @param thd The thread whose transaction should be flushed
+ @param cache_data Pointer to the cache
+ @param end_ev The end event either commit/rollback
+ @param is_transactional The type of the cache: transactional or
+ non-transactional
@return
- nonzero if an error pops up when flushing the transactional cache.
+ nonzero if an error pops up when flushing the cache.
*/
-static int
-binlog_flush_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr,
- Log_event *end_ev)
+static inline int
+binlog_flush_cache(THD *thd, binlog_cache_data* cache_data, Log_event *end_evt,
+ bool is_transactional)
{
- DBUG_ENTER("binlog_flush_trx_cache");
- int error=0;
- IO_CACHE *cache_log= &cache_mngr->trx_cache.cache_log;
-
- /*
- This function handles transactional changes and as such
- this flag equals to true.
- */
- bool const is_transactional= TRUE;
-
- if (thd->binlog_flush_pending_rows_event(TRUE, is_transactional))
- DBUG_RETURN(1);
- /*
- Doing a commit or a rollback including non-transactional tables,
- i.e., ending a transaction where we might write the transaction
- cache to the binary log.
-
- We can always end the statement when ending a transaction since
- transactions are not allowed inside stored functions. If they
- were, we would have to ensure that we're not ending a statement
- inside a stored function.
- */
- error= mysql_bin_log.write(thd, &cache_mngr->trx_cache.cache_log, end_ev,
- cache_mngr->trx_cache.has_incident());
- cache_mngr->reset_cache(&cache_mngr->trx_cache);
+ DBUG_ENTER("binlog_flush_cache");
+ int error= 0;
- statistic_increment(binlog_cache_use, &LOCK_status);
- if (cache_log->disk_writes != 0)
+ if (!cache_data->empty())
{
- statistic_increment(binlog_cache_disk_use, &LOCK_status);
- cache_log->disk_writes= 0;
+ if (thd->binlog_flush_pending_rows_event(TRUE, is_transactional))
+ DBUG_RETURN(1);
+ /*
+ Doing a commit or a rollback including non-transactional tables,
+ i.e., ending a transaction where we might write the transaction
+ cache to the binary log.
+
+ We can always end the statement when ending a transaction since
+ transactions are not allowed inside stored functions. If they
+ were, we would have to ensure that we're not ending a statement
+ inside a stored function.
+ */
+ error= mysql_bin_log.write(thd, &cache_data->cache_log, end_evt,
+ cache_data->has_incident());
}
+ cache_data->reset();
- DBUG_ASSERT(cache_mngr->trx_cache.empty());
+ DBUG_ASSERT(cache_data->empty());
DBUG_RETURN(error);
}
/**
+ This function flushes the stmt-cache upon commit.
+
+ @param thd The thread whose transaction should be flushed
+ @param cache_mngr Pointer to the cache manager
+
+ @return
+ nonzero if an error pops up when flushing the cache.
+*/
+static inline int
+binlog_commit_flush_stmt_cache(THD *thd,
+ binlog_cache_mngr *cache_mngr)
+{
+ Query_log_event end_evt(thd, STRING_WITH_LEN("COMMIT"),
+ FALSE, FALSE, TRUE, 0);
+ return (binlog_flush_cache(thd, &cache_mngr->stmt_cache, &end_evt,
+ FALSE));
+}
+
+/**
+ This function flushes the trx-cache upon commit.
+
+ @param thd The thread whose transaction should be flushed
+ @param cache_mngr Pointer to the cache manager
+
+ @return
+ nonzero if an error pops up when flushing the cache.
+*/
+static inline int
+binlog_commit_flush_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr)
+{
+ Query_log_event end_evt(thd, STRING_WITH_LEN("COMMIT"),
+ TRUE, FALSE, TRUE, 0);
+ return (binlog_flush_cache(thd, &cache_mngr->trx_cache, &end_evt,
+ TRUE));
+}
+
+/**
+ This function flushes the trx-cache upon rollback.
+
+ @param thd The thread whose transaction should be flushed
+ @param cache_mngr Pointer to the cache manager
+
+ @return
+ nonzero if an error pops up when flushing the cache.
+*/
+static inline int
+binlog_rollback_flush_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr)
+{
+ Query_log_event end_evt(thd, STRING_WITH_LEN("ROLLBACK"),
+ TRUE, FALSE, TRUE, 0);
+ return (binlog_flush_cache(thd, &cache_mngr->trx_cache, &end_evt,
+ TRUE));
+}
+
+/**
+ This function flushes the trx-cache upon commit.
+
+ @param thd The thread whose transaction should be flushed
+ @param cache_mngr Pointer to the cache manager
+ @param xid Transaction Id
+
+ @return
+ nonzero if an error pops up when flushing the cache.
+*/
+static inline int
+binlog_commit_flush_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr,
+ my_xid xid)
+{
+ Xid_log_event end_evt(thd, xid);
+ return (binlog_flush_cache(thd, &cache_mngr->trx_cache, &end_evt,
+ TRUE));
+}
+
+/**
This function truncates the transactional cache upon committing or rolling
back either a transaction or a statement.
@@ -1579,23 +1729,24 @@ binlog_truncate_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr, bool all)
*/
bool const is_transactional= TRUE;
- DBUG_PRINT("info", ("thd->options={ %s%s}, transaction: %s",
+ DBUG_PRINT("info", ("thd->options={ %s %s}, transaction: %s",
FLAGSTR(thd->variables.option_bits, OPTION_NOT_AUTOCOMMIT),
FLAGSTR(thd->variables.option_bits, OPTION_BEGIN),
all ? "all" : "stmt"));
+
+ thd->binlog_remove_pending_rows_event(TRUE, is_transactional);
/*
If rolling back an entire transaction or a single statement not
inside a transaction, we reset the transaction cache.
*/
- thd->binlog_remove_pending_rows_event(TRUE, is_transactional);
if (ending_trans(thd, all))
{
if (cache_mngr->trx_cache.has_incident())
error= mysql_bin_log.write_incident(thd, TRUE);
- cache_mngr->reset_cache(&cache_mngr->trx_cache);
-
thd->clear_binlog_table_maps();
+
+ cache_mngr->reset_cache(&cache_mngr->trx_cache);
}
/*
If rolling back a statement in a transaction, we truncate the
@@ -1620,51 +1771,6 @@ static int binlog_prepare(handlerton *hton, THD *thd, bool all)
}
/**
- This function flushes the non-transactional to the binary log upon
- committing or rolling back a statement.
-
- @param thd The thread whose transaction should be flushed
- @param cache_mngr Pointer to the cache data to be flushed
-
- @return
- nonzero if an error pops up when flushing the non-transactional cache.
-*/
-static int
-binlog_flush_stmt_cache(THD *thd, binlog_cache_mngr *cache_mngr)
-{
- int error= 0;
- DBUG_ENTER("binlog_flush_stmt_cache");
- /*
- If we are flushing the statement cache, it means that the changes get
- through otherwise the cache is empty and this routine should not be called.
- */
- DBUG_ASSERT(cache_mngr->stmt_cache.has_incident() == FALSE);
- /*
- This function handles non-transactional changes and as such this flag equals
- to false.
- */
- bool const is_transactional= FALSE;
- IO_CACHE *cache_log= &cache_mngr->stmt_cache.cache_log;
-
- if (thd->binlog_flush_pending_rows_event(TRUE, is_transactional))
- DBUG_RETURN(1);
-
- Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE, TRUE, 0);
- if ((error= mysql_bin_log.write(thd, cache_log, &qev,
- cache_mngr->stmt_cache.has_incident())))
- DBUG_RETURN(error);
- cache_mngr->reset_cache(&cache_mngr->stmt_cache);
-
- statistic_increment(binlog_cache_use, &LOCK_status);
- if (cache_log->disk_writes != 0)
- {
- statistic_increment(binlog_cache_disk_use, &LOCK_status);
- cache_log->disk_writes= 0;
- }
- DBUG_RETURN(error);
-}
-
-/**
This function is called once after each statement.
It has the responsibility to flush the caches to the binary log on commits.
@@ -1692,7 +1798,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
if (!cache_mngr->stmt_cache.empty())
{
- binlog_flush_stmt_cache(thd, cache_mngr);
+ error= binlog_commit_flush_stmt_cache(thd, cache_mngr);
}
if (cache_mngr->trx_cache.empty())
@@ -1701,7 +1807,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
we're here because cache_log was flushed in MYSQL_BIN_LOG::log_xid()
*/
cache_mngr->reset_cache(&cache_mngr->trx_cache);
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
/*
@@ -1710,17 +1816,15 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
- We are in a transaction and a full transaction is committed.
Otherwise, we accumulate the changes.
*/
- if (ending_trans(thd, all))
- {
- Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE, TRUE, 0);
- error= binlog_flush_trx_cache(thd, cache_mngr, &qev);
- }
+ if (!error && ending_trans(thd, all))
+ error= binlog_commit_flush_trx_cache(thd, cache_mngr);
/*
This is part of the stmt rollback.
*/
if (!all)
cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+
DBUG_RETURN(error);
}
@@ -1737,7 +1841,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
static int binlog_rollback(handlerton *hton, THD *thd, bool all)
{
DBUG_ENTER("binlog_rollback");
- int error=0;
+ int error= 0;
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
@@ -1757,16 +1861,16 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
}
else if (!cache_mngr->stmt_cache.empty())
{
- binlog_flush_stmt_cache(thd, cache_mngr);
+ error= binlog_commit_flush_stmt_cache(thd, cache_mngr);
}
if (cache_mngr->trx_cache.empty())
{
- /*
+ /*
we're here because cache_log was flushed in MYSQL_BIN_LOG::log_xid()
*/
cache_mngr->reset_cache(&cache_mngr->trx_cache);
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
if (mysql_bin_log.check_write_error(thd))
@@ -1782,9 +1886,9 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
We reach this point if the effect of a statement did not properly get into
a cache and need to be rolled back.
*/
- error= binlog_truncate_trx_cache(thd, cache_mngr, all);
+ error |= binlog_truncate_trx_cache(thd, cache_mngr, all);
}
- else
+ else if (!error)
{
/*
We flush the cache wrapped in a beging/rollback if:
@@ -1796,7 +1900,6 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
. the format is MIXED, non-trans table was updated and
aborting a single statement transaction;
*/
-
if (ending_trans(thd, all) &&
((thd->variables.option_bits & OPTION_KEEP_LOG) ||
(trans_has_updated_non_trans_table(thd) &&
@@ -1806,10 +1909,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
(trans_has_updated_non_trans_table(thd) &&
ending_single_stmt_trans(thd,all) &&
thd->variables.binlog_format == BINLOG_FORMAT_MIXED)))
- {
- Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE, TRUE, 0);
- error= binlog_flush_trx_cache(thd, cache_mngr, &qev);
- }
+ error= binlog_rollback_flush_trx_cache(thd, cache_mngr);
/*
Truncate the cache if:
. aborting a single or multi-statement transaction or;
@@ -1832,11 +1932,12 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
This is part of the stmt rollback.
*/
if (!all)
- cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+ cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+
DBUG_RETURN(error);
}
-void MYSQL_BIN_LOG::set_write_error(THD *thd)
+void MYSQL_BIN_LOG::set_write_error(THD *thd, bool is_transactional)
{
DBUG_ENTER("MYSQL_BIN_LOG::set_write_error");
@@ -1846,9 +1947,20 @@ void MYSQL_BIN_LOG::set_write_error(THD *thd)
DBUG_VOID_RETURN;
if (my_errno == EFBIG)
- my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(MY_WME));
+ {
+ if (is_transactional)
+ {
+ my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(MY_WME));
+ }
+ else
+ {
+ my_message(ER_STMT_CACHE_FULL, ER(ER_STMT_CACHE_FULL), MYF(MY_WME));
+ }
+ }
else
+ {
my_error(ER_ERROR_ON_WRITE, MYF(MY_WME), name, errno);
+ }
DBUG_VOID_RETURN;
}
@@ -1865,6 +1977,7 @@ bool MYSQL_BIN_LOG::check_write_error(THD *thd)
switch (thd->stmt_da->sql_errno())
{
case ER_TRANS_CACHE_FULL:
+ case ER_STMT_CACHE_FULL:
case ER_ERROR_ON_WRITE:
case ER_BINLOG_LOGGING_IMPOSSIBLE:
checked= TRUE;
@@ -2072,7 +2185,8 @@ static int find_uniq_filename(char *name)
*end='.';
length= (size_t) (end - start + 1);
- if (!(dir_info= my_dir(buff,MYF(MY_DONT_SORT))))
+ if ((DBUG_EVALUATE_IF("error_unique_log_filename", 1,
+ !(dir_info= my_dir(buff,MYF(MY_DONT_SORT))))))
{ // This shouldn't happen
strmov(end,".1"); // use name+1
DBUG_RETURN(1);
@@ -2099,7 +2213,11 @@ updating the index files.", max_found);
}
next= max_found + 1;
- sprintf(ext_buf, "%06lu", next);
+ if (sprintf(ext_buf, "%06lu", next)<0)
+ {
+ error= 1;
+ goto end;
+ }
*end++='.';
/*
@@ -2116,7 +2234,11 @@ index files.", name, ext_buf, (strlen(ext_buf) + (end - name)));
goto end;
}
- sprintf(end, "%06lu", next);
+ if (sprintf(end, "%06lu", next)<0)
+ {
+ error= 1;
+ goto end;
+ }
/* print warning if reaching the end of available extensions. */
if ((next > (MAX_LOG_UNIQUE_FN_EXT - LOG_WARN_UNIQUE_FN_EXT_LEFT)))
@@ -2349,13 +2471,8 @@ 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);
+ my_printf_error(ER_NO_UNIQUE_LOGFILE, ER(ER_NO_UNIQUE_LOGFILE),
+ MYF(ME_FATALERROR), log_name);
sql_print_error(ER(ER_NO_UNIQUE_LOGFILE), log_name);
return 1;
}
@@ -2859,6 +2976,23 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
sync_purge_index_file() ||
DBUG_EVALUATE_IF("fault_injection_registering_index", 1, 0))
{
+ /**
+ TODO: although this was introduced to appease valgrind
+ when injecting emulated faults using fault_injection_registering_index
+ it may be good to consider what actually happens when
+ open_purge_index_file succeeds but register or sync fails.
+
+ Perhaps we might need the code below in MYSQL_LOG_BIN::cleanup
+ for "real life" purposes as well?
+ */
+ DBUG_EXECUTE_IF("fault_injection_registering_index", {
+ if (my_b_inited(&purge_index_file))
+ {
+ end_io_cache(&purge_index_file);
+ my_close(purge_index_file.file, MYF(0));
+ }
+ });
+
sql_print_error("MSYQL_BIN_LOG::open failed to sync the index file.");
DBUG_RETURN(1);
}
@@ -2868,7 +3002,10 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
write_error= 0;
/* open the main log file */
- if (MYSQL_LOG::open(key_file_binlog,
+ if (MYSQL_LOG::open(
+#ifdef HAVE_PSI_INTERFACE
+ key_file_binlog,
+#endif
log_name, log_type_arg, new_name, io_cache_type_arg))
{
#ifdef HAVE_REPLICATION
@@ -3308,7 +3445,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
}
/* Start logging with a new file */
- close(LOG_CLOSE_INDEX);
+ close(LOG_CLOSE_INDEX | LOG_CLOSE_TO_BE_OPENED);
if ((error= my_delete_allow_opened(index_file_name, MYF(0)))) // Reset (open will update)
{
if (my_errno == ENOENT)
@@ -3337,7 +3474,8 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
if (!thd->slave_thread)
need_start_event=1;
if (!open_index_file(index_file_name, 0, FALSE))
- open(save_name, log_type, 0, io_cache_type, no_auto_events, max_size, 0, FALSE);
+ if ((error= open(save_name, log_type, 0, io_cache_type, no_auto_events, max_size, 0, FALSE)))
+ goto err;
my_free((void *) save_name);
err:
@@ -4002,17 +4140,23 @@ bool MYSQL_BIN_LOG::is_active(const char *log_file_name_arg)
incapsulation 3) allows external access to the class without
a lock (which is not possible with private new_file_without_locking
method).
+
+ @retval
+ nonzero - error
*/
-void MYSQL_BIN_LOG::new_file()
+int MYSQL_BIN_LOG::new_file()
{
- new_file_impl(1);
+ return new_file_impl(1);
}
-
-void MYSQL_BIN_LOG::new_file_without_locking()
+/*
+ @retval
+ nonzero - error
+ */
+int MYSQL_BIN_LOG::new_file_without_locking()
{
- new_file_impl(0);
+ return new_file_impl(0);
}
@@ -4021,19 +4165,23 @@ void MYSQL_BIN_LOG::new_file_without_locking()
@param need_lock Set to 1 if caller has not locked LOCK_log
+ @retval
+ nonzero - error
+
@note
The new file name is stored last in the index file
*/
-void MYSQL_BIN_LOG::new_file_impl(bool need_lock)
+int MYSQL_BIN_LOG::new_file_impl(bool need_lock)
{
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
+ int error= 0, close_on_error= FALSE;
+ char new_name[FN_REFLEN], *new_name_ptr, *old_name, *file_to_open;
DBUG_ENTER("MYSQL_BIN_LOG::new_file_impl");
if (!is_open())
{
DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
if (need_lock)
@@ -4071,7 +4219,7 @@ void MYSQL_BIN_LOG::new_file_impl(bool need_lock)
We have to do this here and not in open as we want to store the
new file name in the current binary log file.
*/
- if (generate_new_name(new_name, name))
+ if ((error= generate_new_name(new_name, name)))
goto end;
new_name_ptr=new_name;
@@ -4085,7 +4233,14 @@ void MYSQL_BIN_LOG::new_file_impl(bool need_lock)
*/
Rotate_log_event r(new_name+dirname_length(new_name),
0, LOG_EVENT_OFFSET, is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
- r.write(&log_file);
+ if(DBUG_EVALUATE_IF("fault_injection_new_file_rotate_event", (error=close_on_error=TRUE), FALSE) ||
+ (error= r.write(&log_file)))
+ {
+ DBUG_EXECUTE_IF("fault_injection_new_file_rotate_event", errno=2;);
+ close_on_error= TRUE;
+ my_printf_error(ER_ERROR_ON_WRITE, ER(ER_CANT_OPEN_FILE), MYF(ME_FATALERROR), name, errno);
+ goto end;
+ }
bytes_written += r.data_written;
}
/*
@@ -4113,17 +4268,56 @@ void MYSQL_BIN_LOG::new_file_impl(bool need_lock)
*/
/* reopen index binlog file, BUG#34582 */
- if (!open_index_file(index_file_name, 0, FALSE))
- open(old_name, log_type, new_name_ptr,
- io_cache_type, no_auto_events, max_size, 1, FALSE);
+ file_to_open= index_file_name;
+ error= open_index_file(index_file_name, 0, FALSE);
+ if (!error)
+ {
+ /* reopen the binary log file. */
+ file_to_open= new_name_ptr;
+ error= open(old_name, log_type, new_name_ptr, io_cache_type,
+ no_auto_events, max_size, 1, FALSE);
+ }
+
+ /* handle reopening errors */
+ if (error)
+ {
+ my_printf_error(ER_CANT_OPEN_FILE, ER(ER_CANT_OPEN_FILE),
+ MYF(ME_FATALERROR), file_to_open, error);
+ close_on_error= TRUE;
+ }
+
my_free(old_name);
end:
+
+ if (error && close_on_error /* rotate or reopen failed */)
+ {
+ /*
+ Close whatever was left opened.
+
+ We are keeping the behavior as it exists today, ie,
+ we disable logging and move on (see: BUG#51014).
+
+ TODO: as part of WL#1790 consider other approaches:
+ - kill mysql (safety);
+ - try multiple locations for opening a log file;
+ - switch server to protected/readonly mode
+ - ...
+ */
+ close(LOG_CLOSE_INDEX);
+ sql_print_error("Could not open %s for logging (error %d). "
+ "Turning logging off for the whole duration "
+ "of the MySQL server process. To turn it on "
+ "again: fix the cause, shutdown the MySQL "
+ "server and restart it.",
+ new_name_ptr, errno);
+ }
+
if (need_lock)
mysql_mutex_unlock(&LOCK_log);
mysql_mutex_unlock(&LOCK_index);
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
@@ -4148,8 +4342,7 @@ bool MYSQL_BIN_LOG::append(Log_event* ev)
if (flush_and_sync(0))
goto err;
if ((uint) my_b_append_tell(&log_file) > max_size)
- new_file_without_locking();
-
+ error= new_file_without_locking();
err:
mysql_mutex_unlock(&LOCK_log);
signal_update(); // Safe as we don't call close
@@ -4180,8 +4373,7 @@ bool MYSQL_BIN_LOG::appendv(const char* buf, uint len,...)
if (flush_and_sync(0))
goto err;
if ((uint) my_b_append_tell(&log_file) > max_size)
- new_file_without_locking();
-
+ error= new_file_without_locking();
err:
if (!error)
signal_update();
@@ -4370,7 +4562,7 @@ int THD::binlog_setup_trx_data()
cache_mngr= (binlog_cache_mngr*) my_malloc(sizeof(binlog_cache_mngr), MYF(MY_ZEROFILL));
if (!cache_mngr ||
open_cached_file(&cache_mngr->stmt_cache.cache_log, mysql_tmpdir,
- LOG_PREFIX, binlog_cache_size, MYF(MY_WME)) ||
+ LOG_PREFIX, binlog_stmt_cache_size, MYF(MY_WME)) ||
open_cached_file(&cache_mngr->trx_cache.cache_log, mysql_tmpdir,
LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
{
@@ -4379,8 +4571,13 @@ int THD::binlog_setup_trx_data()
}
thd_set_ha_data(this, binlog_hton, cache_mngr);
- cache_mngr= new (thd_get_ha_data(this, binlog_hton)) binlog_cache_mngr;
-
+ cache_mngr= new (thd_get_ha_data(this, binlog_hton))
+ binlog_cache_mngr(max_binlog_stmt_cache_size,
+ max_binlog_cache_size,
+ &binlog_stmt_cache_use,
+ &binlog_stmt_cache_disk_use,
+ &binlog_cache_use,
+ &binlog_cache_disk_use);
DBUG_RETURN(0);
}
@@ -4632,7 +4829,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
*/
if (pending->write(file))
{
- set_write_error(thd);
+ set_write_error(thd, is_transactional);
if (check_write_error(thd) && cache_data &&
stmt_has_updated_non_trans_table(thd))
cache_data->set_incident();
@@ -4657,6 +4854,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
bool error= 1;
DBUG_ENTER("MYSQL_BIN_LOG::write(Log_event *)");
binlog_cache_data *cache_data= 0;
+ bool is_trans_cache= FALSE;
if (thd->binlog_evt_union.do_union)
{
@@ -4717,7 +4915,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
- bool is_trans_cache= use_trans_cache(thd, event_info->use_trans_cache());
+ is_trans_cache= use_trans_cache(thd, event_info->use_trans_cache());
file= cache_mngr->get_binlog_cache_log(is_trans_cache);
cache_data= cache_mngr->get_binlog_cache_data(is_trans_cache);
@@ -4798,7 +4996,6 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
goto err;
error= 0;
-
err:
if (event_info->use_direct_logging())
{
@@ -4823,7 +5020,7 @@ unlock:
if (error)
{
- set_write_error(thd);
+ set_write_error(thd, is_trans_cache);
if (check_write_error(thd) && cache_data &&
stmt_has_updated_non_trans_table(thd))
cache_data->set_incident();
@@ -4903,8 +5100,19 @@ bool general_log_write(THD *thd, enum enum_server_command command,
return FALSE;
}
-void MYSQL_BIN_LOG::rotate_and_purge(uint flags)
+/**
+ @note
+ If rotation fails, for instance the server was unable
+ to create a new log file, we still try to write an
+ incident event to the current log.
+
+ @retval
+ nonzero - error
+*/
+int MYSQL_BIN_LOG::rotate_and_purge(uint flags)
{
+ int error= 0;
+ DBUG_ENTER("MYSQL_BIN_LOG::rotate_and_purge");
#ifdef HAVE_REPLICATION
bool check_purge= false;
#endif
@@ -4913,26 +5121,38 @@ void MYSQL_BIN_LOG::rotate_and_purge(uint flags)
if ((flags & RP_FORCE_ROTATE) ||
(my_b_tell(&log_file) >= (my_off_t) max_size))
{
- new_file_without_locking();
+ if ((error= new_file_without_locking()))
+ /**
+ Be conservative... There are possible lost events (eg,
+ failing to log the Execute_load_query_log_event
+ on a LOAD DATA while using a non-transactional
+ table)!
+
+ We give it a shot and try to write an incident event anyway
+ to the current log.
+ */
+ if (!write_incident(current_thd, FALSE))
+ flush_and_sync(0);
+
#ifdef HAVE_REPLICATION
check_purge= true;
#endif
}
if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
mysql_mutex_unlock(&LOCK_log);
-
#ifdef HAVE_REPLICATION
/*
NOTE: Run purge_logs wo/ holding LOCK_log
as it otherwise will deadlock in ndbcluster_binlog_index_purge_file
*/
- if (check_purge && expire_logs_days)
+ if (!error && check_purge && expire_logs_days)
{
time_t purge_time= my_time(0) - expire_logs_days*24*60*60;
if (purge_time >= 0)
purge_logs_before_date(purge_time);
}
#endif
+ DBUG_RETURN(error);
}
uint MYSQL_BIN_LOG::next_file_id()
@@ -5118,6 +5338,10 @@ bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock)
{
uint error= 0;
DBUG_ENTER("MYSQL_BIN_LOG::write_incident");
+
+ if (!is_open())
+ DBUG_RETURN(error);
+
LEX_STRING const write_error_msg=
{ C_STRING_WITH_LEN("error writing to the binary log") };
Incident incident= INCIDENT_LOST_EVENTS;
@@ -5130,7 +5354,7 @@ bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock)
if (!error && !(error= flush_and_sync(0)))
{
signal_update();
- rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
+ error= rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
}
mysql_mutex_unlock(&LOCK_log);
}
@@ -5239,7 +5463,8 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event,
mysql_mutex_unlock(&LOCK_prep_xids);
}
else
- rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
+ if (rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED))
+ goto err;
}
mysql_mutex_unlock(&LOCK_log);
@@ -6072,7 +6297,7 @@ int TC_LOG_MMAP::sync()
cookie points directly to the memory where xid was logged.
*/
-void TC_LOG_MMAP::unlog(ulong cookie, my_xid xid)
+int TC_LOG_MMAP::unlog(ulong cookie, my_xid xid)
{
PAGE *p=pages+(cookie/tc_log_page_size);
my_xid *x=(my_xid *)(data+cookie);
@@ -6090,6 +6315,7 @@ void TC_LOG_MMAP::unlog(ulong cookie, my_xid xid)
if (p->waiters == 0) // the page is in pool and ready to rock
mysql_cond_signal(&COND_pool); // ping ... for overflow()
mysql_mutex_unlock(&p->lock);
+ return 0;
}
void TC_LOG_MMAP::close()
@@ -6322,19 +6548,19 @@ void TC_LOG_BINLOG::close()
int TC_LOG_BINLOG::log_xid(THD *thd, my_xid xid)
{
DBUG_ENTER("TC_LOG_BINLOG::log");
- Xid_log_event xle(thd, xid);
binlog_cache_mngr *cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
/*
We always commit the entire transaction when writing an XID. Also
note that the return value is inverted.
*/
- DBUG_RETURN(!binlog_flush_stmt_cache(thd, cache_mngr) &&
- !binlog_flush_trx_cache(thd, cache_mngr, &xle));
+ DBUG_RETURN(!binlog_commit_flush_stmt_cache(thd, cache_mngr) &&
+ !binlog_commit_flush_trx_cache(thd, cache_mngr, xid));
}
-void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
+int TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
{
+ DBUG_ENTER("TC_LOG_BINLOG::unlog");
mysql_mutex_lock(&LOCK_prep_xids);
DBUG_ASSERT(prepared_xids > 0);
if (--prepared_xids == 0) {
@@ -6342,7 +6568,7 @@ void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
mysql_cond_signal(&COND_prep_xids);
}
mysql_mutex_unlock(&LOCK_prep_xids);
- rotate_and_purge(0); // as ::write() did not rotate
+ DBUG_RETURN(rotate_and_purge(0)); // as ::write() did not rotate
}
int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle)
diff --git a/sql/log.h b/sql/log.h
index d824d3afa26..05f8a4ce286 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -45,7 +45,7 @@ class TC_LOG
virtual int open(const char *opt_name)=0;
virtual void close()=0;
virtual int log_xid(THD *thd, my_xid xid)=0;
- virtual void unlog(ulong cookie, my_xid xid)=0;
+ virtual int unlog(ulong cookie, my_xid xid)=0;
};
class TC_LOG_DUMMY: public TC_LOG // use it to disable the logging
@@ -55,7 +55,7 @@ public:
int open(const char *opt_name) { return 0; }
void close() { }
int log_xid(THD *thd, my_xid xid) { return 1; }
- void unlog(ulong cookie, my_xid xid) { }
+ int unlog(ulong cookie, my_xid xid) { return 0; }
};
#ifdef HAVE_MMAP
@@ -100,7 +100,7 @@ class TC_LOG_MMAP: public TC_LOG
int open(const char *opt_name);
void close();
int log_xid(THD *thd, my_xid xid);
- void unlog(ulong cookie, my_xid xid);
+ int unlog(ulong cookie, my_xid xid);
int recover();
private:
@@ -334,8 +334,8 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
new_file() is locking. new_file_without_locking() does not acquire
LOCK_log.
*/
- void new_file_without_locking();
- void new_file_impl(bool need_lock);
+ int new_file_without_locking();
+ int new_file_impl(bool need_lock);
public:
MYSQL_LOG::generate_name;
@@ -365,7 +365,7 @@ public:
int open(const char *opt_name);
void close();
int log_xid(THD *thd, my_xid xid);
- void unlog(ulong cookie, my_xid xid);
+ int unlog(ulong cookie, my_xid xid);
int recover(IO_CACHE *log, Format_description_log_event *fdle);
#if !defined(MYSQL_CLIENT)
@@ -408,14 +408,14 @@ public:
bool open_index_file(const char *index_file_name_arg,
const char *log_name, bool need_mutex);
/* Use this to start writing a new log file */
- void new_file();
+ int new_file();
bool write(Log_event* event_info); // binary log write
bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
bool write_incident(THD *thd, bool lock);
int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync);
- void set_write_error(THD *thd);
+ void set_write_error(THD *thd, bool is_transactional);
bool check_write_error(THD *thd);
void start_union_events(THD *thd, query_id_t query_id_param);
@@ -432,7 +432,7 @@ public:
void make_log_name(char* buf, const char* log_ident);
bool is_active(const char* log_file_name);
int update_log_index(LOG_INFO* linfo, bool need_update_threads);
- void rotate_and_purge(uint flags);
+ int rotate_and_purge(uint flags);
/**
Flush binlog cache and synchronize to disk.
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 537865197da..b01b1766a9a 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3442,7 +3442,8 @@ compare_errors:
rli->report(ERROR_LEVEL, 0,
"\
Query caused different errors on master and slave. \
-Error on master: '%s' (%d), Error on slave: '%s' (%d). \
+Error on master: message (format)='%s' error code=%d ; \
+Error on slave: actual message='%s', error code=%d. \
Default database: '%s'. Query: '%s'",
ER_SAFE(expected_error),
expected_error,
diff --git a/sql/log_event.h b/sql/log_event.h
index 1841420ed86..a4d76e692a8 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2506,7 +2506,7 @@ class Xid_log_event: public Log_event
my_xid xid;
#ifdef MYSQL_SERVER
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
+ Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, TRUE), xid(x) {}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 09c17d600a8..d56b6715d6e 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -462,6 +462,8 @@ ulonglong slave_type_conversions_options;
ulong thread_cache_size=0;
ulong binlog_cache_size=0;
ulonglong max_binlog_cache_size=0;
+ulong binlog_stmt_cache_size=0;
+ulonglong max_binlog_stmt_cache_size=0;
ulong query_cache_size=0;
ulong refresh_version; /* Increments on each reload */
query_id_t global_query_id;
@@ -473,6 +475,7 @@ ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
ulong delayed_insert_errors,flush_time;
ulong specialflag=0;
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
+ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0;
ulong max_connections, max_connect_errors;
/**
Limit of the total number of prepared statements in the server.
@@ -1131,7 +1134,7 @@ static void close_connections(void)
tmp->thread_id,
(tmp->main_security_ctx.user ?
tmp->main_security_ctx.user : ""));
- close_connection(tmp,0,0);
+ close_connection(tmp);
}
#endif
DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
@@ -1957,38 +1960,28 @@ static void network_init(void)
/**
Close a connection.
- @param thd Thread handle
- @param errcode Error code to print to console
- @param lock 1 if we have have to lock LOCK_thread_count
+ @param thd Thread handle.
+ @param sql_errno The error code to send before disconnect.
@note
For the connection that is doing shutdown, this is called twice
*/
-void close_connection(THD *thd, uint errcode, bool lock)
+void close_connection(THD *thd, uint sql_errno)
{
- st_vio *vio;
DBUG_ENTER("close_connection");
- DBUG_PRINT("enter",("fd: %s error: '%s'",
- thd->net.vio ? vio_description(thd->net.vio) :
- "(not connected)",
- errcode ? ER_DEFAULT(errcode) : ""));
- if (lock)
- mysql_mutex_lock(&LOCK_thread_count);
- thd->killed= THD::KILL_CONNECTION;
- if ((vio= thd->net.vio) != 0)
- {
- if (errcode)
- net_send_error(thd, errcode,
- ER_DEFAULT(errcode), NULL); /* purecov: inspected */
- vio_close(vio); /* vio is freed in delete thd */
- }
- if (lock)
- mysql_mutex_unlock(&LOCK_thread_count);
- MYSQL_CONNECTION_DONE((int) errcode, thd->thread_id);
+
+ if (sql_errno)
+ net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL);
+
+ thd->disconnect();
+
+ MYSQL_CONNECTION_DONE((int) sql_errno, thd->thread_id);
+
if (MYSQL_CONNECTION_DONE_ENABLED())
{
sleep(0); /* Workaround to avoid tailcall optimisation */
}
+ MYSQL_AUDIT_NOTIFY_CONNECTION_DISCONNECT(thd, sql_errno);
DBUG_VOID_RETURN;
}
#endif /* EMBEDDED_LIBRARY */
@@ -2428,7 +2421,7 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n",
if (!(test_flags & TEST_NO_STACKTRACE))
{
- fprintf(stderr, "thd: 0x%lx\n",(long) thd);
+ fprintf(stderr, "Thread pointer: 0x%lx\n", (long) thd);
fprintf(stderr, "Attempting backtrace. You can use the following "
"information to find out\nwhere mysqld died. If "
"you see no messages after this, something went\n"
@@ -2456,11 +2449,13 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n",
kreason= "KILLED_NO_VALUE";
break;
}
- fprintf(stderr, "Trying to get some variables.\n\
-Some pointers may be invalid and cause the dump to abort...\n");
- my_safe_print_str("thd->query", thd->query(), 1024);
- fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id);
- fprintf(stderr, "thd->killed=%s\n", kreason);
+ fprintf(stderr, "\nTrying to get some variables.\n"
+ "Some pointers may be invalid and cause the dump to abort.\n");
+ fprintf(stderr, "Query (%p): ", thd->query());
+ my_safe_print_str(thd->query(), min(1024, thd->query_length()));
+ fprintf(stderr, "Connection ID (thread ID): %lu\n", (ulong) thd->thread_id);
+ fprintf(stderr, "Status: %s\n", kreason);
+ fputc('\n', stderr);
}
fprintf(stderr, "\
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains\n\
@@ -2741,7 +2736,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
case SIGHUP:
if (!abort_loop)
{
- bool not_used;
+ int not_used;
mysql_print_status(); // Print some debug info
reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
@@ -4945,8 +4940,8 @@ void create_thread_to_handle_connection(THD *thd)
my_snprintf(error_message_buff, sizeof(error_message_buff),
ER_THD(thd, ER_CANT_CREATE_THREAD), error);
net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff, NULL);
+ close_connection(thd);
mysql_mutex_lock(&LOCK_thread_count);
- close_connection(thd,0,0);
delete thd;
mysql_mutex_unlock(&LOCK_thread_count);
return;
@@ -4987,7 +4982,7 @@ static void create_new_thread(THD *thd)
mysql_mutex_unlock(&LOCK_connection_count);
DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
+ close_connection(thd, ER_CON_COUNT_ERROR);
delete thd;
DBUG_VOID_RETURN;
}
@@ -5368,7 +5363,7 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) ||
my_net_init(&thd->net, thd->net.vio))
{
- close_connection(thd, ER_OUT_OF_RESOURCES, 1);
+ close_connection(thd, ER_OUT_OF_RESOURCES);
delete thd;
continue;
}
@@ -5563,7 +5558,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
event_conn_closed)) ||
my_net_init(&thd->net, thd->net.vio))
{
- close_connection(thd, ER_OUT_OF_RESOURCES, 1);
+ close_connection(thd, ER_OUT_OF_RESOURCES);
errmsg= 0;
goto errorconn;
}
@@ -6406,6 +6401,8 @@ SHOW_VAR status_vars[]= {
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
{"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG},
{"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG},
+ {"Binlog_stmt_cache_disk_use",(char*) &binlog_stmt_cache_disk_use, SHOW_LONG},
+ {"Binlog_stmt_cache_use", (char*) &binlog_stmt_cache_use, SHOW_LONG},
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
{"Com", (char*) com_status_vars, SHOW_ARRAY},
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 7fe4dc7258a..9218503d477 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -64,7 +64,7 @@ typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
some places */
/* Function prototypes */
void kill_mysql(void);
-void close_connection(THD *thd, uint errcode, bool lock);
+void close_connection(THD *thd, uint sql_errno= 0);
void handle_connection_in_main_thread(THD *thd);
void create_thread_to_handle_connection(THD *thd);
void unlink_thd(THD *thd);
@@ -153,6 +153,7 @@ extern ulonglong keybuff_size;
extern ulonglong thd_startup_options;
extern ulong thread_id;
extern ulong binlog_cache_use, binlog_cache_disk_use;
+extern ulong binlog_stmt_cache_use, binlog_stmt_cache_disk_use;
extern ulong aborted_threads,aborted_connects;
extern ulong delayed_insert_timeout;
extern ulong delayed_insert_limit, delayed_queue_size;
@@ -172,8 +173,9 @@ extern uint slave_net_timeout;
extern uint max_user_connections;
extern ulong what_to_log,flush_time;
extern ulong max_prepared_stmt_count, prepared_stmt_count;
-extern ulong binlog_cache_size, open_files_limit;
-extern ulonglong max_binlog_cache_size;
+extern ulong open_files_limit;
+extern ulong binlog_cache_size, binlog_stmt_cache_size;
+extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size;
extern ulong max_binlog_size, max_relay_log_size;
extern ulong opt_binlog_rows_event_max_size;
extern ulong rpl_recovery_rank, thread_cache_size;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 2ac860d25e3..f39037e9db9 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -11391,7 +11391,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_min_result()
min_functions_it->rewind();
while ((min_func= (*min_functions_it)++))
- min_func->reset();
+ min_func->reset_and_add();
}
@@ -11423,7 +11423,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_max_result()
max_functions_it->rewind();
while ((max_func= (*max_functions_it)++))
- max_func->reset();
+ max_func->reset_and_add();
}
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index e020c94a3bd..a2f8b9c4447 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -424,7 +424,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
item_sum->aggregator_clear();
}
else
- item_sum->reset();
+ item_sum->reset_and_add();
item_sum->make_const();
recalc_const_item= 1;
break;
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
index 75ccb617e9e..52c8b9f0655 100644
--- a/sql/rpl_injector.cc
+++ b/sql/rpl_injector.cc
@@ -237,8 +237,7 @@ int injector::record_incident(THD *thd, Incident incident)
Incident_log_event ev(thd, incident);
if (int error= mysql_bin_log.write(&ev))
return error;
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
- return 0;
+ return mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
}
int injector::record_incident(THD *thd, Incident incident, LEX_STRING const message)
@@ -246,6 +245,5 @@ int injector::record_incident(THD *thd, Incident incident, LEX_STRING const mess
Incident_log_event ev(thd, incident, message);
if (int error= mysql_bin_log.write(&ev))
return error;
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
- return 0;
+ return mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
}
diff --git a/sql/share/charsets/cp1251.xml b/sql/share/charsets/cp1251.xml
index b80db9f8ec0..06ba8a5a4b9 100644
--- a/sql/share/charsets/cp1251.xml
+++ b/sql/share/charsets/cp1251.xml
@@ -98,7 +98,7 @@
0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
- 0402 0403 201A 0453 201E 2026 2020 2021 0000 2030 0409 2039 040A 040C 040B 040F
+ 0402 0403 201A 0453 201E 2026 2020 2021 20AC 2030 0409 2039 040A 040C 040B 040F
0452 2018 2019 201C 201D 2022 2013 2014 0000 2122 0459 203A 045A 045C 045B 045F
00A0 040E 045E 0408 00A4 0490 00A6 00A7 0401 00A9 0404 00AB 00AC 00AD 00AE 0407
00B0 00B1 0406 0456 0491 00B5 00B6 00B7 0451 2116 0454 00BB 0458 0405 0455 0457
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index be97afe055a..b0dc4d9195b 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -6392,3 +6392,5 @@ ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX
eng "The requested value for the heartbeat period exceeds the value of `slave_net_timeout' seconds. A sensible value for the period should be less than the timeout."
+ER_STMT_CACHE_FULL
+ eng "Multi-row statements required more than 'max_binlog_stmt_cache_size' bytes of storage; increase this mysqld variable and try again"
diff --git a/sql/slave.cc b/sql/slave.cc
index c4be7c7a6f7..e081d2406be 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -523,7 +523,8 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
if (flush_master_info(mi, TRUE, FALSE))
DBUG_RETURN(ER_ERROR_DURING_FLUSH_LOGS);
- if (my_sync(mi->rli.relay_log.get_log_file()->file, MYF(MY_WME)))
+ if (mi->rli.relay_log.is_open() &&
+ my_sync(mi->rli.relay_log.get_log_file()->file, MYF(MY_WME)))
DBUG_RETURN(ER_ERROR_DURING_FLUSH_LOGS);
if (my_sync(mi->fd, MYF(MY_WME)))
@@ -3632,8 +3633,7 @@ static int process_io_rotate(Master_info *mi, Rotate_log_event *rev)
Rotate the relay log makes binlog format detection easier (at next slave
start or mysqlbinlog)
*/
- rotate_relay_log(mi); /* will take the right mutexes */
- DBUG_RETURN(0);
+ DBUG_RETURN(rotate_relay_log(mi) /* will take the right mutexes */);
}
/*
@@ -4870,12 +4870,13 @@ err:
is void).
*/
-void rotate_relay_log(Master_info* mi)
+int rotate_relay_log(Master_info* mi)
{
DBUG_ENTER("rotate_relay_log");
Relay_log_info* rli= &mi->rli;
+ int error= 0;
- DBUG_EXECUTE_IF("crash_before_rotate_relaylog", abort(););
+ DBUG_EXECUTE_IF("crash_before_rotate_relaylog", DBUG_SUICIDE(););
/*
We need to test inited because otherwise, new_file() will attempt to lock
@@ -4888,7 +4889,8 @@ void rotate_relay_log(Master_info* mi)
}
/* If the relay log is closed, new_file() will do nothing. */
- rli->relay_log.new_file();
+ if ((error= rli->relay_log.new_file()))
+ goto end;
/*
We harvest now, because otherwise BIN_LOG_HEADER_SIZE will not immediately
@@ -4905,7 +4907,7 @@ void rotate_relay_log(Master_info* mi)
*/
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end:
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
diff --git a/sql/slave.h b/sql/slave.h
index 4073c90b612..73db3e4b61e 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -205,7 +205,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
const char** errmsg);
void set_slave_thread_options(THD* thd);
void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli);
-void rotate_relay_log(Master_info* mi);
+int rotate_relay_log(Master_info* mi);
int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli);
pthread_handler_t handle_slave_io(void *arg);
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 54e32b67c65..6959d21abd6 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3156,7 +3156,7 @@ sp_instr_stmt::exec_core(THD *thd, uint *nextp)
MYSQL_QUERY_EXEC_START(thd->query(),
thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *)thd->security_ctx->host_or_ip,
3);
int res= mysql_execute_command(thd);
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index b7d363dc09a..74e9e603ebe 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -81,9 +81,34 @@ static void general_class_handler(THD *thd, uint event_subtype, va_list ap)
}
+static void connection_class_handler(THD *thd, uint event_subclass, va_list ap)
+{
+ mysql_event_connection event;
+ event.event_class= MYSQL_AUDIT_CONNECTION_CLASS;
+ event.event_subclass= event_subclass;
+ event.status= va_arg(ap, int);
+ event.thread_id= va_arg(ap, unsigned long);
+ event.user= va_arg(ap, const char *);
+ event.user_length= va_arg(ap, unsigned int);
+ event.priv_user= va_arg(ap, const char *);
+ event.priv_user_length= va_arg(ap, unsigned int);
+ event.external_user= va_arg(ap, const char *);
+ event.external_user_length= va_arg(ap, unsigned int);
+ event.proxy_user= va_arg(ap, const char *);
+ event.proxy_user_length= va_arg(ap, unsigned int);
+ event.host= va_arg(ap, const char *);
+ event.host_length= va_arg(ap, unsigned int);
+ event.ip= va_arg(ap, const char *);
+ event.ip_length= va_arg(ap, unsigned int);
+ event.database= va_arg(ap, const char *);
+ event.database_length= va_arg(ap, unsigned int);
+ event_class_dispatch(thd, (const mysql_event *) &event);
+}
+
+
static audit_handler_t audit_handlers[] =
{
- general_class_handler
+ general_class_handler, connection_class_handler
};
static const uint audit_handlers_count=
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index cbc4c7a7232..d676c3974bc 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -32,8 +32,12 @@ extern void mysql_audit_free_thd(THD *thd);
extern void mysql_audit_acquire_plugins(THD *thd, uint event_class);
+#ifndef EMBEDDED_LIBRARY
extern void mysql_audit_notify(THD *thd, uint event_class,
uint event_subtype, ...);
+#else
+#define mysql_audit_notify(...)
+#endif
extern void mysql_audit_release(THD *thd);
#define MAX_USER_HOST_SIZE 512
@@ -84,6 +88,7 @@ void mysql_audit_general_log(THD *thd, time_t time,
event_subtype should be set to one of:
MYSQL_AUDIT_GENERAL_ERROR
MYSQL_AUDIT_GENERAL_RESULT
+ MYSQL_AUDIT_GENERAL_STATUS
@param[in] thd
@param[in] event_subtype Type of general audit event.
@@ -126,5 +131,41 @@ void mysql_audit_general(THD *thd, uint event_subtype,
#endif
}
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CONNECT,\
+ (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+ (thd)->thread_id, (thd)->security_ctx->user,\
+ (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
+ (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\
+ (thd)->security_ctx->external_user,\
+ (thd)->security_ctx->external_user ?\
+ strlen((thd)->security_ctx->external_user) : 0,\
+ (thd)->security_ctx->proxy_user, strlen((thd)->security_ctx->proxy_user),\
+ (thd)->security_ctx->host,\
+ (thd)->security_ctx->host ? strlen((thd)->security_ctx->host) : 0,\
+ (thd)->security_ctx->ip,\
+ (thd)->security_ctx->ip ? strlen((thd)->security_ctx->ip) : 0,\
+ (thd)->db, (thd)->db ? strlen((thd)->db) : 0)
+
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_DISCONNECT(thd, errcode)\
+ mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_DISCONNECT,\
+ (errcode), (thd)->thread_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER(thd) mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CHANGE_USER,\
+ (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+ (thd)->thread_id, (thd)->security_ctx->user,\
+ (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
+ (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\
+ (thd)->security_ctx->external_user,\
+ (thd)->security_ctx->external_user ?\
+ strlen((thd)->security_ctx->external_user) : 0,\
+ (thd)->security_ctx->proxy_user, strlen((thd)->security_ctx->proxy_user),\
+ (thd)->security_ctx->host,\
+ (thd)->security_ctx->host ? strlen((thd)->security_ctx->host) : 0,\
+ (thd)->security_ctx->ip,\
+ (thd)->security_ctx->ip ? strlen((thd)->security_ctx->ip) : 0,\
+ (thd)->db, (thd)->db ? strlen((thd)->db) : 0)
#endif /* SQL_AUDIT_INCLUDED */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 60c32a1a376..82302d9da30 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5408,11 +5408,19 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
if (lock_tables(thd, tables, counter, flags))
goto err;
- if (derived &&
- (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
- (thd->fill_derived_tables() &&
- mysql_handle_derived(thd->lex, &mysql_derived_filling))))
- goto err;
+ if (derived)
+ {
+ if (mysql_handle_derived(thd->lex, &mysql_derived_prepare))
+ goto err;
+ if (thd->fill_derived_tables() &&
+ mysql_handle_derived(thd->lex, &mysql_derived_filling))
+ {
+ mysql_handle_derived(thd->lex, &mysql_derived_cleanup);
+ goto err;
+ }
+ if (!thd->lex->describe)
+ mysql_handle_derived(thd->lex, &mysql_derived_cleanup);
+ }
DBUG_RETURN(FALSE);
err:
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 6f59c3f51e1..503d830a10e 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -61,6 +61,13 @@ void mysql_client_binlog_statement(THD* thd)
size_t decoded_len= base64_needed_decoded_length(coded_len);
/*
+ option_bits will be changed when applying the event. But we don't expect
+ it be changed permanently after BINLOG statement, so backup it first.
+ It will be restored at the end of this function.
+ */
+ ulonglong thd_options= thd->variables.option_bits;
+
+ /*
Allocation
*/
@@ -246,6 +253,7 @@ void mysql_client_binlog_statement(THD* thd)
my_ok(thd);
end:
+ thd->variables.option_bits= thd_options;
rli->slave_close_thread_tables(thd);
my_free(buf);
DBUG_VOID_RETURN;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2df7a2c8572..c4aa4ba7efb 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1283,6 +1283,40 @@ void THD::awake(THD::killed_state state_to_set)
DBUG_VOID_RETURN;
}
+
+/**
+ Close the Vio associated this session.
+
+ @remark LOCK_thd_data is taken due to the fact that
+ the Vio might be disassociated concurrently.
+*/
+
+void THD::disconnect()
+{
+ Vio *vio= NULL;
+
+ mysql_mutex_lock(&LOCK_thd_data);
+
+ killed= THD::KILL_CONNECTION;
+
+#ifdef SIGNAL_WITH_VIO_CLOSE
+ /*
+ Since a active vio might might have not been set yet, in
+ any case save a reference to avoid closing a inexistent
+ one or closing the vio twice if there is a active one.
+ */
+ vio= active_vio;
+ close_active_vio();
+#endif
+
+ /* Disconnect even if a active vio is not associated. */
+ if (net.vio != vio)
+ vio_close(net.vio);
+
+ mysql_mutex_unlock(&LOCK_thd_data);
+}
+
+
/*
Remember the location of thread info, the structure needed for
sql_alloc() and the structure for the net buffer
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 02f28b54e10..b8e7b685108 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2209,6 +2209,9 @@ public:
#endif
void awake(THD::killed_state state_to_set);
+ /** Disconnect the associated communication endpoint. */
+ void disconnect();
+
#ifndef MYSQL_CLIENT
enum enum_binlog_query_type {
/* The query can be logged in row format or in statement format. */
@@ -2503,8 +2506,6 @@ public:
(variables.sql_mode & MODE_STRICT_ALL_TABLES)));
}
void set_status_var_init();
- bool is_context_analysis_only()
- { return stmt_arena->is_stmt_prepare() || lex->view_prepare_mode; }
void reset_n_backup_open_tables_state(Open_tables_backup *backup);
void restore_backup_open_tables_state(Open_tables_backup *backup);
void reset_sub_statement_state(Sub_statement_state *backup, uint new_state);
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index d03d77c1f66..ad6fe492056 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -518,7 +518,7 @@ bool setup_connection_thread_globals(THD *thd)
{
if (thd->store_globals())
{
- close_connection(thd, ER_OUT_OF_RESOURCES, 1);
+ close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
return 1; // Error
@@ -693,7 +693,7 @@ void do_handle_one_connection(THD *thd_arg)
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
{
- close_connection(thd, ER_OUT_OF_RESOURCES, 1);
+ close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
return;
@@ -728,12 +728,15 @@ void do_handle_one_connection(THD *thd_arg)
for (;;)
{
NET *net= &thd->net;
+ bool rc;
lex_start(thd);
- if (login_connection(thd))
+ rc= login_connection(thd);
+ MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd);
+ if (rc)
goto end_thread;
- MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+ MYSQL_CONNECTION_START(thd->thread_id, &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip);
prepare_new_connection_state(thd);
@@ -748,7 +751,7 @@ void do_handle_one_connection(THD *thd_arg)
end_connection(thd);
end_thread:
- close_connection(thd, 0, 1);
+ close_connection(thd);
if (MYSQL_CALLBACK_ELSE(thread_scheduler, end_thread, (thd, 1), 0))
return; // Probably no-threads
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index acc591f1ea2..f607936d5b9 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -111,7 +111,7 @@ int mysql_open_cursor(THD *thd, select_result *result,
MYSQL_QUERY_EXEC_START(thd->query(),
thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip,
2);
rc= mysql_execute_command(thd);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 292fbba2352..38f39ec0be7 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -794,14 +794,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
}
}
- thd->push_internal_handler(&err_handler);
-
if (find_db_tables_and_rm_known_files(thd, dirp, db, path, &tables,
&found_other_files))
- {
- thd->pop_internal_handler();
goto exit;
- }
/*
Disable drop of enabled log tables, must be done before name locking.
@@ -815,7 +810,6 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
table->table_name_length, table->table_name, true))
{
my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP");
- thd->pop_internal_handler();
goto exit;
}
}
@@ -825,10 +819,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if (lock_table_names(thd, tables, NULL, thd->variables.lock_wait_timeout,
MYSQL_OPEN_SKIP_TEMPORARY) ||
lock_db_routines(thd, db))
- {
- thd->pop_internal_handler();
goto exit;
- }
/* mysql_ha_rm_tables() requires a non-null TABLE_LIST. */
if (tables)
@@ -841,6 +832,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
deleted_tables++;
}
+ thd->push_internal_handler(&err_handler);
if (thd->killed ||
(tables && mysql_rm_table_no_locks(thd, tables, true, false, true, true)))
{
@@ -1094,8 +1086,16 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
else
{
strxmov(filePath, path, "/", file->name, NullS);
- if (mysql_file_delete_with_symlink(key_file_misc, filePath, MYF(MY_WME)))
- DBUG_RETURN(true);
+ /*
+ We ignore ENOENT error in order to skip files that was deleted
+ by concurrently running statement like REAPIR TABLE ...
+ */
+ if (my_delete_with_symlink(filePath, MYF(0)) &&
+ my_errno != ENOENT)
+ {
+ my_error(EE_DELETE, MYF(0), filePath, my_errno);
+ DBUG_RETURN(true);
+ }
}
}
*tables= tot_list;
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 47bc13beb53..9b1b9353a23 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -151,10 +151,11 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
if (!(derived_result= new select_union))
DBUG_RETURN(TRUE); // out of memory
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
// st_select_lex_unit::prepare correctly work for single select
if ((res= unit->prepare(thd, derived_result, 0)))
goto exit;
-
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
if ((res= check_duplicate_names(unit->types, 0)))
goto exit;
@@ -306,13 +307,21 @@ bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
*/
if (derived_result->flush())
res= TRUE;
-
- if (!lex->describe)
- unit->cleanup();
}
- else
- unit->cleanup();
lex->current_select= save_current_select;
}
return res;
}
+
+
+/**
+ Cleans up the SELECT_LEX_UNIT for the derived table (if any).
+*/
+
+bool mysql_derived_cleanup(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ SELECT_LEX_UNIT *unit= derived->derived;
+ if (unit)
+ unit->cleanup();
+ return false;
+}
diff --git a/sql/sql_derived.h b/sql/sql_derived.h
index 0d4eddedf22..11a6fd4105e 100644
--- a/sql/sql_derived.h
+++ b/sql/sql_derived.h
@@ -26,4 +26,16 @@ bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
+/**
+ Cleans up the SELECT_LEX_UNIT for the derived table (if any).
+
+ @param thd Thread handler
+ @param lex LEX for this thread
+ @param derived TABLE_LIST for the derived table
+
+ @retval false Success
+ @retval true Failure
+*/
+bool mysql_derived_cleanup(THD *thd, LEX *lex, TABLE_LIST *derived);
+
#endif /* SQL_DERIVED_INCLUDED */
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index bd2aa70806a..0b463ff1202 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -420,8 +420,7 @@ void prepare_triggers_for_insert_stmt(TABLE *table)
static
void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
- enum_duplicates duplic,
- bool is_multi_insert)
+ enum_duplicates duplic)
{
if (duplic == DUP_UPDATE ||
(duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT))
@@ -470,10 +469,9 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
return;
}
- bool log_on= (thd->variables.option_bits & OPTION_BIN_LOG ||
- ! (thd->security_ctx->master_access & SUPER_ACL));
+ bool log_on= (thd->variables.option_bits & OPTION_BIN_LOG);
if (global_system_variables.binlog_format == BINLOG_FORMAT_STMT &&
- log_on && mysql_bin_log.is_open() && is_multi_insert)
+ log_on && mysql_bin_log.is_open())
{
/*
Statement-based binary logging does not work in this case, because:
@@ -677,8 +675,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
By default, both logs are enabled (this won't cause problems if the server
runs without --log-bin).
*/
- bool log_on= ((thd->variables.option_bits & OPTION_BIN_LOG) ||
- (!(thd->security_ctx->master_access & SUPER_ACL)));
+ bool log_on= (thd->variables.option_bits & OPTION_BIN_LOG);
#endif
thr_lock_type lock_type;
Item *unused_conds= 0;
@@ -688,8 +685,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
Upgrade lock type if the requested lock is incompatible with
the current connection mode or table operation.
*/
- upgrade_lock_type(thd, &table_list->lock_type, duplic,
- values_list.elements > 1);
+ upgrade_lock_type(thd, &table_list->lock_type, duplic);
/*
We can't write-delayed into a table locked with LOCK TABLES:
@@ -1022,7 +1018,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
if (was_insert_delayed && table_list->lock_type == TL_WRITE)
{
- /* Binlog multi INSERT DELAYED as INSERT without DELAYED. */
+ /* Binlog INSERT DELAYED as INSERT without DELAYED. */
String log_query;
if (create_insert_stmt_from_insert_delayed(thd, &log_query))
{
@@ -1906,22 +1902,6 @@ public:
thd.lex->current_select= 0; // for my_message_sql
thd.lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock()
/*
- Statement-based replication of INSERT DELAYED has problems with
- RAND() and user variables, so in mixed mode we go to row-based.
- For normal commands, the unsafe flag is set at parse time.
- However, since the flag is a member of the THD object, of which
- the delayed_insert thread has its own copy, we must set the
- statement to unsafe here and explicitly set row logging mode.
-
- @todo set_current_stmt_binlog_format_row_if_mixed should not be
- called by anything else than thd->decide_logging_format(). When
- we call set_current_blah here, none of the checks in
- decide_logging_format is made. We should probably call
- thd->decide_logging_format() directly instead. /Sven
- */
- thd.lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
- thd.set_current_stmt_binlog_format_row_if_mixed();
- /*
Prevent changes to global.lock_wait_timeout from affecting
delayed insert threads as any timeouts in delayed inserts
are not communicated to the client.
@@ -2650,11 +2630,11 @@ pthread_handler_t handle_delayed_insert(void *arg)
}
thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock()
+
/*
- Statement-based replication of INSERT DELAYED has problems with RAND()
- and user vars, so in mixed mode we go to row-based.
+ INSERT DELAYED has to go to row-based format because the time
+ at which rows are inserted cannot be determined in mixed mode.
*/
- thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
thd->set_current_stmt_binlog_format_row_if_mixed();
/*
@@ -2922,6 +2902,13 @@ bool Delayed_insert::handle_inserts(void)
if (log_query)
{
/*
+ Guaranteed that the INSERT DELAYED STMT will not be here
+ in SBR when mysql binlog is enabled.
+ */
+ DBUG_ASSERT(!(mysql_bin_log.is_open() &&
+ !thd.is_current_stmt_binlog_format_row()));
+
+ /*
This is the first value of an INSERT statement.
It is the right place to clear a forced insert_id.
This is usually done after the last value of an INSERT statement,
@@ -2988,39 +2975,6 @@ bool Delayed_insert::handle_inserts(void)
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
}
- if (log_query && mysql_bin_log.is_open())
- {
- bool backup_time_zone_used = thd.time_zone_used;
- Time_zone *backup_time_zone = thd.variables.time_zone;
- if (row->time_zone != NULL)
- {
- thd.time_zone_used = true;
- thd.variables.time_zone = row->time_zone;
- }
-
- /* if the delayed insert was killed, the killed status is
- ignored while binlogging */
- int errcode= 0;
- if (thd.killed == THD::NOT_KILLED)
- errcode= query_error_code(&thd, TRUE);
-
- /*
- If the query has several rows to insert, only the first row will come
- here. In row-based binlogging, this means that the first row will be
- written to binlog as one Table_map event and one Rows event (due to an
- event flush done in binlog_query()), then all other rows of this query
- will be binlogged together as one single Table_map event and one
- single Rows event.
- */
- if (thd.binlog_query(THD::ROW_QUERY_TYPE,
- row->query.str, row->query.length,
- FALSE, FALSE, FALSE, errcode))
- goto err;
-
- thd.time_zone_used = backup_time_zone_used;
- thd.variables.time_zone = backup_time_zone;
- }
-
if (table->s->blob_fields)
free_delayed_insert_blobs(table);
thread_safe_decrement(delayed_rows_in_use,&LOCK_delayed_status);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 7a8a86d3ca4..5e8ecc6b815 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -383,7 +383,7 @@ void lex_start(THD *thd)
lex->select_lex.group_list.empty();
lex->describe= 0;
lex->subqueries= FALSE;
- lex->view_prepare_mode= FALSE;
+ lex->context_analysis_only= 0;
lex->derived_tables= 0;
lex->safe_to_cache_query= 1;
lex->leaf_tables_insert= 0;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 191562bd3e8..2d11bc7aad7 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2286,19 +2286,12 @@ struct LEX: public Query_tables_list
uint8 derived_tables;
uint8 create_view_algorithm;
uint8 create_view_check;
+ uint8 context_analysis_only;
bool drop_if_exists, drop_temporary, local_file, one_shot_set;
bool autocommit;
bool verbose, no_write_to_binlog;
enum enum_yes_no_unknown tx_chain, tx_release;
- /*
- Special JOIN::prepare mode: changing of query is prohibited.
- When creating a view, we need to just check its syntax omitting
- any optimizations: afterwards definition of the view will be
- reconstructed by means of ::print() methods and written to
- to an .frm file. We need this definition to stay untouched.
- */
- bool view_prepare_mode;
bool safe_to_cache_query;
bool subqueries, ignore;
st_parsing_options parsing_options;
@@ -2403,6 +2396,13 @@ struct LEX: public Query_tables_list
delete_dynamic(&plugins);
}
+ inline bool is_ps_or_view_context_analysis()
+ {
+ return (context_analysis_only &
+ (CONTEXT_ANALYSIS_ONLY_PREPARE |
+ CONTEXT_ANALYSIS_ONLY_VIEW));
+ }
+
inline void uncacheable(uint8 cause)
{
safe_to_cache_query= 0;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index ca6e0d818e2..5ec6e4a0467 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -625,6 +625,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
transactional_table,
errcode);
}
+
+ /*
+ Flushing the IO CACHE while writing the execute load query log event
+ may result in error (for instance, because the max_binlog_size has been
+ reached, and rotation of the binary log failed).
+ */
+ error= error || mysql_bin_log.get_log_file()->error;
}
if (error)
goto err;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cb641b5ff68..188fd6bda53 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -600,7 +600,7 @@ void do_handle_bootstrap(THD *thd)
if (my_thread_init() || thd->store_globals())
{
#ifndef EMBEDDED_LIBRARY
- close_connection(thd, ER_OUT_OF_RESOURCES, 1);
+ close_connection(thd, ER_OUT_OF_RESOURCES);
#endif
thd->fatal_error();
goto end;
@@ -877,7 +877,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->profiling.start_new_query();
#endif
MYSQL_COMMAND_START(thd->thread_id, command,
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip);
thd->command=command;
@@ -937,6 +937,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
case COM_CHANGE_USER:
{
+ bool rc;
status_var_increment(thd->status_var.com_other);
thd->change_user();
@@ -956,7 +957,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
CHARSET_INFO *save_character_set_results=
thd->variables.character_set_results;
- if (acl_authenticate(thd, 0, packet_length))
+ rc= acl_authenticate(thd, 0, packet_length);
+ MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER(thd);
+ if (rc)
{
my_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx;
@@ -1015,7 +1018,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break; // fatal error is set
MYSQL_QUERY_START(thd->query(), thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip);
char *packet_end= thd->query() + thd->query_length();
/* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
@@ -1067,7 +1070,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
MYSQL_QUERY_START(beginning_of_next_stmt, thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip);
thd->set_query_and_id(beginning_of_next_stmt, length,
@@ -1215,7 +1218,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
case COM_REFRESH:
{
- bool not_used;
+ int not_used;
status_var_increment(thd->status_var.com_stat[SQLCOM_FLUSH]);
ulong options= (ulong) (uchar) packet[0];
if (trans_commit_implicit(thd))
@@ -1395,6 +1398,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (!thd->is_error() && !thd->killed_errno())
mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_RESULT, 0, 0);
+ mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_STATUS,
+ thd->stmt_da->is_error() ? thd->stmt_da->sql_errno() : 0,
+ command_name[command].str);
+
log_slow_statement(thd);
thd_proc_info(thd, "cleaning up");
@@ -2773,7 +2780,11 @@ end_with_restore_list:
{
Incident_log_event ev(thd, incident);
(void) mysql_bin_log.write(&ev); /* error is ignored */
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
+ if (mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE))
+ {
+ res= 1;
+ break;
+ }
}
DBUG_PRINT("debug", ("Just after generate_incident()"));
}
@@ -3509,8 +3520,7 @@ end_with_restore_list:
lex->no_write_to_binlog= 1;
case SQLCOM_FLUSH:
{
- bool write_to_binlog;
-
+ int write_to_binlog;
if (check_global_access(thd,RELOAD_ACL))
goto error;
@@ -3539,12 +3549,22 @@ end_with_restore_list:
/*
Presumably, RESET and binlog writing doesn't require synchronization
*/
- if (!lex->no_write_to_binlog && write_to_binlog)
+
+ if (write_to_binlog > 0) // we should write
+ {
+ if (!lex->no_write_to_binlog)
+ res= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
+ } else if (write_to_binlog < 0)
{
- if ((res= write_bin_log(thd, FALSE, thd->query(), thd->query_length())))
- break;
- }
- my_ok(thd);
+ /*
+ We should not write, but rather report error because
+ reload_acl_and_cache binlog interactions failed
+ */
+ res= 1;
+ }
+
+ if (!res)
+ my_ok(thd);
}
break;
@@ -5295,13 +5315,6 @@ mysql_new_select(LEX *lex, bool move_down)
DBUG_RETURN(1);
}
select_lex->nest_level= lex->nest_level;
- /*
- Don't evaluate this subquery during statement prepare even if
- it's a constant one. The flag is switched off in the end of
- mysqld_stmt_prepare.
- */
- if (thd->stmt_arena->is_stmt_prepare())
- select_lex->uncacheable|= UNCACHEABLE_PREPARE;
if (move_down)
{
SELECT_LEX_UNIT *unit;
@@ -5489,7 +5502,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
MYSQL_QUERY_EXEC_START(thd->query(),
thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip,
0);
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 8f6ab5803d7..cadfc587c1c 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -110,6 +110,7 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd)
ha_partition *partition;
ulong timeout= thd->variables.lock_wait_timeout;
TABLE_LIST *first_table= thd->lex->select_lex.table_list.first;
+ bool binlog_stmt;
DBUG_ENTER("Alter_table_truncate_partition_statement::execute");
/*
@@ -161,16 +162,18 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd)
partition= (ha_partition *) first_table->table->file;
/* Invoke the handler method responsible for truncating the partition. */
- if ((error= partition->truncate_partition(&thd->lex->alter_info)))
+ if ((error= partition->truncate_partition(&thd->lex->alter_info,
+ &binlog_stmt)))
first_table->table->file->print_error(error, MYF(0));
/*
All effects of a truncate operation are committed even if the
operation fails. Thus, the query must be written to the binary
- log. The only exception is a unimplemented truncate method. Also,
- it is logged in statement format, regardless of the binlog format.
+ log. The exception is a unimplemented truncate method or failure
+ before any call to handler::truncate() is done.
+ Also, it is logged in statement format, regardless of the binlog format.
*/
- if (error != HA_ERR_WRONG_COMMAND)
+ if (error != HA_ERR_WRONG_COMMAND && binlog_stmt)
error|= write_bin_log(thd, !error, thd->query(), thd->query_length());
/*
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 0fe89cd3748..dc5b7b5a37b 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -280,6 +280,26 @@ static void report_error(int where_to, uint error, ...)
}
}
+/**
+ Check if the provided path is valid in the sense that it does cause
+ a relative reference outside the directory.
+
+ @note Currently, this function only check if there are any
+ characters in FN_DIRSEP in the string, but it might change in the
+ future.
+
+ @code
+ check_valid_path("../foo.so") -> true
+ check_valid_path("foo.so") -> false
+ @endcode
+ */
+bool check_valid_path(const char *path, size_t len)
+{
+ size_t prefix= my_strcspn(files_charset_info, path, path + len, FN_DIRSEP);
+ return prefix < len;
+}
+
+
/****************************************************************************
Value type thunks, allows the C world to play in the C++ world
****************************************************************************/
@@ -408,13 +428,15 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
struct st_plugin_dl *tmp, plugin_dl;
void *sym;
DBUG_ENTER("plugin_dl_add");
+ DBUG_PRINT("enter", ("dl->str: '%s', dl->length: %d",
+ dl->str, (int) dl->length));
plugin_dir_len= strlen(opt_plugin_dir);
/*
Ensure that the dll doesn't have a path.
This is done to ensure that only approved libraries from the
plugin directory are used (to make this even remotely secure).
*/
- if (my_strchr(files_charset_info, dl->str, dl->str + dl->length, FN_LIBCHAR) ||
+ if (check_valid_path(dl->str, dl->length) ||
check_string_char_length((LEX_STRING *) dl, "", NAME_CHAR_LEN,
system_charset_info, 1) ||
plugin_dir_len + dl->length + 1 >= FN_REFLEN)
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 5fa9afb3066..0cbd5a519c1 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -153,6 +153,7 @@ extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
extern void plugin_thdvar_init(THD *thd);
extern void plugin_thdvar_cleanup(THD *thd);
extern SHOW_COMP_OPTION plugin_status(const char *name, int len, size_t type);
+extern bool check_valid_path(const char *path, size_t length);
typedef my_bool (plugin_foreach_func)(THD *thd,
plugin_ref plugin,
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 4a1d1ae7fe3..f319c0fdd8b 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1780,7 +1780,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL))
goto err;
- lex->view_prepare_mode= 1;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
res= select_like_stmt_test(stmt, 0, 0);
err:
@@ -2292,19 +2292,6 @@ end:
}
-/** Init PS/SP specific parse tree members. */
-
-static void init_stmt_after_parse(LEX *lex)
-{
- SELECT_LEX *sl= lex->all_selects_list;
- /*
- Switch off a temporary flag that prevents evaluation of
- subqueries in statement prepare.
- */
- for (; sl; sl= sl->next_select_in_list())
- sl->uncacheable&= ~UNCACHEABLE_PREPARE;
-}
-
/**
SQLCOM_PREPARE implementation.
@@ -3223,6 +3210,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
parser_state.m_lip.multi_statements= FALSE;
lex_start(thd);
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_PREPARE;
error= parse_sql(thd, & parser_state, NULL) ||
thd->is_error() ||
@@ -3283,7 +3271,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
if (error == 0)
{
setup_set_params();
- init_stmt_after_parse(lex);
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_PREPARE;
state= Query_arena::PREPARED;
flags&= ~ (uint) IS_IN_USE;
@@ -3771,7 +3759,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
MYSQL_QUERY_EXEC_START(thd->query(),
thd->thread_id,
(char *) (thd->db ? thd->db : ""),
- thd->security_ctx->priv_user,
+ &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip,
1);
error= mysql_execute_command(thd);
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index f0f6a1969f5..434dfb1e306 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -144,6 +144,12 @@
*/
#define OPTION_MASTER_SQL_ERROR (1ULL << 35)
+/*
+ Dont report errors for individual rows,
+ But just report error on commit (or read ofcourse)
+ Note! Reserved for use in MySQL Cluster
+*/
+#define OPTION_ALLOW_BATCH (ULL(1) << 36) // THD, intern (slave)
/* The rest of the file is included in the server only */
#ifndef MYSQL_CLIENT
@@ -176,17 +182,42 @@
*/
+/*
+ Flags below are set when we perform
+ context analysis of the statement and make
+ subqueries non-const. It prevents subquery
+ evaluation at context analysis stage.
+*/
+
+/*
+ Don't evaluate this subquery during statement prepare even if
+ it's a constant one. The flag is switched off in the end of
+ mysqld_stmt_prepare.
+*/
+#define CONTEXT_ANALYSIS_ONLY_PREPARE 1
+/*
+ Special JOIN::prepare mode: changing of query is prohibited.
+ When creating a view, we need to just check its syntax omitting
+ any optimizations: afterwards definition of the view will be
+ reconstructed by means of ::print() methods and written to
+ to an .frm file. We need this definition to stay untouched.
+*/
+#define CONTEXT_ANALYSIS_ONLY_VIEW 2
+/*
+ Don't evaluate this subquery during derived table prepare even if
+ it's a constant one.
+*/
+#define CONTEXT_ANALYSIS_ONLY_DERIVED 4
+
// uncachable cause
#define UNCACHEABLE_DEPENDENT 1
#define UNCACHEABLE_RAND 2
#define UNCACHEABLE_SIDEEFFECT 4
/// forcing to save JOIN for explain
#define UNCACHEABLE_EXPLAIN 8
-/** Don't evaluate subqueries in prepare even if they're not correlated */
-#define UNCACHEABLE_PREPARE 16
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
-#define UNCACHEABLE_UNITED 32
-#define UNCACHEABLE_CHECKOPTION 64
+#define UNCACHEABLE_UNITED 16
+#define UNCACHEABLE_CHECKOPTION 32
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
#define UNDEF_POS (-1)
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 35f27408247..0810459cb49 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -33,7 +33,11 @@
@param thd Thread handler (can be NULL!)
@param options What should be reset/reloaded (tables, privileges, slave...)
@param tables Tables to flush (if any)
- @param write_to_binlog True if we can write to the binlog.
+ @param write_to_binlog < 0 if there was an error while interacting with the binary log inside
+ reload_acl_and_cache,
+ 0 if we should not write to the binary log,
+ > 0 if we can write to the binlog.
+
@note Depending on 'options', it may be very bad to write the
query to the binlog (e.g. FLUSH SLAVE); this is a
@@ -47,11 +51,11 @@
*/
bool reload_acl_and_cache(THD *thd, unsigned long options,
- TABLE_LIST *tables, bool *write_to_binlog)
+ TABLE_LIST *tables, int *write_to_binlog)
{
bool result=0;
select_errors=0; /* Write if more errors */
- bool tmp_write_to_binlog= 1;
+ int tmp_write_to_binlog= *write_to_binlog= 1;
DBUG_ASSERT(!thd || !thd->in_sub_stmt);
@@ -136,13 +140,17 @@ bool reload_acl_and_cache(THD *thd, unsigned long options,
*/
tmp_write_to_binlog= 0;
if (mysql_bin_log.is_open())
- mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
+ {
+ if (mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE))
+ *write_to_binlog= -1;
+ }
}
if (options & REFRESH_RELAY_LOG)
{
#ifdef HAVE_REPLICATION
mysql_mutex_lock(&LOCK_active_mi);
- rotate_relay_log(active_mi);
+ if (rotate_relay_log(active_mi))
+ *write_to_binlog= -1;
mysql_mutex_unlock(&LOCK_active_mi);
#endif
}
@@ -274,7 +282,8 @@ bool reload_acl_and_cache(THD *thd, unsigned long options,
#endif
if (options & REFRESH_USER_RESOURCES)
reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */
- *write_to_binlog= tmp_write_to_binlog;
+ if (*write_to_binlog != -1)
+ *write_to_binlog= tmp_write_to_binlog;
/*
If the query was killed then this function must fail.
*/
diff --git a/sql/sql_reload.h b/sql/sql_reload.h
index 0df5485c907..ebb3d78c003 100644
--- a/sql/sql_reload.h
+++ b/sql/sql_reload.h
@@ -19,7 +19,7 @@ class THD;
struct TABLE_LIST;
bool reload_acl_and_cache(THD *thd, unsigned long options,
- TABLE_LIST *tables, bool *write_to_binlog);
+ TABLE_LIST *tables, int *write_to_binlog);
bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7bca41f1265..4e8b70c58f6 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1925,7 +1925,7 @@ bool show_binlogs(THD* thd)
if (!mysql_bin_log.is_open())
{
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
+ my_error(ER_NO_BINARY_LOGGING, MYF(0));
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ef2dd1d76e1..6e42b65175a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -567,7 +567,8 @@ JOIN::prepare(Item ***rref_pointer_array,
thd->lex->allow_sum_func= save_allow_sum_func;
}
- if (!thd->lex->view_prepare_mode && !(select_options & SELECT_DESCRIBE))
+ if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
+ !(select_options & SELECT_DESCRIBE))
{
Item_subselect *subselect;
/* Is it subselect? */
@@ -6498,10 +6499,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
{
/* Use quick key read if it's a constant and it's not used
with key reading */
- if (tab->needed_reg.is_clear_all() && tab->type != JT_EQ_REF
- && tab->type != JT_FT && (tab->type != JT_REF ||
- (uint) tab->ref.key == tab->quick->index))
- {
+ if (tab->needed_reg.is_clear_all() && tab->type != JT_EQ_REF &&
+ tab->type != JT_FT &&
+ ((tab->type != JT_CONST && tab->type != JT_REF) ||
+ (uint)tab->ref.key == tab->quick->index))
+ {
sel->quick=tab->quick; // Use value from get_quick_...
sel->quick_keys.clear_all();
sel->needed_reg.clear_all();
@@ -13856,7 +13858,7 @@ check_reverse_order:
SYNOPSIS
create_sort_index()
thd Thread handler
- tab Table to sort (in join structure)
+ join Join with table to sort
order How table should be sorted
filesort_limit Max number of rows that needs to be sorted
select_limit Max number of rows in final output
@@ -13866,8 +13868,8 @@ check_reverse_order:
IMPLEMENTATION
- - If there is an index that can be used, 'tab' is modified to use
- this index.
+ - If there is an index that can be used, the first non-const join_tab in
+ 'join' is modified to use this index.
- If no index, create with filesort() an index file that can be used to
retrieve rows in order (should be done with 'read_record').
The sorted data is stored in tab->table and will be freed when calling
@@ -15850,7 +15852,7 @@ init_sum_functions(Item_sum **func_ptr, Item_sum **end_ptr)
{
for (; func_ptr != end_ptr ;func_ptr++)
{
- if ((*func_ptr)->reset())
+ if ((*func_ptr)->reset_and_add())
return 1;
}
/* If rollup, calculate the upper sum levels */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 74924f74fec..0421cc35c5d 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -676,7 +676,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
/* We want to preserve the tree for views. */
- thd->lex->view_prepare_mode= TRUE;
+ thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
{
/*
@@ -3444,7 +3444,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
uint derived_tables= lex->derived_tables;
int error= 1;
Open_tables_backup open_tables_state_backup;
- bool save_view_prepare_mode= lex->view_prepare_mode;
+ uint8 save_context_analysis_only= lex->context_analysis_only;
Query_tables_list query_tables_list_backup;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context *sctx= thd->security_ctx;
@@ -3464,7 +3464,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
*/
can_deadlock= thd->mdl_context.has_locks();
- lex->view_prepare_mode= TRUE;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
/*
Restore Query_tables_list::sql_command value, which was reset
@@ -3694,7 +3694,7 @@ err:
lex->restore_backup_query_tables_list(&query_tables_list_backup);
lex->derived_tables= derived_tables;
lex->all_selects_list= old_all_select_lex;
- lex->view_prepare_mode= save_view_prepare_mode;
+ lex->context_analysis_only= save_context_analysis_only;
DBUG_RETURN(error);
}
@@ -3790,6 +3790,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
{
const char *tmp_buff;
MYSQL_TIME time;
+ int info_error= 0;
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_tables_record");
@@ -3797,22 +3798,21 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
table->field[0]->store(STRING_WITH_LEN("def"), cs);
table->field[1]->store(db_name->str, db_name->length, cs);
table->field[2]->store(table_name->str, table_name->length, cs);
+
if (res)
{
- /*
- there was errors during opening tables
- */
- const char *error= thd->is_error() ? thd->stmt_da->message() : "";
+ /* There was a table open error, so set the table type and return */
if (tables->view)
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
else if (tables->schema_table)
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
else
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
- table->field[20]->store(error, strlen(error), cs);
- thd->clear_error();
+
+ goto err;
}
- else if (tables->view)
+
+ if (tables->view)
{
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
table->field[20]->store(STRING_WITH_LEN("VIEW"), cs);
@@ -3827,6 +3827,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
#ifdef WITH_PARTITION_STORAGE_ENGINE
bool is_partitioned= FALSE;
#endif
+
if (share->tmp_table == SYSTEM_TMP_TABLE)
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
else if (share->tmp_table)
@@ -3840,6 +3841,9 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
continue;
table->field[i]->set_notnull();
}
+
+ /* Collect table info from the table share */
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (share->db_type() == partition_hton &&
share->partition_info_str_len)
@@ -3848,62 +3852,82 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
is_partitioned= TRUE;
}
#endif
+
tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
table->field[5]->store((longlong) share->frm_version, TRUE);
ptr=option_buff;
+
if (share->min_rows)
{
ptr=strmov(ptr," min_rows=");
ptr=longlong10_to_str(share->min_rows,ptr,10);
}
+
if (share->max_rows)
{
ptr=strmov(ptr," max_rows=");
ptr=longlong10_to_str(share->max_rows,ptr,10);
}
+
if (share->avg_row_length)
{
ptr=strmov(ptr," avg_row_length=");
ptr=longlong10_to_str(share->avg_row_length,ptr,10);
}
+
if (share->db_create_options & HA_OPTION_PACK_KEYS)
ptr=strmov(ptr," pack_keys=1");
+
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
ptr=strmov(ptr," pack_keys=0");
+
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
if (share->db_create_options & HA_OPTION_CHECKSUM)
ptr=strmov(ptr," checksum=1");
+
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
ptr=strmov(ptr," delay_key_write=1");
+
if (share->row_type != ROW_TYPE_DEFAULT)
ptr=strxmov(ptr, " row_format=",
ha_row_type[(uint) share->row_type],
NullS);
+
if (share->key_block_size)
{
ptr= strmov(ptr, " KEY_BLOCK_SIZE=");
ptr= longlong10_to_str(share->key_block_size, ptr, 10);
}
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (is_partitioned)
ptr= strmov(ptr, " partitioned");
#endif
+
table->field[19]->store(option_buff+1,
(ptr == option_buff ? 0 :
(uint) (ptr-option_buff)-1), cs);
tmp_buff= (share->table_charset ?
share->table_charset->name : "default");
+
table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
if (share->comment.str)
table->field[20]->store(share->comment.str, share->comment.length, cs);
+ /* Collect table info from the storage engine */
+
if(file)
{
- file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
+ /* If info() fails, then there's nothing else to do */
+ if ((info_error= file->info(HA_STATUS_VARIABLE |
+ HA_STATUS_TIME |
+ HA_STATUS_AUTO)) != 0)
+ goto err;
+
enum row_type row_type = file->get_row_type();
switch (row_type) {
case ROW_TYPE_NOT_USED:
@@ -3932,7 +3956,9 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
tmp_buff= "Paged";
break;
}
+
table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
+
if (!tables->schema_table)
{
table->field[7]->store((longlong) file->stats.records, TRUE);
@@ -3981,6 +4007,26 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
}
}
}
+
+err:
+ if (res || info_error)
+ {
+ /*
+ If an error was encountered, push a warning, set the TABLE COMMENT
+ column with the error text, and clear the error so that the operation
+ can continue.
+ */
+ const char *error= thd->is_error() ? thd->stmt_da->message() : "";
+ table->field[20]->store(error, strlen(error), cs);
+
+ if (thd->is_error())
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->stmt_da->sql_errno(), thd->stmt_da->message());
+ thd->clear_error();
+ }
+ }
+
DBUG_RETURN(schema_table_store_record(thd, table));
}
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index ba1d0ceadeb..94e2fe43f03 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -199,10 +199,7 @@ void udf_init()
On windows we must check both FN_LIBCHAR and '/'.
*/
- if (my_strchr(files_charset_info, dl_name,
- dl_name + strlen(dl_name), FN_LIBCHAR) ||
- IF_WIN(my_strchr(files_charset_info, dl_name,
- dl_name + strlen(dl_name), '/'), 0) ||
+ if (check_valid_path(dl_name, strlen(dl_name)) ||
check_string_char_length(&name, "", NAME_CHAR_LEN,
system_charset_info, 1))
{
@@ -442,13 +439,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
Ensure that the .dll doesn't have a path
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
-
- On windows we must check both FN_LIBCHAR and '/'.
*/
- if (my_strchr(files_charset_info, udf->dl,
- udf->dl + strlen(udf->dl), FN_LIBCHAR) ||
- IF_WIN(my_strchr(files_charset_info, udf->dl,
- udf->dl + strlen(udf->dl), '/'), 0))
+ if (check_valid_path(udf->dl, strlen(udf->dl)))
{
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
DBUG_RETURN(1);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index b49ed2beafe..082c603bb5a 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -296,11 +296,17 @@ int mysql_update(THD *thd,
if (lock_tables(thd, table_list, table_count, 0))
DBUG_RETURN(1);
- if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
- (thd->fill_derived_tables() &&
- mysql_handle_derived(thd->lex, &mysql_derived_filling)))
+ if (mysql_handle_derived(thd->lex, &mysql_derived_prepare))
DBUG_RETURN(1);
+ if (thd->fill_derived_tables() &&
+ mysql_handle_derived(thd->lex, &mysql_derived_filling))
+ {
+ mysql_handle_derived(thd->lex, &mysql_derived_cleanup);
+ DBUG_RETURN(1);
+ }
+ mysql_handle_derived(thd->lex, &mysql_derived_cleanup);
+
thd_proc_info(thd, "init");
table= table_list->table;
@@ -1194,7 +1200,11 @@ int mysql_multi_update_prepare(THD *thd)
if (thd->fill_derived_tables() &&
mysql_handle_derived(lex, &mysql_derived_filling))
+ {
+ mysql_handle_derived(lex, &mysql_derived_cleanup);
DBUG_RETURN(TRUE);
+ }
+ mysql_handle_derived(lex, &mysql_derived_cleanup);
DBUG_RETURN (FALSE);
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 54b5eb43ab1..f569c679776 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -550,7 +550,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
}
/* prepare select to resolve all fields */
- lex->view_prepare_mode= 1;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
if (unit->prepare(thd, 0, 0))
{
/*
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 9ca97b5dded..68bb77d467f 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -236,14 +236,23 @@ static Sys_var_charptr Sys_basedir(
IN_FS_CHARSET, DEFAULT(0));
static Sys_var_ulong Sys_binlog_cache_size(
- "binlog_cache_size", "The size of the cache to "
- "hold the SQL statements for the binary log during a "
- "transaction. If you often use big, multi-statement "
- "transactions you can increase this to get more performance",
+ "binlog_cache_size", "The size of the transactional cache for "
+ "updates to transactional engines for the binary log. "
+ "If you often use transactions containing many statements, "
+ "you can increase this to get more performance",
GLOBAL_VAR(binlog_cache_size),
CMD_LINE(REQUIRED_ARG),
VALID_RANGE(IO_SIZE, ULONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE));
+static Sys_var_ulong Sys_binlog_stmt_cache_size(
+ "binlog_stmt_cache_size", "The size of the statement cache for "
+ "updates to non-transactional engines for the binary log. "
+ "If you often use statements updating a great number of rows, "
+ "you can increase this to get more performance",
+ GLOBAL_VAR(binlog_stmt_cache_size),
+ CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(IO_SIZE, ULONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE));
+
static bool check_has_super(sys_var *self, THD *thd, set_var *var)
{
DBUG_ASSERT(self->scope() != sys_var::GLOBAL);// don't abuse check_has_super()
@@ -1031,13 +1040,20 @@ static Sys_var_ulong Sys_max_allowed_packet(
static Sys_var_ulonglong Sys_max_binlog_cache_size(
"max_binlog_cache_size",
- "Can be used to restrict the total size used to cache a "
- "multi-transaction query",
+ "Sets the total size of the transactional cache",
GLOBAL_VAR(max_binlog_cache_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(IO_SIZE, ULONGLONG_MAX),
DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE),
BLOCK_SIZE(IO_SIZE));
+static Sys_var_ulonglong Sys_max_binlog_stmt_cache_size(
+ "max_binlog_stmt_cache_size",
+ "Sets the total size of the statement cache",
+ GLOBAL_VAR(max_binlog_stmt_cache_size), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(IO_SIZE, ULONGLONG_MAX),
+ DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE),
+ BLOCK_SIZE(IO_SIZE));
+
static bool fix_max_binlog_size(sys_var *self, THD *thd, enum_var_type type)
{
mysql_bin_log.set_max_size(max_binlog_size);
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index c24fbc21f94..fe167318743 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -20,6 +20,7 @@
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h" // SSV
+#include "sql_table.h"
#include <myisam.h>
#include "ha_archive.h"
@@ -256,7 +257,7 @@ int archive_discover(handlerton *hton, THD* thd, const char *db,
char *frm_ptr;
MY_STAT file_stat;
- fn_format(az_file, name, db, ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
+ build_table_filename(az_file, sizeof(az_file) - 1, db, name, ARZ, 0);
if (!(my_stat(az_file, &file_stat, MYF(0))))
goto err;
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 9b2c348a349..709750fc4e7 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -1939,13 +1939,15 @@ err_exit:
err = trx->error_state;
- switch (err) {
- case DB_SUCCESS:
- break;
- case DB_OUT_OF_FILE_SPACE:
+ if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, NULL);
+ /* TO DO: free table? The code below will dereference
+ table->name, though. */
+ }
+ switch (err) {
+ case DB_OUT_OF_FILE_SPACE:
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: cannot create table ",
stderr);
@@ -1960,13 +1962,9 @@ err_exit:
break;
case DB_DUPLICATE_KEY:
- default:
/* We may also get err == DB_ERROR if the .ibd file for the
table already exists */
- trx->error_state = DB_SUCCESS;
- trx_general_rollback_for_mysql(trx, NULL);
- dict_mem_table_free(table);
break;
}
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 6bf01cd63c7..79a8105f823 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -1748,6 +1748,8 @@ err:
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1))
got_error=1;
+
+ param->retry_repair= 0;
}
}
if (got_error)
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index 896117397a2..8e3486a4fa3 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -228,7 +228,6 @@ int ha_perfschema::write_row(uchar *buf)
result= m_table_share->m_write_row(table, buf, table->field);
else
{
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
result= HA_ERR_WRONG_COMMAND;
}
@@ -339,7 +338,6 @@ int ha_perfschema::delete_all_rows(void)
result= m_table_share->m_delete_all_rows();
else
{
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
result= HA_ERR_WRONG_COMMAND;
}
DBUG_RETURN(result);
@@ -370,7 +368,6 @@ int ha_perfschema::delete_table(const char *name)
int ha_perfschema::rename_table(const char * from, const char * to)
{
DBUG_ENTER("ha_perfschema::rename_table ");
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
@@ -395,7 +392,37 @@ int ha_perfschema::create(const char *name, TABLE *table_arg,
This is not a general purpose engine.
Failure to CREATE TABLE is the expected result.
*/
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
+void ha_perfschema::print_error(int error, myf errflag)
+{
+ switch (error)
+ {
+ case HA_ERR_TABLE_NEEDS_UPGRADE:
+ /*
+ The error message for ER_TABLE_NEEDS_UPGRADE refers to REPAIR table,
+ which does not apply to performance schema tables.
+ */
+ my_error(ER_WRONG_NATIVE_TABLE_STRUCTURE, MYF(0),
+ table_share->db.str, table_share->table_name.str);
+ break;
+ case HA_ERR_WRONG_COMMAND:
+ /*
+ The performance schema is not a general purpose storage engine,
+ some operations are not supported, by design.
+ We do not want to print "Command not supported",
+ which gives the impression that a command implementation is missing,
+ and that the failure should be considered a bug.
+ We print "Invalid performance_schema usage." instead,
+ to emphasise that the operation attempted is not meant to be legal,
+ and that the failure returned is indeed the expected result.
+ */
+ my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
+ break;
+ default:
+ handler::print_error(error, errflag);
+ break;
+ }
+}
+
diff --git a/storage/perfschema/ha_perfschema.h b/storage/perfschema/ha_perfschema.h
index 1a0c16541be..c0ee0827dbc 100644
--- a/storage/perfschema/ha_perfschema.h
+++ b/storage/perfschema/ha_perfschema.h
@@ -100,9 +100,6 @@ public:
double scan_time(void)
{ return 1.0; }
- double read_time(ha_rows)
- { return 1.0; }
-
int open(const char *name, int mode, uint test_if_locked);
int close(void);
@@ -149,6 +146,8 @@ public:
return FALSE;
}
+ virtual void print_error(int error, myf errflags);
+
private:
/** MySQL lock */
THR_LOCK_DATA m_thr_lock;
diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc
index 3b1959c98d2..38f6df3003d 100644
--- a/storage/perfschema/pfs_engine_table.cc
+++ b/storage/perfschema/pfs_engine_table.cc
@@ -232,8 +232,6 @@ int PFS_engine_table::read_row(TABLE *table,
*/
if (! m_share_ptr->m_checked)
{
- my_error(ER_WRONG_NATIVE_TABLE_STRUCTURE, MYF(0),
- PERFORMANCE_SCHEMA_str.str, m_share_ptr->m_name.str);
return HA_ERR_TABLE_NEEDS_UPGRADE;
}
@@ -279,8 +277,6 @@ int PFS_engine_table::update_row(TABLE *table,
*/
if (! m_share_ptr->m_checked)
{
- my_error(ER_WRONG_NATIVE_TABLE_STRUCTURE, MYF(0),
- PERFORMANCE_SCHEMA_str.str, m_share_ptr->m_name.str);
return HA_ERR_TABLE_NEEDS_UPGRADE;
}
@@ -351,7 +347,6 @@ int PFS_engine_table::update_row_values(TABLE *,
unsigned char *,
Field **)
{
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
return HA_ERR_WRONG_COMMAND;
}
@@ -524,9 +519,9 @@ bool pfs_show_status(handlerton *hton, THD *thd,
/*
Note about naming conventions:
- Internal buffers exposed as a table in the performance schema are named
- after the table, as in 'EVENTS_WAITS_CURRENT'
+ after the table, as in 'events_waits_current'
- Internal buffers not exposed by a table are named with parenthesis,
- as in '(PFS_MUTEX_CLASS)'.
+ as in '(pfs_mutex_class)'.
*/
if (stat != HA_ENGINE_STATUS)
DBUG_RETURN(false);
@@ -537,219 +532,219 @@ bool pfs_show_status(handlerton *hton, THD *thd,
{
switch (i){
case 0:
- name= "EVENTS_WAITS_CURRENT.ROW_SIZE";
+ name= "events_waits_current.row_size";
size= sizeof(PFS_wait_locker);
break;
case 1:
- name= "EVENTS_WAITS_CURRENT.ROW_COUNT";
+ name= "events_waits_current.row_count";
size= LOCKER_STACK_SIZE * thread_max;
break;
case 2:
- name= "EVENTS_WAITS_HISTORY.ROW_SIZE";
+ name= "events_waits_history.row_size";
size= sizeof(PFS_events_waits);
break;
case 3:
- name= "EVENTS_WAITS_HISTORY.ROW_COUNT";
+ name= "events_waits_history.row_count";
size= events_waits_history_per_thread * thread_max;
break;
case 4:
- name= "EVENTS_WAITS_HISTORY.MEMORY";
+ name= "events_waits_history.memory";
size= events_waits_history_per_thread * thread_max
* sizeof(PFS_events_waits);
total_memory+= size;
break;
case 5:
- name= "EVENTS_WAITS_HISTORY_LONG.ROW_SIZE";
+ name= "events_waits_history_long.row_size";
size= sizeof(PFS_events_waits);
break;
case 6:
- name= "EVENTS_WAITS_HISTORY_LONG.ROW_COUNT";
+ name= "events_waits_history_long.row_count";
size= events_waits_history_long_size;
break;
case 7:
- name= "EVENTS_WAITS_HISTORY_LONG.MEMORY";
+ name= "events_waits_history_long.memory";
size= events_waits_history_long_size * sizeof(PFS_events_waits);
total_memory+= size;
break;
case 8:
- name= "(PFS_MUTEX_CLASS).ROW_SIZE";
+ name= "(pfs_mutex_class).row_size";
size= sizeof(PFS_mutex_class);
break;
case 9:
- name= "(PFS_MUTEX_CLASS).ROW_COUNT";
+ name= "(pfs_mutex_class).row_count";
size= mutex_class_max;
break;
case 10:
- name= "(PFS_MUTEX_CLASS).MEMORY";
+ name= "(pfs_mutex_class).memory";
size= mutex_class_max * sizeof(PFS_mutex_class);
total_memory+= size;
break;
case 11:
- name= "(PFS_RWLOCK_CLASS).ROW_SIZE";
+ name= "(pfs_rwlock_class).row_size";
size= sizeof(PFS_rwlock_class);
break;
case 12:
- name= "(PFS_RWLOCK_CLASS).ROW_COUNT";
+ name= "(pfs_rwlock_class).row_count";
size= rwlock_class_max;
break;
case 13:
- name= "(PFS_RWLOCK_CLASS).MEMORY";
+ name= "(pfs_rwlock_class).memory";
size= rwlock_class_max * sizeof(PFS_rwlock_class);
total_memory+= size;
break;
case 14:
- name= "(PFS_COND_CLASS).ROW_SIZE";
+ name= "(pfs_cond_class).row_size";
size= sizeof(PFS_cond_class);
break;
case 15:
- name= "(PFS_COND_CLASS).ROW_COUNT";
+ name= "(pfs_cond_class).row_count";
size= cond_class_max;
break;
case 16:
- name= "(PFS_COND_CLASS).MEMORY";
+ name= "(pfs_cond_class).memory";
size= cond_class_max * sizeof(PFS_cond_class);
total_memory+= size;
break;
case 17:
- name= "(PFS_THREAD_CLASS).ROW_SIZE";
+ name= "(pfs_thread_class).row_size";
size= sizeof(PFS_thread_class);
break;
case 18:
- name= "(PFS_THREAD_CLASS).ROW_COUNT";
+ name= "(pfs_thread_class).row_count";
size= thread_class_max;
break;
case 19:
- name= "(PFS_THREAD_CLASS).MEMORY";
+ name= "(pfs_thread_class).memory";
size= thread_class_max * sizeof(PFS_thread_class);
total_memory+= size;
break;
case 20:
- name= "(PFS_FILE_CLASS).ROW_SIZE";
+ name= "(pfs_file_class).row_size";
size= sizeof(PFS_file_class);
break;
case 21:
- name= "(PFS_FILE_CLASS).ROW_COUNT";
+ name= "(pfs_file_class).row_count";
size= file_class_max;
break;
case 22:
- name= "(PFS_FILE_CLASS).MEMORY";
+ name= "(pfs_file_class).memory";
size= file_class_max * sizeof(PFS_file_class);
total_memory+= size;
break;
case 23:
- name= "MUTEX_INSTANCES.ROW_SIZE";
+ name= "mutex_instances.row_size";
size= sizeof(PFS_mutex);
break;
case 24:
- name= "MUTEX_INSTANCES.ROW_COUNT";
+ name= "mutex_instances.row_count";
size= mutex_max;
break;
case 25:
- name= "MUTEX_INSTANCES.MEMORY";
+ name= "mutex_instances.memory";
size= mutex_max * sizeof(PFS_mutex);
total_memory+= size;
break;
case 26:
- name= "RWLOCK_INSTANCES.ROW_SIZE";
+ name= "rwlock_instances.row_size";
size= sizeof(PFS_rwlock);
break;
case 27:
- name= "RWLOCK_INSTANCES.ROW_COUNT";
+ name= "rwlock_instances.row_count";
size= rwlock_max;
break;
case 28:
- name= "RWLOCK_INSTANCES.MEMORY";
+ name= "rwlock_instances.memory";
size= rwlock_max * sizeof(PFS_rwlock);
total_memory+= size;
break;
case 29:
- name= "COND_INSTANCES.ROW_SIZE";
+ name= "cond_instances.row_size";
size= sizeof(PFS_cond);
break;
case 30:
- name= "COND_INSTANCES.ROW_COUNT";
+ name= "cond_instances.row_count";
size= cond_max;
break;
case 31:
- name= "COND_INSTANCES.MEMORY";
+ name= "cond_instances.memory";
size= cond_max * sizeof(PFS_cond);
total_memory+= size;
break;
case 32:
- name= "PROCESSLIST.ROW_SIZE";
+ name= "threads.row_size";
size= sizeof(PFS_thread);
break;
case 33:
- name= "PROCESSLIST.ROW_COUNT";
+ name= "threads.row_count";
size= thread_max;
break;
case 34:
- name= "PROCESSLIST.MEMORY";
+ name= "threads.memory";
size= thread_max * sizeof(PFS_thread);
total_memory+= size;
break;
case 35:
- name= "FILE_INSTANCES.ROW_SIZE";
+ name= "file_instances.row_size";
size= sizeof(PFS_file);
break;
case 36:
- name= "FILE_INSTANCES.ROW_COUNT";
+ name= "file_instances.row_count";
size= file_max;
break;
case 37:
- name= "FILE_INSTANCES.MEMORY";
+ name= "file_instances.memory";
size= file_max * sizeof(PFS_file);
total_memory+= size;
break;
case 38:
- name= "(PFS_FILE_HANDLE).ROW_SIZE";
+ name= "(pfs_file_handle).row_size";
size= sizeof(PFS_file*);
break;
case 39:
- name= "(PFS_FILE_HANDLE).ROW_COUNT";
+ name= "(pfs_file_handle).row_count";
size= file_handle_max;
break;
case 40:
- name= "(PFS_FILE_HANDLE).MEMORY";
+ name= "(pfs_file_handle).memory";
size= file_handle_max * sizeof(PFS_file*);
total_memory+= size;
break;
case 41:
- name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE";
+ name= "events_waits_summary_by_thread_by_event_name.row_size";
size= sizeof(PFS_single_stat_chain);
break;
case 42:
- name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_COUNT";
+ name= "events_waits_summary_by_thread_by_event_name.row_count";
size= thread_max * instr_class_per_thread;
break;
case 43:
- name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.MEMORY";
+ name= "events_waits_summary_by_thread_by_event_name.memory";
size= thread_max * instr_class_per_thread * sizeof(PFS_single_stat_chain);
total_memory+= size;
break;
case 44:
- name= "(PFS_TABLE_SHARE).ROW_SIZE";
+ name= "(pfs_table_share).row_size";
size= sizeof(PFS_table_share);
break;
case 45:
- name= "(PFS_TABLE_SHARE).ROW_COUNT";
+ name= "(pfs_table_share).row_count";
size= table_share_max;
break;
case 46:
- name= "(PFS_TABLE_SHARE).MEMORY";
+ name= "(pfs_table_share).memory";
size= table_share_max * sizeof(PFS_table_share);
total_memory+= size;
break;
case 47:
- name= "(PFS_TABLE).ROW_SIZE";
+ name= "(pfs_table).row_size";
size= sizeof(PFS_table);
break;
case 48:
- name= "(PFS_TABLE).ROW_COUNT";
+ name= "(pfs_table).row_count";
size= table_max;
break;
case 49:
- name= "(PFS_TABLE).MEMORY";
+ name= "(pfs_table).memory";
size= table_max * sizeof(PFS_table);
total_memory+= size;
break;
@@ -758,7 +753,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
for aggregation in total_memory.
*/
case 50:
- name= "PERFORMANCE_SCHEMA.MEMORY";
+ name= "performance_schema.memory";
size= total_memory;
/* This will fail if something is not advertised here */
DBUG_ASSERT(size == pfs_allocated_memory);
diff --git a/storage/perfschema/table_setup_consumers.cc b/storage/perfschema/table_setup_consumers.cc
index 5b39fd89a03..601e0483b14 100644
--- a/storage/perfschema/table_setup_consumers.cc
+++ b/storage/perfschema/table_setup_consumers.cc
@@ -192,7 +192,6 @@ int table_setup_consumers::update_row_values(TABLE *table,
switch(f->field_index)
{
case 0: /* NAME */
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
return HA_ERR_WRONG_COMMAND;
case 1: /* ENABLED */
{
diff --git a/storage/perfschema/table_setup_instruments.cc b/storage/perfschema/table_setup_instruments.cc
index 310f859248b..480c0dbc13f 100644
--- a/storage/perfschema/table_setup_instruments.cc
+++ b/storage/perfschema/table_setup_instruments.cc
@@ -253,7 +253,6 @@ int table_setup_instruments::update_row_values(TABLE *table,
switch(f->field_index)
{
case 0: /* NAME */
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
return HA_ERR_WRONG_COMMAND;
case 1: /* ENABLED */
value= (enum_yes_no) get_field_enum(f);
diff --git a/storage/perfschema/table_setup_timers.cc b/storage/perfschema/table_setup_timers.cc
index 24ec18dafb1..f8b1bfa4fe2 100644
--- a/storage/perfschema/table_setup_timers.cc
+++ b/storage/perfschema/table_setup_timers.cc
@@ -164,7 +164,6 @@ int table_setup_timers::update_row_values(TABLE *table,
switch(f->field_index)
{
case 0: /* NAME */
- my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
return HA_ERR_WRONG_COMMAND;
case 1: /* TIMER_NAME */
value= get_field_enum(f);
diff --git a/strings/CHARSET_INFO.txt b/strings/CHARSET_INFO.txt
index bb8e40025c7..6f0a810be37 100644
--- a/strings/CHARSET_INFO.txt
+++ b/strings/CHARSET_INFO.txt
@@ -208,14 +208,11 @@ charpos() - calculates the offset of the given position in the string.
Used in SQL functions LEFT(), RIGHT(), SUBSTRING(),
INSERT()
-well_formed_length()
- - finds the length of correctly formed multi-byte beginning.
- Used in INSERTs to cut a beginning of the given string
- which is
- a) "well formed" according to the given character set.
+well_formed_len()
+ - returns length of a given multi-byte string in bytes
+ Used in INSERTs to shorten the given string so it
+ a) is "well formed" according to the given character set
b) can fit into the given data type
- Terminates the string in the good position, taking in account
- multi-byte character boundaries.
lengthsp() - returns the length of the given string without trailing spaces.
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index ba12f3f4267..f89a45d6ed8 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -1040,7 +1040,7 @@ uint16 to_uni_cp1251_bulgarian_ci[] = {
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021,
-0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
+0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F,
0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7,
@@ -1730,7 +1730,7 @@ uint16 to_uni_cp1251_ukrainian_ci[] = {
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021,
-0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
+0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F,
0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7,
@@ -3762,7 +3762,7 @@ uint16 to_uni_cp1251_bin[] = {
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021,
-0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
+0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F,
0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7,
@@ -3877,7 +3877,7 @@ uint16 to_uni_cp1251_general_ci[] = {
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021,
-0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
+0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F,
0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7,
@@ -3992,7 +3992,7 @@ uint16 to_uni_cp1251_general_cs[] = {
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021,
-0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
+0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F,
0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F,
0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7,
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index b2f2e3cd22e..8b985b7405b 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -636,7 +636,7 @@ static void pad_max_char(CHARSET_INFO *cs, char *str, char *end)
DBUG_ASSERT(buflen > 0);
do
{
- if ((str + buflen) < end)
+ if ((str + buflen) <= end)
{
/* Enough space for the characer */
memcpy(str, buf, buflen);
@@ -802,6 +802,192 @@ fill_max_and_min:
}
+/**
+ Calculate min_str and max_str that ranges a LIKE string.
+ Generic function, currently used for ucs2, utf16, utf32,
+ but should be suitable for any other character sets with
+ cs->min_sort_char and cs->max_sort_char represented in
+ Unicode code points.
+
+ @param cs Character set and collation pointer
+ @param ptr Pointer to LIKE pattern.
+ @param ptr_length Length of LIKE pattern.
+ @param escape Escape character pattern, typically '\'.
+ @param w_one 'One character' pattern, typically '_'.
+ @param w_many 'Many characters' pattern, typically '%'.
+ @param res_length Length of min_str and max_str.
+
+ @param[out] min_str Smallest string that ranges LIKE.
+ @param[out] max_str Largest string that ranges LIKE.
+ @param[out] min_len Length of min_str
+ @param[out] max_len Length of max_str
+
+ @return Optimization status.
+ @retval FALSE if LIKE pattern can be optimized
+ @rerval TRUE if LIKE can't be optimized.
+*/
+my_bool
+my_like_range_generic(CHARSET_INFO *cs,
+ const char *ptr, size_t ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ size_t res_length,
+ char *min_str,char *max_str,
+ size_t *min_length,size_t *max_length)
+{
+ const char *end= ptr + ptr_length;
+ const char *min_org= min_str;
+ const char *max_org= max_str;
+ char *min_end= min_str + res_length;
+ char *max_end= max_str + res_length;
+ size_t charlen= res_length / cs->mbmaxlen;
+ size_t res_length_diff;
+ my_bool have_contractions= my_cs_have_contractions(cs);
+
+ for ( ; charlen > 0; charlen--)
+ {
+ my_wc_t wc, wc2;
+ int res;
+ if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0)
+ {
+ if (res == MY_CS_ILSEQ) /* Bad sequence */
+ return TRUE; /* min_length and max_length are not important */
+ break; /* End of the string */
+ }
+ ptr+= res;
+
+ if (wc == (my_wc_t) escape)
+ {
+ if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0)
+ {
+ if (res == MY_CS_ILSEQ)
+ return TRUE; /* min_length and max_length are not important */
+ /*
+ End of the string: Escape is the last character.
+ Put escape as a normal character.
+ We'll will leave the loop on the next iteration.
+ */
+ }
+ else
+ ptr+= res;
+
+ /* Put escape character to min_str and max_str */
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) min_str, (uchar*) min_end)) <= 0)
+ goto pad_set_lengths; /* No space */
+ min_str+= res;
+
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) max_str, (uchar*) max_end)) <= 0)
+ goto pad_set_lengths; /* No space */
+ max_str+= res;
+ continue;
+ }
+ else if (wc == (my_wc_t) w_one)
+ {
+ if ((res= cs->cset->wc_mb(cs, cs->min_sort_char,
+ (uchar*) min_str, (uchar*) min_end)) <= 0)
+ goto pad_set_lengths;
+ min_str+= res;
+
+ if ((res= cs->cset->wc_mb(cs, cs->max_sort_char,
+ (uchar*) max_str, (uchar*) max_end)) <= 0)
+ goto pad_set_lengths;
+ max_str+= res;
+ continue;
+ }
+ else if (wc == (my_wc_t) w_many)
+ {
+ /*
+ Calculate length of keys:
+ a\min\min... is the smallest possible string
+ a\max\max... is the biggest possible string
+ */
+ *min_length= ((cs->state & MY_CS_BINSORT) ?
+ (size_t) (min_str - min_org) :
+ res_length);
+ *max_length= res_length;
+ goto pad_min_max;
+ }
+
+ if (have_contractions &&
+ my_cs_can_be_contraction_head(cs, wc) &&
+ (res= cs->cset->mb_wc(cs, &wc2, (uchar*) ptr, (uchar*) end)) > 0)
+ {
+ uint16 *weight;
+ if ((wc2 == (my_wc_t) w_one || wc2 == (my_wc_t) w_many))
+ {
+ /* Contraction head followed by a wildcard */
+ *min_length= *max_length= res_length;
+ goto pad_min_max;
+ }
+
+ if (my_cs_can_be_contraction_tail(cs, wc2) &&
+ (weight= my_cs_contraction2_weight(cs, wc, wc2)) && weight[0])
+ {
+ /* Contraction found */
+ if (charlen == 1)
+ {
+ /* contraction does not fit to result */
+ *min_length= *max_length= res_length;
+ goto pad_min_max;
+ }
+
+ ptr+= res;
+ charlen--;
+
+ /* Put contraction head */
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) min_str, (uchar*) min_end)) <= 0)
+ goto pad_set_lengths;
+ min_str+= res;
+
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) max_str, (uchar*) max_end)) <= 0)
+ goto pad_set_lengths;
+ max_str+= res;
+ wc= wc2; /* Prepare to put contraction tail */
+ }
+ }
+
+ /* Normal character, or contraction tail */
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) min_str, (uchar*) min_end)) <= 0)
+ goto pad_set_lengths;
+ min_str+= res;
+ if ((res= cs->cset->wc_mb(cs, wc,
+ (uchar*) max_str, (uchar*) max_end)) <= 0)
+ goto pad_set_lengths;
+ max_str+= res;
+ }
+
+pad_set_lengths:
+ *min_length= (size_t) (min_str - min_org);
+ *max_length= (size_t) (max_str - max_org);
+
+pad_min_max:
+ /*
+ Fill up max_str and min_str to res_length.
+ fill() cannot set incomplete characters and
+ requires that "length" argument is divisible to mbminlen.
+ Make sure to call fill() with proper "length" argument.
+ */
+ res_length_diff= res_length % cs->mbminlen;
+ cs->cset->fill(cs, min_str, min_end - min_str - res_length_diff,
+ cs->min_sort_char);
+ cs->cset->fill(cs, max_str, max_end - max_str - res_length_diff,
+ cs->max_sort_char);
+
+ /* In case of incomplete characters set the remainder to 0x00's */
+ if (res_length_diff)
+ {
+ /* Example: odd res_length for ucs2 */
+ memset(min_end - res_length_diff, 0, res_length_diff);
+ memset(max_end - res_length_diff, 0, res_length_diff);
+ }
+ return FALSE;
+}
+
+
int
my_wildcmp_mb_bin(CHARSET_INFO *cs,
const char *str,const char *str_end,
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 3cf61b213eb..2f7bf030d90 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -8127,7 +8127,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler =
my_strnncollsp_ucs2_uca,
my_strnxfrm_ucs2_uca,
my_strnxfrmlen_simple,
- my_like_range_ucs2,
+ my_like_range_generic,
my_wildcmp_uca,
NULL,
my_instr_mb,
@@ -10134,7 +10134,7 @@ MY_COLLATION_HANDLER my_collation_utf32_uca_handler =
my_strnncollsp_any_uca,
my_strnxfrm_any_uca,
my_strnxfrmlen_simple,
- my_like_range_utf32,
+ my_like_range_generic,
my_wildcmp_uca,
NULL,
my_instr_mb,
@@ -10801,7 +10801,7 @@ MY_COLLATION_HANDLER my_collation_utf16_uca_handler =
my_strnncollsp_any_uca,
my_strnxfrm_any_uca,
my_strnxfrmlen_simple,
- my_like_range_utf16,
+ my_like_range_generic,
my_wildcmp_uca,
NULL,
my_instr_mb,
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 85d391d0c70..67be793c3dc 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -903,7 +903,8 @@ static void
my_fill_mb2(CHARSET_INFO *cs __attribute__((unused)),
char *s, size_t l, int fill)
{
- for ( ; l >= 2; s[0]= 0, s[1]= fill, s+= 2, l-= 2);
+ DBUG_ASSERT(fill <= 0xFFFF);
+ for ( ; l >= 2; s[0]= (fill >> 8), s[1]= (fill & 0xFF), s+= 2, l-= 2);
}
@@ -1563,98 +1564,6 @@ my_hash_sort_utf16_bin(CHARSET_INFO *cs __attribute__((unused)),
}
-/**
- Calculate min_str and max_str that ranges a LIKE string.
-
- @param ptr Pointer to LIKE pattern.
- @param ptr_length Length of LIKE pattern.
- @param escape Escape character in LIKE. (Normally '\').
- All escape characters should be removed
- from min_str and max_str.
- @param res_length Length of min_str and max_str.
- @param min_str Smallest case sensitive string that ranges LIKE.
- Should be space padded to res_length.
- @param max_str Largest case sensitive string that ranges LIKE.
- Normally padded with the biggest character sort value.
-
- @return Optimization status.
- @retval FALSE if LIKE pattern can be optimized
- @rerval TRUE if LIKE can't be optimized.
-*/
-
-my_bool
-my_like_range_utf16(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str,char *max_str,
- size_t *min_length,size_t *max_length)
-{
- const char *end=ptr+ptr_length;
- char *min_org=min_str;
- char *min_end=min_str+res_length;
- size_t charlen= res_length / cs->mbmaxlen;
-
- for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0
- ; ptr+=2, charlen--)
- {
- if (ptr[0] == '\0' && ptr[1] == escape && ptr + 1 < end)
- {
- ptr+=2; /* Skip escape */
- *min_str++= *max_str++ = ptr[0];
- *min_str++= *max_str++ = ptr[1];
- continue;
- }
- if (ptr[0] == '\0' && ptr[1] == w_one) /* '_' in SQL */
- {
- *min_str++= (char) (cs->min_sort_char >> 8);
- *min_str++= (char) (cs->min_sort_char & 255);
- *max_str++= (char) (cs->max_sort_char >> 8);
- *max_str++= (char) (cs->max_sort_char & 255);
- continue;
- }
- if (ptr[0] == '\0' && ptr[1] == w_many) /* '%' in SQL */
- {
- /*
- Calculate length of keys:
- 'a\0\0... is the smallest possible string when we have space expand
- a\ff\ff... is the biggest possible string
- */
- *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) :
- res_length);
- *max_length= res_length;
- do {
- *min_str++ = 0;
- *min_str++ = 0;
- *max_str++ = (char) (cs->max_sort_char >> 8);
- *max_str++ = (char) (cs->max_sort_char & 255);
- } while (min_str + 1 < min_end);
- return FALSE;
- }
- *min_str++= *max_str++ = ptr[0];
- *min_str++= *max_str++ = ptr[1];
- }
-
- /* Temporary fix for handling w_one at end of string (key compression) */
- {
- char *tmp;
- for (tmp= min_str ; tmp-1 > min_org && tmp[-1] == '\0' && tmp[-2]=='\0';)
- {
- *--tmp=' ';
- *--tmp='\0';
- }
- }
-
- *min_length= *max_length = (size_t) (min_str - min_org);
- while (min_str + 1 < min_end)
- {
- *min_str++ = *max_str++ = '\0';
- *min_str++ = *max_str++ = ' '; /* Because if key compression */
- }
- return FALSE;
-}
-
-
static MY_COLLATION_HANDLER my_collation_utf16_general_ci_handler =
{
NULL, /* init */
@@ -1662,7 +1571,7 @@ static MY_COLLATION_HANDLER my_collation_utf16_general_ci_handler =
my_strnncollsp_utf16,
my_strnxfrm_unicode,
my_strnxfrmlen_simple,
- my_like_range_utf16,
+ my_like_range_generic,
my_wildcmp_utf16_ci,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
@@ -1678,7 +1587,7 @@ static MY_COLLATION_HANDLER my_collation_utf16_bin_handler =
my_strnncollsp_utf16_bin,
my_strnxfrm_unicode_full_bin,
my_strnxfrmlen_unicode_full_bin,
- my_like_range_utf16,
+ my_like_range_generic,
my_wildcmp_utf16_bin,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
@@ -2551,113 +2460,6 @@ my_strnncollsp_utf32_bin(CHARSET_INFO *cs __attribute__((unused)),
}
-/**
- Calculate min_str and max_str that ranges a LIKE string.
-
- @param ptr Pointer to LIKE pattern.
- @param ptr_length Length of LIKE pattern.
- @param escape Escape character in LIKE. (Normally '\').
- All escape characters should be removed
- from min_str and max_str.
- @param res_length Length of min_str and max_str.
- @param min_str Smallest case sensitive string that ranges LIKE.
- Should be space padded to res_length.
- @param max_str Largest case sensitive string that ranges LIKE.
- Normally padded with the biggest character sort value.
-
- @return Optimization status.
- @retval FALSE if LIKE pattern can be optimized
- @rerval TRUE if LIKE can't be optimized.
-*/
-
-my_bool
-my_like_range_utf32(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str,char *max_str,
- size_t *min_length,size_t *max_length)
-{
- const char *end= ptr + ptr_length;
- char *min_org= min_str;
- char *min_end= min_str + res_length;
- char *max_end= max_str + res_length;
- size_t charlen= res_length / cs->mbmaxlen;
-
- DBUG_ASSERT((res_length % 4) == 0);
-
- for ( ; charlen > 0; ptr+= 4, charlen--)
- {
- my_wc_t wc;
- int res;
- if ((res= my_utf32_uni(cs, &wc, (uchar*) ptr, (uchar*) end)) < 0)
- {
- my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char);
- my_fill_utf32(cs, max_str, min_end - min_str, cs->max_sort_char);
- /* min_length and max_legnth are not important */
- return TRUE;
- }
-
- if (wc == (my_wc_t) escape)
- {
- ptr+= 4; /* Skip escape */
- if ((res= my_utf32_uni(cs, &wc, (uchar*) ptr, (uchar*) end)) < 0)
- {
- my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char);
- my_fill_utf32(cs, max_str, max_end - min_str, cs->max_sort_char);
- /* min_length and max_length are not important */
- return TRUE;
- }
- if (my_uni_utf32(cs, wc, (uchar*) min_str, (uchar*) min_end) != 4 ||
- my_uni_utf32(cs, wc, (uchar*) max_str, (uchar*) max_end) != 4)
- goto pad_set_lengths;
- *min_str++= 4;
- *max_str++= 4;
- continue;
- }
-
- if (wc == (my_wc_t) w_one)
- {
- if (my_uni_utf32(cs, cs->min_sort_char, (uchar*) min_str, (uchar*) min_end) != 4 ||
- my_uni_utf32(cs, cs->max_sort_char, (uchar*) max_str, (uchar*) max_end) != 4)
- goto pad_set_lengths;
- min_str+= 4;
- max_str+= 4;
- continue;
- }
-
- if (wc == (my_wc_t) w_many)
- {
- /*
- Calculate length of keys:
- 'a\0\0... is the smallest possible string when we have space expand
- a\ff\ff... is the biggest possible string
- */
- *min_length= ((cs->state & MY_CS_BINSORT) ?
- (size_t) (min_str - min_org) :
- res_length);
- *max_length= res_length;
- goto pad_min_max;
- }
-
- /* Normal character */
- if (my_uni_utf32(cs, wc, (uchar*) min_str, (uchar*) min_end) != 4 ||
- my_uni_utf32(cs, wc, (uchar*) max_str, (uchar*) max_end) != 4)
- goto pad_set_lengths;
- min_str+= 4;
- max_str+= 4;
- }
-
-pad_set_lengths:
- *min_length= *max_length= (size_t) (min_str - min_org);
-
-pad_min_max:
- my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char);
- my_fill_utf32(cs, max_str, max_end - max_str, cs->max_sort_char);
- return FALSE;
-}
-
-
static size_t
my_scan_utf32(CHARSET_INFO *cs,
const char *str, const char *end, int sequence_type)
@@ -2689,7 +2491,7 @@ static MY_COLLATION_HANDLER my_collation_utf32_general_ci_handler =
my_strnncollsp_utf32,
my_strnxfrm_unicode,
my_strnxfrmlen_utf32,
- my_like_range_utf32,
+ my_like_range_generic,
my_wildcmp_utf32_ci,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
@@ -2705,7 +2507,7 @@ static MY_COLLATION_HANDLER my_collation_utf32_bin_handler =
my_strnncollsp_utf32_bin,
my_strnxfrm_unicode_full_bin,
my_strnxfrmlen_unicode_full_bin,
- my_like_range_utf32,
+ my_like_range_generic,
my_wildcmp_utf32_bin,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
@@ -2891,7 +2693,10 @@ static int my_uni_ucs2(CHARSET_INFO *cs __attribute__((unused)) ,
{
if ( r+2 > e )
return MY_CS_TOOSMALL2;
-
+
+ if (wc > 0xFFFF) /* UCS2 does not support characters outside BMP */
+ return MY_CS_ILUNI;
+
r[0]= (uchar) (wc >> 8);
r[1]= (uchar) (wc & 0xFF);
return 2;
@@ -3252,120 +3057,6 @@ void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)),
}
}
-/*
-** Calculate min_str and max_str that ranges a LIKE string.
-** Arguments:
-** ptr Pointer to LIKE string.
-** ptr_length Length of LIKE string.
-** escape Escape character in LIKE. (Normally '\').
-** All escape characters should be removed from min_str and max_str
-** res_length Length of min_str and max_str.
-** min_str Smallest case sensitive string that ranges LIKE.
-** Should be space padded to res_length.
-** max_str Largest case sensitive string that ranges LIKE.
-** Normally padded with the biggest character sort value.
-**
-** The function should return 0 if ok and 1 if the LIKE string can't be
-** optimized !
-*/
-
-my_bool my_like_range_ucs2(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str,char *max_str,
- size_t *min_length,size_t *max_length)
-{
- const char *end=ptr+ptr_length;
- char *min_org=min_str;
- char *min_end=min_str+res_length;
- size_t charlen= res_length / cs->mbmaxlen;
- const char *contraction_flags= cs->contractions ?
- ((const char*) cs->contractions) + 0x40*0x40 : NULL;
-
- for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0
- ; ptr+=2, charlen--)
- {
- if (ptr[0] == '\0' && ptr[1] == escape && ptr + 1 < end)
- {
- ptr+=2; /* Skip escape */
- *min_str++= *max_str++ = ptr[0];
- *min_str++= *max_str++ = ptr[1];
- continue;
- }
- if (ptr[0] == '\0' && ptr[1] == w_one) /* '_' in SQL */
- {
- *min_str++= (char) (cs->min_sort_char >> 8);
- *min_str++= (char) (cs->min_sort_char & 255);
- *max_str++= (char) (cs->max_sort_char >> 8);
- *max_str++= (char) (cs->max_sort_char & 255);
- continue;
- }
- if (ptr[0] == '\0' && ptr[1] == w_many) /* '%' in SQL */
- {
-fill_max_and_min:
- /*
- Calculate length of keys:
- 'a\0\0... is the smallest possible string when we have space expand
- a\ff\ff... is the biggest possible string
- */
- *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) :
- res_length);
- *max_length= res_length;
- do {
- *min_str++ = 0;
- *min_str++ = 0;
- *max_str++ = (char) (cs->max_sort_char >> 8);
- *max_str++ = (char) (cs->max_sort_char & 255);
- } while (min_str + 1 < min_end);
- return 0;
- }
-
- if (contraction_flags && ptr + 3 < end &&
- ptr[0] == '\0' && contraction_flags[(uchar) ptr[1]])
- {
- /* Contraction head found */
- if (ptr[2] == '\0' && (ptr[3] == w_one || ptr[3] == w_many))
- {
- /* Contraction head followed by a wildcard, quit */
- goto fill_max_and_min;
- }
-
- /*
- Check if the second letter can be contraction part,
- and if two letters really produce a contraction.
- */
- if (ptr[2] == '\0' && contraction_flags[(uchar) ptr[3]] &&
- cs->contractions[(ptr[1]-0x40)*0x40 + ptr[3] - 0x40])
- {
- /* Contraction found */
- if (charlen == 1 || min_str + 2 >= min_end)
- {
- /* Full contraction doesn't fit, quit */
- goto fill_max_and_min;
- }
-
- /* Put contraction head */
- *min_str++= *max_str++= *ptr++;
- *min_str++= *max_str++= *ptr++;
- charlen--;
- }
- }
- /* Put contraction tail, or a single character */
- *min_str++= *max_str++ = ptr[0];
- *min_str++= *max_str++ = ptr[1];
- }
-
- *min_length= *max_length = (size_t) (min_str - min_org);
- while (min_str + 1 < min_end)
- {
- *min_str++ = *max_str++ = '\0';
- *min_str++ = *max_str++ = ' '; /* Because if key compression */
- }
- return 0;
-}
-
-
static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
{
@@ -3374,7 +3065,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
my_strnncollsp_ucs2,
my_strnxfrm_unicode,
my_strnxfrmlen_simple,
- my_like_range_ucs2,
+ my_like_range_generic,
my_wildcmp_ucs2_ci,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
@@ -3390,7 +3081,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler =
my_strnncollsp_ucs2_bin,
my_strnxfrm_unicode,
my_strnxfrmlen_simple,
- my_like_range_ucs2,
+ my_like_range_generic,
my_wildcmp_ucs2_bin,
my_strcasecmp_mb2_or_mb4,
my_instr_mb,
diff --git a/strings/my_strchr.c b/strings/my_strchr.c
index 6724bf39ff2..08fa51ba17a 100644
--- a/strings/my_strchr.c
+++ b/strings/my_strchr.c
@@ -13,6 +13,45 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+#include "m_string.h"
+#include "m_ctype.h"
+
+#define NEQ(A, B) ((A) != (B))
+#define EQU(A, B) ((A) == (B))
+
+/**
+ Macro for the body of the string scanning.
+
+ @param CS The character set of the string
+ @param STR Pointer to beginning of string
+ @param END Pointer to one-after-end of string
+ @param ACC Pointer to beginning of accept (or reject) string
+ @param LEN Length of accept (or reject) string
+ @param CMP is a function-like for doing the comparison of two characters.
+ */
+
+#define SCAN_STRING(CS, STR, END, ACC, LEN, CMP) \
+ do { \
+ uint mbl; \
+ const char *ptr_str, *ptr_acc; \
+ const char *acc_end= (ACC) + (LEN); \
+ for (ptr_str= (STR) ; ptr_str < (END) ; ptr_str+= mbl) \
+ { \
+ mbl= my_mbcharlen((CS), *(uchar*)ptr_str); \
+ if (mbl < 2) \
+ { \
+ DBUG_ASSERT(mbl == 1); \
+ for (ptr_acc= (ACC) ; ptr_acc < acc_end ; ++ptr_acc) \
+ if (CMP(*ptr_acc, *ptr_str)) \
+ goto end; \
+ } \
+ } \
+end: \
+ return (size_t) (ptr_str - (STR)); \
+ } while (0)
+
+
/*
my_strchr(cs, str, end, c) returns a pointer to the first place in
str where c (1-byte character) occurs, or NULL if c does not occur
@@ -21,11 +60,6 @@
frequently.
*/
-#include <my_global.h>
-#include "m_string.h"
-#include "m_ctype.h"
-
-
char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
pchar c)
{
@@ -45,3 +79,26 @@ char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
return(0);
}
+/**
+ Calculate the length of the initial segment of 'str' which consists
+ entirely of characters not in 'reject'.
+
+ @note The reject string points to single-byte characters so it is
+ only possible to find the first occurrence of a single-byte
+ character. Multi-byte characters in 'str' are treated as not
+ matching any character in the reject string.
+
+ @todo should be moved to CHARSET_INFO if it's going to be called
+ frequently.
+
+ @internal The implementation builds on the assumption that 'str' is long,
+ while 'reject' is short. So it compares each character in string
+ with the characters in 'reject' in a tight loop over the characters
+ in 'reject'.
+*/
+
+size_t my_strcspn(CHARSET_INFO *cs, const char *str, const char *str_end,
+ const char *reject)
+{
+ SCAN_STRING(cs, str, str_end, reject, strlen(reject), EQU);
+}