summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@skysql.com>2014-08-11 23:55:41 -0400
committerNirbhay Choubey <nirbhay@skysql.com>2014-08-11 23:55:41 -0400
commit8358dd53b7406deaa9f50ad09b16a86b7e367632 (patch)
treeef8995ad0e400cb6a1842649c3c886c7b3474835 /mysql-test
parente06e12f5b8dfe0ab2e5976eec1b27b25d318441b (diff)
parent4105cbf4a230c82ea7dee31d4d2262b798fad9f4 (diff)
downloadmariadb-git-8358dd53b7406deaa9f50ad09b16a86b7e367632.tar.gz
bzr merge -r4346 maria/10.0 (maria-10.0.13)
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/gis_debug.inc161
-rw-r--r--mysql-test/include/gis_generic.inc13
-rw-r--r--mysql-test/include/have_mysql_upgrade.inc4
-rw-r--r--mysql-test/include/have_semisync_plugin.inc15
-rw-r--r--mysql-test/include/install_semisync.inc4
-rw-r--r--mysql-test/include/mtr_warnings.sql1
-rw-r--r--mysql-test/include/mysql_upgrade_preparation.inc7
-rw-r--r--mysql-test/include/search_pattern_in_file.inc17
-rw-r--r--mysql-test/include/show_events.inc2
-rw-r--r--mysql-test/include/stop_dump_threads.inc32
-rw-r--r--mysql-test/include/uninstall_semisync.inc5
-rw-r--r--mysql-test/mtr.out-of-source6
-rw-r--r--mysql-test/r/ctype_ucs.result33
-rw-r--r--mysql-test/r/ctype_upgrade.result30
-rw-r--r--mysql-test/r/ctype_utf32.result33
-rw-r--r--mysql-test/r/features.result16
-rw-r--r--mysql-test/r/func_str.result3
-rw-r--r--mysql-test/r/func_time.result79
-rw-r--r--mysql-test/r/gis-debug.result294
-rw-r--r--mysql-test/r/gis-precise.result353
-rw-r--r--mysql-test/r/gis.result11
-rw-r--r--mysql-test/r/group_min_max.result56
-rw-r--r--mysql-test/r/group_min_max_innodb.result168
-rw-r--r--mysql-test/r/have_mysql_upgrade.result2
-rw-r--r--mysql-test/r/huge_frm-6224.result1
-rw-r--r--mysql-test/r/innodb_load_xa.result21
-rw-r--r--mysql-test/r/innodb_mysql_lock2.result55
-rw-r--r--mysql-test/r/innodb_mysql_sync.result3
-rw-r--r--mysql-test/r/ipv4_and_ipv6.result58
-rw-r--r--mysql-test/r/key_cache.result33
-rw-r--r--mysql-test/r/lock_sync.result103
-rw-r--r--mysql-test/r/log_tables_upgrade.result15
-rw-r--r--mysql-test/r/myisam_explain_non_select_all.result25
-rw-r--r--mysql-test/r/mysql_client_test_comp.result4
-rw-r--r--mysql-test/r/mysql_upgrade.result154
-rw-r--r--mysql-test/r/mysql_upgrade_no_innodb.result46
-rw-r--r--mysql-test/r/mysql_upgrade_ssl.result15
-rw-r--r--mysql-test/r/mysqld--help.result10
-rw-r--r--mysql-test/r/mysqltest.result3
-rw-r--r--mysql-test/r/order_by_innodb.result13
-rw-r--r--mysql-test/r/order_by_sortkey.result2
-rw-r--r--mysql-test/r/partition.result44
-rw-r--r--mysql-test/r/partition_innodb.result28
-rw-r--r--mysql-test/r/partition_pruning.result114
-rw-r--r--mysql-test/r/plugin_loaderr.result3
-rw-r--r--mysql-test/r/rpl_mysqldump_slave.result41
-rw-r--r--mysql-test/r/single_delete_update.result42
-rw-r--r--mysql-test/r/stat_tables-enospc.result10
-rw-r--r--mysql-test/r/subselect_mat.result37
-rw-r--r--mysql-test/r/subselect_sj_mat.result37
-rw-r--r--mysql-test/r/table_options-5867.result37
-rw-r--r--mysql-test/r/type_bit.result7
-rw-r--r--mysql-test/r/type_bit_innodb.result9
-rw-r--r--mysql-test/r/type_decimal.result4
-rw-r--r--mysql-test/r/type_newdecimal.result6
-rw-r--r--mysql-test/r/union.result34
-rw-r--r--mysql-test/r/variables.result4
-rw-r--r--mysql-test/r/view.result94
-rwxr-xr-x[-rw-r--r--]mysql-test/std_data/checkDBI_DBD-mysql.pl0
-rw-r--r--mysql-test/std_data/mdev6020-mysql-bin.000001bin0 -> 516117 bytes
-rw-r--r--mysql-test/std_data/new-format-relay-log-win.info6
-rw-r--r--mysql-test/std_data/new-format-relay-log.info6
-rw-r--r--mysql-test/std_data/old-format-relay-log-win.info4
-rw-r--r--mysql-test/std_data/old-format-relay-log.info4
-rw-r--r--mysql-test/suite/archive/partition_archive.result26
-rw-r--r--mysql-test/suite/archive/partition_archive.test18
-rw-r--r--mysql-test/suite/binlog/t/binlog_killed.test4
-rw-r--r--mysql-test/suite/engines/iuds/r/insert_time.result4
-rw-r--r--mysql-test/suite/engines/iuds/suite.opt2
-rw-r--r--mysql-test/suite/innodb/include/innodb_simulate_comp_failures.inc147
-rw-r--r--mysql-test/suite/innodb/r/blob_unique2pk.result15
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-table-disk-full.result50
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk.result35
-rw-r--r--mysql-test/suite/innodb/r/innodb-stats-initialize-failure.result32
-rw-r--r--mysql-test/suite/innodb/r/innodb_simulate_comp_failures.result8
-rw-r--r--mysql-test/suite/innodb/r/innodb_simulate_comp_failures_small.result8
-rw-r--r--mysql-test/suite/innodb/t/blob_unique2pk.test20
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-table-disk-full-master.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-table-disk-full.test47
-rw-r--r--mysql-test/suite/innodb/t/innodb-fk.test86
-rw-r--r--mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test39
-rw-r--r--mysql-test/suite/innodb/t/innodb_simulate_comp_failures-master.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test8
-rw-r--r--mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small-master.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small.test5
-rw-r--r--mysql-test/suite/maria/maria3.result1
-rw-r--r--mysql-test/suite/maria/maria_partition.result15
-rw-r--r--mysql-test/suite/maria/maria_partition.test22
-rw-r--r--mysql-test/suite/plugins/r/false_dupes-6543.result5
-rw-r--r--mysql-test/suite/plugins/t/false_dupes-6543.test18
-rw-r--r--mysql-test/suite/roles/ip-6401.result13
-rw-r--r--mysql-test/suite/roles/ip-6401.test13
-rw-r--r--mysql-test/suite/rpl/r/failed_create_view-6409.result15
-rw-r--r--mysql-test/suite/rpl/r/kill_hard-6290.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_checksum.result26
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result119
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_crash.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_errorlog.result42
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_master_promote.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_stop_start.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_until.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_heartbeat_debug.result25
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev6020.result49
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev6386.result56
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel.result34
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel_retry.result196
-rw-r--r--mysql-test/suite/rpl/r/rpl_read_new_relay_log_info.result14
-rw-r--r--mysql-test/suite/rpl/r/rpl_read_old_relay_log_info.result14
-rw-r--r--mysql-test/suite/rpl/r/rpl_semi_sync_uninstall_plugin.result63
-rw-r--r--mysql-test/suite/rpl/r/rpl_skip_incident.result25
-rw-r--r--mysql-test/suite/rpl/r/rpl_stop_slave.result7
-rw-r--r--mysql-test/suite/rpl/r/rpl_table_options.result6
-rw-r--r--mysql-test/suite/rpl/t/failed_create_view-6409.test24
-rw-r--r--mysql-test/suite/rpl/t/kill_hard-6290.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_checksum.test58
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_basic.test127
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_crash.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_errorlog.test76
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_master_promote.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_stop_start.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_until.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_heartbeat_debug.test52
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev6020.test70
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev6386-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev6386.test71
-rw-r--r--mysql-test/suite/rpl/t/rpl_mysql_upgrade.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel.test57
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_retry.test220
-rw-r--r--mysql-test/suite/rpl/t/rpl_read_new_relay_log_info.test43
-rw-r--r--mysql-test/suite/rpl/t/rpl_read_old_relay_log_info.test44
-rw-r--r--mysql-test/suite/rpl/t/rpl_semi_sync_uninstall_plugin.test138
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_incident-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_incident-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_incident.test28
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_stop_slave.test27
-rw-r--r--mysql-test/suite/rpl/t/rpl_table_options.test2
-rw-r--r--mysql-test/suite/sys_vars/r/aria_pagecache_file_hash_size_basic.result21
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_simulate_comp_failures_basic.result77
-rw-r--r--mysql-test/suite/sys_vars/r/key_cache_file_hash_size_basic.result114
-rw-r--r--mysql-test/suite/sys_vars/r/timed_mutexes_basic.result20
-rw-r--r--mysql-test/suite/sys_vars/t/aria_pagecache_file_hash_size_basic.test22
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_simulate_comp_failures_basic.test64
-rw-r--r--mysql-test/suite/sys_vars/t/key_cache_file_hash_size_basic.test168
-rw-r--r--mysql-test/suite/sys_vars/t/report_port_basic.test2
-rw-r--r--mysql-test/t/ctype_ucs.test17
-rw-r--r--mysql-test/t/ctype_utf32.test16
-rw-r--r--mysql-test/t/features.test19
-rw-r--r--mysql-test/t/func_str.test5
-rw-r--r--mysql-test/t/func_time.test46
-rw-r--r--mysql-test/t/gis-debug.test6
-rw-r--r--mysql-test/t/gis-precise.test47
-rw-r--r--mysql-test/t/gis.test12
-rw-r--r--mysql-test/t/group_min_max.test25
-rw-r--r--mysql-test/t/group_min_max_innodb.test93
-rw-r--r--mysql-test/t/huge_frm-6224.test20
-rw-r--r--mysql-test/t/innodb_load_xa.opt1
-rw-r--r--mysql-test/t/innodb_load_xa.test18
-rw-r--r--mysql-test/t/innodb_mysql_lock2.test55
-rw-r--r--mysql-test/t/ipv4_and_ipv6.opt1
-rw-r--r--mysql-test/t/ipv4_and_ipv6.test13
-rw-r--r--mysql-test/t/key_cache.test32
-rw-r--r--mysql-test/t/lock_sync.test114
-rw-r--r--mysql-test/t/log_tables_upgrade.test8
-rwxr-xr-x[-rw-r--r--]mysql-test/t/long_tmpdir-master.sh0
-rwxr-xr-x[-rw-r--r--]mysql-test/t/lowercase_mixed_tmpdir-master.sh0
-rw-r--r--mysql-test/t/mysql_client_test-master.opt1
-rw-r--r--mysql-test/t/mysql_client_test_comp-master.opt2
-rw-r--r--mysql-test/t/mysql_client_test_comp.test20
-rw-r--r--mysql-test/t/mysql_client_test_nonblock-master.opt1
-rw-r--r--mysql-test/t/mysqltest.test8
-rw-r--r--mysql-test/t/order_by_innodb.test23
-rw-r--r--mysql-test/t/partition.test41
-rw-r--r--mysql-test/t/partition_innodb.test28
-rw-r--r--mysql-test/t/partition_pruning.test48
-rw-r--r--mysql-test/t/plugin_loaderr.test16
-rw-r--r--mysql-test/t/rpl_mysqldump_slave.test49
-rw-r--r--mysql-test/t/stat_tables-enospc.test23
-rw-r--r--mysql-test/t/subselect_sj_mat.test33
-rw-r--r--mysql-test/t/table_options-5867.test30
-rw-r--r--mysql-test/t/type_bit.test4
-rw-r--r--mysql-test/t/type_bit_innodb.test9
-rw-r--r--mysql-test/t/union.test30
-rw-r--r--mysql-test/t/view.test104
-rw-r--r--mysql-test/valgrind.supp11
185 files changed, 6059 insertions, 363 deletions
diff --git a/mysql-test/include/gis_debug.inc b/mysql-test/include/gis_debug.inc
new file mode 100644
index 00000000000..c81932ef90c
--- /dev/null
+++ b/mysql-test/include/gis_debug.inc
@@ -0,0 +1,161 @@
+#
+# This is a shared file included from t/gis-precise.test and t/gis-debug.test
+#
+# - gis-precise.test is executed both in debug and production builds
+# and makes sure that the checked GIS functions return the expected results.
+#
+# - gis-debug.test is executed only in debug builds
+# (and is skipped in production builds).
+# gis-debug.test activates tracing of the internal GIS routines.
+# The trace log is printed to the client side warnings.
+# So gis-debug.test makes sure not only that the correct results are returned,
+# but also check *how* these results were generated - makes sure that
+# the internal GIS routines went through the expected data and code flow paths.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS p1;
+--enable_warnings
+
+DELIMITER |;
+CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
+BEGIN
+ DECLARE g GEOMETRY;
+ SET g=GeomFromText(geom);
+ SELECT geom AS `-----`;
+ SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
+END|
+DELIMITER ;|
+
+--disable_query_log
+
+--echo #
+--echo # Testing ST_BUFFER with positive distance
+--echo #
+
+CALL p1(1, 'POINT(0 0))');
+CALL p1(1, 'LineString(0 1, 1 1))');
+CALL p1(1, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(1, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+CALL p1(1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+CALL p1(1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+CALL p1(1, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(1, 'MultiLineString((0 0,2 2))');
+CALL p1(1, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(1, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+CALL p1(1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+CALL p1(1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+CALL p1(1, 'GeometryCollection(Point(0 0))');
+CALL p1(1, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+CALL p1(1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+CALL p1(1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--echo #
+--echo # Testing ST_BUFFER with zero distance
+--echo #
+
+CALL p1(0, 'POINT(0 0))');
+CALL p1(0, 'LineString(0 1, 1 1))');
+CALL p1(0, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(0, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+CALL p1(0, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+CALL p1(0, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+CALL p1(0, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(0, 'MultiLineString((0 0,2 2))');
+CALL p1(0, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(0, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(0, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+CALL p1(0, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+CALL p1(0, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+CALL p1(0, 'GeometryCollection(Point(0 0))');
+CALL p1(0, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(0, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(0, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(0, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+CALL p1(0, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+CALL p1(0, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--echo #
+--echo # Testing ST_BUFFER with negative distance
+--echo #
+
+CALL p1(-1, 'POINT(0 0))');
+CALL p1(-1, 'LineString(0 1, 1 1))');
+CALL p1(-1, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(-1, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+#
+# Wrong shape
+# CALL p1(-1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+# Wrong shape
+# CALL p1(-1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+#
+CALL p1(-1, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(-1, 'MultiLineString((0 0,2 2))');
+CALL p1(-1, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(-1, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(-1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+#
+# Wrong shape
+#CALL p1(-1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+#CALL p1(-1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+#
+CALL p1(-1, 'GeometryCollection(Point(0 0))');
+CALL p1(-1, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(-1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(-1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(-1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+#
+# Wrong shape
+# CALL p1(-1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+#
+CALL p1(-1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--enable_query_log
+
+SELECT ST_CONTAINS(
+ GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+ GeomFromText('POINT(5 10)'));
+SELECT AsText(ST_UNION(
+ GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+ GeomFromText('POINT(5 10)')));
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
+--echo #
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
+
+--echo #
+--echo # Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
+--echo #
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
+
+
+--echo #
+--echo # Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
+--echo #
+
+DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
+
+SELECT ST_WITHIN(
+ LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
+ ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
+
+SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
+
+SELECT ST_NUMINTERIORRINGS(
+ ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+ SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
+
+SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+ SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
diff --git a/mysql-test/include/gis_generic.inc b/mysql-test/include/gis_generic.inc
index e4fee4448c1..59acf04dfa2 100644
--- a/mysql-test/include/gis_generic.inc
+++ b/mysql-test/include/gis_generic.inc
@@ -72,6 +72,19 @@ INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE gis_point;
+ANALYZE TABLE gis_line;
+ANALYZE TABLE gis_polygon;
+ANALYZE TABLE gis_multi_point;
+ANALYZE TABLE gis_multi_line;
+ANALYZE TABLE gis_multi_polygon;
+ANALYZE TABLE gis_geometrycollection;
+ANALYZE TABLE gis_geometry;
+-- enable_result_log
+-- enable_query_log
+
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
diff --git a/mysql-test/include/have_mysql_upgrade.inc b/mysql-test/include/have_mysql_upgrade.inc
deleted file mode 100644
index 8f486176018..00000000000
--- a/mysql-test/include/have_mysql_upgrade.inc
+++ /dev/null
@@ -1,4 +0,0 @@
---require r/have_mysql_upgrade.result
---disable_query_log
-select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
---enable_query_log
diff --git a/mysql-test/include/have_semisync_plugin.inc b/mysql-test/include/have_semisync_plugin.inc
new file mode 100644
index 00000000000..8a1679de636
--- /dev/null
+++ b/mysql-test/include/have_semisync_plugin.inc
@@ -0,0 +1,15 @@
+#
+# Check if server has support for loading plugins
+#
+if (`SELECT @@have_dynamic_loading != 'YES'`) {
+ --skip Requires dynamic loading
+}
+
+#
+# Check if the variable SEMISYNC_MASTER_SO is set
+#
+if (!$SEMISYNC_MASTER_SO)
+{
+ skip Need semisync plugins;
+}
+
diff --git a/mysql-test/include/install_semisync.inc b/mysql-test/include/install_semisync.inc
index 368b7b7cb4a..9cc6df2072a 100644
--- a/mysql-test/include/install_semisync.inc
+++ b/mysql-test/include/install_semisync.inc
@@ -14,7 +14,7 @@
if ($value == No such row)
{
SET sql_log_bin = 0;
- eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN';
+ install plugin rpl_semi_sync_master soname 'semisync_master';
SET GLOBAL rpl_semi_sync_master_enabled = 1;
SET sql_log_bin = 1;
}
@@ -28,7 +28,7 @@ if ($value == No such row)
if ($value == No such row)
{
SET sql_log_bin = 0;
- eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN';
+ install plugin rpl_semi_sync_slave soname 'semisync_slave';
SET GLOBAL rpl_semi_sync_slave_enabled = 1;
SET sql_log_bin = 1;
}
diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql
index 06a7b49e979..97309be0857 100644
--- a/mysql-test/include/mtr_warnings.sql
+++ b/mysql-test/include/mtr_warnings.sql
@@ -159,6 +159,7 @@ INSERT INTO global_suppressions VALUES
("InnoDB: Error: in ALTER TABLE `test`.`t[123]`"),
("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
("InnoDB: Error: table `test`.`t[123]` .*does not exist in the InnoDB internal"),
+ ("InnoDB: Warning: semaphore wait:"),
/*
BUG#32080 - Excessive warnings on Solaris: setrlimit could not
diff --git a/mysql-test/include/mysql_upgrade_preparation.inc b/mysql-test/include/mysql_upgrade_preparation.inc
index a3c81c4c1e7..03019ae29ff 100644
--- a/mysql-test/include/mysql_upgrade_preparation.inc
+++ b/mysql-test/include/mysql_upgrade_preparation.inc
@@ -2,13 +2,6 @@
# Can't run test of external client with embedded server
-- source include/not_embedded.inc
-
-# Only run test if "mysql_upgrade" is found
---require r/have_mysql_upgrade.result
---disable_query_log
-select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
---enable_query_log
-
#
# Hack:
#
diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc
index c047b5bc499..0d09cdcd36e 100644
--- a/mysql-test/include/search_pattern_in_file.inc
+++ b/mysql-test/include/search_pattern_in_file.inc
@@ -10,6 +10,10 @@
# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
# before sourcing this routine.
#
+# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
+# to search. If negative, it will search that many bytes at the end of the
+# file. The default is to search only the first 50000 bytes of the file.
+#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
@@ -38,6 +42,7 @@
# --error 0,1
# --remove_file $error_log
# let SEARCH_FILE= $error_log;
+# let SEARCH_RANGE= -50000;
# # Stop the server
# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
# --exec echo "wait" > $restart_file
@@ -57,8 +62,18 @@ perl;
use strict;
my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
+ my $search_range= $ENV{'SEARCH_RANGE'};
+ my $file_content;
+ $search_range= 50000 unless $search_range =~ /-?[0-9]+/;
open(FILE, "$search_file") or die("Unable to open '$search_file': $!\n");
- read(FILE, my $file_content, 50000, 0);
+ if ($search_range >= 0) {
+ read(FILE, $file_content, $search_range, 0);
+ } else {
+ my $size= -s $search_file;
+ $search_range = -$size if $size > -$search_range;
+ seek(FILE, $search_range, 2);
+ read(FILE, $file_content, -$search_range, 0);
+ }
close(FILE);
if ( not $file_content =~ m{$search_pattern} ) {
die("# ERROR: The file '$search_file' does not contain the expected pattern $search_pattern\n->$file_content<-\n");
diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc
index f7b0931c812..9a39ec67d0e 100644
--- a/mysql-test/include/show_events.inc
+++ b/mysql-test/include/show_events.inc
@@ -83,7 +83,7 @@ let $script=
s{block_len=[0-9]+}{block_len=#};
s{Server ver:.*DOLLAR}{SERVER_VERSION, BINLOG_VERSION};
s{GTID [0-9]+-[0-9]+-[0-9]+}{GTID #-#-#};
- s{\[[0-9]-[0-9]-[0-9]+\]}{[#-#-#]};
+ s{\[([0-9]-[0-9]-[0-9]+,?)+\]}{[#-#-#]};
s{cid=[0-9]+}{cid=#};
s{SQL_LOAD-[a-z,0-9,-]*.[a-z]*}{SQL_LOAD-<SERVER UUID>-<MASTER server-id>-<file-id>.<extension>};
s{rand_seed1=[0-9]*,rand_seed2=[0-9]*}{rand_seed1=<seed 1>,rand_seed2=<seed 2>};
diff --git a/mysql-test/include/stop_dump_threads.inc b/mysql-test/include/stop_dump_threads.inc
new file mode 100644
index 00000000000..ae33c963d9a
--- /dev/null
+++ b/mysql-test/include/stop_dump_threads.inc
@@ -0,0 +1,32 @@
+# ==== Purpose ====
+#
+# Stop all dump threads on the server of the current connection.
+#
+# ==== Usage ====
+#
+# --source include/stop_dump_threads.inc
+
+--let $include_filename= stop_dump_threads.inc
+--source include/begin_include_file.inc
+
+
+--let $_sdt_show_rpl_debug_info_old= $show_rpl_debug_info
+--let $show_rpl_debug_info= 1
+--disable_query_log
+--disable_result_log
+
+--let $_sdt_dump_thread_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND = 'Binlog dump'`
+
+while ($_sdt_dump_thread_id != '')
+{
+ eval KILL $_sdt_dump_thread_id;
+ --let $wait_condition= SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID = $_sdt_dump_thread_id
+ --source include/wait_condition.inc
+
+ --let $_sdt_dump_thread_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND = 'Binlog dump'`
+}
+
+--let $show_rpl_debug_info= $_sdt_show_rpl_debug_info_old
+
+--let $include_filename= stop_dump_threads.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/uninstall_semisync.inc b/mysql-test/include/uninstall_semisync.inc
index 11668d1db97..0a4c55fa4f2 100644
--- a/mysql-test/include/uninstall_semisync.inc
+++ b/mysql-test/include/uninstall_semisync.inc
@@ -13,6 +13,11 @@
UNINSTALL PLUGIN rpl_semi_sync_slave;
--connection master
+# After BUG#17638477 fix, uninstallation of rpl_semi_sync_master
+# is not allowed when there are semi sync slaves. Hence kill
+# all dump threads before uninstalling it.
+SET GLOBAL rpl_semi_sync_master_enabled = OFF;
+--source include/stop_dump_threads.inc
UNINSTALL PLUGIN rpl_semi_sync_master;
--enable_warnings
diff --git a/mysql-test/mtr.out-of-source b/mysql-test/mtr.out-of-source
index c2809ede136..51713517ae1 100644
--- a/mysql-test/mtr.out-of-source
+++ b/mysql-test/mtr.out-of-source
@@ -1,5 +1,5 @@
#!/usr/bin/perl
# Call mtr in out-of-source build
-$ENV{MTR_BINDIR} = "@CMAKE_BINARY_DIR@";
-chdir("@CMAKE_SOURCE_DIR@/mysql-test");
-exit(system($^X, "@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl", @ARGV) >> 8); \ No newline at end of file
+$ENV{MTR_BINDIR} = '@CMAKE_BINARY_DIR@';
+chdir('@CMAKE_SOURCE_DIR@/mysql-test');
+exit(system($^X, '@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl', @ARGV) >> 8);
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 492c9877917..c4236af1697 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -4508,6 +4508,39 @@ COALESCE(c1)
DROP TABLE t1;
#
+# MDEV-5745 analyze MySQL fix for bug#12368495
+#
+SELECT CHAR_LENGTH(TRIM(LEADING 0x000000 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(LEADING 0x000000 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(LEADING 0x00 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(LEADING 0x00 FROM _ucs2 0x0061))
+1
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x000000 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(TRAILING 0x000000 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _ucs2 0x0061))
+1
+SELECT CHAR_LENGTH(TRIM(BOTH 0x000000 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(BOTH 0x000000 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _ucs2 0x0061))
+2
+SELECT CHAR_LENGTH(TRIM(BOTH 0x61 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(BOTH 0x61 FROM _ucs2 0x0061))
+1
+SELECT CHAR_LENGTH(TRIM(BOTH 0x00 FROM _ucs2 0x0061));
+CHAR_LENGTH(TRIM(BOTH 0x00 FROM _ucs2 0x0061))
+1
+#
# End of 5.5 tests
#
#
diff --git a/mysql-test/r/ctype_upgrade.result b/mysql-test/r/ctype_upgrade.result
index 0fc73203494..3d23280c2e8 100644
--- a/mysql-test/r/ctype_upgrade.result
+++ b/mysql-test/r/ctype_upgrade.result
@@ -227,13 +227,8 @@ DROP TABLE mysql050614_xxx_croatian_ci;
# Checking mysql_upgrade
#
# Running mysql_upgrade
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -263,6 +258,13 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
test.maria050313_ucs2_croatian_ci_def Needs upgrade
@@ -276,17 +278,11 @@ test.maria050313_ucs2_croatian_ci_def OK
test.maria050313_utf8_croatian_ci OK
test.maria050533_xxx_croatian_ci OK
test.maria100004_xxx_croatian_ci OK
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
# Running mysql_upgrade for the second time
# This should report OK for all tables
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -316,6 +312,13 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
test.maria050313_ucs2_croatian_ci_def OK
@@ -323,7 +326,6 @@ test.maria050313_utf8_croatian_ci OK
test.maria050533_xxx_croatian_ci OK
test.maria100004_xxx_croatian_ci OK
test.mysql050614_xxx_croatian_ci OK
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
SHOW CREATE TABLE maria050313_ucs2_croatian_ci_def;
Table Create Table
diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result
index 214ec9f9b1d..01edaac88d7 100644
--- a/mysql-test/r/ctype_utf32.result
+++ b/mysql-test/r/ctype_utf32.result
@@ -1626,6 +1626,39 @@ SELECT '2010-10-10 10:10:10' + INTERVAL GeometryType(GeomFromText('POINT(1 1)'))
'2010-10-10 10:10:10' + INTERVAL GeometryType(GeomFromText('POINT(1 1)')) hour_second
2010-10-10 10:10:10
#
+# MDEV-5745 analyze MySQL fix for bug#12368495
+#
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0000000000 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(LEADING 0x0000000000 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(LEADING 0x00 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(LEADING 0x00 FROM _utf32 0x00000061))
+1
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0000000000 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(TRAILING 0x0000000000 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _utf32 0x00000061))
+3
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0000000000 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(BOTH 0x0000000000 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _utf32 0x00000061))
+4
+SELECT CHAR_LENGTH(TRIM(BOTH 0x61 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(BOTH 0x61 FROM _utf32 0x00000061))
+3
+SELECT CHAR_LENGTH(TRIM(BOTH 0x00 FROM _utf32 0x00000061));
+CHAR_LENGTH(TRIM(BOTH 0x00 FROM _utf32 0x00000061))
+1
+#
# End of 5.5 tests
#
#
diff --git a/mysql-test/r/features.result b/mysql-test/r/features.result
index 7b6a352ab0c..66d2c6bf71d 100644
--- a/mysql-test/r/features.result
+++ b/mysql-test/r/features.result
@@ -1,6 +1,8 @@
drop table if exists t1;
+flush status;
show status like "feature%";
Variable_name Value
+Feature_delay_key_write 0
Feature_dynamic_columns 0
Feature_fulltext 0
Feature_gis 0
@@ -138,3 +140,17 @@ upd1
show status like "feature_xml";
Variable_name Value
Feature_xml 2
+#
+# Feature delayed_keys
+#
+create table t1 (a int, key(a)) engine=myisam delay_key_write=1;
+insert into t1 values(1);
+insert into t1 values(2);
+drop table t1;
+create table t1 (a int, key(a)) engine=aria delay_key_write=1;
+insert into t1 values(1);
+insert into t1 values(2);
+drop table t1;
+show status like "feature_delay_key_write";
+Variable_name Value
+Feature_delay_key_write 2
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index e5edabb0130..44a67fe6b27 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -2961,6 +2961,9 @@ replace(var, '00000000', table_name)
(( t2 ++ t2 ))
drop procedure foo;
drop table t1,t2;
+select md5(_filename "a"), sha(_filename "a");
+md5(_filename "a") sha(_filename "a")
+0cc175b9c0f1b6a831c399e269772661 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
#
# End of 5.5 tests
#
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index db68f08cbba..bf07595bc3a 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -2023,10 +2023,72 @@ SEC_TO_TIME(1.12)+0.1 decimal(14,2) YES NULL
SEC_TO_TIME(1.123456)+0.1 decimal(18,6) YES NULL
SEC_TO_TIME(1.1234567)+0.1 decimal(18,6) YES NULL
DROP TABLE t1;
+CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
+a
+2000-02-23
+2005-05-04
+SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
+a
+2005-05-04
+2000-02-23
+SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
+a
+2005-05-04
+2000-02-23
+SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
+a
+2000-02-23
+2005-05-04
+SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);
+a
+2000-02-23
+2005-05-04
+DROP TABLE t1;
+SET TIME_ZONE='+02:00';
+#
+# MDEV-6302 Wrong result set when using GROUP BY FROM_UNIXTIME(...)+0
+#
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, FROM_UNIXTIME(CONCAT(a,'10'))+0 AS f2 FROM t1;
+a f1 f2
+2005-05-04 1970-01-01 02:33:25 19700101023325.000000
+2000-02-23 1970-01-01 02:33:20 19700101023320.000000
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(CONCAT(a,'10'))+0;
+a
+2000-02-23
+2005-05-04
+DROP TABLE t1;
+CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))/1;
+a
+2000-02-23
+2005-05-04
+DROP TABLE t1;
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES ('2005-05-04');
+SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
+f2
+0.000000
+SELECT CHAR_LENGTH(CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10')))) AS f2 FROM t1;
+f2
+8
+CREATE TABLE t2 AS SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f2` varchar(26) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+f2
+0.000000
+DROP TABLE t1,t2;
#
# MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
#
-SET TIME_ZONE='+02:00';
SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'));
UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
NULL
@@ -2600,3 +2662,18 @@ SELECT COALESCE(TIME'10:20:30',DATE'2001-01-01');
COALESCE(TIME'10:20:30',DATE'2001-01-01')
2014-04-15 10:20:30
SET timestamp=DEFAULT;
+#
+# MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column
+#
+CREATE TABLE t1 ( d DATE, t TIME );
+INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02');
+SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1;
+EXTRACT(DAY_MINUTE FROM GREATEST(t,d)) GREATEST(t,d)
+342259 838:59:59
+342259 838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '9336:00:00'
+Warning 1292 Truncated incorrect time value: '9336:00:00'
+Warning 1292 Truncated incorrect time value: '2952:00:00'
+Warning 1292 Truncated incorrect time value: '2952:00:00'
+DROP TABLE t1;
diff --git a/mysql-test/r/gis-debug.result b/mysql-test/r/gis-debug.result
new file mode 100644
index 00000000000..8593f434c2b
--- /dev/null
+++ b/mysql-test/r/gis-debug.result
@@ -0,0 +1,294 @@
+SET @tmp=ST_GIS_DEBUG(1);
+DROP TABLE IF EXISTS p1;
+CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
+BEGIN
+DECLARE g GEOMETRY;
+SET g=GeomFromText(geom);
+SELECT geom AS `-----`;
+SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
+END|
+#
+# Testing ST_BUFFER with positive distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+1 POLYGON 3.14
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+1 POLYGON 5.14
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+1 POLYGON 44.63
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+1 POLYGON 63.14
+-----
+Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
+dist buffer buf_area
+1 POLYGON 95.14
+-----
+Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
+dist buffer buf_area
+1 POLYGON 174.93
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+1 MULTIPOLYGON 9.42
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+1 POLYGON 8.80
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+1 POLYGON 14.24
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+1 POLYGON 13.59
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+1 MULTIPOLYGON 70.06
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+1 POLYGON 73.18
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+1 POLYGON 73.18
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+1 POLYGON 3.14
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+1 POLYGON 8.80
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+1 POLYGON 63.14
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+1 MULTIPOLYGON 9.42
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+1 MULTIPOLYGON 10.28
+-----
+GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
+dist buffer buf_area
+1 MULTIPOLYGON 48.28
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+1 POLYGON 75.92
+#
+# Testing ST_BUFFER with zero distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+0 POINT 0.00
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+0 LINESTRING 0.00
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+0 LINESTRING 0.00
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+0 POLYGON 36.00
+-----
+Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
+dist buffer buf_area
+0 POLYGON 48.00
+-----
+Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
+dist buffer buf_area
+0 POLYGON 116.00
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+0 MULTIPOINT NULL
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+0 MULTIPOLYGON 66.00
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+0 MULTIPOLYGON 62.00
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 36.00
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION NULL
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION NULL
+-----
+GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 18.00
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 36.00
+#
+# Testing ST_BUFFER with negative distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+-1 POLYGON 16.00
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+-1 POLYGON 16.00
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+-1 POLYGON 16.00
+SELECT ST_CONTAINS(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)'));
+ST_CONTAINS(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)'))
+0
+SELECT AsText(ST_UNION(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)')));
+AsText(ST_UNION(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)')))
+GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)),POLYGON((6 6,6 11,11 11,11 6,6 6)),POINT(5 10))
+DROP PROCEDURE p1;
+#
+# Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
+#
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
+GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3))
+POLYGON
+#
+# Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
+#
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
+GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1))
+POLYGON
+#
+# Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
+#
+DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
+SELECT ST_WITHIN(
+LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
+ST_WITHIN(
+LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) ')
+0
+SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
+ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))))
+2
+SELECT ST_NUMINTERIORRINGS(
+ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
+ST_NUMINTERIORRINGS(
+ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))))
+0
+SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
+ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))))
+POLYGON((9 9,5 2,4 5,9 9))
diff --git a/mysql-test/r/gis-precise.result b/mysql-test/r/gis-precise.result
index 71eed65b2ea..c0b8b85d216 100644
--- a/mysql-test/r/gis-precise.result
+++ b/mysql-test/r/gis-precise.result
@@ -156,19 +156,19 @@ POLYGON((1 0,0.950932325672582 0.001204543794827595,0.9019828596704393 0.0048152
create table t1(geom geometrycollection);
insert into t1 values (geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))'));
insert into t1 values (geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))'));
-select astext(geom), area(geom),area(ST_buffer(geom,2)) from t1;
-astext(geom) area(geom) area(ST_buffer(geom,2))
-POLYGON((0 0,10 10,0 8,0 0)) 40 117.2416763959153
-POLYGON((1 1,10 10,0 8,1 1)) 36 108.55539589266459
-select astext(ST_buffer(geom,2)) from t1;
-astext(ST_buffer(geom,2))
-POLYGON((0 -2,-0.09813534865483604 -1.9975909124103448,-0.1960342806591212 -1.9903694533443936,-0.2934609489107236 -1.978353019929562,-0.3901806440322566 -1.9615705608064609,-0.4859603598065278 -1.940062506389088,-0.5805693545089246 -1.9138806714644179,-0.6737797067844402 -1.8830881303660416,-0.7653668647301796 -1.8477590650225735,-0.8551101868605642 -1.8079785862468867,-0.9427934736519952 -1.7638425286967099,-1.0282054883864433 -1.7154572200005442,-1.1111404660392044 -1.6629392246050905,-1.1913986089848667 -1.6064150629612897,-1.268786568327291 -1.546020906725474,-1.3431179096940367 -1.4819022507099182,-1.414213562373095 -1.414213562373095,-1.4819022507099182 -1.3431179096940367,-1.546020906725474 -1.268786568327291,-1.6064150629612897 -1.1913986089848667,-1.6629392246050905 -1.1111404660392044,-1.7154572200005442 -1.0282054883864433,-1.7638425286967099 -0.9427934736519952,-1.8079785862468867 -0.8551101868605642,-1.8477590650225735 -0.7653668647301796,-1.8830881303660416 -0.6737797067844402,-1.9138806714644179 -0.5805693545089246,-1.940062506389088 -0.4859603598065278,-1.9615705608064609 -0.3901806440322566,-1.978353019929562 -0.2934609489107236,-1.9903694533443936 -0.1960342806591212,-1.9975909124103448 -0.09813534865483604,-2 0,-2 8,-1.9976924709932495 8.096045777298562,-1.9905734200023315 8.193952209526529,-1.978658903288988 8.291391393893539,-1.9619776239675701 8.388128590869789,-1.940569768701071 8.483930752074583,-1.9144869108879337 8.578567081710304,-1.8837918864172196 8.67180959256969,-1.848558642291444 8.763433655277009,-1.8088720584817741 8.853218539439872,-1.7648277434447421 8.940947945408109,-1.716531803793098 9.02641052535855,-1.6641005886756872 9.109400392450459,-1.6076604094821603 9.189717616824955,-1.5473472355477698 9.267168707253568,-1.483306366591334 9.341567077275533,-1.415692082675486 9.412733494700944,-1.3446672725324915 9.480496513396783,-1.2704030411510234 9.54469288631567,-1.1930782975692584 9.605167958772302,-1.1128793238673322 9.661776041020147,-1.0299993263974934 9.714380759230782,-0.9446379703330767 9.762855384030411,-0.8570008986576141 9.807083135802014,-0.7672992367528719 9.846957466017683,-0.6757490837793165 9.882382313923348,-0.5825709920743072 9.913272337957553,-0.4879894358221987 9.939553121346753,-0.3922322702763681 9.96116135138184,9.607767729723632 11.96116135138184,9.609819355967744 11.96157056080646,9.706539051089276 11.978353019929562,9.803965719340878 11.990369453344393,9.901864651345164 11.997590912410345,10 12,10.098135348654836 11.997590912410345,10.196034280659122 11.990369453344393,10.293460948910724 11.978353019929562,10.390180644032256 11.96157056080646,10.485960359806528 11.940062506389088,10.580569354508924 11.913880671464417,10.67377970678444 11.88308813036604,10.76536686473018 11.847759065022574,10.855110186860564 11.807978586246886,10.942793473651996 11.76384252869671,11.028205488386444 11.715457220000545,11.111140466039204 11.66293922460509,11.191398608984866 11.60641506296129,11.268786568327291 11.546020906725474,11.343117909694037 11.481902250709918,11.414213562373096 11.414213562373096,11.481902250709918 11.343117909694037,11.546020906725474 11.268786568327291,11.60641506296129 11.191398608984866,11.66293922460509 11.111140466039204,11.715457220000545 11.028205488386444,11.76384252869671 10.942793473651996,11.807978586246886 10.855110186860564,11.847759065022574 10.76536686473018,11.88308813036604 10.67377970678444,11.913880671464417 10.580569354508924,11.940062506389088 10.485960359806528,11.96157056080646 10.390180644032256,11.978353019929562 10.293460948910724,11.990369453344393 10.196034280659122,11.997590912410345 10.098135348654836,12 10,11.997590912410345 9.901864651345164,11.990369453344393 9.803965719340878,11.978353019929562 9.706539051089276,11.96157056080646 9.609819355967744,11.940062506389088 9.514039640193472,11.913880671464417 9.419430645491076,11.88308813036604 9.32622029321556,11.847759065022574 9.23463313526982,11.807978586246886 9.144889813139436,11.76384252869671 9.057206526348004,11.715457220000545 8.971794511613556,11.66293922460509 8.888859533960796,11.60641506296129 8.808601391015134,11.546020906725474 8.731213431672709,11.481902250709918 8.656882090305963,11.414213562373096 8.585786437626904,1.414213562373095 -1.414213562373095,1.3431179096940367 -1.4819022507099182,1.268786568327291 -1.546020906725474,1.1913986089848667 -1.6064150629612897,1.1111404660392044 -1.6629392246050905,1.0282054883864433 -1.7154572200005442,0.9427934736519952 -1.7638425286967099,0.8551101868605642 -1.8079785862468867,0.7653668647301796 -1.8477590650225735,0.6737797067844402 -1.8830881303660416,0.5805693545089246 -1.9138806714644179,0.4859603598065278 -1.940062506389088,0.3901806440322566 -1.9615705608064609,0.2934609489107236 -1.978353019929562,0.1960342806591212 -1.9903694533443936,0.09813534865483604 -1.9975909124103448,0 -2))
-POLYGON((0.9892698494111194 -0.9999712157599518,0.8911488380683092 -0.9970356593075951,0.7932900587088283 -0.9892890690323013,0.6959292617035704 -0.9767501071485654,0.5993009977403192 -0.959448981113848,0.5036380527705995 -0.9374273708561667,0.40917088720792716 -0.9107383283634973,0.3161270807284893 -0.8794461498768888,0.2247307840117696 -0.843626220995187,0.13520217874192864 -0.8033648350645226,0.04775694717084156 -0.7587589852900836,-0.03739424747933939 -0.7099161310709878,-0.12004626852233802 -0.6569539391211774,-0.19999999999999996 -0.5999999999999999,-0.27706282637007584 -0.5391915207353741,-0.35104909653393324 -0.47467499428004234,-0.42178057108631606 -0.40660584659721555,-0.4890868517096818 -0.3351480622258147,-0.5528057916786753 -0.26047378922735365,-0.6127838864857904 -0.18276292446617926,-0.6688766436471771 -0.10220268022216916,-0.7209489307976877 -0.018987133179951154,-0.7688753012365837 0.06668324311882912,-0.8125402961396226 0.15460206123382925,-0.8518387227094812 0.2445575170314307,-0.8866759075944177 0.33633289993945015,-0.9169679249646674 0.4297071150218881,-0.9426417986971172 0.5244552156159955,-0.9636356781811806 0.6203489452484875,-0.9798989873223332 0.717157287525381,-1.9798989873223332 7.717157287525381,-1.990163308912474 7.8018838627003015,-1.9974871681520578 7.899775187364235,-1.9999989058443504 7.997907962380466,-1.9976924709932495 8.096045777298562,-1.9905734200023315 8.193952209526529,-1.978658903288988 8.291391393893539,-1.9619776239675701 8.388128590869789,-1.940569768701071 8.483930752074583,-1.9144869108879337 8.578567081710304,-1.8837918864172196 8.67180959256969,-1.848558642291444 8.763433655277009,-1.8088720584817741 8.853218539439872,-1.7648277434447421 8.940947945408109,-1.716531803793098 9.02641052535855,-1.6641005886756872 9.109400392450459,-1.6076604094821603 9.189717616824955,-1.5473472355477698 9.267168707253568,-1.483306366591334 9.341567077275533,-1.415692082675486 9.412733494700944,-1.3446672725324915 9.480496513396783,-1.2704030411510234 9.54469288631567,-1.1930782975692584 9.605167958772302,-1.1128793238673322 9.661776041020147,-1.0299993263974934 9.714380759230782,-0.9446379703330767 9.762855384030411,-0.8570008986576141 9.807083135802014,-0.7672992367528719 9.846957466017683,-0.6757490837793165 9.882382313923348,-0.5825709920743072 9.913272337957553,-0.4879894358221987 9.939553121346753,-0.3922322702763681 9.96116135138184,9.607767729723632 11.96116135138184,9.609819355967744 11.96157056080646,9.706539051089276 11.978353019929562,9.803965719340878 11.990369453344393,9.901864651345164 11.997590912410345,10 12,10.098135348654836 11.997590912410345,10.196034280659122 11.990369453344393,10.293460948910724 11.978353019929562,10.390180644032256 11.96157056080646,10.485960359806528 11.940062506389088,10.580569354508924 11.913880671464417,10.67377970678444 11.88308813036604,10.76536686473018 11.847759065022574,10.855110186860564 11.807978586246886,10.942793473651996 11.76384252869671,11.028205488386444 11.715457220000545,11.111140466039204 11.66293922460509,11.191398608984866 11.60641506296129,11.268786568327291 11.546020906725474,11.343117909694037 11.481902250709918,11.414213562373096 11.414213562373096,11.481902250709918 11.343117909694037,11.546020906725474 11.268786568327291,11.60641506296129 11.191398608984866,11.66293922460509 11.111140466039204,11.715457220000545 11.028205488386444,11.76384252869671 10.942793473651996,11.807978586246886 10.855110186860564,11.847759065022574 10.76536686473018,11.88308813036604 10.67377970678444,11.913880671464417 10.580569354508924,11.940062506389088 10.485960359806528,11.96157056080646 10.390180644032256,11.978353019929562 10.293460948910724,11.990369453344393 10.196034280659122,11.997590912410345 10.098135348654836,12 10,11.997590912410345 9.901864651345164,11.990369453344393 9.803965719340878,11.978353019929562 9.706539051089276,11.96157056080646 9.609819355967744,11.940062506389088 9.514039640193472,11.913880671464417 9.419430645491076,11.88308813036604 9.32622029321556,11.847759065022574 9.23463313526982,11.807978586246886 9.144889813139436,11.76384252869671 9.057206526348004,11.715457220000545 8.971794511613556,11.66293922460509 8.888859533960796,11.60641506296129 8.808601391015134,11.546020906725474 8.731213431672709,11.481902250709918 8.656882090305963,11.414213562373096 8.585786437626904,2.414213562373095 -0.4142135623730949,2.4066058465972153 -0.42178057108631606,2.335148062225815 -0.4890868517096818,2.260473789227354 -0.5528057916786753,2.1827629244661795 -0.6127838864857904,2.1022026802221694 -0.6688766436471771,2.018987133179951 -0.7209489307976877,1.9333167568811709 -0.7688753012365837,1.8453979387661708 -0.8125402961396226,1.7554424829685693 -0.8518387227094812,1.6636671000605499 -0.8866759075944177,1.570292884978112 -0.9169679249646674,1.4755447843840046 -0.9426417986971172,1.3796510547515126 -0.9636356781811806,1.282842712474619 -0.9798989873223332,1.1853529773292786 -0.9913925463843567,1.0874167106265484 -0.9980886663767536,0.9892698494111194 -0.9999712157599518))
+select astext(geom), area(geom),round(area(ST_buffer(geom,2)), 7) from t1;
+astext(geom) area(geom) round(area(ST_buffer(geom,2)), 7)
+POLYGON((0 0,10 10,0 8,0 0)) 40 117.2416764
+POLYGON((1 1,10 10,0 8,1 1)) 36 108.5553959
+select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1;
+ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2)))
+133
+134
set @geom=geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
set @buff=ST_buffer(@geom,1);
-select astext(@buff);
-astext(@buff)
-POLYGON((2.0218594008566466 0.00023894525032219782,1.9727771204112932 0.00037061126290494073,1.9237604222673113 0.002910472030148492,1.8749273919438858 0.0078524088049996,1.8263956724883341 0.015184516028905026,1.7782821810637013 0.024889130013345362,1.7307028272850733 0.03694287149320841,1.683772233983162 0.05131670194948634,1.6376034610678665 0.06797599356561079,1.592307733157046 0.08688061264889702,1.5479941716266756 0.10798501631612445,1.504769531727891 0.13123836221033125,1.46273794540424 0.1565846309845056,1.4220006704287085 0.18396276125709976,1.382655846464876 0.21330679671424568,1.3447982586398712 0.24454604500429356,1.3085191091986976 0.2776052480418776,1.2739057977900368 0.3124047633112361,1.241041710912841 0.34886075573200737,1.2100060210309511 0.38688539962528223,1.1808734958396978 0.4263870902933562,1.1537143181439746 0.46727066470347056,1.1285939167817136 0.5094376307438929,1.1055728090000843 0.5527864045000421,1.0847064546641425 0.5972125549790352,1.0660451226491614 0.6426090556930975,1.0496337697385036 0.6888665424957445,1.0355119323187965 0.7358735770495916,1.0237136311333106 0.7835169152910685,1.0142672893230111 0.8316817802452878,1.0071956639527206 0.8802521385338314,1.0025157911873577 0.9291109799093207,1.0002389452503222 0.9781405991433534,1.000370611262905 1.0272228795887068,1.0029104720301485 1.0762395777326887,1.0078524088049996 1.1250726080561142,1.015184516028905 1.1736043275116659,1.0248891300133454 1.2217178189362987,1.0369428714932085 1.2692971727149267,1.0513167019494865 1.316227766016838,1.0679759935656108 1.3623965389321335,1.086880612648897 1.407692266842954,1.1079850163161244 1.4520058283733244,1.1312383622103312 1.495230468272109,1.1565846309845056 1.53726205459576,1.1839627612570998 1.5779993295712915,1.2133067967142457 1.617344153535124,1.2445460450042936 1.6552017413601288,1.2776052480418776 1.6914808908013024,1.3124047633112361 1.7260942022099632,1.3488607557320074 1.758958289087159,1.3868853996252821 1.7899939789690489,1.4263870902933562 1.8191265041603022,1.4672706647034706 1.8462856818560254,1.5094376307438928 1.8714060832182864,1.5527864045000421 1.8944271909999157,1.7639320225002106 2,1.5527864045000421 2.1055728090000843,1.5286032631740025 2.118078735651645,1.4858972558067784 2.1422713899997277,1.4444297669803978 2.1685303876974547,1.4043006955075668 2.196792468519355,1.3656067158363545 2.226989546637263,1.3284410451529816 2.259048874645041,1.2928932188134525 2.2928932188134525,1.2590488746450408 2.3284410451529816,1.2269895466372631 2.3656067158363543,1.1967924685193552 2.4043006955075668,1.1685303876974547 2.444429766980398,1.1422713899997279 2.4858972558067784,1.118078735651645 2.5286032631740025,1.0960107068765566 2.572444906569718,1.0761204674887133 2.6173165676349104,1.0584559348169793 2.66311014660778,1.043059664267791 2.709715322745538,1.029968746805456 2.757019820096736,1.0192147195967696 2.8049096779838716,1.0108234900352189 2.853269525544638,1.0048152733278033 2.9019828596704396,1.0012045437948276 2.950932325672582,1 3,1 5,1.0048152733278033 5.098017140329561,1.0108234900352189 5.146730474455362,1.0192147195967696 5.195090322016128,1.029968746805456 5.242980179903264,1.043059664267791 5.290284677254462,1.0584559348169793 5.33688985339222,1.0761204674887133 5.38268343236509,1.0960107068765566 5.427555093430282,1.118078735651645 5.471396736825998,1.1422713899997279 5.514102744193222,1.1685303876974547 5.555570233019602,1.1967924685193552 5.595699304492434,1.2269895466372631 5.634393284163646,1.2590488746450408 5.671558954847018,1.2928932188134525 5.707106781186548,1.3284410451529816 5.740951125354959,1.3656067158363545 5.773010453362737,1.4043006955075668 5.803207531480645,1.4444297669803978 5.831469612302545,1.4858972558067784 5.857728610000272,1.5286032631740025 5.881921264348355,1.572444906569718 5.903989293123443,1.6173165676349102 5.923879532511287,1.6631101466077798 5.941544065183021,1.7097153227455377 5.956940335732209,1.7570198200967362 5.970031253194544,1.8049096779838716 5.98078528040323,1.853269525544638 5.989176509964781,1.9019828596704393 5.995184726672197,1.950932325672582 5.998795456205173,2 6,2.049067674327418 5.998795456205173,2.0980171403295604 5.995184726672197,2.146730474455362 5.989176509964781,2.1950903220161284 5.98078528040323,2.242980179903264 5.970031253194544,2.290284677254462 5.956940335732209,2.33688985339222 5.941544065183021,2.3826834323650896 5.923879532511287,2.427555093430282 5.903989293123443,2.4713967368259975 5.881921264348355,2.5141027441932216 5.857728610000272,2.555570233019602 5.831469612302545,2.5956993044924332 5.803207531480645,2.6343932841636457 5.773010453362737,2.6715589548470184 5.740951125354959,2.7071067811865475 5.707106781186548,2.740951125354959 5.671558954847018,2.773010453362737 5.634393284163646,2.803207531480645 5.595699304492434,2.8314696123025453 5.555570233019602,2.8577286100002723 5.514102744193222,2.881921264348355 5.471396736825998,2.9039892931234434 5.427555093430282,2.923879532511287 5.38268343236509,2.9415440651830207 5.33688985339222,2.956940335732209 5.290284677254462,2.970031253194544 5.242980179903264,2.9807852804032304 5.195090322016128,2.989176509964781 5.146730474455362,2.9951847266721967 5.098017140329561,2.9987954562051726 5.049067674327418,3 5,3 3.618033988749895,4.447213595499958 2.8944271909999157,4.452005828373324 2.8920149836838753,4.4952304682721085 2.8687616377896688,4.53726205459576 2.8434153690154944,4.577999329571291 2.8160372387429002,4.617344153535124 2.786693203285754,4.655201741360129 2.7554539549957067,4.691480890801302 2.7223947519581224,4.726094202209963 2.6875952366887637,4.758958289087159 2.6511392442679926,4.789993978969049 2.613114600374718,4.819126504160303 2.573612909706644,4.846285681856025 2.5327293352965294,4.871406083218286 2.490562369256107,4.894427190999916 2.447213595499958,4.9152935453358575 2.402787445020965,4.933954877350839 2.3573909443069025,4.950366230261497 2.3111334575042557,4.964488067681204 2.2641264229504086,4.976286368866689 2.2164830847089316,4.985732710676989 2.1683182197547124,4.992804336047279 2.1197478614661684,4.997484208812643 2.070889020090679,4.999761054749678 2.0218594008566466,4.999629388737095 1.9727771204112932,4.997089527969852 1.9237604222673113,4.992147591195001 1.8749273919438858,4.984815483971095 1.8263956724883341,4.975110869986654 1.7782821810637013,4.963057128506792 1.7307028272850733,4.948683298050514 1.683772233983162,4.932024006434389 1.6376034610678665,4.913119387351103 1.592307733157046,4.892014983683875 1.5479941716266756,4.868761637789669 1.504769531727891,4.843415369015494 1.46273794540424,4.816037238742901 1.4220006704287085,4.786693203285754 1.382655846464876,4.755453954995707 1.3447982586398712,4.722394751958122 1.3085191091986976,4.687595236688764 1.2739057977900368,4.651139244267993 1.241041710912841,4.613114600374717 1.2100060210309511,4.573612909706644 1.1808734958396978,4.53272933529653 1.1537143181439746,4.490562369256107 1.1285939167817136,4.447213595499958 1.1055728090000843,2.447213595499958 0.10557280900008414,2.3573909443069025 0.06604512264916129,2.3111334575042557 0.04963376973850353,2.2641264229504086 0.03551193231879646,2.2164830847089316 0.023713631133310598,2.1683182197547124 0.014267289323011023,2.1197478614661684 0.007195663952720532,2.070889020090679 0.0025157911873575634,2.0218594008566466 0.00023894525032219782))
+select ST_NUMPOINTS(ST_EXTERIORRING(@buff));
+ST_NUMPOINTS(ST_EXTERIORRING(@buff))
+202
DROP TABLE t1;
select st_touches(geomfromtext('point(0 0)'), geomfromtext('point(1 1)'));
st_touches(geomfromtext('point(0 0)'), geomfromtext('point(1 1)'))
@@ -200,6 +200,31 @@ result
SELECT ST_Equals(PointFromText('POINT (12 13)'),PointFromText('POINT (12 13)')) as result;
result
1
+#
+# BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD
+# BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL
+#
+SELECT ASTEXT(ST_UNION(GEOMFROMTEXT('POLYGON((525000 183300,525400
+183300,525400 18370, 525000 183700,525000 183300))'),
+geomfromtext('POLYGON((525298.67 183511.53,525296.57
+183510.39,525296.42 183510.31,525289.11 183506.62,525283.17
+183503.47,525280.98 183502.26,525278.63 183500.97,525278.39
+183500.84,525276.79 183500,525260.7 183491.55,525263.95
+183484.75,525265.58 183481.95,525278.97 183488.73,525276.5
+183493.45,525275.5 183495.7,525280.35 183498.2,525282.3
+183499.1,525282.2 183499.3,525283.55 183500,525301.75
+183509.35,525304.45 183504.25,525307.85 183504.95,525304.5
+183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06
+183489.89,525272.06 183488.37,525268.94 183494.51,525271.94
+183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15
+183493.04,525269.88 183485.82,525266.99 183484.33,525263.26
+183491.55))'))) st_u;
+st_u
+MULTIPOLYGON(((525400 18370,525000.9677614468 183300,525400 183300,525400 18370)),((525000 183300,525000 183700,525000.9677614468 183300,525000 183300)),((525265.58 183481.95,525263.95 183484.75,525260.7 183491.55,525276.79 183500,525278.39 183500.84,525278.63 183500.97,525280.98 183502.26,525283.17 183503.47,525289.11 183506.62,525296.42 183510.31,525296.57 183510.39,525298.67 183511.53,525302.81 183513.8,525304.5 183510.83,525307.85 183504.95,525304.45 183504.25,525301.75 183509.35,525283.55 183500,525282.2 183499.3,525282.3 183499.1,525280.35 183498.2,525275.5 183495.7,525276.5 183493.45,525278.97 183488.73,525265.58 183481.95),(525266.99 183484.33,525263.26 183491.55,525266.15 183493.04,525269.88 183485.82,525266.99 183484.33),(525272.06 183488.37,525268.94 183494.51,525271.94 183496.03,525275.06 183489.89,525272.06 183488.37)))
+SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
+SELECT ASTEXT(TOUCHES(@a, GEOMFROMTEXT('point(0 0)'))) t;
+t
+NULL
SELECT astext(ST_UNION (
PolyFromText('POLYGON(( 2 2 ,3 2,2 7,2 2),( 0 0,8 2,1 9,0 0))'),
ExteriorRing( Envelope( MultiLineStringFromText('MULTILINESTRING((3 4,5 3),(3 0,0 5))')))));
@@ -230,15 +255,15 @@ MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4))
((2 2,5 2,4 4,2 8,2 2)))'),
MULTIPOLY
POLYGON((0 2,1 4,1 3,2 3,2 4,1 4,1.5 5,2 5,2 8,8 8,8 2,0 2),(4 4,4 6,6 6,6 4,4 4))
-SELECT ASTEXT(ST_UNION(
+SELECT ROUND(ST_LENGTH(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
(8 2,1 3,9 0,4 4))'),
-MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))')));
-ASTEXT(ST_UNION(
+MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))'))), 7);
+ROUND(ST_LENGTH(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
(8 2,1 3,9 0,4 4))'),
-MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))')))
-MULTILINESTRING((3.5945945945945947 2.027027027027027,4 0,4.75 0.75),(5 0,4.75 0.75),(5.363636363636363 1.3636363636363635,9 0,6.173913043478262 2.260869565217391),(4.75 0.75,4.428571428571429 1.7142857142857142),(4.75 0.75,5.363636363636363 1.3636363636363635),(5.363636363636363 1.3636363636363635,4.428571428571429 1.7142857142857142),(5.363636363636363 1.3636363636363635,6 2),(4.428571428571429 1.7142857142857142,3.5945945945945947 2.027027027027027),(4.428571428571429 1.7142857142857142,4.15 2.55),(4.5 2.5,5 2,5.3076923076923075 2.3846153846153846),(8 2,6.173913043478262 2.260869565217391),(3.5945945945945947 2.027027027027027,1 3,3.4705882352941178 2.6470588235294117),(3.5945945945945947 2.027027027027027,3.4705882352941178 2.6470588235294117),(6.173913043478262 2.260869565217391,5.3076923076923075 2.3846153846153846),(6.173913043478262 2.260869565217391,5.585365853658536 2.7317073170731705),(5.3076923076923075 2.3846153846153846,4.5 2.5),(5.3076923076923075 2.3846153846153846,5.585365853658536 2.7317073170731705),(4.5 2.5,4.15 2.55),(4.5 2.5,4 3),(4.15 2.55,3.4705882352941178 2.6470588235294117),(4.15 2.55,4 3),(3.4705882352941178 2.6470588235294117,3.25 3.75),(5.585365853658536 2.7317073170731705,4.769230769230769 3.3846153846153846),(5.585365853658536 2.7317073170731705,7.054054054054054 4.5675675675675675),(4 3,3.25 3.75),(4 3,3.142857142857143 5.571428571428571),(4 3,4.769230769230769 3.3846153846153846),(4.769230769230769 3.3846153846153846,4 4),(4.769230769230769 3.3846153846153846,6 4,4.875 5.875),(3.25 3.75,2 5),(3.25 3.75,3 5,3 5.5),(7.054054054054054 4.5675675675675675,8 4,7.16 4.7),(7.054054054054054 4.5675675675675675,4.875 5.875),(7.054054054054054 4.5675675675675675,7.16 4.7),(7.16 4.7,5 6.5),(7.16 4.7,9 7,6 7,5 6.5),(2 5,1 6,3 6),(2 5,3 5.5),(3 5.5,3 6),(3 5.5,3.142857142857143 5.571428571428571),(3.142857142857143 5.571428571428571,3 6),(3.142857142857143 5.571428571428571,4.363636363636363 6.181818181818182),(4.875 5.875,4.363636363636363 6.181818181818182),(4.875 5.875,4.615384615384615 6.3076923076923075),(3 6,2.6666666666666665 7),(4.363636363636363 6.181818181818182,3 7,2.6666666666666665 7),(4.363636363636363 6.181818181818182,4.615384615384615 6.3076923076923075),(4.615384615384615 6.3076923076923075,4 7.333333333333333),(4.615384615384615 6.3076923076923075,5 6.5),(5 6.5,4 7.333333333333333),(2.1818181818181817 8.454545454545455,0 7,2.6666666666666665 7),(2.6666666666666665 7,2.1818181818181817 8.454545454545455),(4 7.333333333333333,2.444444444444444 8.62962962962963),(4 7.333333333333333,3 9,2.444444444444444 8.62962962962963),(2.1818181818181817 8.454545454545455,2 9,2.444444444444444 8.62962962962963),(2.1818181818181817 8.454545454545455,2.444444444444444 8.62962962962963))
+MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6)
+90.2783626
SELECT ST_NUMGEOMETRIES((ST_UNION(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 0,4 2,0 2,1 5,0 3,7 0,8 5,5 8),
(6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
@@ -434,9 +459,6 @@ ST_WITHIN( MULTIPOINTFROMTEXT(' MULTIPOINT( 2 9 , 2 9 , 4 9 , 9 1 ) ') , POLYGON
SELECT ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29)') );
ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,
1
-select ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3));
-ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3))
-POLYGON((3.999999999999999 6.999999999999998,4 7,3.999999999999999 6.999999999999998))
SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
-2.910427500435995 0.727606875108998,
-0.910427500435995 8.727606875108998,
@@ -455,3 +477,296 @@ ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
select astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1));
astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1))
GEOMETRYCOLLECTION EMPTY
+DROP TABLE IF EXISTS p1;
+CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
+BEGIN
+DECLARE g GEOMETRY;
+SET g=GeomFromText(geom);
+SELECT geom AS `-----`;
+SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
+END|
+#
+# Testing ST_BUFFER with positive distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+1 POLYGON 3.14
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+1 POLYGON 5.14
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+1 POLYGON 44.63
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+1 POLYGON 63.14
+-----
+Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
+dist buffer buf_area
+1 POLYGON 95.14
+-----
+Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
+dist buffer buf_area
+1 POLYGON 174.93
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+1 MULTIPOLYGON 9.42
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+1 POLYGON 8.80
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+1 POLYGON 14.24
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+1 POLYGON 13.59
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+1 MULTIPOLYGON 70.06
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+1 POLYGON 73.18
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+1 POLYGON 73.18
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+1 POLYGON 3.14
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+1 POLYGON 8.80
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+1 POLYGON 63.14
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+1 MULTIPOLYGON 9.42
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+1 MULTIPOLYGON 10.28
+-----
+GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
+dist buffer buf_area
+1 MULTIPOLYGON 48.28
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+1 POLYGON 75.92
+#
+# Testing ST_BUFFER with zero distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+0 POINT 0.00
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+0 LINESTRING 0.00
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+0 LINESTRING 0.00
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+0 POLYGON 36.00
+-----
+Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
+dist buffer buf_area
+0 POLYGON 48.00
+-----
+Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
+dist buffer buf_area
+0 POLYGON 116.00
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+0 MULTIPOINT NULL
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+0 MULTILINESTRING NULL
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+0 MULTIPOLYGON 66.00
+-----
+MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
+dist buffer buf_area
+0 MULTIPOLYGON 62.00
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 36.00
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION NULL
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION NULL
+-----
+GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 18.00
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+0 GEOMETRYCOLLECTION 36.00
+#
+# Testing ST_BUFFER with negative distance
+#
+-----
+POINT(0 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+LineString(0 1, 1 1))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+LineString(9 9,8 1,1 5,0 0)
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+Polygon((2 2,2 8,8 8,8 2,2 2))
+dist buffer buf_area
+-1 POLYGON 16.00
+-----
+MultiPoint(9 9,8 1,1 5)
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2,0 4))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((0 0,2 2),(0 2,2 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Point(0 0))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(LineString(0 0, 2 2)))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
+dist buffer buf_area
+-1 POLYGON 16.00
+-----
+GeometryCollection(MultiPoint(9 9,8 1,1 5))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
+dist buffer buf_area
+-1 GEOMETRYCOLLECTION 0.00
+-----
+GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
+dist buffer buf_area
+-1 POLYGON 16.00
+SELECT ST_CONTAINS(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)'));
+ST_CONTAINS(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)'))
+0
+SELECT AsText(ST_UNION(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)')));
+AsText(ST_UNION(
+GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+GeomFromText('POINT(5 10)')))
+GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)),POLYGON((6 6,6 11,11 11,11 6,6 6)),POINT(5 10))
+DROP PROCEDURE p1;
+#
+# Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
+#
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
+GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3))
+POLYGON
+#
+# Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
+#
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
+GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1))
+POLYGON
+#
+# Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
+#
+DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
+SELECT ST_WITHIN(
+LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
+ST_WITHIN(
+LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) ')
+0
+SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
+ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))))
+2
+SELECT ST_NUMINTERIORRINGS(
+ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
+ST_NUMINTERIORRINGS(
+ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))))
+0
+SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
+ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))))
+POLYGON((9 9,5 2,4 5,9 9))
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 9acdb1a87c2..a1d2ec862b7 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -834,6 +834,17 @@ create table t1 (g geometry not null);
insert into t1 values(default);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
+CREATE TABLE t1 (a GEOMETRY);
+CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;
+CREATE VIEW v2 AS SELECT a FROM t1;
+DESCRIBE v1;
+Field Type Null Key Default Extra
+GeomFromwkb(ASBINARY(a)) geometry YES NULL
+DESCRIBE v2;
+Field Type Null Key Default Extra
+a geometry YES NULL
+DROP VIEW v1,v2;
+DROP TABLE t1;
create table t1 (name VARCHAR(100), square GEOMETRY);
INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 81cdad8c523..06a8a8a06b8 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -3536,7 +3536,7 @@ COUNT(DISTINCT a, b) SUM(DISTINCT a)
0 NULL
EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range NULL a 5 NULL 9 Using index for group-by
+1 SIMPLE t2 index NULL a 15 NULL 16 Using index
SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
SUM(DISTINCT a) MAX(b)
1 8
@@ -3564,7 +3564,7 @@ SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
168
EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range NULL a 5 NULL 9 Using index for group-by
+1 SIMPLE t2 index NULL a 15 NULL 16 Using index
SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
(SUM(DISTINCT a) + MAX(b))
9
@@ -3593,6 +3593,58 @@ id select_type table type possible_keys key key_len ref rows Extra
drop table t1;
# End of test#50539.
#
+# Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND
+# "HAVING SUM(DISTINCT)": WRONG RESULTS.
+#
+CREATE TABLE t (a INT, b INT, KEY(a,b));
+INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5);
+ANALYZE TABLE t;
+Table Op Msg_type Msg_text
+test.t analyze status OK
+SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MIN(b)
+1 1 0
+2 2 2
+3 3 2
+4 4 4
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MAX(b)
+1 1 1
+2 2 2
+3 3 3
+4 4 5
+EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+a MAX(b)
+1 1
+2 2
+3 3
+4 5
+EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+SUM(DISTINCT a) MIN(b) MAX(b)
+10 0 5
+EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MIN(b) MAX(b)
+1 1 0 1
+2 2 2 2
+3 3 2 3
+4 4 4 5
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+DROP TABLE t;
+#
# MDEV-4219 A simple select query returns random data (upstream bug#68473)
#
drop table if exists faulty;
diff --git a/mysql-test/r/group_min_max_innodb.result b/mysql-test/r/group_min_max_innodb.result
index 320c4b2b750..f3511b0ad4a 100644
--- a/mysql-test/r/group_min_max_innodb.result
+++ b/mysql-test/r/group_min_max_innodb.result
@@ -118,3 +118,171 @@ COUNT(DISTINCT a)
1
DROP TABLE t1;
End of 5.5 tests
+#
+# Bug#17909656 - WRONG RESULTS FOR A SIMPLE QUERY WITH GROUP BY
+#
+CREATE TABLE t0 (
+i1 INTEGER NOT NULL
+);
+INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
+(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),
+(21),(22),(23),(24),(25),(26),(27),(28),(29),(30);
+CREATE TABLE t1 (
+c1 CHAR(1) NOT NULL,
+i1 INTEGER NOT NULL,
+i2 INTEGER NOT NULL,
+UNIQUE KEY k1 (c1,i2)
+) ENGINE=InnoDB;
+INSERT INTO t1 SELECT 'A',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'B',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'C',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'D',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'E',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'F',i1,i1 FROM t0;
+CREATE TABLE t2 (
+c1 CHAR(1) NOT NULL,
+i1 INTEGER NOT NULL,
+i2 INTEGER NOT NULL,
+UNIQUE KEY k2 (c1,i1,i2)
+) ENGINE=InnoDB;
+INSERT INTO t2 SELECT 'A',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'B',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'C',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'D',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'E',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'F',i1,i1 FROM t0;
+ANALYZE TABLE t1;
+ANALYZE TABLE t2;
+EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F')
+GROUP BY c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 5 NULL 31 Using where; Using index
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F')
+GROUP BY c1;
+c1 max(i2)
+C 17
+F 30
+EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17))
+GROUP BY c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 5 NULL 31 Using where; Using index
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17))
+GROUP BY c1;
+c1 max(i2)
+C 30
+F 17
+EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 )
+GROUP BY c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 5 NULL 2 Using where; Using index
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 )
+GROUP BY c1;
+c1 max(i2)
+C 17
+F 17
+EXPLAIN SELECT c1, max(i2) FROM t1
+WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 )))
+GROUP BY c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 5 NULL 3 Using where; Using index
+SELECT c1, max(i2) FROM t1
+WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 )))
+GROUP BY c1;
+c1 max(i2)
+C 30
+EXPLAIN SELECT c1, i1, max(i2) FROM t2
+WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )
+GROUP BY c1,i1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range k2 k2 5 NULL 59 Using where; Using index
+SELECT c1, i1, max(i2) FROM t2
+WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )
+GROUP BY c1,i1;
+c1 i1 max(i2)
+C 17 17
+F 17 17
+EXPLAIN SELECT c1, i1, max(i2) FROM t2
+WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ))
+GROUP BY c1,i1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range k2 k2 5 NULL 58 Using where; Using index
+SELECT c1, i1, max(i2) FROM t2
+WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ))
+GROUP BY c1,i1;
+c1 i1 max(i2)
+C 17 17
+F 17 17
+EXPLAIN SELECT c1, i1, max(i2) FROM t2
+WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 ))
+GROUP BY c1,i1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index k2 k2 9 NULL 180 Using where; Using index
+SELECT c1, i1, max(i2) FROM t2
+WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 ))
+GROUP BY c1,i1;
+c1 i1 max(i2)
+A 17 17
+B 17 17
+C 1 1
+C 2 2
+C 3 3
+C 4 4
+C 5 5
+C 6 6
+C 7 7
+C 8 8
+C 9 9
+C 10 10
+C 11 11
+C 12 12
+C 13 13
+C 14 14
+C 15 15
+C 16 16
+C 17 17
+C 18 18
+C 19 19
+C 20 20
+C 21 21
+C 22 22
+C 23 23
+C 24 24
+C 25 25
+C 26 26
+C 27 27
+C 28 28
+C 29 29
+C 30 30
+D 17 17
+E 17 17
+F 1 1
+F 2 2
+F 3 3
+F 4 4
+F 5 5
+F 6 6
+F 7 7
+F 8 8
+F 9 9
+F 10 10
+F 11 11
+F 12 12
+F 13 13
+F 14 14
+F 15 15
+F 16 16
+F 17 17
+F 18 18
+F 19 19
+F 20 20
+F 21 21
+F 22 22
+F 23 23
+F 24 24
+F 25 25
+F 26 26
+F 27 27
+F 28 28
+F 29 29
+F 30 30
+DROP TABLE t0,t1,t2;
diff --git a/mysql-test/r/have_mysql_upgrade.result b/mysql-test/r/have_mysql_upgrade.result
deleted file mode 100644
index 952bea420f9..00000000000
--- a/mysql-test/r/have_mysql_upgrade.result
+++ /dev/null
@@ -1,2 +0,0 @@
-have_mysql_upgrade
-1
diff --git a/mysql-test/r/huge_frm-6224.result b/mysql-test/r/huge_frm-6224.result
new file mode 100644
index 00000000000..3772317c04d
--- /dev/null
+++ b/mysql-test/r/huge_frm-6224.result
@@ -0,0 +1 @@
+ERROR HY000: The definition for table `t1` is too big
diff --git a/mysql-test/r/innodb_load_xa.result b/mysql-test/r/innodb_load_xa.result
new file mode 100644
index 00000000000..85e6d52c098
--- /dev/null
+++ b/mysql-test/r/innodb_load_xa.result
@@ -0,0 +1,21 @@
+install plugin innodb soname 'ha_innodb';
+Warnings:
+Warning 1105 Cannot enable tc-log at run-time. XA features of InnoDB are disabled
+select engine,support,transactions,xa from information_schema.engines where engine='innodb';
+engine support transactions xa
+InnoDB YES YES NO
+create table t1 (a int) engine=innodb;
+start transaction;
+insert t1 values (1);
+insert t1 values (2);
+commit;
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+mysqld-bin.000001 # Gtid # # GTID #-#-#
+mysqld-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb
+mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
+mysqld-bin.000001 # Query # # use `test`; insert t1 values (1)
+mysqld-bin.000001 # Query # # use `test`; insert t1 values (2)
+mysqld-bin.000001 # Query # # COMMIT
+drop table t1;
+uninstall plugin innodb;
diff --git a/mysql-test/r/innodb_mysql_lock2.result b/mysql-test/r/innodb_mysql_lock2.result
index 17dd747de6f..54203c140a2 100644
--- a/mysql-test/r/innodb_mysql_lock2.result
+++ b/mysql-test/r/innodb_mysql_lock2.result
@@ -331,13 +331,14 @@ Success: 'update v2 set j= j-10 where j = 3' takes shared row locks on 't1'.
# 4.1 SELECT/SET with a stored function which does not
# modify data and uses SELECT in its turn.
#
-# In theory there is no need to take row locks on the table
+# There is no need to take row locks on the table
# being selected from in SF as the call to such function
-# won't get into the binary log. In practice, however, we
-# discover that fact too late in the process to be able to
-# affect the decision what locks should be taken.
-# Hence, strong locks are taken in this case.
-Success: 'select f1()' takes shared row locks on 't1'.
+# won't get into the binary log.
+#
+# However in practice innodb takes strong lock on tables
+# being selected from within SF, when SF is called from
+# non SELECT statements like 'set' statement below.
+Success: 'select f1()' doesn't take row locks on 't1'.
Success: 'set @a:= f1()' takes shared row locks on 't1'.
#
# 4.2 INSERT (or other statement which modifies data) with
@@ -364,13 +365,15 @@ Success: 'set @a:= f2()' takes shared row locks on 't1'.
# modify data and reads a table through subselect
# in a control construct.
#
-# Again, in theory a call to this function won't get to the
-# binary log and thus no locking is needed. But in practice
-# we don't detect this fact early enough (get_lock_type_for_table())
-# to avoid taking row locks.
-Success: 'select f3()' takes shared row locks on 't1'.
+# Call to this function won't get to the
+# binary log and thus no locking is needed.
+#
+# However in practice innodb takes strong lock on tables
+# being selected from within SF, when SF is called from
+# non SELECT statements like 'set' statement below.
+Success: 'select f3()' doesn't take row locks on 't1'.
Success: 'set @a:= f3()' takes shared row locks on 't1'.
-Success: 'select f4()' takes shared row locks on 't1'.
+Success: 'select f4()' doesn't take row locks on 't1'.
Success: 'set @a:= f4()' takes shared row locks on 't1'.
#
# 4.5. INSERT (or other statement which modifies data) with
@@ -398,13 +401,15 @@ Success: 'set @a:= f5()' takes shared row locks on 't1'.
# doesn't modify data and reads tables through
# a view.
#
-# Once again, in theory, calls to such functions won't
-# get into the binary log and thus don't need row
-# locks. But in practice this fact is discovered
-# too late to have any effect.
-Success: 'select f6()' takes shared row locks on 't1'.
+# Calls to such functions won't get into
+# the binary log and thus don't need row locks.
+#
+# However in practice innodb takes strong lock on tables
+# being selected from within SF, when SF is called from
+# non SELECT statements like 'set' statement below.
+Success: 'select f6()' doesn't take row locks on 't1'.
Success: 'set @a:= f6()' takes shared row locks on 't1'.
-Success: 'select f7()' takes shared row locks on 't1'.
+Success: 'select f7()' doesn't take row locks on 't1'.
Success: 'set @a:= f7()' takes shared row locks on 't1'.
#
# 4.8 INSERT which uses stored function which
@@ -431,10 +436,9 @@ Success: 'select f9()' takes shared row locks on 't1'.
# data and reads a table indirectly, by calling another
# function.
#
-# In theory, calls to such functions won't get into the binary
-# log and thus don't need to acquire row locks. But in practice
-# this fact is discovered too late to have any effect.
-Success: 'select f10()' takes shared row locks on 't1'.
+# Calls to such functions won't get into the binary
+# log and thus don't need to acquire row locks.
+Success: 'select f10()' doesn't take row locks on 't1'.
#
# 4.11 INSERT which uses a stored function which doesn't modify
# data and reads a table indirectly, by calling another
@@ -494,10 +498,9 @@ Success: 'select f14()' takes shared row locks on 't1'.
# 5.3 SELECT that calls a function that doesn't modify data and
# uses a CALL statement that reads a table via SELECT.
#
-# In theory, calls to such functions won't get into the binary
-# log and thus don't need to acquire row locks. But in practice
-# this fact is discovered too late to have any effect.
-Success: 'select f15()' takes shared row locks on 't1'.
+# Calls to such functions won't get into the binary
+# log and thus don't need to acquire row locks.
+Success: 'select f15()' doesn't take row locks on 't1'.
#
# 5.4 INSERT which calls function which doesn't modify data and
# uses CALL statement which reads table through SELECT.
diff --git a/mysql-test/r/innodb_mysql_sync.result b/mysql-test/r/innodb_mysql_sync.result
index 21e9cd04c22..49d69d13e40 100644
--- a/mysql-test/r/innodb_mysql_sync.result
+++ b/mysql-test/r/innodb_mysql_sync.result
@@ -86,7 +86,10 @@ SET DEBUG_SYNC= 'now SIGNAL killed';
# Reaping: OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
+test.t1 optimize error Query execution was interrupted
test.t1 optimize status Operation failed
+Warnings:
+Error 1317 Query execution was interrupted
# Connection default
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/r/ipv4_and_ipv6.result b/mysql-test/r/ipv4_and_ipv6.result
new file mode 100644
index 00000000000..f15aeba65fa
--- /dev/null
+++ b/mysql-test/r/ipv4_and_ipv6.result
@@ -0,0 +1,58 @@
+=============Test of '::1' ========================================
+mysqld is alive
+CREATE USER testuser@'::1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'::1';
+SHOW GRANTS FOR testuser@'::1';
+Grants for testuser@::1
+GRANT USAGE ON *.* TO 'testuser'@'::1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'::1'
+SET @nip= inet_aton('::1');
+SELECT @nip;
+@nip
+NULL
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+NULL
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'::1';
+RENAME USER testuser@'::1' to testuser1@'::1';
+SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'::1';
+=============Test of '127.0.0.1' (IPv4) ===========================
+mysqld is alive
+CREATE USER testuser@'127.0.0.1' identified by '1234';
+GRANT ALL ON test.* TO testuser@'127.0.0.1';
+SHOW GRANTS FOR testuser@'127.0.0.1';
+Grants for testuser@127.0.0.1
+GRANT USAGE ON *.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF'
+GRANT ALL PRIVILEGES ON `test`.* TO 'testuser'@'127.0.0.1'
+SET @nip= inet_aton('127.0.0.1');
+SELECT @nip;
+@nip
+2130706433
+SELECT inet_ntoa(@nip);
+inet_ntoa(@nip)
+127.0.0.1
+SELECT USER();
+USER()
+root@localhost
+SELECT current_user();
+current_user()
+root@localhost
+SHOW PROCESSLIST;
+REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
+RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
+SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
+SELECT USER();
+USER()
+root@localhost
+DROP USER testuser1@'127.0.0.1';
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
index fad980c810c..8634beb290f 100644
--- a/mysql-test/r/key_cache.result
+++ b/mysql-test/r/key_cache.result
@@ -2,6 +2,7 @@ drop table if exists t1, t2, t3;
SET @save_key_buffer_size=@@key_buffer_size;
SET @save_key_cache_block_size=@@key_cache_block_size;
SET @save_key_cache_segments=@@key_cache_segments;
+SET @save_key_cache_file_hash_size=@@key_cache_file_hash_size;
SELECT @@key_buffer_size, @@small.key_buffer_size;
@@key_buffer_size @@small.key_buffer_size
2097152 131072
@@ -84,15 +85,15 @@ select @@key_buffer_size;
select @@key_cache_block_size;
@@key_cache_block_size
1024
+select @@key_cache_file_hash_size;
+@@key_cache_file_hash_size
+512
set global keycache1.key_buffer_size=1024*1024;
create table t1 (p int primary key, a char(10)) delay_key_write=1;
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
-show status like 'key_blocks_used';
-Variable_name Value
-Key_blocks_used 0
-show status like 'key_blocks_unused';
-Variable_name Value
-Key_blocks_unused KEY_BLOCKS_UNUSED
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
+key_blocks_unused key_blocks_used
+0 0
insert into t1 values (1, 'qqqq'), (11, 'yyyy');
insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
(3, 1, 'yyyy'), (4, 3, 'zzzz');
@@ -108,12 +109,9 @@ p i a
4 3 zzzz
update t1 set p=2 where p=1;
update t2 set i=2 where i=1;
-show status like 'key_blocks_used';
-Variable_name Value
-Key_blocks_used 4
-show status like 'key_blocks_unused';
-Variable_name Value
-Key_blocks_unused KEY_BLOCKS_UNUSED
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
+key_blocks_unused key_blocks_used
+4 4
cache index t1 key (`primary`) in keycache1;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
@@ -270,12 +268,9 @@ Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
test.t2 assign_to_keycache status OK
drop table t1,t2,t3;
-show status like 'key_blocks_used';
-Variable_name Value
-Key_blocks_used 4
-show status like 'key_blocks_unused';
-Variable_name Value
-Key_blocks_unused KEY_BLOCKS_UNUSED
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
+key_blocks_unused key_blocks_used
+0 4
create table t1 (a int primary key);
cache index t1 in keycache2;
Table Op Msg_type Msg_text
@@ -558,6 +553,7 @@ KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_B
default 1 NULL 2097152 1024 4 # 0 0 0 0 0
small NULL NULL 1048576 1024 1 # 0 0 0 0 0
set global key_buffer_size=32*1024;
+set global key_cache_file_hash_size=128;
select @@key_buffer_size;
@@key_buffer_size
32768
@@ -833,3 +829,4 @@ set global keycache1.key_buffer_size=0;
set global keycache2.key_buffer_size=0;
set global key_buffer_size=@save_key_buffer_size;
set global key_cache_segments=@save_key_cache_segments;
+set global key_cache_file_hash_size=@save_key_cache_file_hash_size;
diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result
index 8fe94679e70..219cc08342e 100644
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@ -27,6 +27,7 @@ drop table if exists t0, t1, t2, t3, t4, t5;
drop view if exists v1, v2;
drop procedure if exists p1;
drop procedure if exists p2;
+drop procedure if exists p3;
drop function if exists f1;
drop function if exists f2;
drop function if exists f3;
@@ -42,6 +43,8 @@ drop function if exists f12;
drop function if exists f13;
drop function if exists f14;
drop function if exists f15;
+drop function if exists f16;
+drop function if exists f17;
create table t1 (i int primary key);
insert into t1 values (1), (2), (3), (4), (5);
create table t2 (j int primary key);
@@ -146,6 +149,26 @@ declare k int;
call p2(k);
return k;
end|
+create function f16() returns int
+begin
+create temporary table if not exists temp1 (a int);
+insert into temp1 select * from t1;
+drop temporary table temp1;
+return 1;
+end|
+create function f17() returns int
+begin
+declare j int;
+select i from t1 where i = 1 into j;
+call p3;
+return 1;
+end|
+create procedure p3()
+begin
+create temporary table if not exists temp1 (a int);
+insert into temp1 select * from t1;
+drop temporary table temp1;
+end|
create trigger t4_bi before insert on t4 for each row
begin
declare k int;
@@ -185,6 +208,7 @@ end|
# once during its execution.
show create procedure p1;
show create procedure p2;
+show create procedure p3;
show create function f1;
show create function f2;
show create function f3;
@@ -200,6 +224,8 @@ show create function f12;
show create function f13;
show create function f14;
show create function f15;
+show create function f16;
+show create function f17;
# Switch back to connection 'default'.
#
# 1. Statements that read tables and do not use subqueries.
@@ -359,14 +385,11 @@ Success: 'update v2 set j= j-10 where j = 3' doesn't allow concurrent inserts in
# 4.1 SELECT/SET with a stored function which does not
# modify data and uses SELECT in its turn.
#
-# In theory there is no need to take strong locks on the table
+# There is no need to take strong locks on the table
# being selected from in SF as the call to such function
-# won't get into the binary log. In practice, however, we
-# discover that fact too late in the process to be able to
-# affect the decision what locks should be taken.
-# Hence, strong locks are taken in this case.
-Success: 'select f1()' doesn't allow concurrent inserts into 't1'.
-Success: 'set @a:= f1()' doesn't allow concurrent inserts into 't1'.
+# won't get into the binary log.
+Success: 'select f1()' allows concurrent inserts into 't1'.
+Success: 'set @a:= f1()' allows concurrent inserts into 't1'.
#
# 4.2 INSERT (or other statement which modifies data) with
# a stored function which does not modify data and uses
@@ -392,14 +415,12 @@ Success: 'set @a:= f2()' doesn't allow concurrent inserts into 't1'.
# modify data and reads a table through subselect
# in a control construct.
#
-# Again, in theory a call to this function won't get to the
-# binary log and thus no strong lock is needed. But in practice
-# we don't detect this fact early enough (get_lock_type_for_table())
-# to avoid taking a strong lock.
-Success: 'select f3()' doesn't allow concurrent inserts into 't1'.
-Success: 'set @a:= f3()' doesn't allow concurrent inserts into 't1'.
-Success: 'select f4()' doesn't allow concurrent inserts into 't1'.
-Success: 'set @a:= f4()' doesn't allow concurrent inserts into 't1'.
+# Call to this function won't get to the
+# binary log and thus no strong lock is needed.
+Success: 'select f3()' allows concurrent inserts into 't1'.
+Success: 'set @a:= f3()' allows concurrent inserts into 't1'.
+Success: 'select f4()' allows concurrent inserts into 't1'.
+Success: 'set @a:= f4()' allows concurrent inserts into 't1'.
#
# 4.5. INSERT (or other statement which modifies data) with
# a stored function which does not modify data and reads
@@ -426,14 +447,13 @@ Success: 'set @a:= f5()' doesn't allow concurrent inserts into 't1'.
# doesn't modify data and reads tables through
# a view.
#
-# Once again, in theory, calls to such functions won't
-# get into the binary log and thus don't need strong
-# locks. But in practice this fact is discovered
-# too late to have any effect.
-Success: 'select f6()' doesn't allow concurrent inserts into 't1'.
-Success: 'set @a:= f6()' doesn't allow concurrent inserts into 't1'.
-Success: 'select f7()' doesn't allow concurrent inserts into 't1'.
-Success: 'set @a:= f7()' doesn't allow concurrent inserts into 't1'.
+# Calls to such functions won't get into
+# the binary log and thus don't need strong
+# locks.
+Success: 'select f6()' allows concurrent inserts into 't1'.
+Success: 'set @a:= f6()' allows concurrent inserts into 't1'.
+Success: 'select f7()' allows concurrent inserts into 't1'.
+Success: 'set @a:= f7()' allows concurrent inserts into 't1'.
#
# 4.8 INSERT which uses stored function which
# doesn't modify data and reads a table
@@ -459,10 +479,9 @@ Success: 'select f9()' doesn't allow concurrent inserts into 't1'.
# data and reads a table indirectly, by calling another
# function.
#
-# In theory, calls to such functions won't get into the binary
-# log and thus don't need to acquire strong locks. But in practice
-# this fact is discovered too late to have any effect.
-Success: 'select f10()' doesn't allow concurrent inserts into 't1'.
+# Calls to such functions won't get into the binary
+# log and thus don't need to acquire strong locks.
+Success: 'select f10()' allows concurrent inserts into 't1'.
#
# 4.11 INSERT which uses a stored function which doesn't modify
# data and reads a table indirectly, by calling another
@@ -501,6 +520,26 @@ Success: 'select f12((select i+10 from t1 where i=1))' allows concurrent inserts
# uses. Therefore it should take strong locks on the data it reads.
Success: 'insert into t2 values (f13((select i+10 from t1 where i=1)))' doesn't allow concurrent inserts into 't1'.
#
+# 4.15 SELECT/SET with a stored function which
+# inserts data into a temporary table using
+# SELECT on t1.
+#
+# Since this statement is written to the binary log it should
+# be serialized with concurrent statements affecting the data it
+# uses. Therefore it should take strong locks on the data it reads.
+Success: 'select f16()' doesn't allow concurrent inserts into 't1'.
+Success: 'set @a:= f16()' doesn't allow concurrent inserts into 't1'.
+#
+# 4.16 SELECT/SET with a stored function which call procedure
+# which inserts data into a temporary table using
+# SELECT on t1.
+#
+# Since this statement is written to the binary log it should
+# be serialized with concurrent statements affecting the data it
+# uses. Therefore it should take strong locks on the data it reads.
+Success: 'select f17()' doesn't allow concurrent inserts into 't1'.
+Success: 'set @a:= f17()' doesn't allow concurrent inserts into 't1'.
+#
# 5. Statements that read tables through stored procedures.
#
#
@@ -522,10 +561,9 @@ Success: 'select f14()' doesn't allow concurrent inserts into 't1'.
# 5.3 SELECT that calls a function that doesn't modify data and
# uses a CALL statement that reads a table via SELECT.
#
-# In theory, calls to such functions won't get into the binary
-# log and thus don't need to acquire strong locks. But in practice
-# this fact is discovered too late to have any effect.
-Success: 'select f15()' doesn't allow concurrent inserts into 't1'.
+# Calls to such functions won't get into the binary
+# log and thus don't need to acquire strong locks.
+Success: 'select f15()' allows concurrent inserts into 't1'.
#
# 5.4 INSERT which calls function which doesn't modify data and
# uses CALL statement which reads table through SELECT.
@@ -585,9 +623,12 @@ drop function f12;
drop function f13;
drop function f14;
drop function f15;
+drop function f16;
+drop function f17;
drop view v1, v2;
drop procedure p1;
drop procedure p2;
+drop procedure p3;
drop table t1, t2, t3, t4, t5;
set @@global.concurrent_insert= @old_concurrent_insert;
#
diff --git a/mysql-test/r/log_tables_upgrade.result b/mysql-test/r/log_tables_upgrade.result
index 6f7bd64eba3..d25fc018cdf 100644
--- a/mysql-test/r/log_tables_upgrade.result
+++ b/mysql-test/r/log_tables_upgrade.result
@@ -11,13 +11,8 @@ Table Op Msg_type Msg_text
test.bug49823 repair status OK
RENAME TABLE general_log TO renamed_general_log;
RENAME TABLE test.bug49823 TO general_log;
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -48,9 +43,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
DROP TABLE general_log;
RENAME TABLE renamed_general_log TO general_log;
diff --git a/mysql-test/r/myisam_explain_non_select_all.result b/mysql-test/r/myisam_explain_non_select_all.result
index 285a1ca6786..3dfa56c38d6 100644
--- a/mysql-test/r/myisam_explain_non_select_all.result
+++ b/mysql-test/r/myisam_explain_non_select_all.result
@@ -755,6 +755,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 11
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
@@ -1231,6 +1232,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
# Status of testing query execution:
@@ -1275,6 +1277,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
@@ -1361,6 +1364,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
@@ -1407,6 +1411,7 @@ Variable_name Value
Variable_name Value
Handler_read_rnd 1
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
@@ -1540,6 +1545,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
# Status of testing query execution:
@@ -1668,6 +1674,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
# Status of testing query execution:
@@ -1675,6 +1682,7 @@ Variable_name Value
Handler_read_rnd 5
Handler_read_rnd_next 27
Handler_update 5
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
@@ -1712,6 +1720,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
@@ -1719,6 +1728,7 @@ Variable_name Value
Handler_read_rnd 1
Handler_read_rnd_next 27
Handler_update 1
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
@@ -1799,12 +1809,14 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_rnd 1
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
@@ -1844,12 +1856,14 @@ Variable_name Value
Variable_name Value
Handler_read_rnd 1
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_rnd 1
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 1
Sort_scan 1
@@ -1977,6 +1991,7 @@ Variable_name Value
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_rnd_next 27
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
# Status of testing query execution:
@@ -1984,6 +1999,7 @@ Variable_name Value
Handler_read_rnd 5
Handler_read_rnd_next 27
Handler_update 4
+Sort_priority_queue_sorts 1
Sort_rows 5
Sort_scan 1
@@ -2067,6 +2083,7 @@ Variable_name Value
Variable_name Value
Handler_read_key 1
Handler_read_next 2
+Sort_priority_queue_sorts 1
Sort_range 1
Sort_rows 2
# Status of testing query execution:
@@ -2075,6 +2092,7 @@ Handler_read_key 1
Handler_read_next 2
Handler_read_rnd 2
Handler_update 2
+Sort_priority_queue_sorts 1
Sort_range 1
Sort_rows 2
@@ -2105,6 +2123,7 @@ Variable_name Value
Variable_name Value
Handler_read_key 1
Handler_read_next 2
+Sort_priority_queue_sorts 1
Sort_range 1
Sort_rows 2
# Status of testing query execution:
@@ -2625,6 +2644,7 @@ Variable_name Value
Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 10
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
# Status of testing query execution:
@@ -2632,6 +2652,7 @@ Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 8
Handler_update 1
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
@@ -2674,12 +2695,14 @@ Variable_name Value
Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 10
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 10
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
@@ -2724,12 +2747,14 @@ Variable_name Value
Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 10
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 3
Handler_read_rnd_next 10
+Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
diff --git a/mysql-test/r/mysql_client_test_comp.result b/mysql-test/r/mysql_client_test_comp.result
new file mode 100644
index 00000000000..b9cac467b92
--- /dev/null
+++ b/mysql-test/r/mysql_client_test_comp.result
@@ -0,0 +1,4 @@
+SET @old_slow_query_log= @@global.slow_query_log;
+call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
+ok
+SET @@global.slow_query_log= @old_slow_query_log;
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index 08eafcc1d5e..40c979b8138 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -1,11 +1,6 @@
Run mysql_upgrade once
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -35,20 +30,21 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
Force should run it regardless of wether it's been run before
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -78,20 +74,21 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
Run mysql_upgrade with password protected account
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -121,9 +118,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
DROP USER mysqltest1@'%';
Version check failed. Got the following error when calling the 'mysql' command line client
@@ -133,13 +136,8 @@ Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -169,9 +167,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
set GLOBAL sql_mode=default;
#
@@ -182,13 +186,8 @@ CREATE PROCEDURE testproc() BEGIN END;
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -218,9 +217,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
CALL testproc();
DROP PROCEDURE testproc;
@@ -234,13 +239,8 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
Run mysql_upgrade with all privileges on a user
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -270,9 +270,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
SHOW GRANTS FOR 'user3'@'%';
Grants for user3@%
@@ -280,8 +286,38 @@ GRANT USAGE ON *.* TO 'user3'@'%'
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
DROP USER 'user3'@'%';
End of 5.1 tests
-The --upgrade-system-tables option was used, databases won't be touched.
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
+The --upgrade-system-tables option was used, user tables won't be touched.
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.host OK
+mysql.index_stats OK
+mysql.innodb_index_stats OK
+mysql.innodb_table_stats OK
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.user OK
OK
#
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
@@ -289,13 +325,8 @@ OK
#
# Droping the previously created mysql_upgrade_info file..
# Running mysql_upgrade with --skip-write-binlog..
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -325,9 +356,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
#
# MDEV-4332 Increase username length from 16 characters
@@ -341,13 +378,8 @@ GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
CREATE PROCEDURE test.pr() BEGIN END;
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -377,9 +409,15 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
SELECT definer FROM mysql.proc WHERE db = 'test' AND name = 'pr';
definer
diff --git a/mysql-test/r/mysql_upgrade_no_innodb.result b/mysql-test/r/mysql_upgrade_no_innodb.result
index ad6f4617657..5a1cd6b9e7d 100644
--- a/mysql-test/r/mysql_upgrade_no_innodb.result
+++ b/mysql-test/r/mysql_upgrade_no_innodb.result
@@ -1,3 +1,45 @@
-The --upgrade-system-tables option was used, databases won't be touched.
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
+The --upgrade-system-tables option was used, user tables won't be touched.
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.host OK
+mysql.index_stats OK
+mysql.innodb_index_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.innodb_table_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.user OK
+
+Repairing tables
+mysql.innodb_index_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.innodb_table_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
OK
diff --git a/mysql-test/r/mysql_upgrade_ssl.result b/mysql-test/r/mysql_upgrade_ssl.result
index 87b7d51e8b7..70801da20ea 100644
--- a/mysql-test/r/mysql_upgrade_ssl.result
+++ b/mysql-test/r/mysql_upgrade_ssl.result
@@ -1,13 +1,8 @@
#
# Bug#55672 mysql_upgrade dies with internal error
#
-Phase 1/3: Fixing table and database names
-Phase 2/3: Checking and upgrading tables
+Phase 1/3: Running 'mysql_fix_privilege_tables'...
Processing databases
-information_schema
-mtr
-mtr.global_suppressions OK
-mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
@@ -37,7 +32,13 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+Phase 2/3: Fixing table and database names
+Phase 3/3: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
performance_schema
test
-Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index dec14751d0d..99e1a86aa68 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -281,6 +281,11 @@ The following options may be given as the first argument:
The default size of key cache blocks
--key-cache-division-limit=#
The minimum percentage of warm blocks in key cache
+ --key-cache-file-hash-size=#
+ Number of hash buckets for open and changed files. If
+ you have a lot of MyISAM files open you should increase
+ this for faster flush of changes. A good value is
+ probably 1/10 of number of possible open MyISAM files.
--key-cache-segments=#
The number of segments in a key cache
-L, --language=name Client error messages in given language. May be given as
@@ -1009,8 +1014,8 @@ The following options may be given as the first argument:
created to handle remaining clients.
--thread-stack=# The stack size for each thread
--time-format=name The TIME format (ignored)
- --timed-mutexes Specify whether to time mutexes (only InnoDB mutexes are
- currently supported)
+ --timed-mutexes Specify whether to time mutexes. Deprecated, has no
+ effect.
--tmp-table-size=# If an internal in-memory temporary table exceeds this
size, MySQL will automatically convert it to an on-disk
MyISAM or Aria table
@@ -1211,6 +1216,7 @@ key-buffer-size 134217728
key-cache-age-threshold 300
key-cache-block-size 1024
key-cache-division-limit 100
+key-cache-file-hash-size 512
key-cache-segments 0
large-pages FALSE
lc-messages en_US
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 7228daa2712..e258b1d156f 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -680,6 +680,9 @@ txt
b is b and more is more
txt
a is a and less is more
+sflfdt 'ABCDfF bbddff h' bs txt;
+txt
+ABCDfF bbddff h
create table t2 ( a char(10));
garbage;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1
diff --git a/mysql-test/r/order_by_innodb.result b/mysql-test/r/order_by_innodb.result
new file mode 100644
index 00000000000..3c6c4053741
--- /dev/null
+++ b/mysql-test/r/order_by_innodb.result
@@ -0,0 +1,13 @@
+drop table if exists t0,t1,t2,t3;
+#
+# MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
+#
+CREATE TABLE t1 (a INT, b INT, c INT, d TEXT, KEY idx(a,b,c)) ENGINE=InnoDB;
+INSERT INTO t1 (a,c) VALUES
+(8, 9),(8, 10),(13, 15),(16, 17),(16, 18),(16, 19),(20, 21),
+(20, 22),(20, 24),(20, 25),(20, 26),(20, 27),(20, 28);
+SELECT * FROM t1 WHERE a = 8 AND (b = 1 OR b IS NULL) ORDER BY c;
+a b c d
+8 NULL 9 NULL
+8 NULL 10 NULL
+DROP TABLE t1;
diff --git a/mysql-test/r/order_by_sortkey.result b/mysql-test/r/order_by_sortkey.result
index 717780f0af2..c1d9609eb47 100644
--- a/mysql-test/r/order_by_sortkey.result
+++ b/mysql-test/r/order_by_sortkey.result
@@ -45,6 +45,7 @@ FLUSH STATUS;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -153,6 +154,7 @@ f0 f1 f2
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 100
Sort_scan 1
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index b8011656415..233494238a5 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -2562,6 +2562,50 @@ id id2 dob address city hours_worked_per_week weeks_worked_last_year
16 16 1949-11-07 address16 city16 40 52
50 50 1923-09-08 address50 city50 40 52
drop table t1;
+#
+# MDEV-6322: The PARTITION engine can return wrong query results
+#
+CREATE TABLE t1 (
+CustomerID varchar(5) DEFAULT NULL,
+CompanyName varchar(40) DEFAULT NULL,
+ContactName varchar(30) DEFAULT NULL,
+ContactTitle varchar(30) DEFAULT NULL,
+Address varchar(60) DEFAULT NULL,
+City varchar(15) DEFAULT NULL,
+Region varchar(15) DEFAULT NULL,
+PostalCode varchar(10) DEFAULT NULL,
+Country varchar(15) NOT NULL,
+Phone varchar(24) DEFAULT NULL,
+Fax varchar(24) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS(Country)
+(PARTITION p1 VALUES IN ('Germany','Austria','Switzerland','Poland'),
+PARTITION p2 VALUES IN ('USA','Canada','Mexico'),
+PARTITION p3 VALUES IN ('Spain','Portugal','Italy'),
+PARTITION p4 VALUES IN ('UK','Ireland'),
+PARTITION p5 VALUES IN ('France','Belgium'),
+PARTITION p6 VALUES IN ('Sweden','Finland','Denmark','Norway'),
+PARTITION p7 VALUES IN ('Venezuela','Argentina','Brazil')
+);
+INSERT INTO t1 (CustomerID, City, Country) VALUES
+('ANATR','México D.F','Mexico'),
+('ANTON','México D.F','Mexico'),
+('BOTTM','Tsawassen','Canada'),
+('CENTC','México D.F','Mexico'),
+('GREAL','Eugene','USA'),
+('HUNGC','Elgin','USA'),
+('LAUGB','Vancouver','Canada'),
+('LAZYK','Walla Walla','USA'),
+('LETSS','San Francisco','USA'),
+('LONEP','Portland','USA');
+SELECT * FROM t1 WHERE Country = 'USA';
+CustomerID CompanyName ContactName ContactTitle Address City Region PostalCode Country Phone Fax
+GREAL NULL NULL NULL NULL Eugene NULL NULL USA NULL NULL
+HUNGC NULL NULL NULL NULL Elgin NULL NULL USA NULL NULL
+LAZYK NULL NULL NULL NULL Walla Walla NULL NULL USA NULL NULL
+LETSS NULL NULL NULL NULL San Francisco NULL NULL USA NULL NULL
+LONEP NULL NULL NULL NULL Portland NULL NULL USA NULL NULL
+DROP TABLE t1;
CREATE TABLE t1 ( d DATE NOT NULL)
PARTITION BY RANGE( YEAR(d) ) (
PARTITION p0 VALUES LESS THAN (1960),
diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
index 82ccbe9c6a8..92c9c01db2d 100644
--- a/mysql-test/r/partition_innodb.result
+++ b/mysql-test/r/partition_innodb.result
@@ -694,6 +694,34 @@ count(*)
drop table t3;
drop table t1,t2;
#
+# MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+#
+create table t1(c1 int, c2 int, c3 int, c4 int,
+primary key(c1,c2)) engine=InnoDB
+partition by list columns(c2)
+(partition p1 values in (1,2) engine=InnoDB,
+partition p2 values in (3,4) engine=InnoDB);
+insert into t1 values (1,1,1,1),(2,3,1,1);
+select * from t1 where c1=2 and c2=3;
+c1 c2 c3 c4
+2 3 1 1
+drop table t1;
+#
+# MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
+# also MDEV-6240: Wrong "Impossible where" with LIST partitioning
+#
+CREATE TABLE t1 ( d DATE) ENGINE = InnoDB
+PARTITION BY LIST COLUMNS (d)
+(
+PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
+PARTITION p1 VALUES IN ('1981-01-01')
+);
+INSERT INTO t1 (d) VALUES ('1991-01-01');
+SELECT * FROM t1 WHERE d = '1991-01-01';
+d
+1991-01-01
+DROP TABLE t1;
+#
# MDEV-5963: InnoDB: Assertion failure in file row0sel.cc line 2503,
# Failing assertion: 0 with "key ptr now exceeds key end by 762 bytes"
# (independent testcase for Oracle Bug#13947868)
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result
index 0a4cf9932c0..e52c2c7d886 100644
--- a/mysql-test/r/partition_pruning.result
+++ b/mysql-test/r/partition_pruning.result
@@ -3302,6 +3302,120 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2 ALL NULL NULL NULL NULL 100 Using where
drop table t0, t1;
#
+# Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+#
+CREATE TABLE t1
+(c1 int,
+c2 int,
+c3 int,
+c4 int,
+PRIMARY KEY (c1,c2))
+PARTITION BY LIST COLUMNS (c2)
+(PARTITION p1 VALUES IN (1,2),
+PARTITION p2 VALUES IN (3,4));
+INSERT INTO t1 VALUES (1, 1, 1, 1), (2, 3, 1, 1);
+INSERT INTO t1 VALUES (1, 2, 1, 1), (2, 4, 1, 1);
+SELECT * FROM t1 WHERE c1 = 1 AND c2 < 1;
+c1 c2 c3 c4
+SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 1;
+c1 c2 c3 c4
+1 1 1 1
+SELECT * FROM t1 WHERE c1 = 1 AND c2 = 1;
+c1 c2 c3 c4
+1 1 1 1
+SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
+c1 c2 c3 c4
+1 1 1 1
+1 2 1 1
+SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
+c1 c2 c3 c4
+1 2 1 1
+SELECT * FROM t1 WHERE c1 = 1 AND c2 < 3;
+c1 c2 c3 c4
+1 1 1 1
+1 2 1 1
+SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
+c1 c2 c3 c4
+1 1 1 1
+1 2 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
+c1 c2 c3 c4
+2 3 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 = 3;
+c1 c2 c3 c4
+2 3 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 3;
+c1 c2 c3 c4
+2 3 1 1
+2 4 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 > 3;
+c1 c2 c3 c4
+2 4 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 < 4;
+c1 c2 c3 c4
+2 3 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
+c1 c2 c3 c4
+2 3 1 1
+2 4 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
+c1 c2 c3 c4
+2 4 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 4;
+c1 c2 c3 c4
+2 4 1 1
+SELECT * FROM t1 WHERE c1 = 2 AND c2 > 4;
+c1 c2 c3 c4
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 < 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 1 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 = 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1 const PRIMARY PRIMARY 8 const,const 1
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 < 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 1 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 1 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 > 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 1 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 < 4;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 4;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2 range PRIMARY PRIMARY 8 NULL 1 Using where
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 > 4;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+DROP TABLE t1;
+#
# MDEV-6239: Partition pruning is not working as expected in an inner query
#
create table t1
diff --git a/mysql-test/r/plugin_loaderr.result b/mysql-test/r/plugin_loaderr.result
index 95e5ec794d2..d1189217355 100644
--- a/mysql-test/r/plugin_loaderr.result
+++ b/mysql-test/r/plugin_loaderr.result
@@ -8,3 +8,6 @@ PLUGIN_TYPE STORAGE ENGINE
PLUGIN_LIBRARY NULL
PLUGIN_LIBRARY_VERSION NULL
LOAD_OPTION ON
+#
+# MDEV-6351 --plugin=force has no effect for built-in plugins
+#
diff --git a/mysql-test/r/rpl_mysqldump_slave.result b/mysql-test/r/rpl_mysqldump_slave.result
index 4b29ff99f61..9d2fe860f47 100644
--- a/mysql-test/r/rpl_mysqldump_slave.result
+++ b/mysql-test/r/rpl_mysqldump_slave.result
@@ -4,18 +4,59 @@ include/master-slave.inc
# New --dump-slave, --apply-slave-statements functionality
#
use test;
+-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
STOP ALL SLAVES;
+-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
START ALL SLAVES;
STOP ALL SLAVES;
+-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
START ALL SLAVES;
start slave;
Warnings:
Note 1254 Slave is already running
+-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
start slave;
Warnings:
Note 1254 Slave is already running
+*** Test mysqldump --dump-slave GTID functionality.
+SET gtid_seq_no = 1000;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+DROP TABLE t1;
+CREATE TABLE t2 (a INT PRIMARY KEY);
+DROP TABLE t2;
+
+1. --dump-slave=1
+
+SET GLOBAL gtid_slave_pos='0-1-1001';
+CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos;
+-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+2. --dump-slave=2
+
+-- SET GLOBAL gtid_slave_pos='0-1-1001';
+-- CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos;
+-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+*** Test mysqldump --master-data GTID functionality.
+
+1. --master-data=1
+
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
+SET GLOBAL gtid_slave_pos='0-2-1003';
+
+2. --master-data=2
+
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+-- CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
+
+3. --master-data --single-transaction
+
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
+SET GLOBAL gtid_slave_pos='0-2-1003';
include/rpl_end.inc
diff --git a/mysql-test/r/single_delete_update.result b/mysql-test/r/single_delete_update.result
index d4534a2c2d8..9332effeb56 100644
--- a/mysql-test/r/single_delete_update.result
+++ b/mysql-test/r/single_delete_update.result
@@ -18,6 +18,7 @@ NULL 15
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -36,6 +37,7 @@ DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -71,6 +73,7 @@ NULL 15
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -89,6 +92,7 @@ DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 8
Sort_scan 1
@@ -121,6 +125,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -139,6 +144,7 @@ DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -175,6 +181,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -193,6 +200,7 @@ DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -223,6 +231,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -241,6 +250,7 @@ DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -269,6 +279,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -287,6 +298,7 @@ DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -318,6 +330,7 @@ NULL 13 13
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 1
Sort_rows 4
Sort_scan 0
@@ -341,6 +354,7 @@ DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 1
Sort_rows 4
Sort_scan 0
@@ -378,6 +392,7 @@ NULL 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -396,6 +411,7 @@ DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -431,6 +447,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -449,6 +466,7 @@ DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 16
Sort_scan 1
@@ -493,6 +511,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -517,6 +536,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -535,6 +555,7 @@ DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -571,6 +592,7 @@ NULL 15
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -589,6 +611,7 @@ UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -629,6 +652,7 @@ NULL 15
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -647,6 +671,7 @@ UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -684,6 +709,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -702,6 +728,7 @@ UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -738,6 +765,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -756,6 +784,7 @@ UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -786,6 +815,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -804,6 +834,7 @@ UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -833,6 +864,7 @@ a b c d
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -851,6 +883,7 @@ UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
@@ -883,6 +916,7 @@ NULL 13 13
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 1
Sort_rows 4
Sort_scan 0
@@ -906,6 +940,7 @@ UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 1
Sort_rows 4
Sort_scan 0
@@ -947,6 +982,7 @@ NULL 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -965,6 +1001,7 @@ UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -1005,6 +1042,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -1023,6 +1061,7 @@ UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 5
Sort_scan 1
@@ -1061,6 +1100,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -1085,6 +1125,7 @@ a b c
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
@@ -1103,6 +1144,7 @@ UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
+Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 0
Sort_scan 0
diff --git a/mysql-test/r/stat_tables-enospc.result b/mysql-test/r/stat_tables-enospc.result
new file mode 100644
index 00000000000..f0d76f04eee
--- /dev/null
+++ b/mysql-test/r/stat_tables-enospc.result
@@ -0,0 +1,10 @@
+call mtr.add_suppression("No space left on device");
+create table t1 (a varchar(255), b varchar(255), c varchar(255));
+set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3;
+set debug_dbug='+d,simulate_file_write_error';
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze Error Error writing file 'tmp-file' (Errcode: 28 "No space left on device")
+test.t1 analyze status Operation failed
+set debug_dbug='';
+drop table t1;
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index 6cc627ad16c..4103a3424e9 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -2108,6 +2108,43 @@ EXECUTE stmt;
a
DROP TABLE t1, t2;
DROP VIEW v2;
+#
+# MDEV-6289 : Unexpected results when querying information_schema
+#
+CREATE TABLE t1 (
+id int(11) unsigned NOT NULL AUTO_INCREMENT,
+db varchar(254) NOT NULL DEFAULT '',
+PRIMARY KEY (id),
+UNIQUE KEY db (db)
+) DEFAULT CHARSET=utf8;
+INSERT INTO t1 (db) VALUES ('mysqltest1'),('mysqltest2'),('mysqltest3'),('mysqltest4');
+drop database if exists mysqltest1;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+drop database if exists mysqltest4;
+create database mysqltest1;
+create database mysqltest2;
+create database mysqltest3;
+create database mysqltest4;
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+db
+mysqltest4
+mysqltest3
+mysqltest2
+mysqltest1
+EXPLAIN EXTENDED
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 PRIMARY t1 eq_ref db db 764 information_schema.schemata.SCHEMA_NAME 1 100.00 Using where; Using index
+2 MATERIALIZED schemata ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 select `test`.`t1`.`db` AS `db` from `test`.`t1` semi join (`information_schema`.`schemata`) where (`test`.`t1`.`db` = `information_schema`.`schemata`.`SCHEMA_NAME`) order by `test`.`t1`.`db` desc
+drop table t1;
+drop database mysqltest1;
+drop database mysqltest2;
+drop database mysqltest3;
+drop database mysqltest4;
# End of 5.5 tests
set @subselect_mat_test_optimizer_switch_value=null;
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result
index 95dfc34777b..c6a0344c8a3 100644
--- a/mysql-test/r/subselect_sj_mat.result
+++ b/mysql-test/r/subselect_sj_mat.result
@@ -2148,4 +2148,41 @@ EXECUTE stmt;
a
DROP TABLE t1, t2;
DROP VIEW v2;
+#
+# MDEV-6289 : Unexpected results when querying information_schema
+#
+CREATE TABLE t1 (
+id int(11) unsigned NOT NULL AUTO_INCREMENT,
+db varchar(254) NOT NULL DEFAULT '',
+PRIMARY KEY (id),
+UNIQUE KEY db (db)
+) DEFAULT CHARSET=utf8;
+INSERT INTO t1 (db) VALUES ('mysqltest1'),('mysqltest2'),('mysqltest3'),('mysqltest4');
+drop database if exists mysqltest1;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+drop database if exists mysqltest4;
+create database mysqltest1;
+create database mysqltest2;
+create database mysqltest3;
+create database mysqltest4;
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+db
+mysqltest4
+mysqltest3
+mysqltest2
+mysqltest1
+EXPLAIN EXTENDED
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 PRIMARY t1 eq_ref db db 764 information_schema.schemata.SCHEMA_NAME 1 100.00 Using where; Using index
+2 MATERIALIZED schemata ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 select `test`.`t1`.`db` AS `db` from `test`.`t1` semi join (`information_schema`.`schemata`) where (`test`.`t1`.`db` = `information_schema`.`schemata`.`SCHEMA_NAME`) order by `test`.`t1`.`db` desc
+drop table t1;
+drop database mysqltest1;
+drop database mysqltest2;
+drop database mysqltest3;
+drop database mysqltest4;
# End of 5.5 tests
diff --git a/mysql-test/r/table_options-5867.result b/mysql-test/r/table_options-5867.result
new file mode 100644
index 00000000000..21041c7c5c3
--- /dev/null
+++ b/mysql-test/r/table_options-5867.result
@@ -0,0 +1,37 @@
+install soname 'ha_example';
+set sql_mode='ignore_bad_table_options';
+create table t1 (
+a int complex='c,f,f,f' invalid=3
+) engine=example ull=10000 str='dskj' one_or_two='one' yesno=0
+foobar=barfoo;
+Warnings:
+Warning 1911 Unknown option 'invalid'
+Warning 1911 Unknown option 'foobar'
+create table t2 (a int, key (a) some_option=2014);
+Warnings:
+Warning 1911 Unknown option 'some_option'
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL `complex`='c,f,f,f' `invalid`=3
+) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=10000 `str`='dskj' `one_or_two`='one' `yesno`=0 `foobar`=barfoo `VAROPT`='5'
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ KEY `a` (`a`) `some_option`=2014
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+set sql_mode='';
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL `complex`='c,f,f,f' /* `invalid`=3 */
+) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=10000 `str`='dskj' `one_or_two`='one' `yesno`=0 /* `foobar`=barfoo */ `VAROPT`='5'
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ KEY `a` (`a`) /* `some_option`=2014 */
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
+uninstall soname 'ha_example';
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index e6f4db26c23..639a97be27b 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -722,7 +722,12 @@ DROP TABLE t1;
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
-ERROR 42000: Invalid default value for 'f1'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` bit(2) NOT NULL DEFAULT b'0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+DROP TABLE t1;
create table t1bit7 (a1 bit(7) not null) engine=MyISAM;
create table t2bit7 (b1 bit(7)) engine=MyISAM;
insert into t1bit7 values (b'1100000');
diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result
index 9bdd8658690..80fc942e77c 100644
--- a/mysql-test/r/type_bit_innodb.result
+++ b/mysql-test/r/type_bit_innodb.result
@@ -413,3 +413,12 @@ a
`
drop table t1;
End of 5.0 tests
+create table t1(f1 bit(2) not null default b'10',f2 bit(14) not null default b'11110000111100');
+insert into t1 (f1) values (default);
+insert into t1 values (b'',b''),('','');
+select hex(f1), hex(f2) from t1;
+hex(f1) hex(f2)
+2 3C3C
+0 0
+0 0
+drop table t1;
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index fa36e9b5567..f8649f030bb 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -810,10 +810,10 @@ c1
drop table t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
%
-0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
+0.012345687012345687012345687012
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
MOD()
-0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
+0.012345687012345687012345687012
create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill);
insert into t1 values (-0.123456,0.123456);
select group_concat(f1),group_concat(f2) from t1;
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 5b3594fe503..fb10e65c0ce 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -703,7 +703,7 @@ select .7777777777777777777777777777777777777 *
777777777777777777.777777777777777777700000000000
select .7777777777777777777777777777777777777 - 0.1;
.7777777777777777777777777777777777777 - 0.1
-0.6777777777777777777777777777777777777
+0.677777777777777777777777777778
select .343434343434343434 + .343434343434343434;
.343434343434343434 + .343434343434343434
0.686868686868686868
@@ -1840,7 +1840,7 @@ Warnings:
Note 1265 Data truncated for column 'c1' at row 4
DESC t2;
Field Type Null Key Default Extra
-c1 decimal(32,30) YES NULL
+c1 decimal(33,30) YES NULL
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(30,30));
INSERT INTO t1 VALUES (0.1),(0.2),(0.3);
@@ -1851,7 +1851,7 @@ Note 1265 Data truncated for column 'c1' at row 2
Note 1265 Data truncated for column 'c1' at row 3
DESC t2;
Field Type Null Key Default Extra
-c1 decimal(34,0) YES NULL
+c1 decimal(33,30) YES NULL
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(30,30));
INSERT INTO t1 VALUES (0.1),(0.2),(0.3);
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 6d99cad30f0..4ecac34d9fa 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1876,6 +1876,40 @@ SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev;
dev
1
#
+# Bug #17059925 : UNIONS COMPUTES ROWS_EXAMINED INCORRECTLY
+#
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_log_output= @@global.log_output;
+SET @old_long_query_time= @@long_query_time;
+SET GLOBAL log_output= "TABLE";
+SET GLOBAL slow_query_log= ON;
+SET SESSION long_query_time= 0;
+CREATE TABLE t17059925 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+INSERT INTO t17059925 VALUES (1), (2), (3);
+INSERT INTO t2 VALUES (4), (5), (6);
+INSERT INTO t3 VALUES (7), (8), (9);
+TRUNCATE table mysql.slow_log;
+SELECT * FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+SELECT sql_text, rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%t17059925%';
+sql_text rows_examined
+SELECT * FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3 18
+DROP TABLE t17059925, t2, t3;
+SET @@long_query_time= @old_long_query_time;
+SET @@global.log_output= @old_log_output;
+SET @@global.slow_query_log= @old_slow_query_log;
+#
# lp:1010729: Unexpected syntax error from UNION
# (bug #54382) with single-table join nest
#
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 2ba64ed3003..a93e3a210ed 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -189,6 +189,8 @@ select @@concurrent_insert;
@@concurrent_insert
AUTO
set global timed_mutexes=ON;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
show variables like 'timed_mutexes';
Variable_name Value
timed_mutexes ON
@@ -196,6 +198,8 @@ select * from information_schema.session_variables where variable_name like 'tim
VARIABLE_NAME VARIABLE_VALUE
TIMED_MUTEXES ON
set global timed_mutexes=0;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
show variables like 'timed_mutexes';
Variable_name Value
timed_mutexes OFF
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 64b329e9e01..ca08c53cabe 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4789,6 +4789,45 @@ DROP DATABASE IF EXISTS nodb;
CREATE VIEW nodb.a AS SELECT 1;
ERROR 42000: Unknown database 'nodb'
#
+# BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION
+# BUG#18405221 - SHOW CREATE VIEW OUTPUT INCORRECT
+#
+CREATE VIEW v1 AS (SELECT '' FROM DUAL);
+CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+(SELECT '' FROM DUAL);
+CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+(SELECT '' FROM DUAL) UNION ALL
+(SELECT '' FROM DUAL);
+CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+(SELECT '' AS col2 FROM DUAL) UNION ALL
+(SELECT '' FROM DUAL);
+CREATE VIEW v5 AS (SELECT 'buggy' AS col1, 'fix' as col2 FROM DUAL) UNION ALL
+(SELECT 'buggy' as a, 'fix' as a FROM DUAL);
+# Name for the column in select1 is set properly with or
+# without this fix.
+SHOW CREATE VIEW v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
+# Name for the column in select2 is set with this fix.
+# Without this fix, name would not have set for the
+# columns in select2.
+SHOW CREATE VIEW v2;
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
+# Name for the field item in select2 & select3 is set with this fix.
+# Without this fix, name would not have set for the
+# columns in select2 & select3.
+SHOW CREATE VIEW v3;
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `Name_exp_1`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
+# Name for the field item in select3 is set with this fix.
+# Without this fix, name would not have set for the
+# columns in select3.
+SHOW CREATE VIEW v4;
+View Create View character_set_client collation_connection
+v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `col2`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
+DROP VIEW v1, v2, v3, v4, v5;
+#
# lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin)
#
CREATE TABLE t1 ( a int, b int );
@@ -5300,6 +5339,61 @@ NULL 8
drop view v1;
drop table t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch_MDEV_3874;
+CREATE TABLE `t1` (
+`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+`f0` int(11) unsigned NOT NULL DEFAULT '0',
+`f1` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`),
+UNIQUE KEY `id` (`id`)
+);
+CREATE TABLE `t2` (
+`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+`f02` bigint(20) unsigned NOT NULL DEFAULT '0',
+`f03` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`),
+UNIQUE KEY `id` (`id`)
+);
+CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v1` AS
+SELECT
+`t1`.`f0` AS `f0`,
+`t1`.`f1` AS `f1`,
+`t2`.`f02` AS `f02`,
+`t2`.`f03` AS `f03`
+FROM
+(`t1` LEFT JOIN `t2` ON((`t1`.`id` = `t2`.`f02`)));
+CREATE FUNCTION `f1`(
+p0 BIGINT(20) UNSIGNED
+)
+RETURNS bigint(20) unsigned
+DETERMINISTIC
+CONTAINS SQL
+SQL SECURITY DEFINER
+COMMENT ''
+BEGIN
+DECLARE k0 INTEGER UNSIGNED DEFAULT 0;
+DECLARE lResult INTEGER UNSIGNED DEFAULT 0;
+SET k0 = 0;
+WHILE k0 < 1 DO
+SELECT COUNT(*) as `f00` INTO lResult FROM `v1` WHERE `v1`.`f0` = p0; -- BUG
+SET k0 = k0 + 1;
+END WHILE;
+RETURN(k0);
+END|
+SELECT `f1`(1);
+`f1`(1)
+1
+SELECT `f1`(1);
+`f1`(1)
+1
+SELECT `f1`(1);
+`f1`(1)
+1
+SELECT `f1`(1);
+`f1`(1)
+1
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE t1, t2;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/std_data/checkDBI_DBD-mysql.pl b/mysql-test/std_data/checkDBI_DBD-mysql.pl
index d62d2f8bfc0..d62d2f8bfc0 100644..100755
--- a/mysql-test/std_data/checkDBI_DBD-mysql.pl
+++ b/mysql-test/std_data/checkDBI_DBD-mysql.pl
diff --git a/mysql-test/std_data/mdev6020-mysql-bin.000001 b/mysql-test/std_data/mdev6020-mysql-bin.000001
new file mode 100644
index 00000000000..49853674e9f
--- /dev/null
+++ b/mysql-test/std_data/mdev6020-mysql-bin.000001
Binary files differ
diff --git a/mysql-test/std_data/new-format-relay-log-win.info b/mysql-test/std_data/new-format-relay-log-win.info
new file mode 100644
index 00000000000..e00383b5565
--- /dev/null
+++ b/mysql-test/std_data/new-format-relay-log-win.info
@@ -0,0 +1,6 @@
+5
+.\slave-relay-bin.000001
+4
+
+0
+0
diff --git a/mysql-test/std_data/new-format-relay-log.info b/mysql-test/std_data/new-format-relay-log.info
new file mode 100644
index 00000000000..883dec1f66b
--- /dev/null
+++ b/mysql-test/std_data/new-format-relay-log.info
@@ -0,0 +1,6 @@
+5
+./slave-relay-bin.000001
+4
+
+0
+0
diff --git a/mysql-test/std_data/old-format-relay-log-win.info b/mysql-test/std_data/old-format-relay-log-win.info
new file mode 100644
index 00000000000..7673de6b956
--- /dev/null
+++ b/mysql-test/std_data/old-format-relay-log-win.info
@@ -0,0 +1,4 @@
+.\slave-relay-bin.000001
+4
+
+0
diff --git a/mysql-test/std_data/old-format-relay-log.info b/mysql-test/std_data/old-format-relay-log.info
new file mode 100644
index 00000000000..6043b4058f6
--- /dev/null
+++ b/mysql-test/std_data/old-format-relay-log.info
@@ -0,0 +1,4 @@
+./slave-relay-bin.000001
+4
+
+0
diff --git a/mysql-test/suite/archive/partition_archive.result b/mysql-test/suite/archive/partition_archive.result
index bb3e531a2ed..eb1fca46522 100644
--- a/mysql-test/suite/archive/partition_archive.result
+++ b/mysql-test/suite/archive/partition_archive.result
@@ -127,3 +127,29 @@ select count(*) from t1;
count(*)
100
drop table t1;
+#
+#BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
+# CORRUPTS FRM
+CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= MYISAM PARTITION BY HASH(fld1)
+PARTITIONS 5;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `fld1` int(11) NOT NULL,
+ PRIMARY KEY (`fld1`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (fld1)
+PARTITIONS 5 */
+ALTER TABLE t1 ENGINE= ARCHIVE;
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
+#After the patch, the ENGINE is correctly displayed as MyISAM
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `fld1` int(11) NOT NULL,
+ PRIMARY KEY (`fld1`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (fld1)
+PARTITIONS 5 */
+#Cleanup.
+DROP TABLE t1;
diff --git a/mysql-test/suite/archive/partition_archive.test b/mysql-test/suite/archive/partition_archive.test
index be2abeada73..899f266c09c 100644
--- a/mysql-test/suite/archive/partition_archive.test
+++ b/mysql-test/suite/archive/partition_archive.test
@@ -129,3 +129,21 @@ show create table t1;
select count(*) from t1;
drop table t1;
+
+--echo #
+--echo #BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
+--echo # CORRUPTS FRM
+
+CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= MYISAM PARTITION BY HASH(fld1)
+PARTITIONS 5;
+SHOW CREATE TABLE t1;
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t1 ENGINE= ARCHIVE;
+
+--echo #After the patch, the ENGINE is correctly displayed as MyISAM
+SHOW CREATE TABLE t1;
+
+--echo #Cleanup.
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_killed.test b/mysql-test/suite/binlog/t/binlog_killed.test
index 0a2ba084d78..73759ee5aa5 100644
--- a/mysql-test/suite/binlog/t/binlog_killed.test
+++ b/mysql-test/suite/binlog/t/binlog_killed.test
@@ -353,6 +353,10 @@ drop function bug27563;
# common cleanup
#
+connection default;
+disconnect con1;
+disconnect con2;
+
drop table t1,t2,t3;
--echo end of the tests
diff --git a/mysql-test/suite/engines/iuds/r/insert_time.result b/mysql-test/suite/engines/iuds/r/insert_time.result
index dceba37ae8e..6680886aad1 100644
--- a/mysql-test/suite/engines/iuds/r/insert_time.result
+++ b/mysql-test/suite/engines/iuds/r/insert_time.result
@@ -5035,9 +5035,9 @@ CAST(0.2359591234567e6 AS TIME)
23:59:59
SELECT CAST(0.2359591234567e+30 AS TIME);
CAST(0.2359591234567e+30 AS TIME)
-NULL
+838:59:59
Warnings:
-Warning 1292 Incorrect datetime value: '2.359591234567e29'
+Warning 1292 Truncated incorrect time value: '2.359591234567e29'
select cast('100:55:50' as time) < cast('24:00:00' as time);
cast('100:55:50' as time) < cast('24:00:00' as time)
0
diff --git a/mysql-test/suite/engines/iuds/suite.opt b/mysql-test/suite/engines/iuds/suite.opt
new file mode 100644
index 00000000000..e5648163418
--- /dev/null
+++ b/mysql-test/suite/engines/iuds/suite.opt
@@ -0,0 +1,2 @@
+--timezone=GMT-3
+
diff --git a/mysql-test/suite/innodb/include/innodb_simulate_comp_failures.inc b/mysql-test/suite/innodb/include/innodb_simulate_comp_failures.inc
new file mode 100644
index 00000000000..47494d60375
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_simulate_comp_failures.inc
@@ -0,0 +1,147 @@
+--echo #
+--echo # Testing robustness against random compression failures
+--echo #
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+
+--disable_query_log
+# record the file format in order to restore in the end.
+--let $file_format_save = `SELECT @@innodb_file_format`
+--let $file_format_max_save = `SELECT @@innodb_file_format_max`
+--let $simulate_comp_failures_save = `SELECT @@innodb_simulate_comp_failures`
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+SET GLOBAL INNODB_FILE_FORMAT='Barracuda';
+--enable_warnings
+
+# since this test generates lot of errors in log, suppress checking errors
+call mtr.add_suppression(".*");
+--enable_query_log
+
+# create the table with compressed pages of size 8K.
+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+# percentage of compressions that will be forced to fail
+SET GLOBAL innodb_simulate_comp_failures = 25;
+
+--disable_query_log
+--disable_result_log
+
+let $num_inserts_ind = $num_inserts;
+while ($num_inserts_ind)
+{
+ let $repeat = `select floor(rand() * 10)`;
+ eval
+INSERT INTO t1(id, msg)
+VALUES ($num_inserts_ind, REPEAT('abcdefghijklmnopqrstuvwxyz', $repeat));
+ dec $num_inserts_ind;
+}
+
+--enable_query_log
+--enable_result_log
+
+SELECT COUNT(*) FROM t1;
+
+--disable_query_log
+--disable_result_log
+
+# do random ops, making sure that some pages will get fragmented and reorganized.
+let $num_ops_ind = $num_ops;
+
+while($num_ops_ind)
+{
+ let $idx = `select floor(rand()*$num_inserts)`;
+ let $insert_or_update = `select floor(rand()*3)`;
+
+ let $repeat = `select floor(rand() * 9) + 1`;
+
+ let $msg = query_get_value(`select repeat('abcdefghijklmnopqrstuvwxyz', $repeat) as x`, x, 1);
+
+ let $single_or_multi = `select floor(rand()*10)`;
+
+ if ($insert_or_update)
+ {
+ let $cnt = query_get_value(SELECT COUNT(*) cnt FROM t1 WHERE id=$idx, cnt, 1);
+
+ if ($cnt)
+ {
+ let $update = `select floor(rand()*2)`;
+
+ if ($update)
+ {
+ if ($single_or_multi)
+ {
+ eval UPDATE t1 SET msg=\"$msg\" WHERE id=$idx;
+ }
+
+ if (!$single_or_multi)
+ {
+ eval UPDATE t1 SET msg=\"$msg\" WHERE id >= $idx - 100 AND id <= $idx + 100;
+ }
+
+ }
+
+ if (!$update)
+ {
+ if ($single_or_multi)
+ {
+ eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id = VALUES(id);
+ }
+
+ if (!$single_or_multi)
+ {
+ let $diff = 200;
+
+ while ($diff)
+ {
+ eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx + 100 - $diff) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id=VALUES(id);
+
+ dec $diff;
+ }
+ }
+ }
+ }
+
+ if (!$cnt)
+ {
+ let $null_msg = `select floor(rand()*2)`;
+
+ if ($null_msg)
+ {
+ eval INSERT INTO t1(id,msg) VALUES ($idx, NULL);
+ }
+
+ if (!$null_msg)
+ {
+ eval INSERT INTO t1(id, msg) VALUES ($idx, \"$msg\");
+ }
+ }
+ }
+
+ if (!$insert_or_update)
+ {
+ if ($single_or_multi)
+ {
+ eval DELETE from t1 WHERE id=$idx;
+ }
+
+ if (!$single_or_multi)
+ {
+ eval DELETE from t1 WHERE id >= $idx - 100 AND id <= $idx + 100;
+ }
+ }
+
+ dec $num_ops_ind;
+}
+
+# final cleanup
+DROP TABLE t1;
+
+# restore innodb_file_format and innodb_file_format_max
+eval SET GLOBAL innodb_file_format = \"$file_format_save\";
+eval SET GLOBAL innodb_file_format_max = \"$file_format_max_save\";
+eval SET GLOBAL innodb_simulate_comp_failures = $simulate_comp_failures_save;
+
+--enable_query_log
diff --git a/mysql-test/suite/innodb/r/blob_unique2pk.result b/mysql-test/suite/innodb/r/blob_unique2pk.result
new file mode 100644
index 00000000000..57953dc8624
--- /dev/null
+++ b/mysql-test/suite/innodb/r/blob_unique2pk.result
@@ -0,0 +1,15 @@
+create table t1 (f1 tinyblob not null) engine=innodb;
+alter table t1 add unique index (f1(255));
+drop table t1;
+create table t1 (f1 tinyblob not null) engine=innodb;
+alter table t1 add unique index (f1(356));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` tinyblob NOT NULL,
+ UNIQUE KEY `f1` (`f1`(255))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (f1 point not null) engine=innodb;
+alter table t1 add unique index (f1);
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-alter-table-disk-full.result b/mysql-test/suite/innodb/r/innodb-alter-table-disk-full.result
new file mode 100644
index 00000000000..ffeacae7951
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-alter-table-disk-full.result
@@ -0,0 +1,50 @@
+create table t1(a int not null primary key, b int) engine=innodb;
+create procedure innodb_insert_proc (repeat_count int)
+begin
+declare current_num int;
+set current_num = 0;
+while current_num < repeat_count do
+insert into t1 values(current_num, current_num);
+set current_num = current_num + 1;
+end while;
+end//
+commit;
+set autocommit=0;
+call innodb_insert_proc(10000);
+commit;
+set autocommit=1;
+set DEBUG_DBUG='+d,ib_os_aio_func_io_failure_28';
+alter table t1 add testcol int;
+ERROR HY000: The table 't1' is full
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+set DEBUG_DBUG='+d,ib_os_aio_func_io_failure_28_2';
+alter table t1 add testcol int;
+ERROR HY000: The table 't1' is full
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+set DEBUG_DBUG=NULL;
+alter table t1 add testcol2 int;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ `testcol2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select count(1) from t1;
+count(1)
+10000
+drop procedure innodb_insert_proc;
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result
new file mode 100644
index 00000000000..cf883d83874
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-fk.result
@@ -0,0 +1,35 @@
+#
+# Bug #18806829 OPENING INNODB TABLES WITH MANY FOREIGN KEY
+# REFERENCES IS SLOW/CRASHES SEMAPHORE
+#
+create table t1 (f1 int primary key) engine=innodb;
+insert into t1 values (5);
+insert into t1 values (2882);
+insert into t1 values (10);
+update t1 set f1 = 28 where f1 = 2882;
+select * from fk_120;
+f1
+5
+10
+28
+select * from fk_1;
+f1
+5
+10
+28
+select * from fk_50;
+f1
+5
+10
+28
+drop table t1;
+#
+# Check if restrict is working fine.
+#
+create table t1 (f1 int primary key) engine=innodb;
+delete from t1 where f1 = 29;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`fk_29`, CONSTRAINT `pc29` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`))
+select * from fk_29;
+f1
+29
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-stats-initialize-failure.result b/mysql-test/suite/innodb/r/innodb-stats-initialize-failure.result
new file mode 100644
index 00000000000..ef2d3182b92
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-stats-initialize-failure.result
@@ -0,0 +1,32 @@
+call mtr.add_suppression("InnoDB: Warning: Index.*");
+set DEBUG_DBUG='+d,ib_ha_innodb_stat_not_initialized';
+create table t1(a int not null primary key, b int, c int, key(b), key(c)) engine=innodb;
+create procedure innodb_insert_proc (repeat_count int)
+begin
+declare current_num int;
+set current_num = 0;
+while current_num < repeat_count do
+insert into t1 values(current_num, current_num, current_num);
+set current_num = current_num + 1;
+end while;
+end//
+commit;
+set autocommit=0;
+call innodb_insert_proc(10000);
+commit;
+set autocommit=1;
+select count(1) from t1;
+count(1)
+10000
+select count(1) from t1 where a between 5 and 100;
+count(1)
+96
+select count(1) from t1 where b between 5 and 256;
+count(1)
+252
+select count(1) from t1 where c between 7 and 787;
+count(1)
+781
+set DEBUG_DBUG=NULL;
+drop procedure innodb_insert_proc;
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb_simulate_comp_failures.result b/mysql-test/suite/innodb/r/innodb_simulate_comp_failures.result
new file mode 100644
index 00000000000..cb7a3b9c282
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_simulate_comp_failures.result
@@ -0,0 +1,8 @@
+#
+# Testing robustness against random compression failures
+#
+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+SET GLOBAL innodb_simulate_comp_failures = 25;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+100000
diff --git a/mysql-test/suite/innodb/r/innodb_simulate_comp_failures_small.result b/mysql-test/suite/innodb/r/innodb_simulate_comp_failures_small.result
new file mode 100644
index 00000000000..1cb2cf77050
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_simulate_comp_failures_small.result
@@ -0,0 +1,8 @@
+#
+# Testing robustness against random compression failures
+#
+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+SET GLOBAL innodb_simulate_comp_failures = 25;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10000
diff --git a/mysql-test/suite/innodb/t/blob_unique2pk.test b/mysql-test/suite/innodb/t/blob_unique2pk.test
new file mode 100644
index 00000000000..ff6720690dd
--- /dev/null
+++ b/mysql-test/suite/innodb/t/blob_unique2pk.test
@@ -0,0 +1,20 @@
+--source include/have_innodb.inc
+
+
+#
+# Bug#16368875 INNODB: FAILING ASSERTION: PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0
+#
+create table t1 (f1 tinyblob not null) engine=innodb;
+alter table t1 add unique index (f1(255));
+drop table t1;
+
+create table t1 (f1 tinyblob not null) engine=innodb;
+alter table t1 add unique index (f1(356));
+show create table t1;
+drop table t1;
+
+create table t1 (f1 point not null) engine=innodb;
+alter table t1 add unique index (f1);
+drop table t1;
+
+
diff --git a/mysql-test/suite/innodb/t/innodb-alter-table-disk-full-master.opt b/mysql-test/suite/innodb/t/innodb-alter-table-disk-full-master.opt
new file mode 100644
index 00000000000..9c2ee7846b6
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-alter-table-disk-full-master.opt
@@ -0,0 +1 @@
+--innodb-use-native-aio=0
diff --git a/mysql-test/suite/innodb/t/innodb-alter-table-disk-full.test b/mysql-test/suite/innodb/t/innodb-alter-table-disk-full.test
new file mode 100644
index 00000000000..4e3a7bfdae6
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-alter-table-disk-full.test
@@ -0,0 +1,47 @@
+# MDEV-6288: Innodb causes server crash after disk full, then can't ALTER TABLE any more
+--source include/have_innodb.inc
+
+# DEBUG_SYNC must be compiled in.
+--source include/have_debug_sync.inc
+
+create table t1(a int not null primary key, b int) engine=innodb;
+
+delimiter //;
+create procedure innodb_insert_proc (repeat_count int)
+begin
+ declare current_num int;
+ set current_num = 0;
+ while current_num < repeat_count do
+ insert into t1 values(current_num, current_num);
+ set current_num = current_num + 1;
+ end while;
+end//
+delimiter ;//
+commit;
+
+set autocommit=0;
+call innodb_insert_proc(10000);
+commit;
+set autocommit=1;
+
+# This caused crash earlier
+set DEBUG_DBUG='+d,ib_os_aio_func_io_failure_28';
+--error 1114
+alter table t1 add testcol int;
+show create table t1;
+
+# This caused crash earlier
+set DEBUG_DBUG='+d,ib_os_aio_func_io_failure_28_2';
+--error 1114
+alter table t1 add testcol int;
+show create table t1;
+
+set DEBUG_DBUG=NULL;
+alter table t1 add testcol2 int;
+show create table t1;
+
+select count(1) from t1;
+
+drop procedure innodb_insert_proc;
+drop table t1;
+
diff --git a/mysql-test/suite/innodb/t/innodb-fk.test b/mysql-test/suite/innodb/t/innodb-fk.test
new file mode 100644
index 00000000000..9839cd2d084
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-fk.test
@@ -0,0 +1,86 @@
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+
+--echo #
+--echo # Bug #18806829 OPENING INNODB TABLES WITH MANY FOREIGN KEY
+--echo # REFERENCES IS SLOW/CRASHES SEMAPHORE
+--echo #
+
+create table t1 (f1 int primary key) engine=innodb;
+insert into t1 values (5);
+insert into t1 values (2882);
+insert into t1 values (10);
+
+let $fk_tables = 120;
+
+--disable_query_log
+let $i = $fk_tables;
+while ($i)
+{
+ eval create table fk_$i (f1 int primary key,
+ constraint pc$i foreign key (f1) references t1(f1)
+ on delete cascade on update cascade) engine=innodb;
+ eval insert into fk_$i values (5);
+ eval insert into fk_$i values (2882);
+ eval insert into fk_$i values (10);
+ dec $i;
+}
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+update t1 set f1 = 28 where f1 = 2882;
+
+select * from fk_120;
+select * from fk_1;
+select * from fk_50;
+
+--disable_query_log
+let $i = $fk_tables;
+while ($i)
+{
+ eval drop table fk_$i;
+ dec $i;
+}
+--enable_query_log
+
+drop table t1;
+
+--echo #
+--echo # Check if restrict is working fine.
+--echo #
+
+create table t1 (f1 int primary key) engine=innodb;
+
+let $fk_tables = 30;
+
+--disable_query_log
+let $i = $fk_tables;
+while ($i)
+{
+ eval create table fk_$i (f1 int primary key,
+ constraint pc$i foreign key (f1) references t1(f1)
+ on delete restrict on update restrict) engine=innodb;
+ eval insert into t1 values ($i);
+ eval insert into fk_$i values ($i);
+ dec $i;
+}
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+--error ER_ROW_IS_REFERENCED_2
+delete from t1 where f1 = 29;
+select * from fk_29;
+
+--disable_query_log
+let $i = $fk_tables;
+while ($i)
+{
+ eval drop table fk_$i;
+ dec $i;
+}
+--enable_query_log
+
+drop table t1;
+
diff --git a/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test b/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test
new file mode 100644
index 00000000000..e480f0caf07
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-stats-initialize-failure.test
@@ -0,0 +1,39 @@
+# MDEV-6424: Mariadb server crashes with assertion failure in file ha_innodb.cc
+--source include/have_innodb.inc
+
+# DEBUG_SYNC must be compiled in.
+--source include/have_debug_sync.inc
+
+call mtr.add_suppression("InnoDB: Warning: Index.*");
+# This caused crash earlier
+set DEBUG_DBUG='+d,ib_ha_innodb_stat_not_initialized';
+create table t1(a int not null primary key, b int, c int, key(b), key(c)) engine=innodb;
+
+delimiter //;
+create procedure innodb_insert_proc (repeat_count int)
+begin
+ declare current_num int;
+ set current_num = 0;
+ while current_num < repeat_count do
+ insert into t1 values(current_num, current_num, current_num);
+ set current_num = current_num + 1;
+ end while;
+end//
+delimiter ;//
+commit;
+
+set autocommit=0;
+call innodb_insert_proc(10000);
+commit;
+set autocommit=1;
+
+select count(1) from t1;
+select count(1) from t1 where a between 5 and 100;
+select count(1) from t1 where b between 5 and 256;
+select count(1) from t1 where c between 7 and 787;
+
+set DEBUG_DBUG=NULL;
+
+drop procedure innodb_insert_proc;
+drop table t1;
+
diff --git a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures-master.opt b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures-master.opt
new file mode 100644
index 00000000000..fae32059249
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures-master.opt
@@ -0,0 +1,2 @@
+--innodb-file-per-table
+
diff --git a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test
new file mode 100644
index 00000000000..a940a926f85
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures.test
@@ -0,0 +1,8 @@
+--source include/big_test.inc
+# test takes too long with valgrind
+--source include/not_valgrind.inc
+--let $num_inserts = 100000
+--let $num_ops = 30000
+--source suite/innodb/include/innodb_simulate_comp_failures.inc
+# clean exit
+--exit
diff --git a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small-master.opt b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small-master.opt
new file mode 100644
index 00000000000..fae32059249
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small-master.opt
@@ -0,0 +1,2 @@
+--innodb-file-per-table
+
diff --git a/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small.test b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small.test
new file mode 100644
index 00000000000..7332a8c6ba4
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_simulate_comp_failures_small.test
@@ -0,0 +1,5 @@
+--let $num_inserts = 10000
+--let $num_ops = 3000
+--source suite/innodb/include/innodb_simulate_comp_failures.inc
+# clean exit
+--exit
diff --git a/mysql-test/suite/maria/maria3.result b/mysql-test/suite/maria/maria3.result
index 021cc8fc357..74eed530bd9 100644
--- a/mysql-test/suite/maria/maria3.result
+++ b/mysql-test/suite/maria/maria3.result
@@ -314,6 +314,7 @@ aria_max_sort_file_size 9223372036853727232
aria_pagecache_age_threshold 300
aria_pagecache_buffer_size 8388608
aria_pagecache_division_limit 100
+aria_pagecache_file_hash_size 512
aria_page_checksum OFF
aria_recover NORMAL
aria_repair_threads 1
diff --git a/mysql-test/suite/maria/maria_partition.result b/mysql-test/suite/maria/maria_partition.result
index 372230c0b71..1c4f0fbaf05 100644
--- a/mysql-test/suite/maria/maria_partition.result
+++ b/mysql-test/suite/maria/maria_partition.result
@@ -33,3 +33,18 @@ insert into t1 values (2);
select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb';
a a
drop table t1,t2;
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria PARTITION BY KEY() PARTITIONS 2;
+CREATE VIEW v1 AS SELECT * FROM t1;
+LOCK TABLE v1 WRITE;
+CREATE TABLE v1 (i INT);
+ERROR HY000: Table 'v1' was not locked with LOCK TABLES
+INSERT INTO v1 VALUES (1);
+UNLOCK TABLES;
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1;
+pk
+1
+drop table t1;
+drop view v1;
diff --git a/mysql-test/suite/maria/maria_partition.test b/mysql-test/suite/maria/maria_partition.test
index 47571c7a4be..ca2651bcdc3 100644
--- a/mysql-test/suite/maria/maria_partition.test
+++ b/mysql-test/suite/maria/maria_partition.test
@@ -49,6 +49,28 @@ insert into t1 values (2);
select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb';
drop table t1,t2;
+#
+# MDEV-6493
+# Assertion `table->file->stats.records > 0 || error'
+# failure, or 'Invalid write' valgrind warnings, or crash on scenario
+# with Aria table, view, LOCK TABLES #
+#
+
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria PARTITION BY KEY() PARTITIONS 2;
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+LOCK TABLE v1 WRITE;
+--error 1100
+CREATE TABLE v1 (i INT);
+INSERT INTO v1 VALUES (1);
+UNLOCK TABLES;
+check table t1;
+
+SELECT * FROM t1;
+
+drop table t1;
+drop view v1;
+
# Set defaults back
--disable_result_log
--disable_query_log
diff --git a/mysql-test/suite/plugins/r/false_dupes-6543.result b/mysql-test/suite/plugins/r/false_dupes-6543.result
new file mode 100644
index 00000000000..22accaaae8a
--- /dev/null
+++ b/mysql-test/suite/plugins/r/false_dupes-6543.result
@@ -0,0 +1,5 @@
+install soname 'ha_federated';
+install soname 'ha_federated';
+install soname 'ha_federatedx';
+ERROR HY000: Function 'FEDERATED' already exists
+uninstall soname 'ha_federated';
diff --git a/mysql-test/suite/plugins/t/false_dupes-6543.test b/mysql-test/suite/plugins/t/false_dupes-6543.test
new file mode 100644
index 00000000000..ebdbe00e47c
--- /dev/null
+++ b/mysql-test/suite/plugins/t/false_dupes-6543.test
@@ -0,0 +1,18 @@
+#
+# MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa
+#
+if(!$HA_FEDERATED_SO) {
+ skip Needs ha_federated.so;
+}
+if(!$HA_FEDERATEDX_SO) {
+ skip Needs ha_federatedx.so;
+}
+
+install soname 'ha_federated';
+# note: no error below! install soname ignores already loaded plugins
+install soname 'ha_federated';
+# note: an error here, even though plugin name is the same!
+--error ER_UDF_EXISTS
+install soname 'ha_federatedx';
+uninstall soname 'ha_federated';
+
diff --git a/mysql-test/suite/roles/ip-6401.result b/mysql-test/suite/roles/ip-6401.result
new file mode 100644
index 00000000000..a9876eb8273
--- /dev/null
+++ b/mysql-test/suite/roles/ip-6401.result
@@ -0,0 +1,13 @@
+create role r1;
+create user foo@'127.0.0.1';
+grant r1 to foo@'127.0.0.1';
+show grants;
+Grants for foo@127.0.0.1
+GRANT r1 TO 'foo'@'127.0.0.1'
+GRANT USAGE ON *.* TO 'foo'@'127.0.0.1'
+set role r1;
+select * from information_schema.enabled_roles;
+ROLE_NAME
+r1
+drop user foo@'127.0.0.1';
+drop role r1;
diff --git a/mysql-test/suite/roles/ip-6401.test b/mysql-test/suite/roles/ip-6401.test
new file mode 100644
index 00000000000..34d8553afa3
--- /dev/null
+++ b/mysql-test/suite/roles/ip-6401.test
@@ -0,0 +1,13 @@
+--source include/not_embedded.inc
+create role r1;
+create user foo@'127.0.0.1';
+grant r1 to foo@'127.0.0.1';
+
+--connect (con1,127.0.0.1,foo,,)
+show grants;
+set role r1;
+select * from information_schema.enabled_roles;
+
+connection default;
+drop user foo@'127.0.0.1';
+drop role r1;
diff --git a/mysql-test/suite/rpl/r/failed_create_view-6409.result b/mysql-test/suite/rpl/r/failed_create_view-6409.result
new file mode 100644
index 00000000000..6b04f2960d1
--- /dev/null
+++ b/mysql-test/suite/rpl/r/failed_create_view-6409.result
@@ -0,0 +1,15 @@
+create table v1 (a int);
+include/master-slave.inc
+[connection master]
+create table t1 (a int);
+create view v1 as select * from t1;
+ERROR 42S01: Table 'v1' already exists
+show tables;
+Tables_in_test
+t1
+v1
+show tables;
+Tables_in_test
+t1
+drop table if exists t1, v1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/kill_hard-6290.result b/mysql-test/suite/rpl/r/kill_hard-6290.result
new file mode 100644
index 00000000000..27b62416368
--- /dev/null
+++ b/mysql-test/suite/rpl/r/kill_hard-6290.result
@@ -0,0 +1,4 @@
+include/master-slave.inc
+[connection master]
+kill user test2@nohost;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_checksum.result b/mysql-test/suite/rpl/r/rpl_checksum.result
index 2229ab63ee4..d88258f3b65 100644
--- a/mysql-test/suite/rpl/r/rpl_checksum.result
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result
@@ -128,7 +128,33 @@ insert into t3 value (1, @@global.binlog_checksum);
drop table t1, t2, t3;
set @@global.binlog_checksum = @master_save_binlog_checksum;
set @@global.master_verify_checksum = @save_master_verify_checksum;
+*** Bug#59123 / MDEV-5799: INCIDENT_EVENT checksum written to error log as garbage characters ***
+CREATE TABLE t4 (a INT PRIMARY KEY);
+INSERT INTO t4 VALUES (1);
+SET sql_log_bin=0;
+CALL mtr.add_suppression("\\[ERROR\\] Can't generate a unique log-filename");
+SET sql_log_bin=1;
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET debug_dbug= '+d,binlog_inject_new_name_error';
+FLUSH LOGS;
+ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
+
+SET debug_dbug= @old_dbug;
+INSERT INTO t4 VALUES (2);
+include/wait_for_slave_sql_error.inc [errno=1590]
+Last_SQL_Error = 'The incident LOST_EVENTS occured on the master. Message: error writing to the binary log'
+SELECT * FROM t4 ORDER BY a;
+a
+1
+STOP SLAVE IO_THREAD;
+SET sql_slave_skip_counter= 1;
+include/start_slave.inc
+SELECT * FROM t4 ORDER BY a;
+a
+1
+2
set @@global.binlog_checksum = @slave_save_binlog_checksum;
set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
End of tests
+DROP TABLE t4;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index fd33221814d..e8e5bf36f84 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -61,13 +61,7 @@ include/stop_slave.inc
INSERT INTO t1 VALUES (5, "m1a");
INSERT INTO t2 VALUES (5, "i1a");
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
-MASTER_USE_GTID=SLAVE_POS;
-SET GLOBAL sql_slave_skip_counter=1;
-ERROR HY000: When using GTID, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position.
-CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
-SET GLOBAL sql_slave_skip_counter=10;
-ERROR HY000: When using GTID, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position.
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
a b
@@ -191,14 +185,8 @@ master-bin.000001 #
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
-master-bin.000001 # Gtid_list # # [1-2-20,0-1-10,0-3-30]
+master-bin.000001 # Gtid_list # # [#-#-#]
master-bin.000001 # Binlog_checkpoint # # master-bin.000001
-SELECT @@GLOBAL.gtid_binlog_pos;
-@@GLOBAL.gtid_binlog_pos
-1-2-20,0-3-30
-SELECT @@GLOBAL.gtid_binlog_state;
-@@GLOBAL.gtid_binlog_state
-1-2-20,0-1-10,0-3-30
SET GLOBAL gtid_binlog_state = @old_state;
ERROR HY000: This operation is not allowed if any GTID has been logged to the binary log. Run RESET MASTER first to erase the log
RESET MASTER;
@@ -258,7 +246,7 @@ a
include/stop_slave.inc
SET gtid_domain_id= 1;
INSERT INTO t1 VALUES (3);
-SET @pos= '1-1-1,0-1-110';
+SET @pos= 'POS';
SELECT master_gtid_wait(@pos, 0);
master_gtid_wait(@pos, 0)
-1
@@ -322,5 +310,108 @@ master_gtid_wait('2-1-10')
0
master_gtid_wait('2-1-10')
0
+*** Test sql_gtid_slave_pos when used with GTID ***
+include/stop_slave.inc
+SET gtid_domain_id=2;
+SET gtid_seq_no=1000;
+INSERT INTO t1 VALUES (10);
+INSERT INTO t1 VALUES (11);
+SET sql_slave_skip_counter= 1;
+include/start_slave.inc
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a
+11
+SELECT IF(LOCATE("2-1-1001", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1001 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+include/stop_slave.inc
+SET gtid_domain_id=2;
+SET gtid_seq_no=1010;
+INSERT INTO t1 VALUES (12);
+INSERT INTO t1 VALUES (13);
+SET sql_slave_skip_counter= 2;
+include/start_slave.inc
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a
+11
+13
+SELECT IF(LOCATE("2-1-1011", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1011 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+include/stop_slave.inc
+SET gtid_domain_id=2;
+SET gtid_seq_no=1020;
+INSERT INTO t1 VALUES (14);
+INSERT INTO t1 VALUES (15);
+INSERT INTO t1 VALUES (16);
+SET sql_slave_skip_counter= 3;
+include/start_slave.inc
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a
+11
+13
+15
+16
+SELECT IF(LOCATE("2-1-1022", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1022 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+include/stop_slave.inc
+SET gtid_domain_id=2;
+SET gtid_seq_no=1030;
+INSERT INTO t1 VALUES (17);
+INSERT INTO t1 VALUES (18);
+INSERT INTO t1 VALUES (19);
+SET sql_slave_skip_counter= 5;
+include/start_slave.inc
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a
+11
+13
+15
+16
+19
+SELECT IF(LOCATE("2-1-1032", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1032 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+include/stop_slave.inc
+SET gtid_domain_id=3;
+SET gtid_seq_no=100;
+CREATE TABLE t2 (a INT PRIMARY KEY);
+DROP TABLE t2;
+SET gtid_domain_id=2;
+SET gtid_seq_no=1040;
+INSERT INTO t1 VALUES (20);
+SET @saved_mode= @@GLOBAL.slave_ddl_exec_mode;
+SET GLOBAL slave_ddl_exec_mode=STRICT;
+SET sql_slave_skip_counter=1;
+START SLAVE UNTIL master_gtid_pos="3-1-100";
+include/sync_with_master_gtid.inc
+include/wait_for_slave_sql_to_stop.inc
+SELECT * FROM t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Slave: Unknown table 'test\\.t2' Error_code: 1051");
+SET sql_log_bin=1;
+START SLAVE;
+include/wait_for_slave_sql_error.inc [errno=1051]
+SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+STOP SLAVE IO_THREAD;
+SET sql_slave_skip_counter=2;
+include/start_slave.inc
+SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
+a
+20
+SELECT IF(LOCATE("3-1-101", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-101 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+SELECT IF(LOCATE("2-1-1040", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1040 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+status
+Ok
+SET GLOBAL slave_ddl_exec_mode= @saved_mode;
DROP TABLE t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_crash.result b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
index fdbd1cc6898..45482e3b03e 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_crash.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
@@ -46,7 +46,7 @@ master-bin.000002 #
master-bin.000003 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000003 # Gtid_list # # [1-1-2,2-1-1,0-1-1]
+master-bin.000003 # Gtid_list # # #
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
@@ -58,7 +58,7 @@ master-bin.000003 #
master-bin.000004 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000004 # Gtid_list # # [1-1-2,0-1-1,2-1-1]
+master-bin.000004 # Gtid_list # # #
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_errorlog.result b/mysql-test/suite/rpl/r/rpl_gtid_errorlog.result
new file mode 100644
index 00000000000..204615201d9
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_gtid_errorlog.result
@@ -0,0 +1,42 @@
+include/master-slave.inc
+[connection master]
+*** Test MDEV-6120, output of current GTID when a replication error is logged to the errorlog ***
+CREATE TABLE t1(a INT PRIMARY KEY);
+include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=slave_pos;
+INSERT INTO t1 VALUES (1);
+SET gtid_seq_no=100;
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES (2);
+SET sql_log_bin=1;
+START SLAVE;
+include/wait_for_slave_sql_error.inc [errno=1062]
+include/stop_slave.inc
+SET GLOBAL gtid_slave_pos= "0-1-100";
+include/start_slave.inc
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+4
+SET @dbug_save= @@debug_dbug;
+SET debug_dbug= '+d,incident_database_resync_on_replace';
+REPLACE INTO t1 VALUES (5);
+SET debug_dbug= @dbug_save;
+include/wait_for_slave_sql_error.inc [errno=1590]
+include/stop_slave.inc
+SET sql_slave_skip_counter=1;
+include/start_slave.inc
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+4
+5
+DROP TABLE t1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_master_promote.result b/mysql-test/suite/rpl/r/rpl_gtid_master_promote.result
index 132c01f5f55..599c35164dd 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_master_promote.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_master_promote.result
@@ -119,7 +119,7 @@ a b
2 3
*** Now replicate all extra changes from 3,4,5 to 2, in preparation for making 2 the new master. ***
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_3;
-START SLAVE UNTIL master_gtid_pos = "1-1-1,0-1-3,3-1-7,2-1-4";
+START SLAVE UNTIL master_gtid_pos = "SERVER3_POS";
include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
a
@@ -142,7 +142,7 @@ a b
3 1
3 3
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4;
-START SLAVE UNTIL master_gtid_pos = "1-1-7,0-1-3,3-1-4,2-1-1";
+START SLAVE UNTIL master_gtid_pos = "SERVER4_POS";
include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
a
@@ -168,7 +168,7 @@ a b
3 1
3 3
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_5;
-START SLAVE UNTIL master_gtid_pos = "1-1-4,0-1-3,3-1-1,2-1-7";
+START SLAVE UNTIL master_gtid_pos = "SERVER5_POS";
include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
a
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
index ddcbaf8dffd..60c8e4666b9 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
@@ -34,10 +34,10 @@ master-bin.000003 # Gtid_list # # [0-1-3]
FLUSH LOGS;
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000004 # Gtid_list # # [1-1-1,0-1-4]
+master-bin.000004 # Gtid_list # # #
SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000005 # Gtid_list # # [1-1-1,0-1-4]
+master-bin.000005 # Gtid_list # # #
show binary logs;
Log_name File_size
master-bin.000002 #
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_until.result b/mysql-test/suite/rpl/r/rpl_gtid_until.result
index 53100af4c71..d86b5cac78c 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_until.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_until.result
@@ -168,7 +168,7 @@ a
include/stop_slave.inc
CREATE TABLE t3 (a INT);
DROP TABLE t3;
-START SLAVE UNTIL master_gtid_pos='1-1-5,2-1-5,0-1-6';
+START SLAVE UNTIL master_gtid_pos='UNTIL_CONDITION';
include/wait_for_slave_to_stop.inc
SHOW CREATE TABLE t3;
Table Create Table
diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat_debug.result b/mysql-test/suite/rpl/r/rpl_heartbeat_debug.result
new file mode 100644
index 00000000000..b9dec686e4a
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_debug.result
@@ -0,0 +1,25 @@
+include/master-slave.inc
+[connection master]
+include/stop_slave.inc
+set @restore_slave_net_timeout= @@global.slave_net_timeout;
+set @@global.slave_net_timeout= 10;
+show status like 'Slave_heartbeat_period';;
+Variable_name Slave_heartbeat_period
+Value 60.000
+SET @save_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,simulate_slave_heartbeat_network_error";
+CALL mtr.add_suppression('SET @master_heartbeat_period to master failed with error');
+CALL mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again');
+include/start_slave.inc
+drop table if exists t1;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+a
+1
+drop table t1;
+include/stop_slave.inc
+SET GLOBAL debug_dbug=@save_dbug;
+set @@global.slave_net_timeout= @restore_slave_net_timeout;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mdev6020.result b/mysql-test/suite/rpl/r/rpl_mdev6020.result
new file mode 100644
index 00000000000..0855f578cfc
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_mdev6020.result
@@ -0,0 +1,49 @@
+include/master-slave.inc
+[connection master]
+include/stop_slave.inc
+include/rpl_stop_server.inc [server_number=1]
+include/rpl_start_server.inc [server_number=1]
+SET SQL_LOG_BIN=0;
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+SET SQL_LOG_BIN=1;
+SET @old_engine= @@GLOBAL.default_storage_engine;
+SET GLOBAL default_storage_engine=InnoDB;
+SET @old_parallel= @@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=12;
+CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
+include/start_slave.inc
+SET SQL_LOG_BIN=0;
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+SET SQL_LOG_BIN=1;
+SELECT @@gtid_slave_pos;
+@@gtid_slave_pos
+0-1-1381
+CHECKSUM TABLE table0_int_autoinc, table0_key_pk_parts_2_int_autoinc, table100_int_autoinc, table100_key_pk_parts_2_int_autoinc, table10_int_autoinc, table10_key_pk_parts_2_int_autoinc, table1_int_autoinc, table1_key_pk_parts_2_int_autoinc, table2_int_autoinc, table2_key_pk_parts_2_int_autoinc;
+Table Checksum
+test.table0_int_autoinc 3623174395
+test.table0_key_pk_parts_2_int_autoinc 2888328157
+test.table100_int_autoinc 3624823809
+test.table100_key_pk_parts_2_int_autoinc 3316583308
+test.table10_int_autoinc 1615053718
+test.table10_key_pk_parts_2_int_autoinc 4147461080
+test.table1_int_autoinc 478809705
+test.table1_key_pk_parts_2_int_autoinc 3032208641
+test.table2_int_autoinc 854763867
+test.table2_key_pk_parts_2_int_autoinc 4231615291
+include/stop_slave.inc
+SET GLOBAL default_storage_engine= @old_engine;
+SET GLOBAL slave_parallel_threads=@old_parallel;
+SET sql_log_bin=0;
+DROP TABLE table0_int_autoinc;
+DROP TABLE table0_key_pk_parts_2_int_autoinc;
+DROP TABLE table100_int_autoinc;
+DROP TABLE table100_key_pk_parts_2_int_autoinc;
+DROP TABLE table10_int_autoinc;
+DROP TABLE table10_key_pk_parts_2_int_autoinc;
+DROP TABLE table1_int_autoinc;
+DROP TABLE table1_key_pk_parts_2_int_autoinc;
+DROP TABLE table2_int_autoinc;
+DROP TABLE table2_key_pk_parts_2_int_autoinc;
+SET sql_log_bin=1;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mdev6386.result b/mysql-test/suite/rpl/r/rpl_mdev6386.result
new file mode 100644
index 00000000000..352b9d07fef
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_mdev6386.result
@@ -0,0 +1,56 @@
+include/master-slave.inc
+[connection master]
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+FLUSH LOGS;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) Engine=InnoDB;
+include/stop_slave.inc
+SET sql_log_bin= 0;
+INSERT INTO t1 VALUES (1, 2);
+SET sql_log_bin= 1;
+CHANGE MASTER TO master_use_gtid= current_pos;
+Contents on slave before:
+SELECT * FROM t1 ORDER BY a;
+a b
+1 2
+SET @old_parallel= @@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=8;
+CREATE TEMPORARY TABLE t2 LIKE t1;
+INSERT INTO t2 VALUE (1, 1);
+INSERT INTO t2 VALUE (2, 1);
+INSERT INTO t2 VALUE (3, 1);
+INSERT INTO t2 VALUE (4, 1);
+INSERT INTO t2 VALUE (5, 1);
+INSERT INTO t1 SELECT * FROM t2;
+DROP TEMPORARY TABLE t2;
+Contents on master:
+SELECT * FROM t1 ORDER BY a;
+a b
+1 1
+2 1
+3 1
+4 1
+5 1
+START SLAVE;
+include/wait_for_slave_sql_error.inc [errno=1062]
+STOP SLAVE IO_THREAD;
+Contents on slave on slave error:
+SELECT * FROM t1 ORDER BY a;
+a b
+1 2
+SET sql_log_bin= 0;
+DELETE FROM t1 WHERE a=1;
+SET sql_log_bin= 1;
+include/start_slave.inc
+Contents on slave after:
+SELECT * FROM t1 ORDER BY a;
+a b
+1 1
+2 1
+3 1
+4 1
+5 1
+DROP TABLE t1;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads= @old_parallel;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_parallel.result b/mysql-test/suite/rpl/r/rpl_parallel.result
index 20b75cbbdab..1c686e44a25 100644
--- a/mysql-test/suite/rpl/r/rpl_parallel.result
+++ b/mysql-test/suite/rpl/r/rpl_parallel.result
@@ -314,7 +314,7 @@ SET debug_sync='now WAIT_FOR t1_ready';
KILL THD_ID;
SET debug_sync='now WAIT_FOR t2_killed';
SET debug_sync='now SIGNAL t1_cont';
-include/wait_for_slave_sql_error.inc [errno=1317,1964]
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
STOP SLAVE IO_THREAD;
SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
a b
@@ -398,7 +398,7 @@ SET debug_sync='now WAIT_FOR t1_ready';
KILL THD_ID;
SET debug_sync='now WAIT_FOR t2_killed';
SET debug_sync='now SIGNAL t1_cont';
-include/wait_for_slave_sql_error.inc [errno=1317,1964]
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
SET debug_sync='RESET';
SET GLOBAL slave_parallel_threads=0;
SET GLOBAL slave_parallel_threads=10;
@@ -481,7 +481,7 @@ SET debug_sync='now WAIT_FOR t1_ready';
KILL THD_ID;
SET debug_sync='now WAIT_FOR t2_killed';
SET debug_sync='now SIGNAL t1_cont';
-include/wait_for_slave_sql_error.inc [errno=1317,1964]
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
a b
51 51
@@ -819,11 +819,37 @@ test_check
OK
test_check
OK
+*** MDEV_6435: Incorrect error handling when query binlogged partially on master with "killed" error ***
+CREATE TABLE t6 (a INT) ENGINE=MyISAM;
+CREATE TRIGGER tr AFTER INSERT ON t6 FOR EACH ROW SET @a = 1;
+SET @old_format= @@binlog_format;
+SET binlog_format= statement;
+SET debug_sync='sp_head_execute_before_loop SIGNAL ready WAIT_FOR cont';
+INSERT INTO t6 VALUES (1), (2), (3);
+SET debug_sync='now WAIT_FOR ready';
+KILL QUERY CONID;
+SET debug_sync='now SIGNAL cont';
+ERROR 70100: Query execution was interrupted
+SET binlog_format= @old_format;
+SET debug_sync='RESET';
+SET debug_sync='RESET';
+include/wait_for_slave_sql_error.inc [errno=1317]
+STOP SLAVE IO_THREAD;
+SET GLOBAL gtid_slave_pos= 'AFTER_ERROR_GTID_POS';
+include/start_slave.inc
+INSERT INTO t6 VALUES (4);
+SELECT * FROM t6 ORDER BY a;
+a
+1
+4
+SELECT * FROM t6 ORDER BY a;
+a
+4
include/stop_slave.inc
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
include/start_slave.inc
SET DEBUG_SYNC= 'RESET';
DROP function foo;
-DROP TABLE t1,t2,t3,t4,t5;
+DROP TABLE t1,t2,t3,t4,t5,t6;
SET DEBUG_SYNC= 'RESET';
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_parallel_retry.result b/mysql-test/suite/rpl/r/rpl_parallel_retry.result
new file mode 100644
index 00000000000..cd12d92430b
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_parallel_retry.result
@@ -0,0 +1,196 @@
+include/rpl_init.inc [topology=1->2]
+*** Test retry of transactions that fail to replicate due to deadlock or similar temporary error. ***
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1);
+SET sql_log_bin=0;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=5;
+include/start_slave.inc
+SET sql_log_bin=0;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+SET gtid_seq_no = 100;
+BEGIN;
+INSERT INTO t1 VALUES (2,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (3,1);
+COMMIT;
+SELECT * FROM t1 ORDER BY a;
+a b
+1 2
+2 1
+3 1
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100";
+include/start_slave.inc
+SET GLOBAL debug_dbug=@old_dbug;
+retries
+1
+SELECT * FROM t1 ORDER BY a;
+a b
+1 2
+2 1
+3 1
+*** Test that double retry works when the first retry also fails with temp error ***
+include/stop_slave.inc
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 10;
+BEGIN;
+INSERT INTO t1 VALUES (4,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (5,1);
+INSERT INTO t1 VALUES (6,1);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 ORDER BY a;
+a b
+1 3
+2 1
+3 1
+4 1
+5 1
+6 1
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_double_temp_err_gtid_0_x_100";
+include/start_slave.inc
+SET GLOBAL debug_dbug=@old_dbug;
+retries
+2
+SELECT * FROM t1 ORDER BY a;
+a b
+1 3
+2 1
+3 1
+4 1
+5 1
+6 1
+*** Test too many retries, eventually causing failure. ***
+include/stop_slave.inc
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 11;
+BEGIN;
+INSERT INTO t1 VALUES (7,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (8,1);
+INSERT INTO t1 VALUES (9,1);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 ORDER BY a;
+a b
+1 4
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Slave worker thread retried transaction 10 time\\(s\\) in vain, giving up");
+CALL mtr.add_suppression("Slave: Deadlock found when trying to get lock; try restarting transaction");
+SET sql_log_bin=1;
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_infinite_temp_err_gtid_0_x_100";
+START SLAVE;
+include/wait_for_slave_sql_error.inc [errno=1213]
+SET GLOBAL debug_dbug=@old_dbug;
+retries
+10
+SELECT * FROM t1 ORDER BY a;
+a b
+1 3
+2 1
+3 1
+4 1
+5 1
+6 1
+STOP SLAVE IO_THREAD;
+include/start_slave.inc
+SELECT * FROM t1 ORDER BY a;
+a b
+1 4
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+*** Test retry of event group that spans multiple relay log files. ***
+CREATE TABLE t2 (a int PRIMARY KEY, b BLOB) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,"Hulubullu");
+include/stop_slave.inc
+SET @old_max= @@GLOBAL.max_relay_log_size;
+SET GLOBAL max_relay_log_size=4096;
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 12;
+BEGIN;
+INSERT INTO t1 VALUES (10, 4);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a b
+10 4
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+a LENGTH(b)
+1 9
+2 5006
+3 5012
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100";
+include/start_slave.inc
+SET GLOBAL debug_dbug=@old_dbug;
+retries
+1
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a b
+10 4
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+a LENGTH(b)
+1 9
+2 5006
+3 5012
+INSERT INTO t1 VALUES (11,11);
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+a b
+10 4
+11 11
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+a LENGTH(b)
+1 9
+2 5006
+3 5012
+4 5000
+SET GLOBAL max_relay_log_size=@old_max;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+include/start_slave.inc
+DROP TABLE t1, t2;
+DROP function foo;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_read_new_relay_log_info.result b/mysql-test/suite/rpl/r/rpl_read_new_relay_log_info.result
new file mode 100644
index 00000000000..e659c3ee283
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_read_new_relay_log_info.result
@@ -0,0 +1,14 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+DROP TABLE t1;
+==== Check that we can understand the new format of relay-log.info ====
+include/stop_slave.inc
+RESET SLAVE;
+# Read relay-log.info
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+# Check that relay log coordinates are equal to those saved in new-format_relay-log.info
+= , 0, slave-relay-bin.000001, 4
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_read_old_relay_log_info.result b/mysql-test/suite/rpl/r/rpl_read_old_relay_log_info.result
new file mode 100644
index 00000000000..7a9d3b795d8
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_read_old_relay_log_info.result
@@ -0,0 +1,14 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+DROP TABLE t1;
+==== Check that we still understand the old format of relay-log.info ====
+include/stop_slave.inc
+RESET SLAVE;
+# Read relay-log.info
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+# Check that relay log coordinates are equal to those we saved in old-format_relay-log.info
+= , 0, slave-relay-bin.000001, 4
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_uninstall_plugin.result b/mysql-test/suite/rpl/r/rpl_semi_sync_uninstall_plugin.result
new file mode 100644
index 00000000000..0809af5f943
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_semi_sync_uninstall_plugin.result
@@ -0,0 +1,63 @@
+include/master-slave.inc
+[connection master]
+call mtr.add_suppression("Read semi-sync reply network error");
+call mtr.add_suppression("Timeout waiting for reply of binlog");
+INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master';
+[connection slave]
+INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave';
+UNINSTALL PLUGIN rpl_semi_sync_slave;
+[connection master]
+UNINSTALL PLUGIN rpl_semi_sync_master;
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (1);
+DROP TABLE t1;
+[connection slave]
+include/install_semisync.inc
+[connection slave]
+UNINSTALL PLUGIN rpl_semi_sync_slave;
+Warnings:
+Warning 1620 Plugin is busy and will be uninstalled on shutdown
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+plugin_name plugin_status
+rpl_semi_sync_slave DELETED
+[connection master]
+UNINSTALL PLUGIN rpl_semi_sync_master;
+Warnings:
+Warning 1620 Plugin is busy and will be uninstalled on shutdown
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+plugin_name plugin_status
+rpl_semi_sync_master DELETED
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (2);
+DROP TABLE t1;
+[connection slave]
+show status like "Rpl_semi_sync_slave_status";
+Variable_name Value
+Rpl_semi_sync_slave_status ON
+[connection master]
+show status like "Rpl_semi_sync_master_status";
+Variable_name Value
+Rpl_semi_sync_master_status ON
+show status like "Rpl_semi_sync_master_clients";
+Variable_name Value
+Rpl_semi_sync_master_clients 1
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+plugin_name plugin_status
+rpl_semi_sync_master DELETED
+[connection slave]
+include/stop_slave.inc
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+plugin_name plugin_status
+[connection master]
+create table t2 (a int);
+drop table t2;
+[connection slave]
+include/start_slave.inc
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+plugin_name plugin_status
+[connection master]
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (3);
+DROP TABLE t1;
+[connection slave]
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_skip_incident.result b/mysql-test/suite/rpl/r/rpl_skip_incident.result
new file mode 100644
index 00000000000..1dc0508af32
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_skip_incident.result
@@ -0,0 +1,25 @@
+include/master-slave.inc
+[connection master]
+**** On Master ****
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
+a
+1
+2
+3
+REPLACE INTO t1 VALUES (4);
+SELECT * FROM t1;
+a
+1
+2
+3
+4
+include/check_slave_is_running.inc
+Should have two binary logs here
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+master-bin.000002 #
+DROP TABLE t1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_stop_slave.result b/mysql-test/suite/rpl/r/rpl_stop_slave.result
index 5959ee09993..b93ecce3597 100644
--- a/mysql-test/suite/rpl/r/rpl_stop_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stop_slave.result
@@ -94,10 +94,12 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (c1 INT KEY, c2 INT) ENGINE=InnoDB;
CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES(1, 1);
+include/stop_slave.inc
[connection master]
+include/stop_dump_threads.inc
SET GLOBAL debug_dbug= '+d,dump_thread_wait_before_send_xid,*';
[connection slave]
-include/restart_slave.inc
+include/start_slave.inc
BEGIN;
UPDATE t1 SET c2 = 2 WHERE c1 = 1;
[connection master]
@@ -116,6 +118,9 @@ SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
[connection slave]
include/wait_for_slave_to_stop.inc
[connection slave1]
+[connection master]
+include/stop_dump_threads.inc
+[connection slave1]
include/start_slave.inc
[connection master]
DROP TABLE t1, t2;
diff --git a/mysql-test/suite/rpl/r/rpl_table_options.result b/mysql-test/suite/rpl/r/rpl_table_options.result
index d69570a1709..a94d6e9bc2f 100644
--- a/mysql-test/suite/rpl/r/rpl_table_options.result
+++ b/mysql-test/suite/rpl/r/rpl_table_options.result
@@ -12,6 +12,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /* `ull`=12340 */
+set sql_mode=ignore_bad_table_options;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 `ull`=12340
drop table t1;
set storage_engine=default;
diff --git a/mysql-test/suite/rpl/t/failed_create_view-6409.test b/mysql-test/suite/rpl/t/failed_create_view-6409.test
new file mode 100644
index 00000000000..5d96e6f8a93
--- /dev/null
+++ b/mysql-test/suite/rpl/t/failed_create_view-6409.test
@@ -0,0 +1,24 @@
+#
+# MDEV-6409 CREATE VIEW replication problem if error occurs in mysql_register_view
+#
+
+#
+#
+# verify that failed CREATE VIEW is not replicated
+
+create table v1 (a int);
+
+source include/master-slave.inc;
+
+connection master;
+create table t1 (a int);
+--error ER_TABLE_EXISTS_ERROR
+create view v1 as select * from t1;
+show tables;
+sync_slave_with_master;
+show tables;
+
+connection master;
+drop table if exists t1, v1;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/kill_hard-6290.test b/mysql-test/suite/rpl/t/kill_hard-6290.test
new file mode 100644
index 00000000000..7624235666a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/kill_hard-6290.test
@@ -0,0 +1,11 @@
+#
+# MDEV-6290 Crash in KILL HARD QUERY USER x@y when slave threads are running
+#
+
+# this test doesn't depend on the binlog format, no need to run it three times
+--source include/have_binlog_format_mixed.inc
+
+--source include/master-slave.inc
+--connection server_2
+kill user test2@nohost;
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_checksum.test b/mysql-test/suite/rpl/t/rpl_checksum.test
index 0f0b84aa632..bd0ab7ecc9c 100644
--- a/mysql-test/suite/rpl/t/rpl_checksum.test
+++ b/mysql-test/suite/rpl/t/rpl_checksum.test
@@ -260,9 +260,67 @@ AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
#connection slave;
sync_slave_with_master;
+
+
+--echo *** Bug#59123 / MDEV-5799: INCIDENT_EVENT checksum written to error log as garbage characters ***
+
+--connection master
+
+--source include/wait_for_binlog_checkpoint.inc
+CREATE TABLE t4 (a INT PRIMARY KEY);
+INSERT INTO t4 VALUES (1);
+
+SET sql_log_bin=0;
+CALL mtr.add_suppression("\\[ERROR\\] Can't generate a unique log-filename");
+SET sql_log_bin=1;
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET debug_dbug= '+d,binlog_inject_new_name_error';
+--error ER_NO_UNIQUE_LOGFILE
+FLUSH LOGS;
+SET debug_dbug= @old_dbug;
+
+INSERT INTO t4 VALUES (2);
+
+--connection slave
+--let $slave_sql_errno= 1590
+--source include/wait_for_slave_sql_error.inc
+
+# Search the error log for the error message.
+# The bug was that 4 garbage bytes were output in the middle of the error
+# message; by searching for a pattern that spans that location, we can
+# catch the error.
+let $log_error_= `SELECT @@GLOBAL.log_error`;
+if(!$log_error_)
+{
+ # MySQL Server on windows is started with --console and thus
+ # does not know the location of its .err log, use default location
+ let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
+}
+--let SEARCH_FILE= $log_error_
+--let SEARCH_RANGE=-50000
+--let SEARCH_PATTERN= Slave SQL: The incident LOST_EVENTS occured on the master\. Message: error writing to the binary log, Internal MariaDB error code: 1590
+--source include/search_pattern_in_file.inc
+
+SELECT * FROM t4 ORDER BY a;
+STOP SLAVE IO_THREAD;
+SET sql_slave_skip_counter= 1;
+--source include/start_slave.inc
+
+--connection master
+--save_master_pos
+
+--connection slave
+--sync_with_master
+SELECT * FROM t4 ORDER BY a;
+
+
+--connection slave
set @@global.binlog_checksum = @slave_save_binlog_checksum;
set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
--echo End of tests
+--connection master
+DROP TABLE t4;
+
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index 3f2d5e1e321..5ecff519aef 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -69,15 +69,7 @@ save_master_pos;
connection server_4;
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
- MASTER_USE_GTID=SLAVE_POS;
-# Test that sql_slave_skip_counter is prevented in GTID mode.
---error ER_SLAVE_SKIP_NOT_IN_GTID
-SET GLOBAL sql_slave_skip_counter=1;
---replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_USE_GTID=CURRENT_POS;
---error ER_SLAVE_SKIP_NOT_IN_GTID
-SET GLOBAL sql_slave_skip_counter=10;
--source include/start_slave.inc
sync_with_master;
SELECT * FROM t1 ORDER BY a;
@@ -184,8 +176,8 @@ SET GLOBAL gtid_binlog_state = '0-1-10,1-2-20,0-3-30';
--let $binlog_file= master-bin.000001
--let $binlog_start= 4
--source include/show_binlog_events.inc
-SELECT @@GLOBAL.gtid_binlog_pos;
-SELECT @@GLOBAL.gtid_binlog_state;
+#SELECT @@GLOBAL.gtid_binlog_pos;
+#SELECT @@GLOBAL.gtid_binlog_state;
--error ER_BINLOG_MUST_BE_EMPTY
SET GLOBAL gtid_binlog_state = @old_state;
RESET MASTER;
@@ -262,6 +254,7 @@ INSERT INTO t1 VALUES (3);
--let $pos= `SELECT @@gtid_binlog_pos`
--connection s1
+--replace_result $pos POS
eval SET @pos= '$pos';
SELECT master_gtid_wait(@pos, 0);
SELECT * FROM t1 WHERE a >= 3;
@@ -374,6 +367,120 @@ reap;
reap;
+--echo *** Test sql_gtid_slave_pos when used with GTID ***
+
+--connection server_2
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_domain_id=2;
+SET gtid_seq_no=1000;
+INSERT INTO t1 VALUES (10);
+INSERT INTO t1 VALUES (11);
+--save_master_pos
+
+--connection server_2
+SET sql_slave_skip_counter= 1;
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT IF(LOCATE("2-1-1001", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1001 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_domain_id=2;
+SET gtid_seq_no=1010;
+INSERT INTO t1 VALUES (12);
+INSERT INTO t1 VALUES (13);
+--save_master_pos
+
+--connection server_2
+SET sql_slave_skip_counter= 2;
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT IF(LOCATE("2-1-1011", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1011 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_domain_id=2;
+SET gtid_seq_no=1020;
+INSERT INTO t1 VALUES (14);
+INSERT INTO t1 VALUES (15);
+INSERT INTO t1 VALUES (16);
+--save_master_pos
+
+--connection server_2
+SET sql_slave_skip_counter= 3;
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT IF(LOCATE("2-1-1022", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1022 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_domain_id=2;
+SET gtid_seq_no=1030;
+INSERT INTO t1 VALUES (17);
+INSERT INTO t1 VALUES (18);
+INSERT INTO t1 VALUES (19);
+--save_master_pos
+
+--connection server_2
+SET sql_slave_skip_counter= 5;
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT IF(LOCATE("2-1-1032", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1032 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_domain_id=3;
+SET gtid_seq_no=100;
+CREATE TABLE t2 (a INT PRIMARY KEY);
+DROP TABLE t2;
+SET gtid_domain_id=2;
+SET gtid_seq_no=1040;
+INSERT INTO t1 VALUES (20);
+--save_master_pos
+
+--connection server_2
+SET @saved_mode= @@GLOBAL.slave_ddl_exec_mode;
+SET GLOBAL slave_ddl_exec_mode=STRICT;
+SET sql_slave_skip_counter=1;
+START SLAVE UNTIL master_gtid_pos="3-1-100";
+--let $master_pos=3-1-100
+--source include/sync_with_master_gtid.inc
+--source include/wait_for_slave_sql_to_stop.inc
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t2;
+SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+# Start the slave again, it should fail on the DROP TABLE as the table is not there.
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Slave: Unknown table 'test\\.t2' Error_code: 1051");
+SET sql_log_bin=1;
+START SLAVE;
+--let $slave_sql_errno=1051
+--source include/wait_for_slave_sql_error.inc
+SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+STOP SLAVE IO_THREAD;
+SET sql_slave_skip_counter=2;
+--source include/start_slave.inc
+--sync_with_master
+
+SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
+SELECT IF(LOCATE("3-1-101", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-101 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+SELECT IF(LOCATE("2-1-1040", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1040 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
+
+SET GLOBAL slave_ddl_exec_mode= @saved_mode;
+
--connection server_1
DROP TABLE t1;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
index e02816e1d30..82667b31e57 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
@@ -100,7 +100,7 @@ SET gtid_domain_id= 2;
INSERT INTO t1 VALUES (3);
FLUSH LOGS;
--source include/show_binary_logs.inc
---replace_column 2 # 4 # 5 #
+--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
@@ -120,7 +120,7 @@ EOF
--source include/wait_until_connected_again.inc
--source include/show_binary_logs.inc
---replace_column 2 # 4 # 5 #
+--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
--save_master_pos
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test b/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test
new file mode 100644
index 00000000000..24298e9893a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test
@@ -0,0 +1,76 @@
+--source include/have_debug.inc
+--source include/master-slave.inc
+
+--echo *** Test MDEV-6120, output of current GTID when a replication error is logged to the errorlog ***
+--connection master
+CREATE TABLE t1(a INT PRIMARY KEY);
+--sync_slave_with_master
+
+--connection slave
+--source include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=slave_pos;
+
+--connection master
+INSERT INTO t1 VALUES (1);
+SET gtid_seq_no=100;
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+--save_master_pos
+
+--connection slave
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES (2);
+SET sql_log_bin=1;
+
+START SLAVE;
+--let $slave_sql_errno=1062
+--source include/wait_for_slave_sql_error.inc
+
+--source include/stop_slave.inc
+# Skip the problem event from the master.
+SET GLOBAL gtid_slave_pos= "0-1-100";
+--source include/start_slave.inc
+--sync_with_master
+
+SELECT * FROM t1 ORDER BY a;
+
+--connection master
+
+SET @dbug_save= @@debug_dbug;
+SET debug_dbug= '+d,incident_database_resync_on_replace';
+REPLACE INTO t1 VALUES (5);
+SET debug_dbug= @dbug_save;
+--save_master_pos
+
+--connection slave
+--let $slave_sql_errno=1590
+--source include/wait_for_slave_sql_error.inc
+--source include/stop_slave.inc
+SET sql_slave_skip_counter=1;
+--source include/start_slave.inc
+--sync_with_master
+
+SELECT * FROM t1 ORDER BY a;
+
+
+# Check error log for correct messages.
+let $log_error_= `SELECT @@GLOBAL.log_error`;
+if(!$log_error_)
+{
+ # MySQL Server on windows is started with --console and thus
+ # does not know the location of its .err log, use default location
+ let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
+}
+--let SEARCH_FILE=$log_error_
+--let SEARCH_RANGE=-50000
+--let SEARCH_PATTERN=Slave SQL: Error 'Duplicate entry .* on query\. .*Query: '.*', Gtid 0-1-100, Internal MariaDB error code:|Slave SQL: Could not execute Write_rows.*table test.t1; Duplicate entry.*, Gtid 0-1-100, Internal MariaDB error
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=Slave SQL: The incident LOST_EVENTS occured on the master\. Message: <none>, Internal MariaDB error code: 1590
+--source include/search_pattern_in_file.inc
+
+
+--connection master
+DROP TABLE t1;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_master_promote.test b/mysql-test/suite/rpl/t/rpl_gtid_master_promote.test
index f3cc4aca135..bd5343d7558 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_master_promote.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_master_promote.test
@@ -139,6 +139,7 @@ SELECT * FROM t4 ORDER BY a,b;
--connection server_2
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3;
+--replace_result $server3_pos SERVER3_POS
eval START SLAVE UNTIL master_gtid_pos = "$server3_pos";
--source include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
@@ -151,6 +152,7 @@ SELECT * FROM t4 ORDER BY a,b;
--connection server_2
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4;
+--replace_result $server4_pos SERVER4_POS
eval START SLAVE UNTIL master_gtid_pos = "$server4_pos";
--source include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
@@ -163,6 +165,7 @@ SELECT * FROM t4 ORDER BY a,b;
--connection server_2
--replace_result $SERVER_MYPORT_5 SERVER_MYPORT_5
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_5;
+--replace_result $server5_pos SERVER5_POS
eval START SLAVE UNTIL master_gtid_pos = "$server5_pos";
--source include/wait_for_slave_to_stop.inc
SELECT * FROM t1 ORDER BY a;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
index 1f0532f9922..b57714aaa57 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
@@ -63,7 +63,7 @@ INSERT INTO t1 VALUES (4);
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
FLUSH LOGS;
---replace_column 2 # 4 # 5 #
+--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
@@ -83,7 +83,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---replace_column 2 # 4 # 5 #
+--replace_column 2 # 4 # 5 # 6 #
SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
--source include/show_binary_logs.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_until.test b/mysql-test/suite/rpl/t/rpl_gtid_until.test
index 68ebd464fd1..4dde7da38a5 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_until.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_until.test
@@ -175,6 +175,7 @@ DROP TABLE t3;
--save_master_pos
--connection server_2
+--replace_result $until_condition UNTIL_CONDITION
eval START SLAVE UNTIL master_gtid_pos='$until_condition';
--source include/wait_for_slave_to_stop.inc
SHOW CREATE TABLE t3;
diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test b/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test
new file mode 100644
index 00000000000..7cdf67d6532
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test
@@ -0,0 +1,52 @@
+# Testing master to slave heartbeat protocol, test cases that need debug build.
+
+--source include/master-slave.inc
+--source include/have_debug.inc
+
+connection slave;
+--source include/stop_slave.inc
+set @restore_slave_net_timeout= @@global.slave_net_timeout;
+--disable_warnings
+set @@global.slave_net_timeout= 10;
+--enable_warnings
+
+###
+### Checking the range
+###
+
+#
+# default period slave_net_timeout/2
+#
+--query_vertical show status like 'Slave_heartbeat_period';
+SET @save_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,simulate_slave_heartbeat_network_error";
+CALL mtr.add_suppression('SET @master_heartbeat_period to master failed with error');
+CALL mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again');
+--source include/start_slave.inc
+
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1);
+
+sync_slave_with_master;
+
+--connection slave
+SELECT * FROM t1;
+
+connection master;
+drop table t1;
+
+connection slave;
+--source include/stop_slave.inc
+--disable_warnings
+SET GLOBAL debug_dbug=@save_dbug;
+set @@global.slave_net_timeout= @restore_slave_net_timeout;
+--enable_warnings
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mdev6020.test b/mysql-test/suite/rpl/t/rpl_mdev6020.test
new file mode 100644
index 00000000000..2fd342f5eda
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_mdev6020.test
@@ -0,0 +1,70 @@
+--source include/have_innodb.inc
+--source include/have_partition.inc
+--source include/have_binlog_format_mixed_or_row.inc
+--source include/master-slave.inc
+
+--connection slave
+--source include/stop_slave.inc
+
+--connection master
+--let $datadir= `SELECT @@datadir`
+
+--let $rpl_server_number= 1
+--source include/rpl_stop_server.inc
+
+--remove_file $datadir/master-bin.000001
+--remove_file $datadir/master-bin.state
+--copy_file $MYSQL_TEST_DIR/std_data/mdev6020-mysql-bin.000001 $datadir/master-bin.000001
+
+--let $rpl_server_number= 1
+--source include/rpl_start_server.inc
+
+--source include/wait_until_connected_again.inc
+
+--connection slave
+SET SQL_LOG_BIN=0;
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+SET SQL_LOG_BIN=1;
+SET @old_engine= @@GLOBAL.default_storage_engine;
+SET GLOBAL default_storage_engine=InnoDB;
+SET @old_parallel= @@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=12;
+--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
+eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
+--source include/start_slave.inc
+
+--connection master
+SET SQL_LOG_BIN=0;
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+SET SQL_LOG_BIN=1;
+--save_master_pos
+
+--connection slave
+--sync_with_master
+
+SELECT @@gtid_slave_pos;
+CHECKSUM TABLE table0_int_autoinc, table0_key_pk_parts_2_int_autoinc, table100_int_autoinc, table100_key_pk_parts_2_int_autoinc, table10_int_autoinc, table10_key_pk_parts_2_int_autoinc, table1_int_autoinc, table1_key_pk_parts_2_int_autoinc, table2_int_autoinc, table2_key_pk_parts_2_int_autoinc;
+
+--source include/stop_slave.inc
+
+
+SET GLOBAL default_storage_engine= @old_engine;
+SET GLOBAL slave_parallel_threads=@old_parallel;
+SET sql_log_bin=0;
+DROP TABLE table0_int_autoinc;
+DROP TABLE table0_key_pk_parts_2_int_autoinc;
+DROP TABLE table100_int_autoinc;
+DROP TABLE table100_key_pk_parts_2_int_autoinc;
+DROP TABLE table10_int_autoinc;
+DROP TABLE table10_key_pk_parts_2_int_autoinc;
+DROP TABLE table1_int_autoinc;
+DROP TABLE table1_key_pk_parts_2_int_autoinc;
+DROP TABLE table2_int_autoinc;
+DROP TABLE table2_key_pk_parts_2_int_autoinc;
+SET sql_log_bin=1;
+
+--source include/start_slave.inc
+
+--connection master
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mdev6386-slave.opt b/mysql-test/suite/rpl/t/rpl_mdev6386-slave.opt
new file mode 100644
index 00000000000..a5d959ae7fe
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_mdev6386-slave.opt
@@ -0,0 +1 @@
+--disable-log-slave-updates
diff --git a/mysql-test/suite/rpl/t/rpl_mdev6386.test b/mysql-test/suite/rpl/t/rpl_mdev6386.test
new file mode 100644
index 00000000000..5513d15a77d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_mdev6386.test
@@ -0,0 +1,71 @@
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+--connection master
+# ToDo: Remove this FLUSH LOGS when MDEV-6403 is fixed.
+ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB;
+FLUSH LOGS;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) Engine=InnoDB;
+--sync_slave_with_master
+
+--connection slave
+--source include/stop_slave.inc
+# Provoke a duplicate key error on replication.
+SET sql_log_bin= 0;
+INSERT INTO t1 VALUES (1, 2);
+SET sql_log_bin= 1;
+CHANGE MASTER TO master_use_gtid= current_pos;
+--echo Contents on slave before:
+SELECT * FROM t1 ORDER BY a;
+
+SET @old_parallel= @@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=8;
+
+--connection master
+
+CREATE TEMPORARY TABLE t2 LIKE t1;
+INSERT INTO t2 VALUE (1, 1);
+INSERT INTO t2 VALUE (2, 1);
+INSERT INTO t2 VALUE (3, 1);
+INSERT INTO t2 VALUE (4, 1);
+INSERT INTO t2 VALUE (5, 1);
+INSERT INTO t1 SELECT * FROM t2;
+DROP TEMPORARY TABLE t2;
+--save_master_pos
+--echo Contents on master:
+SELECT * FROM t1 ORDER BY a;
+
+--connection slave
+START SLAVE;
+# The slave will stop with a duplicate key error.
+# The bug was 1) that the next DROP TEMPORARY TABLE would be allowed to run
+# anyway, and 2) that then record_gtid() would get an error during commit
+# (since the prior commit failed), and this error was not correctly handled,
+# which caused an assertion about closing tables while a statement was still
+# active.
+--let $slave_sql_errno=1062
+--source include/wait_for_slave_sql_error.inc
+
+STOP SLAVE IO_THREAD;
+--echo Contents on slave on slave error:
+SELECT * FROM t1 ORDER BY a;
+
+# Resolve the duplicate key error so replication can be resumed.
+SET sql_log_bin= 0;
+DELETE FROM t1 WHERE a=1;
+SET sql_log_bin= 1;
+
+--source include/start_slave.inc
+--sync_with_master
+--echo Contents on slave after:
+SELECT * FROM t1 ORDER BY a;
+
+--connection master
+DROP TABLE t1;
+
+--connection slave
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads= @old_parallel;
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
index 398768e87bf..e99a233ac34 100644
--- a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
+++ b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
@@ -5,11 +5,9 @@
# options are added into mysql_upgrade. These options control whether sql
# statements are binlogged or not.
#############################################################################
---source include/master-slave.inc
--source include/have_innodb.inc
-
-# Only run test if "mysql_upgrade" is found
---source include/have_mysql_upgrade.inc
+--source include/mysql_upgrade_preparation.inc
+--source include/master-slave.inc
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("table or database name 'mysqltest-1'");
diff --git a/mysql-test/suite/rpl/t/rpl_parallel.test b/mysql-test/suite/rpl/t/rpl_parallel.test
index 9b68d6648e0..0f679fa18ee 100644
--- a/mysql-test/suite/rpl/t/rpl_parallel.test
+++ b/mysql-test/suite/rpl/t/rpl_parallel.test
@@ -438,7 +438,7 @@ SET debug_sync='now WAIT_FOR t2_killed';
# Now we can allow T1 to proceed.
SET debug_sync='now SIGNAL t1_cont';
---let $slave_sql_errno= 1317,1964
+--let $slave_sql_errno= 1317,1927,1964
--source include/wait_for_slave_sql_error.inc
STOP SLAVE IO_THREAD;
SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
@@ -573,7 +573,7 @@ SET debug_sync='now WAIT_FOR t2_killed';
# Now we can allow T1 to proceed.
SET debug_sync='now SIGNAL t1_cont';
---let $slave_sql_errno= 1317,1964
+--let $slave_sql_errno= 1317,1927,1964
--source include/wait_for_slave_sql_error.inc
# Now we have to disable the debug_sync statements, so they do not trigger
@@ -712,7 +712,7 @@ SET debug_sync='now WAIT_FOR t2_killed';
# Now we can allow T1 to proceed.
SET debug_sync='now SIGNAL t1_cont';
---let $slave_sql_errno= 1317,1964
+--let $slave_sql_errno= 1317,1927,1964
--source include/wait_for_slave_sql_error.inc
SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
@@ -1277,6 +1277,7 @@ eval SELECT IF('$io_pos' = '$sql_pos', "OK", "Not ok, $io_pos <> $sql_pos") AS t
--connection server_1
FLUSH LOGS;
+--source include/wait_for_binlog_checkpoint.inc
--save_master_pos
--connection server_2
@@ -1291,6 +1292,54 @@ eval SELECT IF('$io_pos' = '$sql_pos', "OK", "Not ok, $io_pos <> $sql_pos") AS t
--enable_query_log
+--echo *** MDEV_6435: Incorrect error handling when query binlogged partially on master with "killed" error ***
+
+--connection server_1
+CREATE TABLE t6 (a INT) ENGINE=MyISAM;
+CREATE TRIGGER tr AFTER INSERT ON t6 FOR EACH ROW SET @a = 1;
+
+--connection con1
+SET @old_format= @@binlog_format;
+SET binlog_format= statement;
+--let $conid = `SELECT CONNECTION_ID()`
+SET debug_sync='sp_head_execute_before_loop SIGNAL ready WAIT_FOR cont';
+send INSERT INTO t6 VALUES (1), (2), (3);
+
+--connection server_1
+SET debug_sync='now WAIT_FOR ready';
+--replace_result $conid CONID
+eval KILL QUERY $conid;
+SET debug_sync='now SIGNAL cont';
+
+--connection con1
+--error ER_QUERY_INTERRUPTED
+--reap
+SET binlog_format= @old_format;
+SET debug_sync='RESET';
+--let $after_error_gtid_pos= `SELECT @@gtid_binlog_pos`
+
+--connection server_1
+SET debug_sync='RESET';
+
+
+--connection server_2
+--let $slave_sql_errno= 1317
+--source include/wait_for_slave_sql_error.inc
+STOP SLAVE IO_THREAD;
+--replace_result $after_error_gtid_pos AFTER_ERROR_GTID_POS
+eval SET GLOBAL gtid_slave_pos= '$after_error_gtid_pos';
+--source include/start_slave.inc
+
+--connection server_1
+INSERT INTO t6 VALUES (4);
+SELECT * FROM t6 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+--sync_with_master
+SELECT * FROM t6 ORDER BY a;
+
+
--connection server_2
--source include/stop_slave.inc
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
@@ -1299,7 +1348,7 @@ SET DEBUG_SYNC= 'RESET';
--connection server_1
DROP function foo;
-DROP TABLE t1,t2,t3,t4,t5;
+DROP TABLE t1,t2,t3,t4,t5,t6;
SET DEBUG_SYNC= 'RESET';
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_retry.test b/mysql-test/suite/rpl/t/rpl_parallel_retry.test
new file mode 100644
index 00000000000..d3be6262cb0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_parallel_retry.test
@@ -0,0 +1,220 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--let $rpl_topology=1->2
+--source include/rpl_init.inc
+
+--echo *** Test retry of transactions that fail to replicate due to deadlock or similar temporary error. ***
+
+--connection server_1
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1);
+--save_master_pos
+
+# Use a stored function to inject a debug_sync into the appropriate THD.
+# The function does nothing on the master, and on the slave it injects the
+# desired debug_sync action(s).
+SET sql_log_bin=0;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_2
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=5;
+--source include/start_slave.inc
+--sync_with_master
+SET sql_log_bin=0;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_seq_no = 100;
+BEGIN;
+INSERT INTO t1 VALUES (2,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (3,1);
+COMMIT;
+SELECT * FROM t1 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100";
+let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--source include/start_slave.inc
+--sync_with_master
+SET GLOBAL debug_dbug=@old_dbug;
+let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--disable_query_log
+eval SELECT $new_retry - $old_retry AS retries;
+--enable_query_log
+
+SELECT * FROM t1 ORDER BY a;
+
+
+--echo *** Test that double retry works when the first retry also fails with temp error ***
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 10;
+BEGIN;
+INSERT INTO t1 VALUES (4,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (5,1);
+INSERT INTO t1 VALUES (6,1);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_double_temp_err_gtid_0_x_100";
+let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--source include/start_slave.inc
+--sync_with_master
+SET GLOBAL debug_dbug=@old_dbug;
+let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--disable_query_log
+eval SELECT $new_retry - $old_retry AS retries;
+--enable_query_log
+
+SELECT * FROM t1 ORDER BY a;
+
+
+--echo *** Test too many retries, eventually causing failure. ***
+--source include/stop_slave.inc
+
+--connection server_1
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 11;
+BEGIN;
+INSERT INTO t1 VALUES (7,1);
+UPDATE t1 SET b=b+1 WHERE a=1;
+INSERT INTO t1 VALUES (8,1);
+INSERT INTO t1 VALUES (9,1);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Slave worker thread retried transaction 10 time\\(s\\) in vain, giving up");
+CALL mtr.add_suppression("Slave: Deadlock found when trying to get lock; try restarting transaction");
+SET sql_log_bin=1;
+
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_infinite_temp_err_gtid_0_x_100";
+let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+START SLAVE;
+--let $slave_sql_errno= 1213
+--let $slave_timeout= 10
+--source include/wait_for_slave_sql_error.inc
+SET GLOBAL debug_dbug=@old_dbug;
+let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--disable_query_log
+eval SELECT $new_retry - $old_retry AS retries;
+--enable_query_log
+
+SELECT * FROM t1 ORDER BY a;
+STOP SLAVE IO_THREAD;
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t1 ORDER BY a;
+
+--echo *** Test retry of event group that spans multiple relay log files. ***
+
+--connection server_1
+CREATE TABLE t2 (a int PRIMARY KEY, b BLOB) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,"Hulubullu");
+--save_master_pos
+
+--connection server_2
+--sync_with_master
+--source include/stop_slave.inc
+SET @old_max= @@GLOBAL.max_relay_log_size;
+SET GLOBAL max_relay_log_size=4096;
+
+--connection server_1
+--let $big= `SELECT REPEAT("*", 5000)`
+SET gtid_seq_no = 100;
+SET @old_server_id = @@server_id;
+SET server_id = 12;
+BEGIN;
+--disable_query_log
+eval INSERT INTO t2 VALUES (2, CONCAT("Hello ", "$big"));
+eval INSERT INTO t2 VALUES (3, CONCAT("Long data: ", "$big"));
+--enable_query_log
+INSERT INTO t1 VALUES (10, 4);
+COMMIT;
+SET server_id = @old_server_id;
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100";
+let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--source include/start_slave.inc
+--sync_with_master
+SET GLOBAL debug_dbug=@old_dbug;
+let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
+--disable_query_log
+eval SELECT $new_retry - $old_retry AS retries;
+--enable_query_log
+
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+
+--connection server_1
+INSERT INTO t1 VALUES (11,11);
+--disable_query_log
+eval INSERT INTO t2 VALUES (4, "$big");
+--enable_query_log
+--save_master_pos
+
+--connection server_2
+--sync_with_master
+SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
+SELECT a, LENGTH(b) FROM t2 ORDER BY a;
+SET GLOBAL max_relay_log_size=@old_max;
+
+
+--connection server_2
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+--source include/start_slave.inc
+
+--connection server_1
+DROP TABLE t1, t2;
+DROP function foo;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_read_new_relay_log_info.test b/mysql-test/suite/rpl/t/rpl_read_new_relay_log_info.test
new file mode 100644
index 00000000000..1e2c8ce2d9f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_read_new_relay_log_info.test
@@ -0,0 +1,43 @@
+# ==== Purpose ====
+#
+# - Verify that the post-WL#344 format of relay_log.info can be parsed.
+
+--source include/master-slave.inc
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+DROP TABLE t1;
+--sync_slave_with_master
+
+--echo ==== Check that we can understand the new format of relay-log.info ====
+--source include/stop_slave.inc
+
+RESET SLAVE;
+--let $MYSQLD_DATADIR= `select @@datadir`
+
+# the new version of relay_log.info comes in two versions: with path
+# separator '/' (most systems) and with path separator '\' (windows)
+if ($SYSTEM_PATH_SEPARATOR != /) {
+ --let $file_suffix= -win
+}
+--copy_file $MYSQL_TEST_DIR/std_data/new-format-relay-log$file_suffix.info $MYSQLD_DATADIR/relay-log.info
+
+--echo # Read relay-log.info
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+--echo # Check that relay log coordinates are equal to those saved in new-format_relay-log.info
+--let $master_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $master_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+--echo $master_file= $master_file, $master_pos, $relay_log_file, $relay_log_pos
+if (`SELECT "$master_file" != "" OR
+ "$master_pos" != "0" OR
+ "$relay_log_file" != "slave-relay-bin.000001" OR
+ "$relay_log_pos" != "4"`) {
+ --echo ERROR: log coordinates changed
+ --die log coordinates changed
+}
+
+--let $rpl_only_running_threads= 1
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_read_old_relay_log_info.test b/mysql-test/suite/rpl/t/rpl_read_old_relay_log_info.test
new file mode 100644
index 00000000000..ce345445c08
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_read_old_relay_log_info.test
@@ -0,0 +1,44 @@
+# ==== Purpose ====
+#
+# - Verify that the pre-WL#344 format of relay_log.info can still be
+# parsed.
+
+--source include/master-slave.inc
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+DROP TABLE t1;
+--sync_slave_with_master
+
+--echo ==== Check that we still understand the old format of relay-log.info ====
+--source include/stop_slave.inc
+
+RESET SLAVE;
+--let $MYSQLD_DATADIR= `select @@datadir`
+
+# the old version of relay_log.info comes in two versions: with path
+# separator '/' (most systems) and with path separator '\' (windows)
+if ($SYSTEM_PATH_SEPARATOR != /) {
+ --let $file_suffix= -win
+}
+--copy_file $MYSQL_TEST_DIR/std_data/old-format-relay-log$file_suffix.info $MYSQLD_DATADIR/relay-log.info
+
+--echo # Read relay-log.info
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+--echo # Check that relay log coordinates are equal to those we saved in old-format_relay-log.info
+--let $master_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $master_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+--echo $master_file= $master_file, $master_pos, $relay_log_file, $relay_log_pos
+if (`SELECT "$master_file" != "" OR
+ "$master_pos" != "0" OR
+ "$relay_log_file" != "slave-relay-bin.000001" OR
+ "$relay_log_pos" != "4"`) {
+ --echo ERROR: log coordinates changed
+ --die log coordinates changed
+}
+
+--let $rpl_only_running_threads= 1
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_uninstall_plugin.test b/mysql-test/suite/rpl/t/rpl_semi_sync_uninstall_plugin.test
new file mode 100644
index 00000000000..4ee345e54ba
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync_uninstall_plugin.test
@@ -0,0 +1,138 @@
+###############################################################################
+# Bug#17638477 UNINSTALL AND INSTALL SEMI-SYNC PLUGIN CAUSES SLAVES TO BREAK
+# Problem: Uninstallation of Semi sync plugin should be blocked when it is
+# in use.
+# Test case: Uninstallation of semi sync should be allowed
+# On Master:
+# 1) When there is no dump thread
+# 2) When there are no semi sync slaves (i.e., async replication).
+# On Slave:
+# 1) When there is no I/O thread
+# 2) When there are no semi sync enabled I/O thread (i.e.,async replication).
+###############################################################################
+
+--source include/have_semisync_plugin.inc
+--source include/not_embedded.inc
+--source include/have_binlog_format_statement.inc
+--source include/master-slave.inc
+
+call mtr.add_suppression("Read semi-sync reply network error");
+call mtr.add_suppression("Timeout waiting for reply of binlog");
+
+###############################################################################
+# Case 1: Uninstallation of semi sync plugins should be allowed when it is
+# not in use i.e., when asynchronous replication is active.
+###############################################################################
+# Step 1.1: Install semi sync master plugin on master
+INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master';
+
+# Step 1.2: Install semi sync slave plugin on slave
+--connection slave
+--echo [connection slave]
+INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave';
+
+# Step 1.3: Uninstallation of semisync plugin on master and slave should be
+# allowed at this state as there is no semi sync replication enabled between
+# master and slave.
+UNINSTALL PLUGIN rpl_semi_sync_slave;
+--connection master
+--echo [connection master]
+UNINSTALL PLUGIN rpl_semi_sync_master;
+
+# Step 1.4: Check that replication is working fine at the end of the test case.
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (1);
+DROP TABLE t1;
+--sync_slave_with_master
+--echo [connection slave]
+
+###############################################################################
+# Case 2: Uninstallation of semi sync plugins should be disallowed
+# when it is in use i.e., when semi sync replication is active
+###############################################################################
+# Step 2.1: Install and enable semi sync replication between master and slave
+--source include/install_semisync.inc
+
+# Step 2.2: Check that rpl_semi_sync_slave uninstallation on Slave is not
+# possible at this state
+--connection slave
+--echo [connection slave]
+UNINSTALL PLUGIN rpl_semi_sync_slave;
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+
+# Step 2.3: Check that rpl_semi_sync_master uninstallation on Master is not
+# possible at this state
+--connection master
+--echo [connection master]
+UNINSTALL PLUGIN rpl_semi_sync_master;
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+
+# Step 2.4: Check that replication is working fine at the end of the test case.
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (2);
+DROP TABLE t1;
+--sync_slave_with_master
+--echo [connection slave]
+
+# Step 2.5: Make sure rpl_semi_sync_master_status on Master and
+# rpl_semi_sync_slave_staus on Slave are ON
+show status like "Rpl_semi_sync_slave_status";
+
+###############################################################################
+# Case 3: Uninstallation of semi sync plugin should be disallowed when there
+# are semi sync slaves even though rpl_semi_sync_master_enabled= OFF;.
+###############################################################################
+# Step 3.1: Disable semi sync on master
+--connection master
+--echo [connection master]
+show status like "Rpl_semi_sync_master_status";
+
+# Step 3.2: Check that still Rpl_semi_sync_master_clients is 1
+show status like "Rpl_semi_sync_master_clients";
+
+# Step 3.3: Since Rpl_semi_sync_master_clients is 1, uninstallation of
+# rpl_semi_sync_master should be disallowed.
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+
+###############################################################################
+# Case 4: Uninstallation of semi sync plugin should be allowed when it is not
+# in use. Same as Case 1 but this case is to check the case after enabling and
+# disabling semi sync replication.
+###############################################################################
+
+# Step 4.1: Stop IO thread on slave.
+--connection slave
+--echo [connection slave]
+--source include/stop_slave.inc
+
+# Step 4.2: Disable semi sync on slave.
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+
+--connection master
+--echo [connection master]
+# Send something to the slave so that the master would notice that nobody's listening.
+create table t2 (a int); drop table t2;
+# and wait for plugin to be unloaded automatically
+let $wait_condition=select count(*) = 0 from information_schema.plugins where plugin_name like 'rpl_%';
+--source include/wait_condition.inc
+
+--connection slave
+--echo [connection slave]
+
+# Step 4.3: Start IO thread on slave.
+--source include/start_slave.inc
+
+# Step 4.4: Uninstall semi sync plugin, it should be successful now.
+select plugin_name,plugin_status from information_schema.plugins where plugin_name like 'rpl_%';
+
+# Step 4.7: Check that replication is working fine at the end of the test case
+--connection master
+--echo [connection master]
+CREATE TABLE t1(i int);
+INSERT INTO t1 values (3);
+DROP TABLE t1;
+--sync_slave_with_master
+--echo [connection slave]
+
+# Cleanup
+source include/rpl_end.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_skip_incident-master.opt b/mysql-test/suite/rpl/t/rpl_skip_incident-master.opt
new file mode 100644
index 00000000000..912801debc4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_skip_incident-master.opt
@@ -0,0 +1 @@
+--loose-debug=+d,incident_database_resync_on_replace
diff --git a/mysql-test/suite/rpl/t/rpl_skip_incident-slave.opt b/mysql-test/suite/rpl/t/rpl_skip_incident-slave.opt
new file mode 100644
index 00000000000..bc90d5ea6c1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_skip_incident-slave.opt
@@ -0,0 +1 @@
+--slave-skip-error=1590
diff --git a/mysql-test/suite/rpl/t/rpl_skip_incident.test b/mysql-test/suite/rpl/t/rpl_skip_incident.test
new file mode 100644
index 00000000000..959fde9374e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_skip_incident.test
@@ -0,0 +1,28 @@
+--source include/master-slave.inc
+--source include/have_debug.inc
+
+--echo **** On Master ****
+CREATE TABLE t1 (a INT);
+
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
+
+# This will generate an incident log event and store it in the binary
+# log before the replace statement.
+REPLACE INTO t1 VALUES (4);
+
+--sync_slave_with_master
+
+# Now, we should have inserted the row into the table and the slave
+# should be running. We should also have rotated to a new binary log.
+
+SELECT * FROM t1;
+source include/check_slave_is_running.inc;
+
+connection master;
+
+--echo Should have two binary logs here
+--source include/show_binary_logs.inc
+DROP TABLE t1;
+--sync_slave_with_master
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test
index 00815ab9d7e..c978a145a92 100644
--- a/mysql-test/suite/rpl/t/rpl_sp.test
+++ b/mysql-test/suite/rpl/t/rpl_sp.test
@@ -614,7 +614,7 @@ show function status like '%mysqltestbug36570%';
connection master;
flush logs;
let $MYSQLD_DATADIR= `select @@datadir`;
---replace_regex s/$MYSQL_TEST_DIR/MYSQL_TEST_DIR/ s/TIMESTAMP=[0-9]*/TIMESTAMP=t/
+--replace_regex /$MYSQL_TEST_DIR/MYSQL_TEST_DIR/ /TIMESTAMP=[0-9]*/TIMESTAMP=t/
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
use test;
drop procedure mysqltestbug36570_p1;
diff --git a/mysql-test/suite/rpl/t/rpl_stop_slave.test b/mysql-test/suite/rpl/t/rpl_stop_slave.test
index d9d7f39c321..340738f8cb2 100644
--- a/mysql-test/suite/rpl/t/rpl_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_stop_slave.test
@@ -74,14 +74,17 @@ CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES(1, 1);
sync_slave_with_master;
+--source include/stop_slave.inc
--source include/rpl_connection_master.inc
+# make sure that there are no zombie threads
+--source include/stop_dump_threads.inc
let $debug_save= `SELECT @@GLOBAL.debug`;
SET GLOBAL debug_dbug= '+d,dump_thread_wait_before_send_xid,*';
--source include/rpl_connection_slave.inc
-source include/restart_slave_sql.inc;
+--source include/start_slave.inc
BEGIN;
UPDATE t1 SET c2 = 2 WHERE c1 = 1;
@@ -93,6 +96,10 @@ INSERT INTO t2 VALUES(1);
UPDATE t1 SET c2 = 3 WHERE c1 = 1;
COMMIT;
+# wait for the dump thread reach the sync point
+--let $wait_condition= select count(*)=1 from information_schema.processlist where state LIKE '%debug sync point%' and command='Binlog Dump'
+--source include/wait_condition.inc
+
--source include/rpl_connection_slave1.inc
let $show_statement= SHOW PROCESSLIST;
let $field= Info;
@@ -105,6 +112,7 @@ send STOP SLAVE;
ROLLBACK;
--source include/rpl_connection_master.inc
+
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
@@ -113,12 +121,25 @@ source include/wait_for_slave_to_stop.inc;
--source include/rpl_connection_slave1.inc
reap;
-source include/start_slave.inc;
+# Slave has stopped, thence lets make sure that
+# we kill the zombie dump threads. Also, make
+# sure that we disable the DBUG_EXECUTE_IF
+# that would set the dump thread to wait
--source include/rpl_connection_master.inc
-DROP TABLE t1, t2;
--disable_query_log
eval SET GLOBAL debug_dbug= '$debug_save';
--enable_query_log
+# make sure that there are no zombie threads
+--source include/stop_dump_threads.inc
+
+--source include/rpl_connection_slave1.inc
+# now the dump thread on the master will start
+# from a clean slate, i.e. without the
+# DBUG_EXECUTE_IF set
+source include/start_slave.inc;
+
+--source include/rpl_connection_master.inc
+DROP TABLE t1, t2;
--source include/rpl_end.inc
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/suite/rpl/t/rpl_table_options.test b/mysql-test/suite/rpl/t/rpl_table_options.test
index 12ff1ca457b..3f52444a3c7 100644
--- a/mysql-test/suite/rpl/t/rpl_table_options.test
+++ b/mysql-test/suite/rpl/t/rpl_table_options.test
@@ -23,6 +23,8 @@ show create table t1;
sync_slave_with_master;
connection slave;
show create table t1;
+set sql_mode=ignore_bad_table_options;
+show create table t1;
connection master;
drop table t1;
diff --git a/mysql-test/suite/sys_vars/r/aria_pagecache_file_hash_size_basic.result b/mysql-test/suite/sys_vars/r/aria_pagecache_file_hash_size_basic.result
new file mode 100644
index 00000000000..0bdd56c298f
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/aria_pagecache_file_hash_size_basic.result
@@ -0,0 +1,21 @@
+select @@global.aria_pagecache_file_hash_size;
+@@global.aria_pagecache_file_hash_size
+512
+select @@session.aria_pagecache_file_hash_size;
+ERROR HY000: Variable 'aria_pagecache_file_hash_size' is a GLOBAL variable
+show global variables like 'aria_pagecache_file_hash_size';
+Variable_name Value
+aria_pagecache_file_hash_size 512
+show session variables like 'aria_pagecache_file_hash_size';
+Variable_name Value
+aria_pagecache_file_hash_size 512
+select * from information_schema.global_variables where variable_name='aria_pagecache_file_hash_size';
+VARIABLE_NAME VARIABLE_VALUE
+ARIA_PAGECACHE_FILE_HASH_SIZE 512
+select * from information_schema.session_variables where variable_name='aria_pagecache_file_hash_size';
+VARIABLE_NAME VARIABLE_VALUE
+ARIA_PAGECACHE_FILE_HASH_SIZE 512
+set global aria_pagecache_file_hash_size=200;
+ERROR HY000: Variable 'aria_pagecache_file_hash_size' is a read only variable
+set session aria_pagecache_file_hash_size=200;
+ERROR HY000: Variable 'aria_pagecache_file_hash_size' is a read only variable
diff --git a/mysql-test/suite/sys_vars/r/innodb_simulate_comp_failures_basic.result b/mysql-test/suite/sys_vars/r/innodb_simulate_comp_failures_basic.result
new file mode 100644
index 00000000000..7a6c9ca2db6
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/innodb_simulate_comp_failures_basic.result
@@ -0,0 +1,77 @@
+SET @start_global_value = @@global.innodb_simulate_comp_failures;
+SELECT @start_global_value;
+@start_global_value
+0
+Valid values are between 0 and 99
+select @@global.innodb_simulate_comp_failures between 0 and 99;
+@@global.innodb_simulate_comp_failures between 0 and 99
+1
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+0
+select @@session.innodb_simulate_comp_failures;
+ERROR HY000: Variable 'innodb_simulate_comp_failures' is a GLOBAL variable
+show global variables like 'innodb_simulate_comp_failures';
+Variable_name Value
+innodb_simulate_comp_failures 0
+show session variables like 'innodb_simulate_comp_failures';
+Variable_name Value
+innodb_simulate_comp_failures 0
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 0
+select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 0
+set global innodb_simulate_comp_failures=10;
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+10
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 10
+select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 10
+set session innodb_simulate_comp_failures=1;
+ERROR HY000: Variable 'innodb_simulate_comp_failures' is a GLOBAL variable and should be set with SET GLOBAL
+set global innodb_simulate_comp_failures=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_simulate_comp_failures'
+set global innodb_simulate_comp_failures=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_simulate_comp_failures'
+set global innodb_simulate_comp_failures="foo";
+ERROR 42000: Incorrect argument type to variable 'innodb_simulate_comp_failures'
+set global innodb_simulate_comp_failures=-7;
+Warnings:
+Warning 1292 Truncated incorrect innodb_simulate_comp_failures value: '-7'
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+0
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 0
+set global innodb_simulate_comp_failures=106;
+Warnings:
+Warning 1292 Truncated incorrect innodb_simulate_comp_failures value: '106'
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+99
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+VARIABLE_NAME VARIABLE_VALUE
+INNODB_SIMULATE_COMP_FAILURES 99
+set global innodb_simulate_comp_failures=0;
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+0
+set global innodb_simulate_comp_failures=99;
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+99
+set global innodb_simulate_comp_failures=DEFAULT;
+select @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+0
+SET @@global.innodb_simulate_comp_failures = @start_global_value;
+SELECT @@global.innodb_simulate_comp_failures;
+@@global.innodb_simulate_comp_failures
+0
diff --git a/mysql-test/suite/sys_vars/r/key_cache_file_hash_size_basic.result b/mysql-test/suite/sys_vars/r/key_cache_file_hash_size_basic.result
new file mode 100644
index 00000000000..52ebfc98cdc
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/key_cache_file_hash_size_basic.result
@@ -0,0 +1,114 @@
+SET @start_value = @@global.key_cache_file_hash_size;
+SELECT @start_value;
+@start_value
+512
+'#--------------------FN_DYNVARS_056_01------------------------#'
+SET @@global.key_cache_file_hash_size = DEFAULT;
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+512
+'#---------------------FN_DYNVARS_056_02-------------------------#'
+SET @@global.key_cache_file_hash_size = @start_value;
+SELECT @@global.key_cache_file_hash_size = 300;
+@@global.key_cache_file_hash_size = 300
+0
+'#--------------------FN_DYNVARS_056_03------------------------#'
+SET @@global.key_cache_file_hash_size = 128;
+SET @@global.key_cache_file_hash_size = 16384;
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+16384
+'#--------------------FN_DYNVARS_056_04-------------------------#'
+SET @@global.key_cache_file_hash_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '-1'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+SET @@global.key_cache_file_hash_size = 42949672951;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '42949672951'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+16384
+SET @@global.key_cache_file_hash_size = 10000.01;
+ERROR 42000: Incorrect argument type to variable 'key_cache_file_hash_size'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+16384
+SET @@global.key_cache_file_hash_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '-1024'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+SET @@global.key_cache_file_hash_size = 99;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '99'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+SET @@global.key_cache_file_hash_size = ON;
+ERROR 42000: Incorrect argument type to variable 'key_cache_file_hash_size'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+SET @@global.key_cache_file_hash_size = 'test';
+ERROR 42000: Incorrect argument type to variable 'key_cache_file_hash_size'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+'#-------------------FN_DYNVARS_056_05----------------------------#'
+SET @@session.key_cache_file_hash_size = 0;
+ERROR HY000: Variable 'key_cache_file_hash_size' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@session.key_cache_file_hash_size;
+ERROR HY000: Variable 'key_cache_file_hash_size' is a GLOBAL variable
+'#----------------------FN_DYNVARS_056_06------------------------#'
+SELECT @@global.key_cache_file_hash_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='key_cache_file_hash_size';
+@@global.key_cache_file_hash_size = VARIABLE_VALUE
+1
+SELECT @@key_cache_file_hash_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='key_cache_file_hash_size';
+@@key_cache_file_hash_size = VARIABLE_VALUE
+1
+'#---------------------FN_DYNVARS_056_07----------------------#'
+SET @@global.key_cache_file_hash_size = TRUE;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '1'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+SET @@global.key_cache_file_hash_size = FALSE;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_file_hash_size value: '0'
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+128
+'#---------------------FN_DYNVARS_056_08----------------------#'
+SET @@global.key_cache_file_hash_size = 150;
+SELECT @@key_cache_file_hash_size = @@global.key_cache_file_hash_size;
+@@key_cache_file_hash_size = @@global.key_cache_file_hash_size
+1
+'#---------------------FN_DYNVARS_056_09----------------------#'
+SET key_cache_file_hash_size = 8000;
+ERROR HY000: Variable 'key_cache_file_hash_size' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@key_cache_file_hash_size;
+@@key_cache_file_hash_size
+150
+SET local.key_cache_file_hash_size = 10;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key_cache_file_hash_size = 10' at line 1
+SELECT local.key_cache_file_hash_size;
+ERROR 42S02: Unknown table 'local' in field list
+SET global.key_cache_file_hash_size = 10;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key_cache_file_hash_size = 10' at line 1
+SELECT global.key_cache_file_hash_size;
+ERROR 42S02: Unknown table 'global' in field list
+SELECT key_cache_file_hash_size = @@session.key_cache_file_hash_size;
+ERROR 42S22: Unknown column 'key_cache_file_hash_size' in 'field list'
+SET @@global.key_cache_file_hash_size = @start_value;
+SELECT @@global.key_cache_file_hash_size;
+@@global.key_cache_file_hash_size
+512
diff --git a/mysql-test/suite/sys_vars/r/timed_mutexes_basic.result b/mysql-test/suite/sys_vars/r/timed_mutexes_basic.result
index 50a5285b0d7..8c295fe8063 100644
--- a/mysql-test/suite/sys_vars/r/timed_mutexes_basic.result
+++ b/mysql-test/suite/sys_vars/r/timed_mutexes_basic.result
@@ -4,7 +4,11 @@ SELECT @global_start_value;
0
'#--------------------FN_DYNVARS_177_01------------------------#'
SET @@global.timed_mutexes = 1;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SET @@global.timed_mutexes = DEFAULT;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
0
@@ -17,15 +21,21 @@ SELECT @@timed_mutexes;
SELECT global.timed_mutexes;
ERROR 42S02: Unknown table 'global' in field list
SET global timed_mutexes = 1;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
1
'#--------------------FN_DYNVARS_177_03------------------------#'
SET @@global.timed_mutexes = 0;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
0
SET @@global.timed_mutexes = 1;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
1
@@ -82,23 +92,33 @@ VARIABLE_VALUE
ON
'#---------------------FN_DYNVARS_177_08-------------------------#'
SET @@global.timed_mutexes = OFF;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
0
SET @@global.timed_mutexes = ON;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
1
'#---------------------FN_DYNVARS_177_09----------------------#'
SET @@global.timed_mutexes = TRUE;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
1
SET @@global.timed_mutexes = FALSE;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
0
SET @@global.timed_mutexes = @global_start_value;
+Warnings:
+Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
SELECT @@global.timed_mutexes;
@@global.timed_mutexes
0
diff --git a/mysql-test/suite/sys_vars/t/aria_pagecache_file_hash_size_basic.test b/mysql-test/suite/sys_vars/t/aria_pagecache_file_hash_size_basic.test
new file mode 100644
index 00000000000..8bedb498e2c
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/aria_pagecache_file_hash_size_basic.test
@@ -0,0 +1,22 @@
+# ulong readonly
+
+--source include/have_maria.inc
+#
+# show the global and session values;
+#
+select @@global.aria_pagecache_file_hash_size;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.aria_pagecache_file_hash_size;
+show global variables like 'aria_pagecache_file_hash_size';
+show session variables like 'aria_pagecache_file_hash_size';
+select * from information_schema.global_variables where variable_name='aria_pagecache_file_hash_size';
+select * from information_schema.session_variables where variable_name='aria_pagecache_file_hash_size';
+
+#
+# show that it's read-only
+#
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set global aria_pagecache_file_hash_size=200;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set session aria_pagecache_file_hash_size=200;
+
diff --git a/mysql-test/suite/sys_vars/t/innodb_simulate_comp_failures_basic.test b/mysql-test/suite/sys_vars/t/innodb_simulate_comp_failures_basic.test
new file mode 100644
index 00000000000..97e69e3f324
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_simulate_comp_failures_basic.test
@@ -0,0 +1,64 @@
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_simulate_comp_failures;
+SELECT @start_global_value;
+
+#
+# exists as global only
+#
+
+--echo Valid values are between 0 and 99
+select @@global.innodb_simulate_comp_failures between 0 and 99;
+select @@global.innodb_simulate_comp_failures;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.innodb_simulate_comp_failures;
+
+show global variables like 'innodb_simulate_comp_failures';
+show session variables like 'innodb_simulate_comp_failures';
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';
+
+#
+# show that it's writable
+#
+
+set global innodb_simulate_comp_failures=10;
+select @@global.innodb_simulate_comp_failures;
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+select * from information_schema.session_variables where variable_name='innodb_simulate_comp_failures';
+
+--error ER_GLOBAL_VARIABLE
+set session innodb_simulate_comp_failures=1;
+
+#
+# incorrect types
+#
+
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_simulate_comp_failures=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_simulate_comp_failures=1e1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_simulate_comp_failures="foo";
+
+set global innodb_simulate_comp_failures=-7;
+select @@global.innodb_simulate_comp_failures;
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+set global innodb_simulate_comp_failures=106;
+select @@global.innodb_simulate_comp_failures;
+select * from information_schema.global_variables where variable_name='innodb_simulate_comp_failures';
+
+#
+# min/max/DEFAULT values
+#
+
+set global innodb_simulate_comp_failures=0;
+select @@global.innodb_simulate_comp_failures;
+set global innodb_simulate_comp_failures=99;
+select @@global.innodb_simulate_comp_failures;
+set global innodb_simulate_comp_failures=DEFAULT;
+select @@global.innodb_simulate_comp_failures;
+
+SET @@global.innodb_simulate_comp_failures = @start_global_value;
+SELECT @@global.innodb_simulate_comp_failures;
diff --git a/mysql-test/suite/sys_vars/t/key_cache_file_hash_size_basic.test b/mysql-test/suite/sys_vars/t/key_cache_file_hash_size_basic.test
new file mode 100644
index 00000000000..deebe708d3d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/key_cache_file_hash_size_basic.test
@@ -0,0 +1,168 @@
+################# mysql-test\t\key_cache_file_hash_size.test ##################
+# #
+# Variable Name: key_cache_file_hash_size #
+# Scope: GLOBAL #
+# Access Type: Dynamic #
+# Data Type: numeric #
+# Default Value: 300 #
+# Range: 100-4294967295 #
+# #
+# #
+# Creation Date: 2008-02-07 #
+# Author: Salman #
+# #
+# Description: Test Cases of Dynamic System Variable key_cache_file_hash_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.1/en/ #
+# server-system-variables.html #
+# #
+###############################################################################
+
+--source include/load_sysvars.inc
+
+########################################################################
+# START OF key_cache_file_hash_size TESTS #
+########################################################################
+
+
+#############################################################################
+# Saving initial value of key_cache_file_hash_size in a temporary variable #
+#############################################################################
+
+SET @start_value = @@global.key_cache_file_hash_size;
+SELECT @start_value;
+
+
+--echo '#--------------------FN_DYNVARS_056_01------------------------#'
+################################################################################
+# Display the DEFAULT value of key_cache_file_hash_size #
+################################################################################
+
+SET @@global.key_cache_file_hash_size = DEFAULT;
+SELECT @@global.key_cache_file_hash_size;
+
+
+--echo '#---------------------FN_DYNVARS_056_02-------------------------#'
+###############################################
+# Verify default value of variable #
+###############################################
+
+SET @@global.key_cache_file_hash_size = @start_value;
+SELECT @@global.key_cache_file_hash_size = 300;
+
+
+--echo '#--------------------FN_DYNVARS_056_03------------------------#'
+###############################################################################
+# Change the value of key_cache_file_hash_size to a valid value #
+###############################################################################
+
+SET @@global.key_cache_file_hash_size = 128;
+SET @@global.key_cache_file_hash_size = 16384;
+SELECT @@global.key_cache_file_hash_size;
+
+--echo '#--------------------FN_DYNVARS_056_04-------------------------#'
+###########################################################################
+# Change the value of key_cache_file_hash_size to invalid value #
+###########################################################################
+
+SET @@global.key_cache_file_hash_size = -1;
+SELECT @@global.key_cache_file_hash_size;
+SET @@global.key_cache_file_hash_size = 42949672951;
+SELECT @@global.key_cache_file_hash_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.key_cache_file_hash_size = 10000.01;
+SELECT @@global.key_cache_file_hash_size;
+SET @@global.key_cache_file_hash_size = -1024;
+SELECT @@global.key_cache_file_hash_size;
+SET @@global.key_cache_file_hash_size = 99;
+SELECT @@global.key_cache_file_hash_size;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.key_cache_file_hash_size = ON;
+SELECT @@global.key_cache_file_hash_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.key_cache_file_hash_size = 'test';
+SELECT @@global.key_cache_file_hash_size;
+
+
+--echo '#-------------------FN_DYNVARS_056_05----------------------------#'
+###########################################################################
+# Test if accessing session key_cache_file_hash_size gives error #
+###########################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET @@session.key_cache_file_hash_size = 0;
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.key_cache_file_hash_size;
+
+
+--echo '#----------------------FN_DYNVARS_056_06------------------------#'
+##############################################################################
+# Check if the value in GLOBAL & SESSION Tables matches values in variable #
+##############################################################################
+
+SELECT @@global.key_cache_file_hash_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='key_cache_file_hash_size';
+
+SELECT @@key_cache_file_hash_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='key_cache_file_hash_size';
+
+
+--echo '#---------------------FN_DYNVARS_056_07----------------------#'
+###################################################################
+# Check if TRUE and FALSE values can be used on variable #
+###################################################################
+
+SET @@global.key_cache_file_hash_size = TRUE;
+SELECT @@global.key_cache_file_hash_size;
+SET @@global.key_cache_file_hash_size = FALSE;
+SELECT @@global.key_cache_file_hash_size;
+
+
+--echo '#---------------------FN_DYNVARS_056_08----------------------#'
+########################################################################################################
+# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
+########################################################################################################
+
+SET @@global.key_cache_file_hash_size = 150;
+SELECT @@key_cache_file_hash_size = @@global.key_cache_file_hash_size;
+
+
+--echo '#---------------------FN_DYNVARS_056_09----------------------#'
+########################################################################## #######
+# Check if key_cache_file_hash_size can be accessed with and without @@ sign #
+##################################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET key_cache_file_hash_size = 8000;
+SELECT @@key_cache_file_hash_size;
+--Error ER_PARSE_ERROR
+SET local.key_cache_file_hash_size = 10;
+--Error ER_UNKNOWN_TABLE
+SELECT local.key_cache_file_hash_size;
+--Error ER_PARSE_ERROR
+SET global.key_cache_file_hash_size = 10;
+--Error ER_UNKNOWN_TABLE
+SELECT global.key_cache_file_hash_size;
+--Error ER_BAD_FIELD_ERROR
+SELECT key_cache_file_hash_size = @@session.key_cache_file_hash_size;
+
+
+##############################
+# Restore initial value #
+##############################
+
+SET @@global.key_cache_file_hash_size = @start_value;
+SELECT @@global.key_cache_file_hash_size;
+
+
+########################################################################
+# END OF key_cache_file_hash_size TESTS #
+########################################################################
diff --git a/mysql-test/suite/sys_vars/t/report_port_basic.test b/mysql-test/suite/sys_vars/t/report_port_basic.test
index 903289230bd..dfe64dd4e8d 100644
--- a/mysql-test/suite/sys_vars/t/report_port_basic.test
+++ b/mysql-test/suite/sys_vars/t/report_port_basic.test
@@ -2,7 +2,7 @@
#
# only global
#
---replace_regex s/[0-9]+/DEFAULT_MASTER_PORT/
+--replace_regex /[0-9]+/DEFAULT_MASTER_PORT/
select @@global.report_port;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.report_port;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 09294b60a04..3040c5b5392 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -796,6 +796,23 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-5745 analyze MySQL fix for bug#12368495
+--echo #
+SELECT CHAR_LENGTH(TRIM(LEADING 0x000000 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(LEADING 0x00 FROM _ucs2 0x0061));
+
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x000000 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _ucs2 0x0061));
+
+SELECT CHAR_LENGTH(TRIM(BOTH 0x000000 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x61 FROM _ucs2 0x0061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x00 FROM _ucs2 0x0061));
+
+
+--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/ctype_utf32.test b/mysql-test/t/ctype_utf32.test
index 2fbe452a716..b4ed48d07a5 100644
--- a/mysql-test/t/ctype_utf32.test
+++ b/mysql-test/t/ctype_utf32.test
@@ -873,6 +873,22 @@ ORDER BY l DESC;
SELECT '2010-10-10 10:10:10' + INTERVAL GeometryType(GeomFromText('POINT(1 1)')) hour_second;
--echo #
+--echo # MDEV-5745 analyze MySQL fix for bug#12368495
+--echo #
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0000000000 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(LEADING 0x0001 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(LEADING 0x00 FROM _utf32 0x00000061));
+
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0000000000 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x0001 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(TRAILING 0x61 FROM _utf32 0x00000061));
+
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0000000000 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x0001 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x61 FROM _utf32 0x00000061));
+SELECT CHAR_LENGTH(TRIM(BOTH 0x00 FROM _utf32 0x00000061));
+
+--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/features.test b/mysql-test/t/features.test
index cdfc9413da5..f2ac5a5bba6 100644
--- a/mysql-test/t/features.test
+++ b/mysql-test/t/features.test
@@ -6,6 +6,8 @@
drop table if exists t1;
--enable_warnings
+flush status;
+
show status like "feature%";
--echo #
@@ -109,3 +111,20 @@ select updatexml('<div><div><span>1</span><span>2</span></div></div>',
'/','<tr><td>1</td><td>2</td></tr>') as upd1;
--replace_result 4 2
show status like "feature_xml";
+
+
+--echo #
+--echo # Feature delayed_keys
+--echo #
+
+create table t1 (a int, key(a)) engine=myisam delay_key_write=1;
+insert into t1 values(1);
+insert into t1 values(2);
+drop table t1;
+
+create table t1 (a int, key(a)) engine=aria delay_key_write=1;
+insert into t1 values(1);
+insert into t1 values(2);
+drop table t1;
+
+show status like "feature_delay_key_write";
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 61a237cb447..f04fda55608 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1595,6 +1595,11 @@ call foo('(( 00000000 ++ 00000000 ))');
drop procedure foo;
drop table t1,t2;
+#
+# Bug#18786138 SHA/MD5 HASHING FUNCTIONS DIE WITH "FILENAME" CHARACTER SET
+#
+select md5(_filename "a"), sha(_filename "a");
+
--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 6bea1aab392..a3f488a8d1e 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1243,13 +1243,47 @@ CREATE TABLE t1 AS SELECT
SHOW COLUMNS FROM t1;
DROP TABLE t1;
+CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
+SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
+SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
+SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
+SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);
+
+DROP TABLE t1;
+
+SET TIME_ZONE='+02:00';
+
+--echo #
+--echo # MDEV-6302 Wrong result set when using GROUP BY FROM_UNIXTIME(...)+0
+--echo #
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, FROM_UNIXTIME(CONCAT(a,'10'))+0 AS f2 FROM t1;
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(CONCAT(a,'10'))+0;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
+SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))/1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES ('2005-05-04');
+SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
+SELECT CHAR_LENGTH(CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10')))) AS f2 FROM t1;
+CREATE TABLE t2 AS SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t1,t2;
+
--echo #
--echo # MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
--echo #
-SET TIME_ZONE='+02:00';
SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'));
-SET TIME_ZONE=DEFAULT;
+SET TIME_ZONE=DEFAULT;
--echo #
--echo # MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context
@@ -1589,3 +1623,11 @@ SELECT IFNULL(TIME'10:20:30',DATE'2001-01-01');
SELECT CASE WHEN 1 THEN TIME'10:20:30' ELSE DATE'2001-01-01' END;
SELECT COALESCE(TIME'10:20:30',DATE'2001-01-01');
SET timestamp=DEFAULT;
+
+--echo #
+--echo # MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column
+--echo #
+CREATE TABLE t1 ( d DATE, t TIME );
+INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02');
+SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/gis-debug.test b/mysql-test/t/gis-debug.test
new file mode 100644
index 00000000000..a0647a2c9f4
--- /dev/null
+++ b/mysql-test/t/gis-debug.test
@@ -0,0 +1,6 @@
+--source include/have_geometry.inc
+--source include/have_debug.inc
+
+SET @tmp=ST_GIS_DEBUG(1);
+
+--source include/gis_debug.inc
diff --git a/mysql-test/t/gis-precise.test b/mysql-test/t/gis-precise.test
index 0c6410b5a75..c6cf42e86e4 100644
--- a/mysql-test/t/gis-precise.test
+++ b/mysql-test/t/gis-precise.test
@@ -69,12 +69,15 @@ select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)')
select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POINT(20 20)')));
select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200)')));
+--replace_result 7.999999999999999 8
select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
+--replace_result 7.999999999999999 8
select astext(ST_UNION(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
select astext(ST_intersection(geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
select astext(ST_symdifference(geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
+--replace_result 7.999999999999999 8
select astext(ST_UNION(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
# Buffer() tests
@@ -83,13 +86,13 @@ select astext(ST_buffer(geometryfromtext('point(1 1)'), 1));
create table t1(geom geometrycollection);
insert into t1 values (geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))'));
insert into t1 values (geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))'));
-select astext(geom), area(geom),area(ST_buffer(geom,2)) from t1;
-select astext(ST_buffer(geom,2)) from t1;
+select astext(geom), area(geom),round(area(ST_buffer(geom,2)), 7) from t1;
+select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1;
set @geom=geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
set @buff=ST_buffer(@geom,1);
--replace_result 40278744502097 40278744502096
-select astext(@buff);
+select ST_NUMPOINTS(ST_EXTERIORRING(@buff));
# cleanup
DROP TABLE t1;
@@ -108,6 +111,32 @@ SELECT ST_Equals(PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13
SELECT ST_Equals(PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),PolyFromText('POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )')) as result;
SELECT ST_Equals(PointFromText('POINT (12 13)'),PointFromText('POINT (12 13)')) as result;
+
+--echo #
+--echo # BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD
+--echo # BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL
+--echo #
+
+SELECT ASTEXT(ST_UNION(GEOMFROMTEXT('POLYGON((525000 183300,525400
+183300,525400 18370, 525000 183700,525000 183300))'),
+geomfromtext('POLYGON((525298.67 183511.53,525296.57
+183510.39,525296.42 183510.31,525289.11 183506.62,525283.17
+183503.47,525280.98 183502.26,525278.63 183500.97,525278.39
+183500.84,525276.79 183500,525260.7 183491.55,525263.95
+183484.75,525265.58 183481.95,525278.97 183488.73,525276.5
+183493.45,525275.5 183495.7,525280.35 183498.2,525282.3
+183499.1,525282.2 183499.3,525283.55 183500,525301.75
+183509.35,525304.45 183504.25,525307.85 183504.95,525304.5
+183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06
+183489.89,525272.06 183488.37,525268.94 183494.51,525271.94
+183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15
+183493.04,525269.88 183485.82,525266.99 183484.33,525263.26
+183491.55))'))) st_u;
+
+SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
+SELECT ASTEXT(TOUCHES(@a, GEOMFROMTEXT('point(0 0)'))) t;
+
+
# bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
SELECT astext(ST_UNION (
@@ -135,11 +164,10 @@ SELECT ASTEXT(ST_INTERSECTION(
#bug 804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
---replace_result 61538461538462 61538461538461
-SELECT ASTEXT(ST_UNION(
+SELECT ROUND(ST_LENGTH(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((6 2,4 0,3 5,3 6,4 3,6 4,3 9,0 7,3 7,8 4,2 9,5 0),
(8 2,1 3,9 0,4 4))'),
- MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))')));
+ MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 5,6 7,9 7,5 2,1 6,3 6))'))), 7);
SELECT ST_NUMGEOMETRIES((ST_UNION(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 0,4 2,0 2,1 5,0 3,7 0,8 5,5 8),
@@ -219,6 +247,7 @@ SELECT AsText(ST_UNION(POLYGONFROMTEXT('POLYGON((12 9, 3 6, 3 0, 12 9))'), POLYG
#bug 841622 Assertion `t->rp->type == Gcalc_function::shape_line' failed in Gcalc_operation_reducer::end_line in maria-5.3-gis
+--replace_result 276 278
SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER(ST_UNION(
MULTILINESTRINGFROMTEXT('MULTILINESTRING((3 4, 2 5, 7 6, 1 8),(0 0 ,1 6 ,0 1, 8 9, 2 4, 6 1, 3 5, 4 8), (9 3, 5 4, 1 8, 4 2, 5 8, 3 0))' ) ,
MULTILINESTRINGFROMTEXT('MULTILINESTRING((3 4, 3 1, 2 7, 4 2, 6 2, 1 5))')
@@ -313,8 +342,8 @@ SELECT ST_WITHIN( MULTIPOINTFROMTEXT(' MULTIPOINT( 2 9 , 2 9 , 4 9 , 9 1 ) ') ,
SELECT ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29)') );
-#bug 977201 ST_BUFFER fails with the negative D
-select ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3));
+#bug 977201 ST_BUFFER fails with the negative D. TODO - check the result deeper.
+# select ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3));
#bug 986977 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int)
SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
@@ -328,3 +357,5 @@ SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0
# MDEV-5615 crash in Gcalc_function::add_operation
select astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1));
+--source include/gis_debug.inc
+
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index c38706959e4..d20e4c1711e 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -541,6 +541,18 @@ insert into t1 values(default);
drop table t1;
#
+# Bug #27300: create view with geometry functions lost columns types
+#
+CREATE TABLE t1 (a GEOMETRY);
+CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;
+CREATE VIEW v2 AS SELECT a FROM t1;
+DESCRIBE v1;
+DESCRIBE v2;
+
+DROP VIEW v1,v2;
+DROP TABLE t1;
+
+#
# Bug#24563: MBROverlaps does not seem to function propertly
# Bug#54888: MBROverlaps missing in 5.1?
#
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index f1a287054ca..c809401bbf8 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -1418,6 +1418,31 @@ drop table t1;
--echo # End of test#50539.
--echo #
+--echo # Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND
+--echo # "HAVING SUM(DISTINCT)": WRONG RESULTS.
+--echo #
+
+CREATE TABLE t (a INT, b INT, KEY(a,b));
+INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5);
+ANALYZE TABLE t;
+
+SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+
+SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+
+SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+
+SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+
+SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+DROP TABLE t;
+
+--echo #
--echo # MDEV-4219 A simple select query returns random data (upstream bug#68473)
--echo #
diff --git a/mysql-test/t/group_min_max_innodb.test b/mysql-test/t/group_min_max_innodb.test
index 7038eb2ff47..6967f847147 100644
--- a/mysql-test/t/group_min_max_innodb.test
+++ b/mysql-test/t/group_min_max_innodb.test
@@ -137,3 +137,96 @@ SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b';
DROP TABLE t1;
--echo End of 5.5 tests
+
+--echo #
+--echo # Bug#17909656 - WRONG RESULTS FOR A SIMPLE QUERY WITH GROUP BY
+--echo #
+
+CREATE TABLE t0 (
+ i1 INTEGER NOT NULL
+);
+
+INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
+ (11),(12),(13),(14),(15),(16),(17),(18),(19),(20),
+ (21),(22),(23),(24),(25),(26),(27),(28),(29),(30);
+
+CREATE TABLE t1 (
+ c1 CHAR(1) NOT NULL,
+ i1 INTEGER NOT NULL,
+ i2 INTEGER NOT NULL,
+ UNIQUE KEY k1 (c1,i2)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 SELECT 'A',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'B',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'C',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'D',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'E',i1,i1 FROM t0;
+INSERT INTO t1 SELECT 'F',i1,i1 FROM t0;
+
+CREATE TABLE t2 (
+ c1 CHAR(1) NOT NULL,
+ i1 INTEGER NOT NULL,
+ i2 INTEGER NOT NULL,
+ UNIQUE KEY k2 (c1,i1,i2)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 SELECT 'A',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'B',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'C',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'D',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'E',i1,i1 FROM t0;
+INSERT INTO t2 SELECT 'F',i1,i1 FROM t0;
+
+-- disable_result_log
+ANALYZE TABLE t1;
+ANALYZE TABLE t2;
+-- enable_result_log
+
+let query=
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F')
+GROUP BY c1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17))
+GROUP BY c1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 )
+GROUP BY c1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, max(i2) FROM t1
+WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 )))
+GROUP BY c1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, i1, max(i2) FROM t2
+WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )
+GROUP BY c1,i1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, i1, max(i2) FROM t2
+WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ))
+GROUP BY c1,i1;
+eval EXPLAIN $query;
+eval $query;
+
+let query=
+SELECT c1, i1, max(i2) FROM t2
+WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 ))
+GROUP BY c1,i1;
+eval EXPLAIN $query;
+eval $query;
+
+DROP TABLE t0,t1,t2;
diff --git a/mysql-test/t/huge_frm-6224.test b/mysql-test/t/huge_frm-6224.test
new file mode 100644
index 00000000000..418722a7b51
--- /dev/null
+++ b/mysql-test/t/huge_frm-6224.test
@@ -0,0 +1,20 @@
+#
+# MDEV-6224 Incorrect information in file when *.frm is > 256K
+#
+# verify that huge frms are rejected during creation, not on opening
+#
+--source include/have_partition.inc
+
+let $n=5646;
+let $a=create table t1 (a int) engine=myisam partition by hash(a) partitions $n (;
+dec $n;
+while ($n)
+{
+ let $a=$a partition p01234567890123456789012345678901234567890123456789012345678$n,;
+ dec $n;
+}
+
+--disable_query_log
+--error ER_TABLE_DEFINITION_TOO_BIG
+eval $a partition foo);
+
diff --git a/mysql-test/t/innodb_load_xa.opt b/mysql-test/t/innodb_load_xa.opt
new file mode 100644
index 00000000000..4ff27e659ce
--- /dev/null
+++ b/mysql-test/t/innodb_load_xa.opt
@@ -0,0 +1 @@
+--ignore-builtin-innodb --loose-innodb --log-bin
diff --git a/mysql-test/t/innodb_load_xa.test b/mysql-test/t/innodb_load_xa.test
new file mode 100644
index 00000000000..52862151b22
--- /dev/null
+++ b/mysql-test/t/innodb_load_xa.test
@@ -0,0 +1,18 @@
+#
+# MDEV-6082 Assertion `0' fails in TC_LOG_DUMMY::log_and_order on DML after installing TokuDB at runtime on server with disabled InnoDB
+#
+--source include/not_embedded.inc
+
+if (!$HA_INNODB_SO) {
+ --skip Need InnoDB plugin
+}
+install plugin innodb soname 'ha_innodb';
+select engine,support,transactions,xa from information_schema.engines where engine='innodb';
+create table t1 (a int) engine=innodb;
+start transaction;
+insert t1 values (1);
+insert t1 values (2);
+commit;
+--source include/show_binlog_events.inc
+drop table t1;
+uninstall plugin innodb;
diff --git a/mysql-test/t/innodb_mysql_lock2.test b/mysql-test/t/innodb_mysql_lock2.test
index b7259e771ae..640f9652462 100644
--- a/mysql-test/t/innodb_mysql_lock2.test
+++ b/mysql-test/t/innodb_mysql_lock2.test
@@ -440,15 +440,16 @@ let $wait_statement= $statement;
--echo # 4.1 SELECT/SET with a stored function which does not
--echo # modify data and uses SELECT in its turn.
--echo #
---echo # In theory there is no need to take row locks on the table
+--echo # There is no need to take row locks on the table
--echo # being selected from in SF as the call to such function
---echo # won't get into the binary log. In practice, however, we
---echo # discover that fact too late in the process to be able to
---echo # affect the decision what locks should be taken.
---echo # Hence, strong locks are taken in this case.
+--echo # won't get into the binary log.
+--echo #
+--echo # However in practice innodb takes strong lock on tables
+--echo # being selected from within SF, when SF is called from
+--echo # non SELECT statements like 'set' statement below.
let $statement= select f1();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
let $statement= set @a:= f1();
let $wait_statement= select i from t1 where i = 1 into j;
--source include/check_shared_row_lock.inc
@@ -486,19 +487,21 @@ let $wait_statement= select i from t1 where i = 1 into k;
--echo # modify data and reads a table through subselect
--echo # in a control construct.
--echo #
---echo # Again, in theory a call to this function won't get to the
---echo # binary log and thus no locking is needed. But in practice
---echo # we don't detect this fact early enough (get_lock_type_for_table())
---echo # to avoid taking row locks.
+--echo # Call to this function won't get to the
+--echo # binary log and thus no locking is needed.
+--echo #
+--echo # However in practice innodb takes strong lock on tables
+--echo # being selected from within SF, when SF is called from
+--echo # non SELECT statements like 'set' statement below.
let $statement= select f3();
let $wait_statement= $statement;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
let $statement= set @a:= f3();
let $wait_statement= $statement;
--source include/check_shared_row_lock.inc
let $statement= select f4();
let $wait_statement= $statement;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
let $statement= set @a:= f4();
let $wait_statement= $statement;
--source include/check_shared_row_lock.inc
@@ -539,19 +542,21 @@ let $wait_statement= insert into t2 values ((select i from t1 where i = 1) + 5);
--echo # doesn't modify data and reads tables through
--echo # a view.
--echo #
---echo # Once again, in theory, calls to such functions won't
---echo # get into the binary log and thus don't need row
---echo # locks. But in practice this fact is discovered
---echo # too late to have any effect.
+--echo # Calls to such functions won't get into
+--echo # the binary log and thus don't need row locks.
+--echo #
+--echo # However in practice innodb takes strong lock on tables
+--echo # being selected from within SF, when SF is called from
+--echo # non SELECT statements like 'set' statement below.
let $statement= select f6();
let $wait_statement= select i from v1 where i = 1 into k;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
let $statement= set @a:= f6();
let $wait_statement= select i from v1 where i = 1 into k;
--source include/check_shared_row_lock.inc
let $statement= select f7();
let $wait_statement= select j from v2 where j = 1 into k;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
let $statement= set @a:= f7();
let $wait_statement= select j from v2 where j = 1 into k;
--source include/check_shared_row_lock.inc
@@ -592,12 +597,11 @@ let $wait_statement= update v2 set j=j+10 where j=1;
--echo # data and reads a table indirectly, by calling another
--echo # function.
--echo #
---echo # In theory, calls to such functions won't get into the binary
---echo # log and thus don't need to acquire row locks. But in practice
---echo # this fact is discovered too late to have any effect.
+--echo # Calls to such functions won't get into the binary
+--echo # log and thus don't need to acquire row locks.
let $statement= select f10();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
--echo #
--echo # 4.11 INSERT which uses a stored function which doesn't modify
@@ -676,12 +680,11 @@ let $wait_statement= select i from t1 where i = 1 into p;
--echo # 5.3 SELECT that calls a function that doesn't modify data and
--echo # uses a CALL statement that reads a table via SELECT.
--echo #
---echo # In theory, calls to such functions won't get into the binary
---echo # log and thus don't need to acquire row locks. But in practice
---echo # this fact is discovered too late to have any effect.
+--echo # Calls to such functions won't get into the binary
+--echo # log and thus don't need to acquire row locks.
let $statement= select f15();
let $wait_statement= select i from t1 where i = 1 into p;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
--echo #
--echo # 5.4 INSERT which calls function which doesn't modify data and
diff --git a/mysql-test/t/ipv4_and_ipv6.opt b/mysql-test/t/ipv4_and_ipv6.opt
new file mode 100644
index 00000000000..a22a7b100c8
--- /dev/null
+++ b/mysql-test/t/ipv4_and_ipv6.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=*
diff --git a/mysql-test/t/ipv4_and_ipv6.test b/mysql-test/t/ipv4_and_ipv6.test
new file mode 100644
index 00000000000..19ab4a253cc
--- /dev/null
+++ b/mysql-test/t/ipv4_and_ipv6.test
@@ -0,0 +1,13 @@
+--source include/check_ipv6.inc
+--source include/not_embedded.inc
+
+echo =============Test of '::1' ========================================;
+let $IPv6= ::1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '127.0.0.1' (IPv4) ===========================;
+let $IPv6= 127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
index 9098ca466b7..86e56a8301b 100644
--- a/mysql-test/t/key_cache.test
+++ b/mysql-test/t/key_cache.test
@@ -8,6 +8,7 @@ drop table if exists t1, t2, t3;
SET @save_key_buffer_size=@@key_buffer_size;
SET @save_key_cache_block_size=@@key_cache_block_size;
SET @save_key_cache_segments=@@key_cache_segments;
+SET @save_key_cache_file_hash_size=@@key_cache_file_hash_size;
SELECT @@key_buffer_size, @@small.key_buffer_size;
@@ -62,19 +63,19 @@ select @@keycache1.key_buffer_size;
select @@keycache1.key_cache_block_size;
select @@key_buffer_size;
select @@key_cache_block_size;
+select @@key_cache_file_hash_size;
set global keycache1.key_buffer_size=1024*1024;
+let org_key_blocks_unused=`select unused_blocks as unused from information_schema.key_caches where key_cache_name="default"`;
+--disable_query_log
+eval set @org_key_blocks_unused=$org_key_blocks_unused;
+--enable_query_log
+
create table t1 (p int primary key, a char(10)) delay_key_write=1;
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
-show status like 'key_blocks_used';
-
-# Following results differs on 64 and 32 bit systems because of different
-# pointer sizes, which takes up different amount of space in key cache
-
---replace_result 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED 1674 KEY_BLOCKS_UNUSED 1818 KEY_BLOCKS_UNUSED 1824 KEY_BLOCKS_UNUSED
-show status like 'key_blocks_unused';
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
insert into t1 values (1, 'qqqq'), (11, 'yyyy');
insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
@@ -85,9 +86,7 @@ select * from t2;
update t1 set p=2 where p=1;
update t2 set i=2 where i=1;
-show status like 'key_blocks_used';
---replace_result 1808 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1814 KEY_BLOCKS_UNUSED 1820 KEY_BLOCKS_UNUSED
-show status like 'key_blocks_unused';
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
cache index t1 key (`primary`) in keycache1;
@@ -147,9 +146,7 @@ cache index t3 in keycache2;
cache index t1,t2 in default;
drop table t1,t2,t3;
-show status like 'key_blocks_used';
---replace_result 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED 1674 KEY_BLOCKS_UNUSED 1818 KEY_BLOCKS_UNUSED 1824 KEY_BLOCKS_UNUSED
-show status like 'key_blocks_unused';
+select @org_key_blocks_unused-unused_blocks as key_blocks_unused, used_blocks as key_blocks_used from information_schema.key_caches where key_cache_name="default";
create table t1 (a int primary key);
cache index t1 in keycache2;
@@ -304,7 +301,7 @@ select * from t2;
update t1 set p=3 where p=1;
update t2 set i=2 where i=1;
---replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED
+--replace_result 1804 KEY_BLOCKS_UNUSED 1801 KEY_BLOCKS_UNUSED 1663 KEY_BLOCKS_UNUSED 1782 KEY_BLOCKS_UNUSED
show status like 'key_%';
--replace_column 7 #
select * from information_schema.key_caches where segment_number is null;
@@ -336,7 +333,8 @@ select * from t2;
update t1 set p=3 where p=1;
update t2 set i=2 where i=1;
---replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1788 KEY_BLOCKS_UNUSED
+
+--replace_result 1800 KEY_BLOCKS_UNUSED 1794 KEY_BLOCKS_UNUSED 1656 KEY_BLOCKS_UNUSED 1775 KEY_BLOCKS_UNUSED
show status like 'key_%';
--replace_column 7 #
select * from information_schema.key_caches where segment_number is null;
@@ -361,7 +359,7 @@ select * from t2;
update t1 set p=3 where p=1;
update t2 set i=2 where i=1;
---replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED
+--replace_result 1804 KEY_BLOCKS_UNUSED 1801 KEY_BLOCKS_UNUSED 1663 KEY_BLOCKS_UNUSED 1782 KEY_BLOCKS_UNUSED
show status like 'key_%';
--replace_column 7 #
select * from information_schema.key_caches where segment_number is null;
@@ -378,6 +376,7 @@ select * from information_schema.key_caches where segment_number is null;
# Switch back to 2 segments
set global key_buffer_size=32*1024;
+set global key_cache_file_hash_size=128;
select @@key_buffer_size;
set global key_cache_segments=2;
select @@key_cache_segments;
@@ -536,5 +535,6 @@ set global keycache2.key_buffer_size=0;
set global key_buffer_size=@save_key_buffer_size;
set global key_cache_segments=@save_key_cache_segments;
+set global key_cache_file_hash_size=@save_key_cache_file_hash_size;
# End of 5.2 tests
diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test
index d5ad7becd7d..f00080d917b 100644
--- a/mysql-test/t/lock_sync.test
+++ b/mysql-test/t/lock_sync.test
@@ -49,6 +49,7 @@ drop table if exists t0, t1, t2, t3, t4, t5;
drop view if exists v1, v2;
drop procedure if exists p1;
drop procedure if exists p2;
+drop procedure if exists p3;
drop function if exists f1;
drop function if exists f2;
drop function if exists f3;
@@ -64,6 +65,8 @@ drop function if exists f12;
drop function if exists f13;
drop function if exists f14;
drop function if exists f15;
+drop function if exists f16;
+drop function if exists f17;
--enable_warnings
create table t1 (i int primary key);
insert into t1 values (1), (2), (3), (4), (5);
@@ -170,6 +173,26 @@ begin
call p2(k);
return k;
end|
+create function f16() returns int
+begin
+ create temporary table if not exists temp1 (a int);
+ insert into temp1 select * from t1;
+ drop temporary table temp1;
+ return 1;
+end|
+create function f17() returns int
+begin
+ declare j int;
+ select i from t1 where i = 1 into j;
+ call p3;
+ return 1;
+end|
+create procedure p3()
+begin
+ create temporary table if not exists temp1 (a int);
+ insert into temp1 select * from t1;
+ drop temporary table temp1;
+end|
create trigger t4_bi before insert on t4 for each row
begin
declare k int;
@@ -217,6 +240,7 @@ connection con1;
--disable_result_log
show create procedure p1;
show create procedure p2;
+show create procedure p3;
show create function f1;
show create function f2;
show create function f3;
@@ -232,6 +256,8 @@ show create function f12;
show create function f13;
show create function f14;
show create function f15;
+show create function f16;
+show create function f17;
--enable_result_log
--echo # Switch back to connection 'default'.
connection default;
@@ -492,18 +518,15 @@ let $restore_table= t2;
--echo # 4.1 SELECT/SET with a stored function which does not
--echo # modify data and uses SELECT in its turn.
--echo #
---echo # In theory there is no need to take strong locks on the table
+--echo # There is no need to take strong locks on the table
--echo # being selected from in SF as the call to such function
---echo # won't get into the binary log. In practice, however, we
---echo # discover that fact too late in the process to be able to
---echo # affect the decision what locks should be taken.
---echo # Hence, strong locks are taken in this case.
+--echo # won't get into the binary log.
let $statement= select f1();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= set @a:= f1();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 4.2 INSERT (or other statement which modifies data) with
@@ -538,22 +561,20 @@ let $restore_table= t2;
--echo # modify data and reads a table through subselect
--echo # in a control construct.
--echo #
---echo # Again, in theory a call to this function won't get to the
---echo # binary log and thus no strong lock is needed. But in practice
---echo # we don't detect this fact early enough (get_lock_type_for_table())
---echo # to avoid taking a strong lock.
+--echo # Call to this function won't get to the
+--echo # binary log and thus no strong lock is needed.
let $statement= select f3();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= set @a:= f3();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= select f4();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= set @a:= f4();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 4.5. INSERT (or other statement which modifies data) with
@@ -591,22 +612,21 @@ let $restore_table= t2;
--echo # doesn't modify data and reads tables through
--echo # a view.
--echo #
---echo # Once again, in theory, calls to such functions won't
---echo # get into the binary log and thus don't need strong
---echo # locks. But in practice this fact is discovered
---echo # too late to have any effect.
+--echo # Calls to such functions won't get into
+--echo # the binary log and thus don't need strong
+--echo # locks.
let $statement= select f6();
let $restore_table= t2;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= set @a:= f6();
let $restore_table= t2;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= select f7();
let $restore_table= t2;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= set @a:= f7();
let $restore_table= t2;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 4.8 INSERT which uses stored function which
@@ -644,12 +664,11 @@ let $restore_table= t2;
--echo # data and reads a table indirectly, by calling another
--echo # function.
--echo #
---echo # In theory, calls to such functions won't get into the binary
---echo # log and thus don't need to acquire strong locks. But in practice
---echo # this fact is discovered too late to have any effect.
+--echo # Calls to such functions won't get into the binary
+--echo # log and thus don't need to acquire strong locks.
let $statement= select f10();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 4.11 INSERT which uses a stored function which doesn't modify
@@ -700,6 +719,36 @@ let $statement= insert into t2 values (f13((select i+10 from t1 where i=1)));
let $restore_table= t2;
--source include/check_no_concurrent_insert.inc
+--echo #
+--echo # 4.15 SELECT/SET with a stored function which
+--echo # inserts data into a temporary table using
+--echo # SELECT on t1.
+--echo #
+--echo # Since this statement is written to the binary log it should
+--echo # be serialized with concurrent statements affecting the data it
+--echo # uses. Therefore it should take strong locks on the data it reads.
+let $statement= select f16();
+let $restore_table= ;
+--source include/check_no_concurrent_insert.inc
+let $statement= set @a:= f16();
+let $restore_table= ;
+--source include/check_no_concurrent_insert.inc
+
+--echo #
+--echo # 4.16 SELECT/SET with a stored function which call procedure
+--echo # which inserts data into a temporary table using
+--echo # SELECT on t1.
+--echo #
+--echo # Since this statement is written to the binary log it should
+--echo # be serialized with concurrent statements affecting the data it
+--echo # uses. Therefore it should take strong locks on the data it reads.
+let $statement= select f17();
+let $restore_table= ;
+--source include/check_no_concurrent_insert.inc
+let $statement= set @a:= f17();
+let $restore_table= ;
+--source include/check_no_concurrent_insert.inc
+
--echo #
--echo # 5. Statements that read tables through stored procedures.
@@ -730,12 +779,11 @@ let $restore_table= t2;
--echo # 5.3 SELECT that calls a function that doesn't modify data and
--echo # uses a CALL statement that reads a table via SELECT.
--echo #
---echo # In theory, calls to such functions won't get into the binary
---echo # log and thus don't need to acquire strong locks. But in practice
---echo # this fact is discovered too late to have any effect.
+--echo # Calls to such functions won't get into the binary
+--echo # log and thus don't need to acquire strong locks.
let $statement= select f15();
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 5.4 INSERT which calls function which doesn't modify data and
@@ -800,7 +848,6 @@ let $statement= update t5 set l= 2 where l = 1;
let $restore_table= t5;
--source include/check_no_concurrent_insert.inc
-
--echo # Clean-up.
drop function f1;
drop function f2;
@@ -817,9 +864,12 @@ drop function f12;
drop function f13;
drop function f14;
drop function f15;
+drop function f16;
+drop function f17;
drop view v1, v2;
drop procedure p1;
drop procedure p2;
+drop procedure p3;
drop table t1, t2, t3, t4, t5;
disconnect con1;
diff --git a/mysql-test/t/log_tables_upgrade.test b/mysql-test/t/log_tables_upgrade.test
index feb2d8c4aa9..d08d74174db 100644
--- a/mysql-test/t/log_tables_upgrade.test
+++ b/mysql-test/t/log_tables_upgrade.test
@@ -1,12 +1,6 @@
---source include/not_embedded.inc
--source include/have_csv.inc
--source include/have_innodb.inc
-
-# Only run test if "mysql_upgrade" is found
---require r/have_mysql_upgrade.result
---disable_query_log
-select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
---enable_query_log
+--source include/mysql_upgrade_preparation.inc
--echo #
--echo # Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL
diff --git a/mysql-test/t/long_tmpdir-master.sh b/mysql-test/t/long_tmpdir-master.sh
index 7bcbee26105..7bcbee26105 100644..100755
--- a/mysql-test/t/long_tmpdir-master.sh
+++ b/mysql-test/t/long_tmpdir-master.sh
diff --git a/mysql-test/t/lowercase_mixed_tmpdir-master.sh b/mysql-test/t/lowercase_mixed_tmpdir-master.sh
index 9330d0581ee..9330d0581ee 100644..100755
--- a/mysql-test/t/lowercase_mixed_tmpdir-master.sh
+++ b/mysql-test/t/lowercase_mixed_tmpdir-master.sh
diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt
index 5b347aa0416..fcaf2b69fbc 100644
--- a/mysql-test/t/mysql_client_test-master.opt
+++ b/mysql-test/t/mysql_client_test-master.opt
@@ -1,3 +1,4 @@
--general-log
--general-log-file=$MYSQLTEST_VARDIR/log/master.log
--log-output=FILE,TABLE
+--max-allowed-packet=32000000
diff --git a/mysql-test/t/mysql_client_test_comp-master.opt b/mysql-test/t/mysql_client_test_comp-master.opt
new file mode 100644
index 00000000000..783093c900b
--- /dev/null
+++ b/mysql-test/t/mysql_client_test_comp-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--max-allowed-packet=32000000
diff --git a/mysql-test/t/mysql_client_test_comp.test b/mysql-test/t/mysql_client_test_comp.test
new file mode 100644
index 00000000000..0a6b0ba1130
--- /dev/null
+++ b/mysql-test/t/mysql_client_test_comp.test
@@ -0,0 +1,20 @@
+# run mysql_client_test with performance schema
+
+# No need to run this with embedded server
+-- source include/not_embedded.inc
+
+# need to have the dynamic loading turned on for the client plugin tests
+--source include/have_plugin_auth.inc
+
+SET @old_slow_query_log= @@global.slow_query_log;
+
+call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
+
+--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1
+--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1
+
+# End of test
+echo ok;
+
+# Restore state changed by mysql_test_run
+SET @@global.slow_query_log= @old_slow_query_log;
diff --git a/mysql-test/t/mysql_client_test_nonblock-master.opt b/mysql-test/t/mysql_client_test_nonblock-master.opt
index 034d5340a23..5775e707c5f 100644
--- a/mysql-test/t/mysql_client_test_nonblock-master.opt
+++ b/mysql-test/t/mysql_client_test_nonblock-master.opt
@@ -1 +1,2 @@
--general-log --general-log-file=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE
+--max-allowed-packet=32000000
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index ffbec36873e..ae59c713c3d 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -2053,7 +2053,7 @@ select "at" as col1, "AT" as col2, "c" as col3;
--replace_regex /a/b/ /ct/d/
select "a" as col1, "ct" as col2;
---replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
+--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/
select "strawberry","blueberry","potato";
--error 1
@@ -2098,6 +2098,12 @@ select "a is a and less is more" as txt;
select "a is a and less is more" as txt;
--enable_query_log
+#
+# different delimiters
+#
+--replace_regex (a)[b] /c/d/ <e>{f}i {g\/\}}/h/
+select 'ABCDEF abcdef g/}' as txt;
+
#-------------------------------------------------------------------------
# BUG #11754855 : Passing variable to --error
#-------------------------------------------------------------------------
diff --git a/mysql-test/t/order_by_innodb.test b/mysql-test/t/order_by_innodb.test
new file mode 100644
index 00000000000..c20eaceb053
--- /dev/null
+++ b/mysql-test/t/order_by_innodb.test
@@ -0,0 +1,23 @@
+#
+# ORDER BY handling (e.g. filesort) tests that require innodb
+#
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t0,t1,t2,t3;
+--enable_warnings
+
+--echo #
+--echo # MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, c INT, d TEXT, KEY idx(a,b,c)) ENGINE=InnoDB;
+
+INSERT INTO t1 (a,c) VALUES
+(8, 9),(8, 10),(13, 15),(16, 17),(16, 18),(16, 19),(20, 21),
+(20, 22),(20, 24),(20, 25),(20, 26),(20, 27),(20, 28);
+
+SELECT * FROM t1 WHERE a = 8 AND (b = 1 OR b IS NULL) ORDER BY c;
+
+DROP TABLE t1;
+
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 1e1150157c7..754677e9b37 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -2816,6 +2816,47 @@ select * from t1 IGNORE INDEX(dob, weeks_worked_last_year, hours_worked_per_week
drop table t1;
+--echo #
+--echo # MDEV-6322: The PARTITION engine can return wrong query results
+--echo #
+CREATE TABLE t1 (
+ CustomerID varchar(5) DEFAULT NULL,
+ CompanyName varchar(40) DEFAULT NULL,
+ ContactName varchar(30) DEFAULT NULL,
+ ContactTitle varchar(30) DEFAULT NULL,
+ Address varchar(60) DEFAULT NULL,
+ City varchar(15) DEFAULT NULL,
+ Region varchar(15) DEFAULT NULL,
+ PostalCode varchar(10) DEFAULT NULL,
+ Country varchar(15) NOT NULL,
+ Phone varchar(24) DEFAULT NULL,
+ Fax varchar(24) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS(Country)
+(PARTITION p1 VALUES IN ('Germany','Austria','Switzerland','Poland'),
+ PARTITION p2 VALUES IN ('USA','Canada','Mexico'),
+ PARTITION p3 VALUES IN ('Spain','Portugal','Italy'),
+ PARTITION p4 VALUES IN ('UK','Ireland'),
+ PARTITION p5 VALUES IN ('France','Belgium'),
+ PARTITION p6 VALUES IN ('Sweden','Finland','Denmark','Norway'),
+ PARTITION p7 VALUES IN ('Venezuela','Argentina','Brazil')
+);
+
+INSERT INTO t1 (CustomerID, City, Country) VALUES
+('ANATR','México D.F','Mexico'),
+('ANTON','México D.F','Mexico'),
+('BOTTM','Tsawassen','Canada'),
+('CENTC','México D.F','Mexico'),
+('GREAL','Eugene','USA'),
+('HUNGC','Elgin','USA'),
+('LAUGB','Vancouver','Canada'),
+('LAZYK','Walla Walla','USA'),
+('LETSS','San Francisco','USA'),
+('LONEP','Portland','USA');
+
+SELECT * FROM t1 WHERE Country = 'USA';
+DROP TABLE t1;
+
#
# Test ALTER TABLE ADD/DROP PARTITION IF EXISTS
#
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index 43f409731a6..1e2aacd474a 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -777,6 +777,34 @@ drop table t3;
drop table t1,t2;
--echo #
+--echo # MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+--echo #
+create table t1(c1 int, c2 int, c3 int, c4 int,
+primary key(c1,c2)) engine=InnoDB
+partition by list columns(c2)
+(partition p1 values in (1,2) engine=InnoDB,
+partition p2 values in (3,4) engine=InnoDB);
+
+insert into t1 values (1,1,1,1),(2,3,1,1);
+select * from t1 where c1=2 and c2=3;
+drop table t1;
+
+--echo #
+--echo # MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
+--echo # also MDEV-6240: Wrong "Impossible where" with LIST partitioning
+--echo #
+CREATE TABLE t1 ( d DATE) ENGINE = InnoDB
+PARTITION BY LIST COLUMNS (d)
+(
+ PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
+ PARTITION p1 VALUES IN ('1981-01-01')
+);
+
+INSERT INTO t1 (d) VALUES ('1991-01-01');
+SELECT * FROM t1 WHERE d = '1991-01-01';
+DROP TABLE t1;
+
+--echo #
--echo # MDEV-5963: InnoDB: Assertion failure in file row0sel.cc line 2503,
--echo # Failing assertion: 0 with "key ptr now exceeds key end by 762 bytes"
--echo # (independent testcase for Oracle Bug#13947868)
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
index 4c97bab454d..06ef99e1e70 100644
--- a/mysql-test/t/partition_pruning.test
+++ b/mysql-test/t/partition_pruning.test
@@ -1414,6 +1414,54 @@ explain partitions select * from t1 where a between 10 and 10+33;
drop table t0, t1;
--echo #
+--echo # Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+--echo #
+CREATE TABLE t1
+(c1 int,
+ c2 int,
+ c3 int,
+ c4 int,
+ PRIMARY KEY (c1,c2))
+PARTITION BY LIST COLUMNS (c2)
+(PARTITION p1 VALUES IN (1,2),
+ PARTITION p2 VALUES IN (3,4));
+INSERT INTO t1 VALUES (1, 1, 1, 1), (2, 3, 1, 1);
+INSERT INTO t1 VALUES (1, 2, 1, 1), (2, 4, 1, 1);
+SELECT * FROM t1 WHERE c1 = 1 AND c2 < 1;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 1;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 = 1;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 < 3;
+SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 = 3;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 3;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 > 3;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 < 4;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 4;
+SELECT * FROM t1 WHERE c1 = 2 AND c2 > 4;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 < 1;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 1;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 = 1;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 < 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 > 3;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 < 4;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 >= 4;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 > 4;
+DROP TABLE t1;
+
+--echo #
--echo # MDEV-6239: Partition pruning is not working as expected in an inner query
--echo #
diff --git a/mysql-test/t/plugin_loaderr.test b/mysql-test/t/plugin_loaderr.test
index e319e2fb54d..7b98a94afd4 100644
--- a/mysql-test/t/plugin_loaderr.test
+++ b/mysql-test/t/plugin_loaderr.test
@@ -1,4 +1,6 @@
+--source include/not_embedded.inc
+
# We used an invalid command-line option and InnoDB failed to start.
# Ignore all related warnings
call mtr.add_suppression("InnoDB");
@@ -8,3 +10,17 @@ SELECT
PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE,PLUGIN_LIBRARY,PLUGIN_LIBRARY_VERSION,LOAD_OPTION
FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name = 'innodb';
+--echo #
+--echo # MDEV-6351 --plugin=force has no effect for built-in plugins
+--echo #
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--shutdown_server
+--source include/wait_until_disconnected.inc
+
+--error 1
+--exec $MYSQLD_CMD --innodb=force --innodb-page-size=6000
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
diff --git a/mysql-test/t/rpl_mysqldump_slave.test b/mysql-test/t/rpl_mysqldump_slave.test
index 77fc4a050cc..345bdb82535 100644
--- a/mysql-test/t/rpl_mysqldump_slave.test
+++ b/mysql-test/t/rpl_mysqldump_slave.test
@@ -36,4 +36,53 @@ start slave;
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave no_such_db
start slave;
+
+--echo *** Test mysqldump --dump-slave GTID functionality.
+
+--connection master
+SET gtid_seq_no = 1000;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+DROP TABLE t1;
+--sync_slave_with_master
+
+--connection slave
+# Inject a local transaction on the slave to check that this is not considered
+# for --dump-slave.
+CREATE TABLE t2 (a INT PRIMARY KEY);
+DROP TABLE t2;
+
+--echo
+--echo 1. --dump-slave=1
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 --gtid test
+
+--echo
+--echo 2. --dump-slave=2
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 --gtid test
+
+
+--echo *** Test mysqldump --master-data GTID functionality.
+--echo
+--echo 1. --master-data=1
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 --gtid test
+
+--echo
+--echo 2. --master-data=2
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 --gtid test
+
+--echo
+--echo 3. --master-data --single-transaction
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test
+
+
+
--source include/rpl_end.inc
diff --git a/mysql-test/t/stat_tables-enospc.test b/mysql-test/t/stat_tables-enospc.test
new file mode 100644
index 00000000000..12e42f6adc0
--- /dev/null
+++ b/mysql-test/t/stat_tables-enospc.test
@@ -0,0 +1,23 @@
+#
+# MDEV-6181 EITS could eat all tmpdir space and hang
+#
+# test that ANALYZE TABLE is immediately aborted when going out of disk space
+--source include/have_debug.inc
+call mtr.add_suppression("No space left on device");
+create table t1 (a varchar(255), b varchar(255), c varchar(255));
+--disable_query_log
+let $i=10000;
+while ($i) {
+ insert t1 values (repeat(format(rand(),10), 20),
+ repeat(format(rand(),10), 20),
+ repeat(format(rand(),10), 20));
+ dec $i;
+}
+--enable_query_log
+set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3;
+set debug_dbug='+d,simulate_file_write_error';
+--replace_regex /'.*'/'tmp-file'/
+analyze table t1;
+set debug_dbug='';
+drop table t1;
+
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
index 91b69a6a09c..912e9d5befd 100644
--- a/mysql-test/t/subselect_sj_mat.test
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -1808,5 +1808,38 @@ EXECUTE stmt;
DROP TABLE t1, t2;
DROP VIEW v2;
+--echo #
+--echo # MDEV-6289 : Unexpected results when querying information_schema
+--echo #
+CREATE TABLE t1 (
+ id int(11) unsigned NOT NULL AUTO_INCREMENT,
+ db varchar(254) NOT NULL DEFAULT '',
+ PRIMARY KEY (id),
+ UNIQUE KEY db (db)
+) DEFAULT CHARSET=utf8;
+INSERT INTO t1 (db) VALUES ('mysqltest1'),('mysqltest2'),('mysqltest3'),('mysqltest4');
+
+--disable_warnings
+drop database if exists mysqltest1;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+drop database if exists mysqltest4;
+--enable_warnings
+create database mysqltest1;
+create database mysqltest2;
+create database mysqltest3;
+create database mysqltest4;
+
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+
+EXPLAIN EXTENDED
+SELECT db FROM t1 WHERE db IN (SELECT SCHEMA_NAME FROM information_schema.schemata) ORDER BY db DESC;
+
+drop table t1;
+drop database mysqltest1;
+drop database mysqltest2;
+drop database mysqltest3;
+drop database mysqltest4;
+
--echo # End of 5.5 tests
diff --git a/mysql-test/t/table_options-5867.test b/mysql-test/t/table_options-5867.test
new file mode 100644
index 00000000000..153ec08e675
--- /dev/null
+++ b/mysql-test/t/table_options-5867.test
@@ -0,0 +1,30 @@
+#
+# MDEV-5867 ALTER TABLE t1 ENGINE=InnoDB keeps bad options when t1 ENGINE is CONNECT
+#
+# verify that SHOW CREATE TABLE hides unknown options when IGNORE_BAD_TABLE_OPTIONS is not set
+
+--source include/have_example_plugin.inc
+--source include/not_embedded.inc
+
+install soname 'ha_example';
+
+set sql_mode='ignore_bad_table_options';
+create table t1 (
+ a int complex='c,f,f,f' invalid=3
+) engine=example ull=10000 str='dskj' one_or_two='one' yesno=0
+ foobar=barfoo;
+
+create table t2 (a int, key (a) some_option=2014);
+
+show create table t1;
+show create table t2;
+
+set sql_mode='';
+
+show create table t1;
+show create table t2;
+
+drop table t1, t2;
+
+uninstall soname 'ha_example';
+
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index 8bedf9357ef..2ca608e76ff 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -362,11 +362,11 @@ f2 bit(14) NOT NULL default b'11110000111100'
SHOW CREATE TABLE t1;
DROP TABLE t1;
---error ER_INVALID_DEFAULT
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
-
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
#
# Bug#31399 Wrong query result when doing join buffering over BIT fields
diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test
index 7ba90bf08fa..27eaeda0f99 100644
--- a/mysql-test/t/type_bit_innodb.test
+++ b/mysql-test/t/type_bit_innodb.test
@@ -148,3 +148,12 @@ select * from t1;
drop table t1;
--echo End of 5.0 tests
+
+#
+# MDEV-6052 Inconsistent results with bit type
+#
+create table t1(f1 bit(2) not null default b'10',f2 bit(14) not null default b'11110000111100');
+insert into t1 (f1) values (default);
+insert into t1 values (b'',b''),('','');
+select hex(f1), hex(f2) from t1;
+drop table t1;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 877509a9fc0..a5d7dae606f 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1273,6 +1273,36 @@ SELECT(SELECT 1 AS a ORDER BY a) AS dev;
SELECT(SELECT 1 AS a LIMIT 1) AS dev;
SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev;
+
+--echo #
+--echo # Bug #17059925 : UNIONS COMPUTES ROWS_EXAMINED INCORRECTLY
+--echo #
+
+## Save current state of slow log variables
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_log_output= @@global.log_output;
+SET @old_long_query_time= @@long_query_time;
+SET GLOBAL log_output= "TABLE";
+SET GLOBAL slow_query_log= ON;
+SET SESSION long_query_time= 0;
+
+CREATE TABLE t17059925 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+INSERT INTO t17059925 VALUES (1), (2), (3);
+INSERT INTO t2 VALUES (4), (5), (6);
+INSERT INTO t3 VALUES (7), (8), (9);
+TRUNCATE table mysql.slow_log;
+--sorted_result
+SELECT * FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3;
+SELECT sql_text, rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%t17059925%';
+DROP TABLE t17059925, t2, t3;
+
+## Reset to initial values
+SET @@long_query_time= @old_long_query_time;
+SET @@global.log_output= @old_log_output;
+SET @@global.slow_query_log= @old_slow_query_log;
+
--echo #
--echo # lp:1010729: Unexpected syntax error from UNION
--echo # (bug #54382) with single-table join nest
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index d1d4b936aba..6029ad471f6 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4700,6 +4700,47 @@ DROP DATABASE IF EXISTS nodb;
--error ER_BAD_DB_ERROR
CREATE VIEW nodb.a AS SELECT 1;
+
+--echo #
+--echo # BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION
+--echo # BUG#18405221 - SHOW CREATE VIEW OUTPUT INCORRECT
+--echo #
+
+CREATE VIEW v1 AS (SELECT '' FROM DUAL);
+CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+ (SELECT '' FROM DUAL);
+CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+ (SELECT '' FROM DUAL) UNION ALL
+ (SELECT '' FROM DUAL);
+CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
+ (SELECT '' AS col2 FROM DUAL) UNION ALL
+ (SELECT '' FROM DUAL);
+
+# In the second (and later) UNIONed queries, duplicate column names are allowed
+CREATE VIEW v5 AS (SELECT 'buggy' AS col1, 'fix' as col2 FROM DUAL) UNION ALL
+ (SELECT 'buggy' as a, 'fix' as a FROM DUAL);
+
+--echo # Name for the column in select1 is set properly with or
+--echo # without this fix.
+SHOW CREATE VIEW v1;
+
+--echo # Name for the column in select2 is set with this fix.
+--echo # Without this fix, name would not have set for the
+--echo # columns in select2.
+SHOW CREATE VIEW v2;
+
+--echo # Name for the field item in select2 & select3 is set with this fix.
+--echo # Without this fix, name would not have set for the
+--echo # columns in select2 & select3.
+SHOW CREATE VIEW v3;
+
+--echo # Name for the field item in select3 is set with this fix.
+--echo # Without this fix, name would not have set for the
+--echo # columns in select3.
+SHOW CREATE VIEW v4;
+
+DROP VIEW v1, v2, v3, v4, v5;
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
@@ -5231,6 +5272,69 @@ drop view v1;
drop table t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch_MDEV_3874;
+#
+# MDEV-5515: sub-bug test of 3rd execution crash
+#
+
+CREATE TABLE `t1` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `f0` int(11) unsigned NOT NULL DEFAULT '0',
+ `f1` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`)
+);
+
+CREATE TABLE `t2` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `f02` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `f03` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`)
+);
+
+CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v1` AS
+ SELECT
+ `t1`.`f0` AS `f0`,
+ `t1`.`f1` AS `f1`,
+ `t2`.`f02` AS `f02`,
+ `t2`.`f03` AS `f03`
+ FROM
+ (`t1` LEFT JOIN `t2` ON((`t1`.`id` = `t2`.`f02`)));
+
+--delimiter |
+CREATE FUNCTION `f1`(
+ p0 BIGINT(20) UNSIGNED
+ )
+ RETURNS bigint(20) unsigned
+ DETERMINISTIC
+ CONTAINS SQL
+ SQL SECURITY DEFINER
+ COMMENT ''
+BEGIN
+
+DECLARE k0 INTEGER UNSIGNED DEFAULT 0;
+DECLARE lResult INTEGER UNSIGNED DEFAULT 0;
+
+ SET k0 = 0;
+ WHILE k0 < 1 DO
+ SELECT COUNT(*) as `f00` INTO lResult FROM `v1` WHERE `v1`.`f0` = p0; -- BUG
+ SET k0 = k0 + 1;
+ END WHILE;
+
+ RETURN(k0);
+END|
+--delimiter ;
+
+
+SELECT `f1`(1);
+SELECT `f1`(1);
+SELECT `f1`(1);
+SELECT `f1`(1);
+
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE t1, t2;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 45499e5891f..f1bc19e27eb 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1138,6 +1138,17 @@
{
+ OpenSSL still reachable.
+ Memcheck:Leak
+ fun:*alloc
+ fun:CRYPTO_malloc
+ obj:*libssl*
+ fun:SSL_COMP_get_compression_methods
+ fun:SSL_library_init
+}
+
+
+{
Problem with udf and libresolve
Memcheck:Cond
obj:*/libresolv*.so